From 6c87c9ca726ed4c6abf9139cab8b9489f42f351b Mon Sep 17 00:00:00 2001 From: tomeyer97 <107920881+tomeyer97@users.noreply.github.com> Date: Wed, 18 Nov 2026 11:55:24 +0100 Subject: [PATCH 1/3] Journeys list harness: the End row counts as in view within a pixel Rows can end at a fraction of a pixel (DejaVu Sans on the CI runner: 760.36 of 760) while the page scrolls by whole pixels, so the focused last row was reported as out of view. The failure message now gives the row's edges. Co-Authored-By: Claude Opus 5.5 --- test/journey-list/shoot.mjs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/journey-list/shoot.mjs b/test/journey-list/shoot.mjs index 18972ee..7dad76b 100644 --- a/test/journey-list/shoot.mjs +++ b/test/journey-list/shoot.mjs @@ -121,8 +121,9 @@ for (const theme of ['dark', 'light']) for (const w of [320, 600, 1000]) { h = await home() if (h.sel === top || h.focusKey !== h.sel) fail(`↓ did not move the focus and selection (${top} → ${h.sel}, focus ${h.focusKey})`) await page.keyboard.press('End'); await settle() - const inView = await page.evaluate(() => { const r = document.activeElement.getBoundingClientRect(); return r.top >= 0 && r.bottom <= innerHeight }) - if (!inView) fail('the focused row (End) is not scrolled into view') + // Within a pixel: the page scrolls by whole pixels, rows can end at fractions (font metrics differ per machine). + const inView = await page.evaluate(() => { const r = document.activeElement.getBoundingClientRect(); return { ok: r.top > -1 && r.bottom < innerHeight + 1, top: r.top, bottom: r.bottom, height: innerHeight } }) + if (!inView.ok) fail(`the focused row (End) is not scrolled into view (${inView.top}–${inView.bottom} of ${inView.height})`) if (OUT) await page.screenshot({ path: path.join(OUT, `home-keys-${w}-${theme}.png`) }) await page.keyboard.press('Home'); await settle(); await page.keyboard.press('ArrowUp'); await settle() if ((await home()).focus !== 'hsearch') fail('↑ from the first row did not go back to the search') From 504c6d7a5511ee3fbe97d1ca6edc2e27db146fff Mon Sep 17 00:00:00 2001 From: tomeyer97 <107920881+tomeyer97@users.noreply.github.com> Date: Wed, 18 Nov 2026 11:55:24 +0100 Subject: [PATCH 2/3] Notes and journeys folders: files already in a folder that was just created are read The file watcher starts watching a new folder only once it has seen it, so files written right after the folder (mkdir -p then a write, a checkout) may come with no event of their own. When the folder, or one above it, is created, its .json files are read. Integration waits print the loaded journeys' ids on a timeout. Co-Authored-By: Claude Opus 5.5 --- src/jsonFolder.ts | 18 +++++++++++++++--- test/integration/main/context.ts | 2 +- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/jsonFolder.ts b/src/jsonFolder.ts index 49ee652..b1212b2 100644 --- a/src/jsonFolder.ts +++ b/src/jsonFolder.ts @@ -17,13 +17,25 @@ export async function readText(uri: vscode.Uri): Promise { try { return decoder.decode(await wfs.readFile(uri)) } catch { return undefined } } -/** Watches `//*.json`: a file created or changed goes to `onFile`, a deleted one to `onDelete`. */ -export function watchJsonFiles(folder: vscode.WorkspaceFolder, rel: string, onFile: (u: vscode.Uri) => unknown, onDelete: (u: vscode.Uri) => unknown): vscode.FileSystemWatcher { +/** + * Watches `//*.json`: a file created or changed goes to `onFile`, a deleted one to `onDelete`. When `rel` + * (or a folder above it) is created, the files already in it go to `onFile` too: the file watcher starts watching a new + * folder only after it sees it, so files written right after the folder (`mkdir -p` then a write, a checkout) can come + * with no event of their own. + */ +export function watchJsonFiles(folder: vscode.WorkspaceFolder, rel: string, onFile: (u: vscode.Uri) => unknown, onDelete: (u: vscode.Uri) => unknown): vscode.Disposable { const w = vscode.workspace.createFileSystemWatcher(new vscode.RelativePattern(folder, `${rel}/*.json`)) w.onDidCreate(onFile) w.onDidChange(onFile) w.onDidDelete(onDelete) - return w + const parts = rel.split('/').filter(Boolean) + const dirs = parts.map((_, i) => parts.slice(0, i + 1).join('/')) + if (!dirs.length) return w + const made = vscode.workspace.createFileSystemWatcher(new vscode.RelativePattern(folder, dirs.length > 1 ? `{${dirs.join(',')}}` : dirs[0]), false, true, true) + made.onDidCreate(async () => { + for (const u of (await jsonFilesIn(vscode.Uri.joinPath(folder.uri, rel)))?.files ?? []) await onFile(u) + }) + return vscode.Disposable.from(w, made) } /** The `.json` files in `dir`, by name, and how many entries it has in all; undefined: it can't be read (not there yet). */ diff --git a/test/integration/main/context.ts b/test/integration/main/context.ts index 292b34a..aca36f1 100644 --- a/test/integration/main/context.ts +++ b/test/integration/main/context.ts @@ -17,7 +17,7 @@ export const ctx = { } /** The main suite's wait (6 s by default): on a timeout it prints the tour's state (most waits are on it). */ -export const until = waiter({ dump: () => { try { const t = ctx.api?.snapshot().tour; return t && { ...t, story: undefined } } catch { return undefined } } }) +export const until = waiter({ dump: () => { try { const s = ctx.api?.snapshot(); return s && { journeys: s.journeys.map((j: { id: string }) => j.id), tour: s.tour && { ...s.tour, story: undefined } } } catch { return undefined } } }) /** Everything the extension shows, as data (notes, journeys, the tour, counts). */ export const snap = () => ctx.api.snapshot() From 847212036894b780c624a4a12d532bf8395be8ef Mon Sep 17 00:00:00 2001 From: tomeyer97 <107920881+tomeyer97@users.noreply.github.com> Date: Wed, 18 Nov 2026 11:55:24 +0100 Subject: [PATCH 3/3] Integration tests: hermetic from the CI job's variables; Add Note typed after a fixed 600 ms The runner drops GITHUB_*/GITLAB_*/CI_*/RUNNER_* before starting VS Code: the extension host passed GITHUB_HEAD_REF to the understanding CLI, and the check suite saw the job's branch instead of its own. Add Note's typing wait is no longer scaled (3x on CI): after a second or two the test window moves the keyboard out of the new box and the text is lost. Co-Authored-By: Claude Opus 5.5 --- test/integration/main/notesReview.ts | 6 ++++-- test/integration/run.ts | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/test/integration/main/notesReview.ts b/test/integration/main/notesReview.ts index 73008bb..efc9ff8 100644 --- a/test/integration/main/notesReview.ts +++ b/test/integration/main/notesReview.ts @@ -5,7 +5,7 @@ import * as vscode from 'vscode' import * as fs from 'fs' import assert from 'assert' -import { appendMessage, now, quiet, readJson, settle, test } from '../helpers' +import { appendMessage, now, quiet, readJson, settle, sleep, test } from '../helpers' import { agentNote, writeNote } from '../fixtures' import { at, bodyOf, tour, closeAllEditors, ctx, journeysTree, noteById, notePath, notesTree, snap, until, wsPath } from './context' import { UNREAD_FINDING } from './shared' @@ -189,7 +189,9 @@ export const notesReviewTests = [ editor.selection = new vscode.Selection(2, 0, 2, 0) const notesBefore = snap().notes.length await vscode.commands.executeCommand('codeNotes.add') - await settle(600, 'the comment box opening and taking the keyboard') + // Typed 600 ms later, as a person would, and not scaled with the other waits: in the test window the keyboard + // leaves the box after a second or two (to an open thread's Reply above it), and what is typed then is lost. + await sleep(600) 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) diff --git a/test/integration/run.ts b/test/integration/run.ts index b46ca14..0a61c3d 100644 --- a/test/integration/run.ts +++ b/test/integration/run.ts @@ -12,6 +12,10 @@ import { connectCdp } from './connectCdp' import { writeSkillStandIn } from './fixtures' import { writeSlowGit } from '../slowGit' +// The CI job's own variables (GITHUB_HEAD_REF, CI_COMMIT_REF_NAME, …) must not reach VS Code: the extension host +// passes its environment to the understanding CLI, which takes the branch from them. CI itself stays (helpers.ts: SCALE). +for (const k of Object.keys(process.env)) if (/^(GITHUB_|GITLAB_|CI_|RUNNER_)/.test(k)) delete process.env[k] + /** The extension's folder (out/test/integration/ is three below it). */ const ROOT = path.resolve(__dirname, '../../..')