Remember for each user which Kanban cards have their task list open

The open cards are kept in the user's board preferences (expanded_cards,
at most 500), saved without redrawing the board and restored on return.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-11-30 11:25:58 +02:00
co-authored by Claude Opus 5.5
parent e274a8d2b1
commit 9eac4c4d4e
10 changed files with 172 additions and 21 deletions
@@ -237,3 +237,27 @@ describe('moving cards', function () {
$this->pin->execute($jobId, $taskId, true);
})->throws(TaskCannotBePinned::class);
});
describe('open cards', function () {
it('remembers which cards are open', function () {
$preferences = BoardPreferences::defaults()
->withCardExpanded('job-12', true)
->withCardExpanded('task-34', true)
->withCardExpanded('job-12', false)
->withCardExpanded('nonsense', true);
expect($preferences->isCardExpanded('task-34'))->toBeTrue()
->and($preferences->isCardExpanded('job-12'))->toBeFalse()
->and($preferences->expandedCards)->toBe(['task-34']);
});
it('keeps only valid keys and the latest cards from stored settings', function () {
$stored = array_map(fn (int $id): string => 'job-'.$id, range(1, BoardPreferences::MAX_EXPANDED_CARDS + 10));
$preferences = BoardPreferences::fromStored(null, null, [], [], [...$stored, 'drop table', 42, 'job-1']);
expect($preferences->expandedCards)->toHaveCount(BoardPreferences::MAX_EXPANDED_CARDS)
->and($preferences->isCardExpanded('job-1'))->toBeFalse()
->and($preferences->isCardExpanded('job-'.(BoardPreferences::MAX_EXPANDED_CARDS + 10)))->toBeTrue()
->and($preferences->isCardExpanded('drop table'))->toBeFalse();
});
});