-
Notifications
You must be signed in to change notification settings - Fork 0
feat(sessions): Batch 1 PR-2 — pinned zone + manual hide #136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+827
−13
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c9adb95
feat(sessions): pins + manual hide (Batch 1 PR-2)
grimmerk 2012c2b
docs: plan status — PR #132 merged, PR-2 pins = #136
grimmerk c2dd811
fix(sessions): PR #136 review round 1 (cubic)
grimmerk 2726c84
fix(sessions): selection re-anchor after pin/hide + hidden marker
grimmerk fcdbe90
fix(sessions): PR #136 review round 2
grimmerk 8329a98
fix(sessions): keep Cmd+D alive after mouse clicks + stable zone count
grimmerk 7e1b36c
fix(sessions): Cmd+D requires an explicit selection
grimmerk d3c0673
fix(sessions): suppress hover re-selection around marks layout shifts
grimmerk 9aa4b7e
feat(sessions): pinned sessions live in the zone only (user verdict)
grimmerk a2f2796
docs(sessions): spell out pin/hide keyboard semantics
grimmerk f416e70
fix(sessions): PR #136 review round 3 (cubic)
grimmerk a7537ca
fix(sessions): PR #136 review round 4 (cubic P3s on watcher retry)
grimmerk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| import * as fs from 'fs'; | ||
| import * as os from 'os'; | ||
| import * as path from 'path'; | ||
| import { afterEach, beforeEach, describe, expect, it } from 'vitest'; | ||
|
|
||
| import { | ||
| emptyMarks, | ||
| normalizeMarks, | ||
| readMarksFile, | ||
| withHidden, | ||
| withoutHidden, | ||
| withoutPin, | ||
| withPin, | ||
| writeMarksFile, | ||
| } from './session-marks'; | ||
|
|
||
| describe('normalizeMarks', () => { | ||
| it('returns empty marks for garbage input', () => { | ||
| expect(normalizeMarks(null)).toEqual(emptyMarks()); | ||
| expect(normalizeMarks('nope')).toEqual(emptyMarks()); | ||
| expect(normalizeMarks([1, 2])).toEqual(emptyMarks()); | ||
| expect(normalizeMarks({ pins: [1], hidden: 'x' })).toEqual(emptyMarks()); | ||
| }); | ||
|
|
||
| it('keeps valid entries, defaults missing fields, dedupes hidden', () => { | ||
| const raw = { | ||
| pins: { | ||
| abc: { pinnedAt: '2026-07-14T00:00:00Z', cwd: '/x', group: 'g1' }, | ||
| bad: 'not-an-object', | ||
| def: {}, | ||
| }, | ||
| hidden: ['h1', 'h1', '', 42, 'h2'], | ||
| }; | ||
| const m = normalizeMarks(raw); | ||
| expect(Object.keys(m.pins).sort()).toEqual(['abc', 'def']); | ||
| expect(m.pins.abc.group).toBe('g1'); | ||
| expect(m.pins.def.cwd).toBe(''); | ||
| expect(typeof m.pins.def.pinnedAt).toBe('string'); | ||
| expect(m.hidden).toEqual(['h1', 'h2']); | ||
| }); | ||
| }); | ||
|
|
||
| describe('pin/hide transitions', () => { | ||
| const info = { pinnedAt: '2026-07-14T00:00:00Z', cwd: '/repo' }; | ||
|
|
||
| it('pinning unhides and hiding unpins (mutual exclusion)', () => { | ||
| let m = withHidden(emptyMarks(), 's1'); | ||
| expect(m.hidden).toEqual(['s1']); | ||
|
|
||
| m = withPin(m, 's1', info); | ||
| expect(m.pins.s1).toBeTruthy(); | ||
| expect(m.hidden).toEqual([]); | ||
|
|
||
| m = withHidden(m, 's1'); | ||
| expect(m.pins.s1).toBeUndefined(); | ||
| expect(m.hidden).toEqual(['s1']); | ||
| }); | ||
|
|
||
| it('unpin and unhide are idempotent and non-destructive', () => { | ||
| let m = withPin(emptyMarks(), 's1', info); | ||
| m = withPin(m, 's2', { ...info, accountLabel: 'work' }); | ||
| m = withoutPin(m, 's1'); | ||
| m = withoutPin(m, 's1'); | ||
| expect(Object.keys(m.pins)).toEqual(['s2']); | ||
| expect(m.pins.s2.accountLabel).toBe('work'); | ||
|
|
||
| m = withHidden(m, 'h1'); | ||
| m = withoutHidden(m, 'h1'); | ||
| m = withoutHidden(m, 'h1'); | ||
| expect(m.hidden).toEqual([]); | ||
| }); | ||
|
|
||
| it('does not mutate the input marks', () => { | ||
| const base = withPin(emptyMarks(), 's1', info); | ||
| const frozen = JSON.stringify(base); | ||
| withHidden(base, 's1'); | ||
| withoutPin(base, 's1'); | ||
| withPin(base, 's2', info); | ||
| expect(JSON.stringify(base)).toBe(frozen); | ||
| }); | ||
| }); | ||
|
|
||
| describe('marks file roundtrip', () => { | ||
| let dir: string; | ||
|
|
||
| beforeEach(() => { | ||
| dir = fs.mkdtempSync(path.join(os.tmpdir(), 'codev-marks-')); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| fs.rmSync(dir, { recursive: true, force: true }); | ||
| }); | ||
|
|
||
| it('writes and reads back the same marks (nested dir is created)', () => { | ||
| const file = path.join(dir, 'nested', 'session-marks.json'); | ||
| const marks = withHidden( | ||
| withPin(emptyMarks(), 'abc', { | ||
| pinnedAt: '2026-07-14T01:02:03Z', | ||
| cwd: '/repo', | ||
| accountLabel: 'work', | ||
| }), | ||
| 'junk-1', | ||
| ); | ||
| writeMarksFile(file, marks); | ||
| expect(readMarksFile(file)).toEqual(marks); | ||
| // no temp leftovers from the rename-based write | ||
| expect( | ||
| fs.readdirSync(path.dirname(file)).filter((f) => f.includes('.tmp-')), | ||
| ).toEqual([]); | ||
| }); | ||
|
|
||
| it('returns empty marks for a missing or corrupt file', () => { | ||
| const file = path.join(dir, 'session-marks.json'); | ||
| expect(readMarksFile(file)).toEqual(emptyMarks()); | ||
| fs.writeFileSync(file, '{not json'); | ||
| expect(readMarksFile(file)).toEqual(emptyMarks()); | ||
| }); | ||
| }); | ||
|
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.