Skip to content

fix(dashboard): watch only the visible file tab, re-read on return - #14262

Merged
iamwhatever merged 1 commit into
mainfrom
fix/side-panel-watch-visible-tab-only
Sep 27, 2026
Merged

iamwhatever merged 1 commit into
mainfrom
fix/side-panel-watch-visible-tab-only

Conversation

@pepmach

@pepmach pepmach commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Open several files as tabs in the chat side panel without the dashboard's other requests stalling behind their file-watch streams -- and without a file that disappears under an open tab taking its last copy with it (#14365).

Open six files as tabs in the chat side panel and the dashboard stops talking to the gateway: the attach button spins, a sent message waits, polls stop arriving. Every open file tab holds its own GET /api/file-watch stream, whether or not the tab is visible. The gateway serves HTTP/1.1 and Chromium allows six connections per host, so six idle tabs hold all six, and every other request sits in the browser's queue until one of them ends (#14236, with the HAR: six streams open for 52 s, the uploads and about 20 other requests blocked behind them).

Why it matters

Anyone who keeps a handful of files open while chatting is hit, on every platform the desktop app runs on. The stall is silent: the gateway is healthy and answers as soon as a request reaches it, so nothing on screen says why the message is not going out.

Not a goal

What changed (motivation → approach → change)

before after
streams for six open tabs 6 1, for the tab on screen
a hidden tab, file changed on disk stream pushes the change re-read when the tab becomes visible
a tab with unsaved edits no stream, no re-read no stream, no re-read
the visible tab's file deleted outside the dashboard stale buffer, no word last copy under a banner

The watch was armed on liveWatch && !editing && !dirty though SidePanel keeps hidden tabs mounted; now on active too.

A tab with no stream would go stale silently, so it re-reads on becoming visible, on mount and on leaving edit mode. One procedure, adoptDisk, one rule: every read is a fresh GET /api/file-read, never the opening read or a cached body, which can predate the change.

A tab is caught up only once a read has APPLIED: adoptDisk settles a due / reading / done latch and nothing else writes done. A read the typing overtook leaves the tab due. The first edit of a clean buffer withdraws any read in flight; save, undo and discard each start one. A save clears dirty only if no keystroke landed during its write (editGenRef) and, like every read, drops the shared cache entry. The stream's first frame is compared, never applied: equal to the clean buffer, no read unless one is in flight; otherwise a re-read.

A gone file (404) is a state, not content: every read that meets it records it, dirty or not, so the retry and the parked stream never depend on the buffer; banner and guards need a real last copy. Buffer and baseline keep the last text under a banner ("File not found on disk — nothing else holds its contents; download it or save it elsewhere to keep it.") with two buffer exits. Refresh and Cancel on a gone file raise the banner. Closing asks first ("Discard the file’s remaining contents?", file and edits named, Download beside them): the unsaved-edits prompt would imply a saved copy. A live-watched tab asks the disk first (the watch polls on silently through a deletion); a read typed past closes nothing; a failed one asks "Close without checking the disk?" -- only over a buffer that could be a copy, the dialog the sole report. A rail click re-targeting a clean tab asks the disk first too; a copy found, or a read that could not answer, opens the next file beside it. A PARTIAL buffer -- its read cut at the gateway's cap (X-Truncated), redacted (X-Redacted) or decoded with replacement characters (X-Lossy-Decode; api_file_read now sets both new headers) -- carries that verdict on the TAB from whichever read filled it, the opening read included, never guessed from the body. It is guarded like a whole copy; only the words change: "only part of it", a .partial download. Meanwhile the tab holds no stream (a 404 stream closes for good) and retries the read once the last settled, never over one in flight, the wait doubling 1 s to 30 s (each GET is a SEL record), until one finds the file and re-arms the stream; a failed read is reported once.

Changed: website/src/components/MarkdownPanel.tsx; website/src/utils/fileReadQuery.ts (header verdicts on FileReadResult), website/src/hooks/usePanelTabs.ts (PanelTab.partial, transient like binary), website/src/hooks/usePanelDocumentActions.ts, website/src/pages/ChatPage.tsx, website/src/pages/chat/SidePanel.tsx (verdict plumbing; disjoint from #12662), website/src/utils/fileReadUrl.ts, src/kiro_crew/dashboard/handlers/files.py (X-Redacted, X-Lossy-Decode), website/src/i18n/locales/ (thirteen keys, twelve languages), website/scripts/capture-file-tab-missing-on-disk.mjs. Untouched: useFileWatch.ts. Not here: ArtifactPanel (#14259).

Backwards compatibility

Compatible: same props, same host callbacks; a tab that is visible behaves as before. The new requests are one GET /api/file-read when the visible tab mounts (right after a chip open too: one more than the opening read), one when a hidden tab comes back, one when a buffer the user edited becomes clean again (save, undo, discard), and one when a clean tab leaves edit mode.

Tests

website/src/test/MarkdownPanel.watchVisibleTab.test.tsx (new, 42 cases), red-first on main @ f6d8b7f: the first assertion failed with expected [ StubEventSource{ …(5) }, …(5) ] to have a length of 1 but got 6.

  • six mounted tabs hold exactly one stream, for the visible tab; the visible tab reads once on mount, hidden tabs not at all;
  • a visible tab remounted after its file was emptied adopts the empty content (red-first on 2d86b96: no read on remount);
  • activating a hidden tab closes the old stream, opens one for the new tab, and re-reads that file once with the change made while it was hidden landing through onDiskContent;
  • a tab with unsaved edits holds no stream and does not re-read; once the edits are undone while it is visible it reads once and the stream arms;
  • each return to a tab re-reads, not only the first;
  • a clean tab sitting in the editor (a .ts file) re-reads on activation and still holds no stream;
  • typing before the catch-up read lands drops that read, and undoing the edits re-reads: the disk revision lands on the second read (red-first on 5310ee3: expected "vi.fn()" to be called with arguments: [ '/tmp/b.md', …(2) ]);
  • a read that lands after the tab was hidden again is applied but does not count: the next return reads again and picks up a second rewrite;
  • a file that is gone (404) keeps the last copy on screen, its heading still rendered, under the banner, with no notice and the buffer and baseline untouched; the banner clears when the file is back (red-first on 98555c5: the placeholder sentence stood where the banner text is asserted);
  • a read that really fails (500) shows the notice once per return, not once per host render, and is tried again on the next return;
  • typing and saving before the catch-up read lands: the older revision never restamps the saved text, and the save's own read finds the written text and restamps nothing (red-first: the older revision export const x = 2 landed over the saved export const x = 3);
  • Refresh overtakes the catch-up read, typing drops Refresh's read, undo re-reads (red-first: no read after the undo);
  • a keystroke typed while a save is in flight stays on screen and dirty, no read runs over it, and the next save writes it (red-first: a read fired after the save);
  • a tab mounted with a restored draft, saved inside the hydration read's 10 s cache window: the post-save read goes to the disk and the saved text stays (red-first on 98555c5: expected 'export const x = 1\n' to be 'export const x = 3\n', the cached pre-save body restamped the save);
  • a clean markdown tab enters edit mode (stream parked), its file is truncated to zero bytes, and leaving edit mode re-reads and adopts the empty file (red-first on 98555c5: no read, onDiskContent never called with '');
  • the mount reads the disk while the read that opened the tab is still fresh in the cache, and finds the file deleted since (red-first on 49c24ab: the cached body was served, no banner);
  • structural: fetchFileRead is spied; one fresh call per mount, per return and per save, equal to the GET count, with a fresh cache entry seeded before each step (red-first on 49c24ab: the mount made no fetch);
  • the re-armed stream's first frame, repeating what the catch-up read brought, costs no second GET; a frame with a real change still re-reads (red-first on 2d86b96: two reads per activation);
  • an equal frame arriving while a read is still in flight re-reads instead of being skipped, so the older in-flight bytes never become the baseline (red-first: no second read);
  • a post-edit read that matches the tab still drops the cached file-read entry (red-first: the entry survived);
  • no banner over the placeholder a chip click on a deleted path seeds, nor over a binary tab (red-first on 49c24ab: the banner rendered);
  • Escape on a tab whose buffer is the last copy opens the confirm, the file named in its body; declined, the tab stays; confirmed, onClose fires once (red-first on 49c24ab: no dialog);
  • a clean tab under a live stream whose file is deleted (the stream says nothing) asks the disk once on Escape and opens the last-copy prompt; with the file back it closes without a prompt (red-first on 167b903: onClose fired, no dialog);
  • typing while the close-time disk check is out closes nothing: the keystroke stays and the next Escape asks about the edits (red-first on 654aeb4: onClose fired on the stale clean state);
  • a tab the host marks partial, whose file is already gone: the banner says "only part of it", Download saves b.md.partial (the buffer's bytes), Escape opens the last-copy prompt in the partial wording and its Download is .partial too; a WHOLE buffer that merely quotes [REDACTED: credential], unmarked: the whole-copy banner, b.md, the plain prompt (red-first on 8a28f7c: the body sniff called the quoting file partial; on 5c06505: the panel had seen no read of its own and called a partial buffer whole; the guard: a partial buffer closed with no prompt);
  • the panel's own read hands the host partial: true with the text when the response carries X-Truncated, and a whole read over a tab still marked partial restamps it although the text is unchanged (red-first on 8a28f7c: two-argument onDiskContent);
  • a failed close-time read asks nothing over an empty buffer or the seeded placeholder -- the tab just closes (red-first on 8a28f7c: the dialog held the close);
  • a dirty tab's close-time 404, declined, leaves the banner standing over the edits with its Download, and the next Escape asks about the edits again (red-first on 8a28f7c: no banner);
  • Refresh on a gone file shows the banner, not "Cannot read file"; Cancel on a gone file shows the banner over the still-dirty edits and the next close names them (red-first on 8a28f7c: the notice, no banner);
  • a deleted EMPTY file is still tracked as missing: no banner, the stream parked, and the retry adopts the recreated content (red-first on 39b3892: the stream stayed armed on the gone path);
  • the last-copy dialog carries a Download action that saves the buffer without closing the dialog (red-first on 39b3892: no such action);
  • no retry starts over a read already in flight (Refresh's, held), and the wait doubles between retries (red-first on 45f5fe6: a fixed 1 s cadence);
  • each retry read is scheduled only after the previous one settled: a held read is not aborted by the next tick, and it is the read that lands (red-first on 45f5fe6: a second retry fired over the first);
  • a failed close-time check asks "Close without checking the disk?" with Close anyway, instead of refusing the close, and raises no "Cannot read file" notice beside the dialog (red-first on 45f5fe6: no dialog, no close; on 8a28f7c: the notice too);
  • a dirty tab's close checks the disk too and names the gone file and the edits in the body (red-first on 45f5fe6: the plain unsaved-edits prompt);
  • the ⋯ menu's Download hands over the buffer while the file is gone, with no /api/file-download request and no "Download failed" (red-first on 167b903: no blob);
  • once the last copy has been edited, Escape opens the last-copy prompt whose body names the unsaved edits, not "Discard unsaved changes?" (red-first on 7fe7a91: the unsaved-edits prompt);
  • a visible tab whose file is gone holds no stream and re-reads on a cadence; the recreated file is adopted, the banner clears and the stream arms again (red-first on 5d7cf11: a stream armed on the gone path, nothing re-read);
  • the navigate predicate a chip click asks answers no for a last-copy tab, so the next file opens beside it (red-first on 49c24ab: expected true to be false);
  • Round 12: a rail re-target of a clean tab under a live stream reads the disk first; a file deleted meanwhile is found, the banner latched and the tab spared -- the next file opens beside it -- instead of the buffer being replaced on a stale verdict (red-first on e3735e8: no read, predicate true); a failed check spares the tab too, an intact file re-targets;
  • Round 12: a read answering X-Lossy-Decode (a Latin-1 file decoded with replacement characters) marks the tab partial through onDiskContent and through openFile, so its banner says partial and its download is named .partial;
  • the banner's Download hands the browser a Blob with the buffer under the file's name with no /api/file-download request; Copy content copies the buffer and shows "Copied" on the button, and a refused copy raises the panel's action notice (red-first on 49c24ab: no Download button; on 7fe7a91: no "Copied", the refusal vanished).

The stale-content regression the maintainer pipeline warned about is the second, third, fourth, sixth and seventh case. MarkdownPanelMoreCoverage.test.tsx's failed-watch-re-read test now lets the mount read land before it fires the failing frame. sidePanelColdTabHydration.test.tsx: a hydration read answering X-Truncated stamps the tab partial, and the persisted tab drops the flag like binary. usePanelDocumentActions.redactionEpoch.test.ts: the opening read's X-Redacted / X-Truncated headers reach tabsCtl.openFile as partial: true, a plain read as false. test/test_dashboard_file_io.py: a read whose body the credential pass rewrote carries X-Redacted: true, a Latin-1 file carries X-Lossy-Decode: true with a replacement character in the body; a plain UTF-8 read carries neither. Green on this head: the module file (42), the related frontend files (sidePanelColdTabHydration, usePanelDocumentActions.redactionEpoch, MarkdownPanel.binaryCard, MarkdownPanelCoverage, usePanelTabs, BinaryFileCard, useFileWatch, i18nLintExemptions: 242 tests), the i18n parity, style and QA gates with the thirteen keys (707), test_dashboard_file_io.py + test_file_watch.py (71, -n0).

Manual verification

Browser: website/scripts/capture-file-tab-missing-on-disk.mjs runs the built SPA against fixtures (the file tab seeded, its read answering 404 after the hydration, its stream delivering one frame), waits for the banner text, its two buttons AND the document heading to be on screen together, captures the frames below in two languages, then sends Escape to the document and captures the confirmation it opens, the "Copied" answer, the banner in a 360px full-screen layout (asserting both buttons visible and the band inside the viewport), and -- in a context with no clipboard -- the refused-copy notice; a pass restores the tab with unsaved edits over a gone file and captures the prompt that names them; a pass seeds the tab from a read answering X-Truncated, then 404, and asserts the partial banner, that the browser is handed release-checklist.md.partial, and the partial prompt; two passes fail the close-time read (500) on a clean and on a dirty tab and capture "Close without checking the disk?". The stream and request counts are unit-tested (the tests count EventSource instances and file-read requests directly). A preview pod could not be driven: it booted, but its token mint was refused for this caller (member_owner_token_refused).

Rebased onto main 8abbf3a64d after #14398 merged (the prepare-pr size ratchet and the CrewWebviewContainment clock test are healed there).

Screenshots / video

The visible tab's file deleted outside the dashboard after the tab was hydrated: the last copy stays on screen and the banner sits over it, with Copy content and Download beside the sentence. Two languages, because a lone English frame does not prove the banner comes from the catalog. Then the close: Escape opens "Discard the file’s remaining contents?" over a body that names the file and the Download way out, with Cancel and Discard the contents -- the one exit that discards the copy asks first; a tab restored with unsaved edits gets the body that names the edits too. Then the copy button's two answers: "Copied", and the notice a refused clipboard raises. Then a PARTIAL copy (the opening read was cut at the gateway's cap): the banner says so and the prompt uses the partial wording. Then the close-time read itself failing, on a clean and on a dirty tab: "Close without checking the disk?" with Close anyway.

English Chinese
Side panel file tab, English: warning banner "File not found on disk — nothing else holds its contents; download it or save it elsewhere to keep it." with Copy content and Download buttons, above the still-rendered Release checklist document Side panel file tab, Chinese: the same banner and buttons from the zh-CN catalog above the still-rendered document

The close confirmation over the dashboard: "Discard the file’s remaining contents?" over the body "release-checklist.md is not on disk; nothing else holds its contents. To keep it, download it first." with its Download action, Cancel and a red Discard the contents button; the banner and the document are still visible behind the dialog

The same dialog for a tab restored with unsaved edits: the body reads "release-checklist.md is not on disk and this tab holds unsaved edits; nothing else holds its contents. To keep it, download it first." with its Download action

Copied Refused copy
The banner with its Copy content button reading "Copied" for a moment after a click The panel's red action notice "Couldn't copy — select the text to copy it manually" with an Ask the agent link, above the banner, after the clipboard refused

Full-screen layout at 360px wide: the banner keeps small gutters and wraps Copy content and Download under the sentence; nothing overflows

Partial copy: banner Partial copy: close prompt
The banner for a partial copy: "File not found on disk — this tab holds only part of it (the copy was cut short or had credentials redacted); download what is here to keep it." with Copy content and Download, over the document The close confirmation for a partial copy: "Discard the file’s remaining contents?" over "release-checklist.md is not on disk and this tab holds only part of it (the copy was cut short or had credentials redacted); nothing else holds even that. To keep what is here, download it first." with Download, Cancel and Discard the contents
Failed close-time read: clean tab Failed close-time read: dirty tab
"Close without checking the disk?" over "release-checklist.md could not be read just now, so this tab may hold the file’s remaining contents. To keep them, download the file first." with Download, Cancel and Close anyway "Close without checking the disk?" over "release-checklist.md could not be read just now and this tab holds unsaved edits. To keep them, download the file first." with Download, Cancel and Close anyway
Full dashboard frames

Full dashboard, English, the file tab with the banner and its two buttons over the last copy

Full dashboard, Chinese, the file tab with the banner and its two buttons over the last copy

Related Issues

Fixes #14236

Also fixes #14365 (the deleted-file data loss the last-copy surface answers).

Pattern harvest

Rule candidate: review-prompt
Pattern: a per-instance background connection (EventSource, WebSocket, long poll) armed on "mounted" rather than "visible", in a host that keeps hidden instances mounted.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@pepmach
pepmach requested review from a team and hoang-phan98 September 26, 2026 16:42
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 26, 2026
@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ human override accepted

Human judgment by @pepmach overrides the GPT 5.6 finding for 673afc56d98d3e97e1759a1eefbe0bcffe7a6029; the recorded reason is authoritative for this commit.

[GPT-OVERRIDE] 673afc5

This comment is updated in place on each push.

The model was not re-run because an authorized human decision supersedes it.

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 673afc56d98d3e97e1759a1eefbe0bcffe7a6029: <one-sentence reason>

@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — 🟡 CONCERNS

Design-level review of 673afc56d98d3e97e1759a1eefbe0bcffe7a6029 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: CONCERNS

Placeholder detection by string-equality with a localized sentence makes the last-copy guard depend on the current locale, not on tab state.

Watch

bufferIsLastCopy / lastCopy decide "not a real copy" by comparing the buffer to i18nT('pages.chatPage.file_not_found_on_disk_it_may_have_been_moved_or') (MarkdownPanel.tsx:1537, 1542) — but the placeholder is seeded into the buffer as rendered text in four host sites. Cause: the "this buffer is a placeholder" verdict lives in the content string; mechanism: a live language switch (which useLanguageGeneration exists to support) or a catalog rewording leaves an old-locale placeholder that no longer equals the sentinel; consequence: the banner and the "Discard the file's remaining contents?" prompt stand over placeholder prose and offer to download it under the file's name — and, in reverse, a real file whose content happens to equal the sentence closes with no guard. This PR itself establishes the right pattern for exactly this category of verdict (binary, and the new partial, are tab flags stamped by the read, "never guessed from the body") — the placeholder verdict is the one member of the family still guessed from the body.
Clears when: the placeholder is carried as a tab/host flag (like binary/partial) instead of a locale-rendered sentinel comparison, or a recorded rationale says why the sentinel is safe across language switches.

[DESIGN-REVIEWED] 673afc5

@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Fable 5) — 🟡 CONCERNS

UX-level review of 673afc56d98d3e97e1759a1eefbe0bcffe7a6029 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

UX-Verdict: CONCERNS

The tab strip's × still skips the new discard guard, so the most habitual close silently loses the last copy the banner warns about.

Watch

  • The guard covers the panel's close paths only; the PR's own Not-a-goal says the SidePanel.tsx tab × "bypasses the panel's close guard" (deferred to refactor(dashboard): host the session side panel inline in main, not a portal #12662). The blind reader's instinct on shot-01 — "I would not click the ×: closing might lose it" — is exactly the click that discards without the "Discard the file's remaining contents?" prompt. High frequency (× is the standard close) × data loss × every time; a human should decide whether the banner ships before refactor(dashboard): host the session side panel inline in main, not a portal #12662 closes the hole.
  • The banner hedges between causes the system already distinguishes: files.py sets X-Truncated, X-Redacted and X-Lossy-Decode separately, but isPartialRead collapses them and the string guesses "the copy was cut short or had credentials redacted" — for a lossy decode both halves are wrong. Plumb which verdict (the booleans are already on FileReadResult) and state it.
  • "Copy" means two things on shot-08: the "Copy content" button beside "the copy was cut short" — the blind reader flagged the collision. Rewording the banner per the previous item ("it was cut short") fixes both.

Suggestions

  • downloadFileName(filePath) + '.partial' yields release-checklist.md.partial, breaking the OS file association; use release-checklist.partial.md instead.

[UX-REVIEWED] 673afc5

@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — 🟡 CONCERNS

Premise-level review of 673afc56d98d3e97e1759a1eefbe0bcffe7a6029 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: CONCERNS

The frozen ## Not a goal defers "a redaction header from api_file_read" as "a follow-up" — this diff ships it anyway, plus a second header beside it.

Not justified as shipped

  • Item 6 — oversized: the description's frozen scope says "a redaction header from api_file_read: the panel works from what the read returns today; the header is a follow-up", yet files.py adds X-Redacted, X-Lossy-Decode and the strict-then-replace decode that feeds it. The read already returns X-Truncated today (consumed on base at MarkdownPanel.tsx:872), so the in-goal partial verdict needs no gateway change.
    Subtraction: delete the X-Redacted/X-Lossy-Decode emission and _TextRead.lossy in files.py, and redacted/lossy on FileReadResult; let isPartialRead rest on truncated alone.
    Clears when: the mechanism is removed, or a human amends the Goal.

What this change ships

Inventory (10 items) — 8 justified

Intent: FIX — stop six idle file-tab watch streams starving every other dashboard request (#14236), and stop a file deleted under an open tab taking its last copy with it (#14365).

  1. Six open tabs hold one watch stream, for the visible tab only — justified
  2. A tab re-reads its file on mount, on return to visibility, and on leaving edit mode; an equal first frame costs no read — justified
  3. A deleted file's tab keeps the last copy on screen under a banner with Copy and Download — justified
  4. Closing or re-targeting a tab whose file is gone (or unverifiable) asks first, Download in the dialog — justified
  5. A visible tab whose file is gone polls for its return, 1 s doubling to 30 s — justified
  6. The gateway's file read newly announces a redacted or lossily decoded body in two headers — oversized: the frozen Not-a-goal defers exactly this
  7. Tabs carry a partial verdict; banner and prompts say "only part of it", downloads named .partial — justified
  8. A save no longer clears dirty when typing landed mid-write, and every read or save drops the shared cache entry — justified
  9. Thirteen new strings in twelve languages — justified
  10. A new screenshot harness script — rides along (644 sibling capture-*.mjs scripts; harm-free)

[FIRST-PRINCIPLES-REVIEWED] 673afc5

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 26, 2026
@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5 Review — ✅ no blocking findings

Reviewed 673afc56d98d3e97e1759a1eefbe0bcffe7a6029 — this comment is updated in place on each push.

Review details

No findings that block.

FINDING — website/src/components/MarkdownPanel.tsx:1541 — the placeholder exclusion compares the buffer to a localized string (content !== i18nT('pages.chatPage.file_not_found_on_disk_it_may_have_been_moved_or')), and a language switch repaints without remounting (LanguageProvider uses cloneElement, and the tab store is module-level, so content and missingOnDisk both survive), so a tab sitting on a missing file flips lastCopy to true the moment the language changes — the banner claims "nothing else holds its contents" over the placeholder sentence, downloadLastCopy hands that sentence to the browser under the real file's name, and an ordinary close now demands "Discard the file's remaining contents?" → Fix: carry "this buffer is the not-found placeholder" as a tab field set where the placeholder is written (the same three writers this diff already touches for partial) instead of string-comparing rendered copy; bufferIsLastCopy at :1535 has the same comparison.

FINDING — website/src/utils/fileReadQuery.ts:44 — X-Lossy-Decode is folded into the same partial verdict as truncation and redaction (return r.truncated || r.redacted || r.lossy), but the only strings that verdict selects assert a cause that did not happen: a Latin-1 notes.txt that is deleted while open gets "this tab holds only part of it (the copy was cut short or had credentials redacted)" for a buffer that holds the whole file mis-decoded, and its rescue lands as notes.txt.partial — while the real hazard (U+FFFD in place of the original bytes) is never named → Fix: give the lossy verdict its own banner/close string (the catalogs are already edited in this diff), and correct the file header, which still says "the two PARTIAL verdicts" beside three fields.

[OPUS-REVIEWED] 673afc5

Verdict parsed from the review's SHA-scoped output markers for commit 673afc56d98d3e97e1759a1eefbe0bcffe7a6029.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 673afc56d98d3e97e1759a1eefbe0bcffe7a6029: <one-sentence reason>

@pepmach
pepmach force-pushed the fix/side-panel-watch-visible-tab-only branch from 5310ee3 to 2d86b96 Compare September 26, 2026 17:58
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 26, 2026
@pepmach

pepmach commented Sep 26, 2026

Copy link
Copy Markdown
Contributor Author
  • Item 3 — the catch-up read for clean editor tabs, span=df28e3757725 — declared-and-kept

Kept, not deleted. The catch-up read runs for every hidden tab that comes back, editor tabs included; the deletion FP proposes is a !editing term on catchUpArmable.
That term reopens the block the GPT lane placed on the first local candidate: a clean editor buffer left at the pre-change revision is exactly what a later save writes over the newer file, and the issue's acceptance names it ("switching tabs picks up a change made while the tab was hidden; an editing or dirty tab still holds no stream").
It also reopens two verified snapshot gaps the re-armed stream cannot cover: api_file_watch emits nothing for a file emptied while the tab was hidden (it emits only when content differs from its initial empty string), and a stream that fails to connect is closed for good by useFileWatch while a queued GET still lands.
The harm of the deletion is named in the PR body ("a clean editor buffer left stale is what a later save writes over the newer file"); the read adds no surface, one GET per return.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Sep 26, 2026
@pepmach
pepmach force-pushed the fix/side-panel-watch-visible-tab-only branch from 2d86b96 to 17f66b6 Compare September 26, 2026 19:42
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 26, 2026
@pepmach
pepmach force-pushed the fix/side-panel-watch-visible-tab-only branch from 17f66b6 to 98555c5 Compare September 26, 2026 20:52
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 26, 2026
@pepmach
pepmach force-pushed the fix/side-panel-watch-visible-tab-only branch from 98555c5 to 49c24ab Compare September 26, 2026 22:42
@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Sep 26, 2026
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 27, 2026
@pepmach

pepmach commented Sep 27, 2026

Copy link
Copy Markdown
Contributor Author

Description gains the **Goal:** line and ## Not a goal section the PR template requires since #14181 — a first write of the frozen sections from this PR's opening intent, not an edit of a frozen goal. Head unchanged by this edit; the round-8 fixes push follows in this window.

@pepmach
pepmach force-pushed the fix/side-panel-watch-visible-tab-only branch from 39b3892 to 8a28f7c Compare September 27, 2026 06:43
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 27, 2026
@pepmach
pepmach force-pushed the fix/side-panel-watch-visible-tab-only branch from 8a28f7c to e3735e8 Compare September 27, 2026 08:41
@pepmach
pepmach requested a review from a team as a code owner September 27, 2026 08:41
@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Sep 27, 2026
Every open file tab in the chat side panel held its own /api/file-watch
EventSource whether or not it was visible. The gateway serves HTTP/1.1 and
Chromium allows six connections per host, so six idle tabs starved every
other request the dashboard makes (uploads, chat sends, polls).

MarkdownPanel arms the watch only while the tab is the visible one, and a
tab re-reads its file when it becomes visible again, through the same
readFromDisk/applyDiskRead pair and under the same dirty/superseded guards,
so a change made while the tab was hidden is on screen on reactivation. A
tab with unsaved edits keeps them and does not re-read.

Fixes #14236
@github-actions

Copy link
Copy Markdown
Contributor

AI-review override not recorded: keep the reason to 500 characters or fewer.

@pepmach

pepmach commented Sep 27, 2026

Copy link
Copy Markdown
Contributor Author
  • bufferIsLastCopy / lastCopy compare the buffer to the locale-rendered placeholder sentence, span=a9912acdb233 — accepted-and-deferred

Deferred to #14449 (item 2, assignee pepmach, Due: 2026-10-09): carry "placeholder-seeded" on the tab the way binary and partial are carried, set where the host seeds the sentence and cleared by any edit or disk adoption, and drop the comparison.
Why not here: the four seeding sites and the tab store are the useDiskSync hook extraction planned with #14259; on this head the comparison is safe for a tab opened and closed in one locale, and the one edge -- a language switch between the seed and the close -- makes the banner offer the placeholder prose for download, never a real copy lost.

@pepmach

pepmach commented Sep 27, 2026

Copy link
Copy Markdown
Contributor Author
  • The tab strip's × and middle-click bypass the panel's close guard, span=717f18db660c — accepted-and-deferred

Deferred to #14449 (item 1, assignee pepmach, Due: 2026-10-09): a per-tab handle registry in SidePanel so the chip's × and middle-click ask requestClose (the tab activated first when hidden, so the prompt renders).
Why not here: those paths live in SidePanel.tsx, which #12662 is changing, and on main today they discard a dirty tab unasked too -- this PR narrows nothing there and adds the guard to every path the panel itself owns (Escape, its header close, requestClose, and now the rail re-target).

@pepmach

pepmach commented Sep 27, 2026

Copy link
Copy Markdown
Contributor Author
  • The partial banner names causes the system already tells apart, span=d72e38115e77 — accepted-and-deferred

Deferred to #14449 (item 3, assignee pepmach, Due: 2026-10-09): carry the three header verdicts (X-Truncated, X-Redacted, X-Lossy-Decode) to the panel separately and word each -- cut short at the gateway's cap, credentials redacted, could not be decoded as UTF-8 -- instead of the folded partial verdict and its "cut short or had credentials redacted" guess.
Why not here: the fold is what keeps the guard and the .partial download name correct for every cause on this head; the per-cause strings are catalog work across twelve languages, deferred so this head can freeze.

@pepmach

pepmach commented Sep 27, 2026

Copy link
Copy Markdown
Contributor Author
  • "Copy content" beside "the copy was cut short" -- two senses of copy on the partial banner, span=7e9f7f8fb9a5 — accepted-and-deferred

Deferred to #14449 (item 3, assignee pepmach, Due: 2026-10-09): the per-cause rewording of the partial banner ("it was cut short at the gateway's cap" / "credentials were redacted" / "it could not be decoded") removes "copy" from the sentence, so the button's "Copy content" stands alone.

@pepmach

pepmach commented Sep 27, 2026

Copy link
Copy Markdown
Contributor Author
  • release-checklist.md.partial breaks the OS file association, span=c909f73c7887 — accepted-and-deferred

Deferred to #14449 (item 4, assignee pepmach, Due: 2026-10-09): name a partial download <stem>.partial.<ext> so the extension stays last.

@pepmach

pepmach commented Sep 27, 2026

Copy link
Copy Markdown
Contributor Author
  • Item 6 — the redaction and lossy-decode headers in api_file_read are outside the frozen scope, span=04b0f0227436 — declared-and-kept

Kept. The headers exist because the review's own blocking finding on 8a28f7c0fa (a body-shape guess for "this buffer is a prefix" suppressed the last-copy close guard) left no way for the panel to know a body is not the file as written except the read saying so: nothing in a body can carry that verdict, a file may quote the redaction tag or the replacement character itself. The data loss they prevent is the one #14365 records (a stale or partial buffer written back over a file deleted on disk, or offered for download under the file's own name as if whole). Three header lines and one strict-then-replace decode; the panel reads them through one predicate.
The "Not a goal" bullet that called the header a follow-up predates that finding and is now stale; amending it is the maintainer's edit of a frozen section, requested in the review thread.

@pepmach

pepmach commented Sep 27, 2026

Copy link
Copy Markdown
Contributor Author
  • The placeholder exclusion compares against a localized string a language switch changes, span=62c33351e01e — accepted-and-deferred

Deferred to #14449 (item 2, assignee pepmach, Due: 2026-10-09): a tab-level "placeholder-seeded" flag replaces the sentence comparison. Until then a tab seeded in one locale and closed in another is offered the placeholder prose for download under the file's name -- a wrong offer, not a lost copy.

@pepmach

pepmach commented Sep 27, 2026

Copy link
Copy Markdown
Contributor Author
  • X-Lossy-Decode folded into partial selects strings that name a cause that did not happen, span=b1174055f901 — accepted-and-deferred

Deferred to #14449 (item 3, assignee pepmach, Due: 2026-10-09): per-cause wording for the banner and the close prompt. On this head the fold keeps the guard and the .partial name right for a lossy decode; only the sentence's stated cause is off for that one case.

@pepmach

pepmach commented Sep 27, 2026

Copy link
Copy Markdown
Contributor Author

/ai-review override gpt 673afc5: The review's own flag, not a data-loss path: it needs a file whose whole content is byte-identical to the locale's "file not found" sentence (MarkdownPanel.tsx:1537). The seeded sentence cannot be saved back -- saving is dirty-gated (:2597, Cmd+S :2552/:2610, the edit band collapsed until dirty :2700) -- so such a file must be authored to say exactly that, and all a guard-less close then discards is that catalog sentence (en.manual.json:4566): reconstructible. Tab flag tracked in #14449.

@github-actions

Copy link
Copy Markdown
Contributor

Human judgment recorded

@pepmach marked the gpt AI finding as false positive, not applicable, or explicitly accepted for 673afc56d98d3e97e1759a1eefbe0bcffe7a6029.

The review's own flag, not a data-loss path: it needs a file whose whole content is byte-identical to the locale's "file not found" sentence (MarkdownPanel.tsx:1537). The seeded sentence cannot be saved back -- saving is dirty-gated (:2597, Cmd+S :2552/:2610, the edit band collapsed until dirty :2700) -- so such a file must be authored to say exactly that, and all a guard-less close then discards is that catalog sentence (en.manual.json:4566): reconstructible. Tab flag tracked in #14449.

This decision applies only to this commit. A new push requires a new judgment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants