diff --git a/src/journeys/panel/layout.ts b/src/journeys/panel/layout.ts index 7c5de81..a5ad17b 100644 --- a/src/journeys/panel/layout.ts +++ b/src/journeys/panel/layout.ts @@ -137,13 +137,15 @@ export class PanelLayout { /** * A step opened with the panel beside it: the code keeps its 80 columns. Squeezed under them (a panel opened by * Ctrl+' V or left open while the window narrowed), the panel shrinks to leave them, or closes: the step card alone. - * The map's room asked for while the panel is open stays, and so does the listening width. + * The map's room asked for while the panel is open stays, and so does the listening width. Nothing is changed once + * `current` says the step is no longer the one shown. */ - async keepCodeRoom(): Promise { + async keepCodeRoom(current: () => boolean = () => true): Promise { if (!this.d.isOpen()) { this.readerChose = false; return } if (this.d.episodeOn()) return const s = await this.sideBySide() - if (!s) return + // `current`: the step is still the one shown (the layout read is a round trip; another journey may be open now). + if (!s || !current()) return const look = this.editorLook() const move = codeRoomMove({ codePx: s.layout.groups[1 - s.panel].size ?? 0, diff --git a/src/podcast/testing.ts b/src/podcast/testing.ts index 15e6b31..b6c1184 100644 --- a/src/podcast/testing.ts +++ b/src/podcast/testing.ts @@ -42,6 +42,8 @@ function snapshot(p: Podcasts, ports: Pick !group || group === 'all' || group.startsWith('area:') +/** The groups under which a journey's row lists its step questions: Continue, All and its areas, and a row of no group + * (the Code Notes view's). A journey is listed once there (a walked one only in Continue); "In this file" repeats it. */ +export const nestsQuestions = (group: string | undefined) => !group || group === 'all' || group === 'continue' || group.startsWith('area:') /** What a journey's row says, worked out once: its description, tooltip, screen-reader label, icon and menus are all * made from it. */ diff --git a/src/tour/walk.ts b/src/tour/walk.ts index a04a9fa..3030805 100644 --- a/src/tour/walk.ts +++ b/src/tour/walk.ts @@ -404,8 +404,11 @@ export class Walk { const editor = await this.openStepFile(lj, n, uri, opts, token) if (!editor) return await this.revealStep(lj, n, editor, uri) - // Beside an open panel the code keeps its 80 columns (the panel narrower, or the step card alone). - if (mapPanel().journey && this.tour.isAt(lj, n)) await panelLayout().keepCodeRoom() + // Beside an open panel the code keeps its 80 columns (the panel narrower, or the step card alone). The trade-off, + // on purpose: one waited layout read per step (a round trip to the window, counted apart in the round-trip test). + // Not waited for, it races the layout a journey sets as it opens and can close the panel it just opened. + const shown = () => this.tour.isAt(lj, n) && mapPanel().journey?.key === lj.key + if (shown()) await panelLayout().keepCodeRoom(shown) } /** The tour is on step n now (another journey's walk ended first), stored, its map and lists follow. False: superseded. */ diff --git a/test/integration/check/branches.ts b/test/integration/check/branches.ts index ec0fbe1..c0a898e 100644 --- a/test/integration/check/branches.ts +++ b/test/integration/check/branches.ts @@ -1,4 +1,4 @@ -// Drift and branches: uncommitted lines asking for a top-up, another branch hiding the check's threads, a branch switch +// Drift and branches: uncommitted lines asking for one more question, another branch hiding the check's threads, a branch switch // while questions are written, another git user. Each test puts the branch, the files and the git config back in // `finally`, so a failure here doesn't leave the next tests on another branch. import * as vscode from 'vscode' @@ -25,15 +25,16 @@ function backTo(branch: string): void { } export const branchesTests = [ - test('drift from uncommitted lines: amber "Needs top-up: +46 lines" in the status bar and the view (Commit… first)', async () => { + test('drift from uncommitted lines: "Understanding: +1 question" in the status bar (amber), the line count in the view (Commit… first)', async () => { const saved = fs.readFileSync(limitsPath, 'utf8') try { - // 45 new lines (uncommitted) → amber "Needs top-up" before any push. + // 45 new lines (uncommitted) → one more question asked for before any push; how much it grew is in the view. fs.appendFileSync(limitsPath, Array.from({ length: 45 }, (_, i) => `export const MORE_${i} = ${i}`).join('\n') + '\n') await vscode.commands.executeCommand('workbench.action.files.revert').then(undefined, () => undefined) void api.checkRefresh() - await until('needs top-up', () => /^\$\(warning\) Needs top-up: \+4\d lines$/.test(chk().item)) - await untilEqual('the warning in the status bar and the view', () => [chk().itemWarn, view().tone, view().action?.id], [true, 'warn', 'scm'], CHECK_WAIT_MS) + await until('one more question asked for', () => chk().item === '$(checklist) Understanding: +1 question') + await untilEqual('amber in the status bar; the view says how much it grew and offers Commit… first', () => [chk().itemWarn, view().tone, /^Your change grew by 4\d code lines$/.test(view().title ?? ''), view().line, view().action?.id], + [true, 'todo', true, 'Commit, then add 1 question about the new lines.', 'scm'], CHECK_WAIT_MS) await pageShot('check-4-drift') } finally { fs.writeFileSync(limitsPath, saved) diff --git a/test/integration/main/journeyFiles.ts b/test/integration/main/journeyFiles.ts index 695d318..d6a4b6a 100644 --- a/test/integration/main/journeyFiles.ts +++ b/test/integration/main/journeyFiles.ts @@ -146,7 +146,7 @@ export const journeyFilesTests = withAfter([ await vscode.commands.executeCommand('codeNotes.refreshJourney', vscode.Uri.file(diskPath).toString()) await until('refreshed: the file rewritten, the step fresh', () => JSON.parse(fs.readFileSync(diskPath, 'utf8')).steps[0].anchor?.v === 3 && !diskStep().stale, 20000) assert.equal(snap().notes.length, notesBeforeRefresh, 'Refresh writes no note in the reader\'s name') - assert.ok(!fs.readdirSync(path.join(ctx.notesDir, '.writing')).length, 'the staging folder is cleaned up') + assert.ok(!fs.existsSync(path.join(ctx.notesDir, '.writing')), 'the staging folder is cleaned up, no empty .writing left') fs.unlinkSync(diskPath) await until('disk gone', () => !snap().journeys.some((x: any) => x.id === 'disk')) }), diff --git a/test/integration/main/journeyTour.ts b/test/integration/main/journeyTour.ts index 5df8189..a0ae3a3 100644 --- a/test/integration/main/journeyTour.ts +++ b/test/integration/main/journeyTour.ts @@ -108,7 +108,7 @@ const withBinaryStep = () => journey('binary', [ const moving = (title: string, from = 0) => journey('moving', demoSteps.slice(from).map((x) => ({ ...x, id: `m-${x.id}` })), { title }) export const journeyTourTests = [ - test('v2 journeys load (v1 and broken files skipped); steps are not notes; the group lists titles, new ones marked', async () => { + test('v2 journeys load (v1 and broken files skipped); steps are not notes; the view lists titles, new ones marked', async () => { writeLines(wsPath('src', 'flow.ts'), ['export function a() {', ' return b()', '}', '', 'export function b() {', ' return 2', '}']) writeLines(wsPath('src', 'flow2.ts'), ['// two', 'export const c = 3']) writeLines(wsPath('lib', 'mail', 'address.go'), Array.from({ length: 60 }, (_, i) => `// line ${i + 1}`)) @@ -127,14 +127,13 @@ export const journeyTourTests = [ assert.equal(snap().notes.length, notesBefore, 'steps are not notes') assert.equal(snap().broken, brokenBefore, 'journey files are not read as notes') assert.equal(snap().badge, badgeBefore, 'steps never count as unread') - // 0.24: journeys have their own view (Journeys), grouped by area; the Notes view lists notes only. + // Journeys have their own view (Journeys); the Notes view lists notes only. Fewer than 8 journeys: one flat list, + // a row each (no area or "All" group above it), its length and "new" in the description. const rows = journeysTree() assert.ok(!notesTree().some((l) => /^journeys:|journey:/.test(l)), 'no journeys in the Notes view') - const demoRow = rows.findIndex((l) => /journey:Demo · new$/.test(l)) - assert.ok(demoRow > 0 && /^\s+jgroup:src · 1$/.test(rows[demoRow - 1]), `Demo under its area (not said again), "new":\n${rows.join('\n')}`) - assert.ok(rows.some((l) => /^jgroup:All · 1$/.test(l)), `an "All" group:\n${rows.join('\n')}`) - // Files that never were valid journeys: one dimmed row each, after the groups. - assert.deepEqual(rows.slice(-2), ['badJourney: · ⚠ half-written.json', 'badJourney: · ⚠ old-v1.json'], `never-valid files are dimmed rows:\n${rows.join('\n')}`) + assert.ok(!rows.some((l) => /jgroup:/.test(l)), `a few journeys are not grouped:\n${rows.join('\n')}`) + // Files that never were valid journeys: one dimmed row each, after the journeys. + assert.deepEqual(rows, ['journey:Demo · 3 steps · new', 'badJourney: · ⚠ half-written.json', 'badJourney: · ⚠ old-v1.json'], `Demo a top row, "3 steps · new"; never-valid files are dimmed rows after it:\n${rows.join('\n')}`) }), test('Open Journey: the map and step 1\'s code, the panel at most 40 %; a read-only step card above the lines, details folded', async () => { @@ -300,8 +299,15 @@ export const journeyTourTests = [ assert.equal(question.session, undefined, 'a normal private note') assert.equal(question.unread, 0) const rows = journeysTree() - const row = rows.findIndex((l) => /^ {6}note:Step 2 · Why does b return 2\?/.test(l)) - assert.ok(row > 0 && /^ {4}journey:Demo\b/.test(rows[row - 1]) && !/question/.test(rows[row - 1]), `listed right under its journey, with its step; no count on the row:\n${rows.join('\n')}`) + // The walked journey is listed once, in Continue: its questions under it there. + const row = rows.findIndex((l) => /^ {4}note:Step 2 · Why does b return 2\?/.test(l)) + assert.ok(row > 1, `the question listed:\n${rows.join('\n')}`) + // Right under its journey (the walked one, in Continue), with its step; no question count on the journey's row. + assert.deepEqual(rows.slice(row - 2, row + 1).map((l) => l.replace(/ \[[^\]]*\]$/, '')), [ + 'jgroup:Continue · 1', + ' journey:Demo · step 2/3', + ' note:Step 2 · Why does b return 2? · flow.ts:8', + ], `listed right under its journey, with its step; no count on the row:\n${rows.join('\n')}`) assert.ok(!rows.some((l) => /^note:Why does b return 2/.test(l)), 'not a loose row too') const askedThread = await until('the asked note\'s thread', () => ctx.api.thread(question.id)) assert.ok(!/openStepLink|About the step/.test(bodyOf(askedThread.comments[0])), 'on that very step: no back-link') diff --git a/test/integration/main/notesReview.ts b/test/integration/main/notesReview.ts index 25702e2..398d50c 100644 --- a/test/integration/main/notesReview.ts +++ b/test/integration/main/notesReview.ts @@ -267,6 +267,10 @@ export const notesReviewTests = [ await vscode.commands.executeCommand('type', { text: 'Typed into the box' }) await vscode.commands.executeCommand('editor.action.submitComment') await until('Add Note saved a note', () => snap().notes.length === notesBefore + 1 && snap().notes.some((x: any) => x.messages[0].body === 'Typed into the box'), 8000) - assert.equal(vscode.workspace.getConfiguration('comments').get('maxHeight'), false, 'More grows the card: no nested scroll') + // Of VS Code's comment defaults the extension changes only openView (no Comments panel on every note); + // comments.maxHeight stays VS Code's own, for every comment extension. + const comments = vscode.workspace.getConfiguration('comments') + assert.equal(comments.inspect('maxHeight')?.defaultValue, true, 'comments.maxHeight left at VS Code\'s default') + assert.equal(comments.get('openView'), 'never', 'no Comments panel popping up on every note') }), ] diff --git a/test/integration/main/podcast/playback.ts b/test/integration/main/podcast/playback.ts index ec947ef..fb45f4b 100644 --- a/test/integration/main/podcast/playback.ts +++ b/test/integration/main/podcast/playback.ts @@ -31,7 +31,7 @@ export const playbackTests = [ // Nothing listened to: no Listen view (nor its focus command), no transport in the palette, a plain row. assert.ok(!pod().listening && !pod().hostAlive, 'no Listen view before a journey is listened to') const idle = ctx.api.journeyRow('podauto')! - assert.match(idle.description ?? '', /^♪ 0:40( · |$)/, `the row: its length: ${idle.description}`) + assert.match(idle.description ?? '', /^1 step · ♪ 0:40( · |$)/, `the row: its steps, then its podcast's length: ${idle.description}`) assert.match(idle.contextValue!, /;podcast$/, 'its ▶ Listen') assert.doesNotMatch(String(idle.tooltip), /podcast|Listen/i, 'no podcast line in the tooltip') await shots('listen-idle', true) @@ -49,7 +49,7 @@ export const playbackTests = [ await audioMoves(pf, 'played in the panel') assert.equal(await pf.evaluate(() => { const e = (globalThis as any).document.querySelector('.pod-err'); return e.hidden ? '' : e.textContent }), '', 'no hint or error line') assert.ok(pod().unlocked.panel && !pod().unlocked.listen, `the panel unlocked, the Listen view not: ${JSON.stringify(pod().unlocked)}`) - await podUntil('the panel has the audio: the Listen view is not there (codeNotes.listening off)', () => pod().panelHosts && !pod().hostAlive && !pod().hostVisible, QUICK_MS) + await podUntil('the panel has the audio: the Listen view is not there (codeNotes.listening off)', () => pod().panelHosts && !pod().listenAlive && !pod().hostVisible, QUICK_MS) // 2. Closing the panel: the audio goes to the Listen view, which may not play yet: it waits there, paused, where // it was (the one start that still needs a click: the status item or ▶ opens the panel again). @@ -72,7 +72,7 @@ export const playbackTests = [ const pf2 = await frameOf('journey', { quiet: true }) await realClick(pf2, '.pod-b.play') await podUntil('the click on the panel\'s ▶: playing in the panel', () => pod().playing && pod().hostIn === 'panel', MOVE_MS) - await podUntil('the Listen view went: the panel\'s player is the one', () => !pod().hostAlive && !pod().hostVisible, QUICK_MS) + await podUntil('the Listen view went: the panel\'s player is the one', () => pod().panelHosts && !pod().listenAlive && !pod().hostVisible, QUICK_MS) await audioMoves(pf2, 'the panel\'s ▶') assert.ok(Math.abs(pod().t - tClose) < 4, `on from where it was: ${tClose} → ${pod().t}`) @@ -88,7 +88,8 @@ export const playbackTests = [ await pause() await closePanel() await podUntil('the audio back in the Listen view', () => pod().hostIn === 'listen' && pod().hostAlive && pod().hostVisible, MOVE_MS) - const lf = await frameOf('listen', { quiet: true }) + // Found by its player (not `quiet`): the side bar has other webviews (the Check view). + const lf = await frameOf('listen') await realClick(lf, '.pod-b.play') await podUntil('the Listen view\'s ▶ plays there; the Listen view unlocked', () => pod().playing && pod().hostIn === 'listen' && pod().unlocked.listen, MOVE_MS) assert.equal(await lf.evaluate(() => (globalThis as any).document.querySelector('.ls-title')?.textContent), 'Pod auto', 'the view names the journey') @@ -336,6 +337,8 @@ export const playbackTests = [ podTest('podcast › the speed is remembered', async () => { await listenTo('podbeat', writeBeatJourney) const f = await frameOf('journey') + // The speed button is at the panel's bottom right, under VS Code's own toasts ("extensions are disabled"). + await vscode.commands.executeCommand('notifications.clearAll') const speedTo = async (r: number) => { for (let i = 0; i < 5 && pod().rate !== r; i++) { await f.click('.pod-rate') diff --git a/test/integration/main/roundTrips.ts b/test/integration/main/roundTrips.ts index d718771..e18e704 100644 --- a/test/integration/main/roundTrips.ts +++ b/test/integration/main/roundTrips.ts @@ -23,6 +23,11 @@ const activeUri = () => vscode.window.activeTextEditor?.document.uri.toString() /** What each action may call at most besides storing its place (stored in the background, not waited for). */ const MOST: Record = { next: 1, previous: 1, link: 1, back: 1, same: 0, chatBack: 1 } +/** Opening a step (Next, Previous, Back to the step) waits for one more round trip, on purpose: an editor layout read + * after the step is shown, so the code beside the journey panel keeps its 80 columns. Counted apart from MOST. */ +const LAYOUT_PROBE = 'command vscode.getEditorLayout' +const STEP_ACTIONS = new Set(['next', 'previous', 'back']) + /** The code link that goes into another file than the card's, and the one into the card's own file. */ const TO_OTHER_FILE = 1, TO_CARD_FILE = 0 @@ -164,8 +169,11 @@ export const roundTripsTests = [ await chatLinks(c, r) fs.rmSync(tripsPath) for (const [k, n] of Object.entries(MOST)) { - const waited = r[k].calls.filter((x) => !x.startsWith('store ')) + // The step's layout read is waited for too; it is held to its own limit below, not to MOST. + const waited = r[k].calls.filter((x) => !x.startsWith('store ') && !(STEP_ACTIONS.has(k) && x === LAYOUT_PROBE)) assert.ok(waited.length <= n, `${k}: ${waited.length} calls into the window (at most ${n}): ${waited.join(', ')}`) + const probes = r[k].calls.filter((x) => x === LAYOUT_PROBE).length + assert.ok(probes <= (STEP_ACTIONS.has(k) ? 1 : 0), `${k}: ${probes} waited layout reads (opening a step: at most one, after the step is shown; other actions: none)`) } } finally { c.dispose() } }), diff --git a/test/journeyRowText.test.ts b/test/journeyRowText.test.ts index 11c9d95..e6c3935 100644 --- a/test/journeyRowText.test.ts +++ b/test/journeyRowText.test.ts @@ -60,8 +60,8 @@ test('a podcast: its length on the row and in the label; one that cannot play sa assert.equal(podcastContext(undefined), '') }) -test('questions nest under All, its areas and a row of no group only', () => { - assert.deepEqual([undefined, 'all', 'area:api', 'here', 'continue'].map(nestsQuestions), [true, true, true, false, false]) +test('questions nest under Continue, All, its areas and a row of no group; not under In this file', () => { + assert.deepEqual([undefined, 'all', 'area:api', 'here', 'continue'].map(nestsQuestions), [true, true, true, false, true]) }) test('a journey being written: its question, then the clock and what Claude is doing', () => {