Skip to content

Make open pages always take a newer frontend build - #610

Open
thiblahute wants to merge 1 commit into
powerfooI:mainfrom
thiblahute:upstream/freshness
Open

thiblahute wants to merge 1 commit into
powerfooI:mainfrom
thiblahute:upstream/freshness

Conversation

@thiblahute

Copy link
Copy Markdown
Collaborator

Summary

Make an open page actually take a newer frontend build: an empty chat box no longer holds the reload back, drafts survive it, and a page that has to wait says why with a button to reload now. A follow-up to #533.

Why

Since #533 an open page notices a new build after an upgrade, but in practice it never reloaded: the reload waited while any editable field held text, and an empty chat box counted, its CodeMirror placeholder ("Message claude...") being text of the editor. Any page showing an agent chat, desktop or phone, stayed on the build it was loaded with for hours and ran old code against the new server.

What changed

  • web/src/frontendFreshness.ts:
    • A placeholder is not text (editableText skips .cm-placeholder, aria-hidden and non-editable parts).
    • Only text the user typed (a keydown, input or paste in it) in a field that does not keep it holds the reload. Boxes marked data-draft-saved and fields the page filled in itself never do.
    • reloadHold decides what holds the reload and until when: sending and uploads and a pause in typing (5 s) end by themselves; an open dialog closes with the reload once the page has been left alone 2 minutes or is hidden; unsaved typed text waits for the user.
    • The page also checks every 5 minutes, and checkFrontendFreshness() lets code that fails against the server ask at once.
    • A small store (frontendFreshnessState, subscribeFrontendFreshness, reloadForNewerBuild) for the notice.
  • web/src/App.tsx: a "A new version of Roamgate is available" toast when the wait is longer than 15 s or only the user can end it, saying what it waits for, with "Reload now". Dismissed, it comes back after 10 minutes.
  • web/src/terminalComposer.ts: terminalComposerDraftSaved(key); TerminalComposer and AgentHistoryComposer mark themselves data-draft-saved when their draft is kept in the browser.
  • web/src/composerAttachments.ts: attachments' paths and names are kept in the tab's session storage, so a reloaded draft shows its images as [Image #N] again (without thumbnails).
  • scripts/check-web-assets.mjs: initial JS budget 833 to 836 KiB, gzip 257 to 258 KiB.
  • FEATURES.md: the reload paragraph.

Verification

  • bun test web/src/frontendFreshness.test.ts web/src/terminalComposer.persistence.test.ts web/src/composerAttachments.test.ts web/src/components/AgentHistoryComposer.test.tsx: 46 pass. New tests, which fail on main:
    • frontendFreshness.test.ts: "what holds a reload back, and until when", "an editor's placeholder is not text", "an empty chat box shown with its placeholder does not hold the reload", "a composer's draft is kept by the browser and does not hold the reload", "a page filled-in field does not hold the reload, a typed one does", "typing holds the reload until a pause", "an open dialog is closed by the reload once the page is left alone", "typed text never reloads by itself, but the notice's button does", "a short wait shows no notice, a long one does", "the page checks by itself now and then, and when something fails"
    • terminalComposer.persistence.test.ts: "a pane's box says its draft outlives a reload once its scope is active"
    • composerAttachments.test.ts: "a reload shows a draft's images as [Image #N] again, without thumbnails"
  • bun run format:check, bun run lint (only the existing TerminalView.tsx warning), bun run typecheck:bun, bun run build:web, bun run test:quick with an isolated HOME/TMPDIR.
  • Asset budget: initial JS 835.1/836 KiB, gzip 257.6/258 KiB, CSS 189.0/196 KiB. The budget is raised in this PR (833 to 836 KiB, 257 to 258 KiB gzip).

Compatibility

Frontend only. An open dialog (settings, a confirmation) is now closed by the reload once the page has been left alone two minutes; text typed into it still holds the reload until the user sends, clears or reloads. The existing tests for unsent text, an unfocused API key in a dialog, and pending uploads still pass.

Manual checks

  • Open an agent chat with an empty box, deploy a new build: the page reloads by itself.
  • Type a draft with an attached image in a pane's message box, deploy a new build, stop typing: the page reloads and the draft comes back with [Image #1].
  • Type in a dialog's text field, deploy a new build: a notice says at once that the reload waits for unsaved text, and "Reload now" reloads.

An open page noticed each new build after an upgrade but never reloaded:
the reload waited while any editable field held text, and an empty chat
box counted, its CodeMirror placeholder ("Message claude...") being text
of the editor. Any page showing an agent chat, desktop or phone, stayed on
the build it was loaded with, for hours, and ran old code against the new
server.

A placeholder is no longer text, and only text the user typed in a field
that does not keep it holds the reload. The message boxes' drafts are
kept in the browser and come back after it, and attached images show as
[Image #N] again. The reload waits for sending and uploads and for a
pause in typing; an open dialog closes with it once the page has been
left alone two minutes or is hidden. A wait longer than 15 s, or one only
the user can end, shows a notice saying why, with a button to reload now.
The page also checks every five minutes.

The initial JS budget goes from 833 to 836 KiB and its gzip budget from
257 to 258 KiB for the notice and the reload logic.
@github-actions github-actions Bot added the enhancement New feature or request label Nov 20, 2026

This branch has not been deployed

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant