Skip to content

feat(web): tool progress toasts + persist all per-screen state across navigation (#1414, #1417) - #1420

Merged
cliffhall merged 6 commits into
v2/mainfrom
feat/1414-progress-toasts-persist-tool-state
Jun 3, 2026
Merged

cliffhall merged 6 commits into
v2/mainfrom
feat/1414-progress-toasts-persist-tool-state

Conversation

@cliffhall

@cliffhall cliffhall commented Jun 2, 2026 •

Copy link
Copy Markdown
Member

Closes #1414. Closes #1417.

This PR delivers two related pieces of v2 state-persistence work.

#1414 — Tool progress toasts

Incoming notifications/progress are surfaced as toasts (the v2 replacement for v1's always-visible "Server Notifications" shelf) so progress is visible while staying on the tool view. Toasts are keyed per progress stream and updated (not stacked) per tick so a chatty server doesn't flood the corner. The full history still lives in the History tab.

#1417 — Persist per-screen selection / search / filter / scroll across navigation

The screens unmount on tab switch, so all their local state used to be lost. This lifts every screen's session state into App as controlled props (controlled "dumb" components, per #1417), cleared only on disconnect (resetSessionScopedUiState) or an explicit user action — never on plain navigation.

Lifted per screen:

  • Tools — selected tool, form values, result (result/selection landed under Show tool progress notifications as toasts (and stop clearing tool selection/results on navigation) #1414), sidebar search
  • Prompts — selected prompt, argument values, submitted marker, search
  • Resources — selected resource/template URI, originating-template marker, search, accordion open-sections
  • Apps — selected app, form values, search (running/maximized stay local — they're tied to the live iframe/bridge that's torn down on unmount, so persisting the flag without its runtime would render a broken app)
  • Tasks — search + status filter
  • Logs — filter text + visible-level set
  • History — search + method filter
  • Network — filter text + visible-category set

The four sidebar *Controls became controlled for search; ResourceControls also controls accordion open-sections.

Scroll — useScrollMemory (a module-keyed hook) remembers each list's scroll offset across unmount/remount and is cleared on disconnect; wired into the Logs/History/Network/Tasks list panels and the Tools/Prompts/Apps sidebars. Pagination already persists (it lives in the App-level Paged*State managers), so no work was needed there.

Acceptance criteria (#1417)

Testing

  • npm run validate (format:check + lint + build + test:coverage) — passes; per-file coverage gate satisfied (1474 unit tests).
  • npm run test:storybook — 329 passed (controlled screens/controls got stateful story hosts).

🤖 Generated with Claude Code

…s navigation (#1414)

Surface incoming notifications/progress as toasts so the user can watch a
long-running tool's progress without leaving the tool view — the v2 replacement
for v1's always-visible "Server Notifications" shelf. Toasts are keyed by
progress stream and updated (not stacked) per tick so a chatty server updates
one toast rather than flooding the corner. Progress notifications still land in
the History tab via the existing transport-level tracking.

Companion change: lift the selected tool and its form values into App.tsx
alongside the already-lifted toolCallState, make ToolsScreen controlled, and
drop the clear-on-unmount effect. Leaving the Tools tab and returning now
preserves selection, inputs, and result. All three reset together on
disconnect via resetSessionScopedUiState, preserving the #1368/#1394 behavior.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@cliffhall cliffhall added the v2 Issues and PRs for v2 label Jun 2, 2026
@cliffhall

Copy link
Copy Markdown
Member Author

Tool progress in toast

Screenshot 2026-06-02 at 7 58 21 PM

cliffhall and others added 2 commits June 2, 2026 22:39
…on (#1417)

Lift every screen's selection, form, search, and filter state out of the
screen components into session-scoped state owned by App, passed down as
controlled props. The screens unmount on tab switch, so this is what keeps
the user's context in place when they navigate away and back within a live
session. State is cleared only on disconnect (resetSessionScopedUiState) or
an explicit user action — never on plain navigation.

Lifted per screen:
- Tools: sidebar search (selection/form/result were lifted in #1414)
- Prompts: selected prompt, argument values, submitted marker, search
- Resources: selected resource/template URI, originating-template marker,
  search, accordion open-sections
- Apps: selected app, form values, search (running/maximized stay local —
  they're tied to the live iframe/bridge that is torn down on unmount)
- Tasks: search + status filter
- Logs: filter text + visible-level set
- History: search + method filter
- Network: filter text + visible-category set

The four sidebar *Controls (Tool/Prompt/App/Resource) become controlled for
search; ResourceControls also controls accordion open-sections. Level/category
default maps move to logLevels.ts / fetchCategories.ts so the screen files
keep a single component export.

Pagination already persists (it lives in the App-level Paged*State managers),
so no work was needed there.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ts (#1417)

Add useScrollMemory: a module-keyed hook that remembers a Mantine ScrollArea's
offset across unmount/remount (the screens unmount on tab switch). Scroll lives
in a module-scope map rather than threaded App state — it's ephemeral DOM state,
and threading ~16 more props would balloon the surface for no benefit. App calls
clearScrollMemory() in resetSessionScopedUiState so offsets clear on disconnect
alongside the lifted selection/filter state.

Wired into the four main list panels (Logs, History, Network, Tasks) and the
Tools/Prompts/Apps sidebar lists. Pagination already persists via the App-level
Paged*State managers.

Tests: useScrollMemory unit test (save/restore, key isolation, clear), and the
App disconnect test now also exercises representative lifted UI state (tool
search, prompt selection, log filter) clearing on disconnect.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@cliffhall cliffhall changed the title feat(web): tool progress toasts + persist tool selection/result across navigation (#1414) feat(web): tool progress toasts + persist all per-screen state across navigation (#1414, #1417) Jun 3, 2026
@cliffhall

Copy link
Copy Markdown
Member Author

@claude review

@claude

claude Bot commented Jun 3, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @cliffhall's task in 2m 12s —— View job


Code Review

  • Read the diff against origin/v2/main
  • Review progress-toast logic (App.tsx)
  • Review state-lifting & controlled props (App + screens + controls)
  • Review useScrollMemory hook
  • Check tests & coverage

Solid, well-documented PR. The controlled-component lift is consistent across all eight screens, the comments explain the why (which deviations are intentional — running/maximized staying local, openSections falling back to compact), and the new modules (logLevels.ts, fetchCategories.ts, useScrollMemory.ts) are cleanly factored with tests. Nothing here blocks merge — the notes below are minor/optional.

Observations (non-blocking)

1. Progress toasts collapse to one stream when no token is sent — App.tsx:218
progressToastId falls back to progress-default when progressToken is absent (the common case you note). Two concurrent long-running tool calls without tokens would interleave their messages into a single toast. Acknowledged in the comment and acceptable, but worth keeping in mind if multi-call progress ever becomes common.

2. Client-swap cleanup doesn't dismiss visible toasts — App.tsx:~625
The effect cleanup does liveToastIds.clear() but doesn't notifications.hide(id) the toasts still on screen, so a stale "Tool progress" toast can linger up to PROGRESS_TOAST_AUTOCLOSE_MS (5s) into the next session. There's also a narrow race: the lingering toast's onClose later runs liveToastIds.delete(id) against the new session's set — if the new session already showed progress-default, that untracks it and the next tick show()s a duplicate-id toast. Dismissing tracked ids in cleanup would close both gaps:

return () => {
  inspectorClient.removeEventListener("progressNotification", onProgress);
  liveToastIds.forEach((id) => notifications.hide(id));
  liveToastIds.clear();
};

Fix this →

3. notifications.update resetting the auto-close window — App.tsx:~600
The comment relies on Mantine resetting the 5s timer on each update. That's the documented behavior, so this is fine — just flagging it as the load-bearing assumption behind "a steady stream keeps one toast alive."

4. Minor: default-{} props create a fresh object each render — ToolsScreen (values = formValues ?? {}) and AppsScreen (formValues = {}). Harmless today, but it gives child panels a new object identity every render, which would defeat any future memo/useMemo keyed on those props. Not worth changing now.

5. AppsScreen: navigating away from a running app doesn't call onCloseApp() — the iframe is torn down by AppRenderer unmounting, and selectedAppName/formValues persist so the form is shown ready to re-open. This matches the documented intent and prior (running-was-always-local) behavior; just confirm no App-level "app is open" state is left stale after such an unmount.

Things I checked that are good

  • ALL_LEVELS_VISIBLE / ALL_CATEGORIES_VISIBLE are shared module constants used as state seeds + reset values, but every toggle spreads into a new object, so the shared references are never mutated. Safe.
  • resetSessionScopedUiState resets all 20+ lifted fields and clearScrollMemory() — disconnect-clears-everything is complete.
  • All seven useScrollMemory keys are distinct (tools-sidebar, prompts-sidebar, apps-sidebar, logs-stream, history-list, network-stream, tasks-list) — no clobbering between concurrently-mounted regions.
  • useScrollMemory closes over the captured viewport node for the unmount save (correct — viewportRef.current would be null during cleanup otherwise), and restores in useLayoutEffect before paint.
  • onClearResult is still wired (ToolDetailPanel "Clear" button → onClearToolResult → setToolCallState(undefined)); removing the unmount-clear didn't orphan it.
    · feat/1414-progress-toasts-persist-tool-state

cliffhall and others added 2 commits June 3, 2026 08:45
…bject

Replace the ~46 individual selection/search/filter props threaded App →
InspectorView → screen with one `{screen}Ui` object + one `on{Screen}UiChange`
setter per screen (8 pairs). Each screen reads its fields from `ui` and updates
via `onUiChange({ ...ui, field })`; the in-flight result panels
(toolCallState / getPromptState / readResourceState) stay separate since
they're written by App's async action handlers, not the screens.

The `*UiState` interfaces live with their screens; the empty-state defaults are
gathered in screenUiState.ts so the screen files keep a single component export
(react-refresh), mirroring logLevels.ts / fetchCategories.ts.

Trims InspectorView's prop surface substantially and keeps the persistence
behavior identical. Tests/stories collapse their stateful wrappers to a single
ui object; added Tools/Tasks/History interaction tests to keep per-file
coverage above the gate.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…eview)

The progressNotification effect cleanup cleared its id-tracking set but left
on-screen "Tool progress" toasts to auto-close up to 5s later — they could
linger into the next session, and the lingering toast's onClose could delete an
id from the new session's set and trigger a duplicate-id re-show. Hide each
tracked toast in cleanup so both gaps close. Addresses @claude review note #2.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@cliffhall

Copy link
Copy Markdown
Member Author

Thanks for the thorough review @claude — went through all five:

2. Client-swap cleanup doesn't dismiss visible toasts — fixed (dc8549e). The effect cleanup now hides each tracked toast before clearing the set:

liveToastIds.forEach((id) => notifications.hide(id));
liveToastIds.clear();

This closes both gaps — the stale toast lingering up to PROGRESS_TOAST_AUTOCLOSE_MS into the next session, and the onClose-deletes-the-new-session's-id race that could re-show a duplicate. Added a test (dismisses still-visible progress toasts when the client is torn down) that fires a tick then tears down the client and asserts notifications.hide(id).

1. Toasts collapse to one stream without a token — leaving as-is, intentional. The inspector doesn't expose a caller progress token today, so concurrent untokened tool calls aren't reachable from the current UI (one call at a time per the Tools view). The comment flags it; if multi-call progress ever lands, the per-token keying is already in place to separate them.

3. notifications.update resetting the auto-close window — confirmed, that's the documented Mantine behavior and it's the load-bearing assumption behind "a steady stream keeps one toast alive." No change.

4. default-{} props create a fresh object each render — already moot after the {screen}Ui collapse: ToolsScreen and AppsScreen now destructure formValues straight off the ui prop (const { …, formValues, … } = ui) with no per-render ?? {} / = {} fallback, so child panels get a stable object identity.

5. Navigating away from a running app leaves no stale App-level state — confirmed. There's no App-level "app is open" flag; appRendererRef is just a ref to the renderer handle that nulls when AppRenderer unmounts, and onCloseApp only calls teardown(). running/maximized are AppsScreen-local (torn down with the screen); only selectedAppName/formValues persist in appsUi, so on return you get the input form ready to re-open, matching the documented intent.

Also confirmed your "things I checked" list still holds after the {screen}Ui refactor — shared ALL_*_VISIBLE seeds are never mutated (every toggle spreads into a new object), resetSessionScopedUiState clears all lifted state + clearScrollMemory(), and the seven scroll keys remain distinct.

npm run validate + test:storybook green.

@claude

claude Bot commented Jun 3, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @cliffhall's task in 1m 45s —— View job


Re-review of the review responses


Thanks for the thorough write-up — went through each point. The fix is correct and the rationale on the other four holds. 👍

#2 (fixed) — verified. App.tsx:565 now does liveToastIds.forEach((id) => notifications.hide(id)) before clear() in the effect cleanup. This closes the lingering-toast gap and substantially shrinks the onClose-races-the-next-session window. The new test (dismisses still-visible progress toasts when the client is torn down) fires a tick, unmounts, and asserts notifications.hide(id) with the captured show id — ran it locally, all three progress-toast tests pass.

One residual, non-blocking: notifications.hide(id) still fires the toast's onClose (→ liveToastIds.delete(id)) asynchronously as it transitions out. Since liveToastIds is the same stable ref (progressToastIdsRef.current) across effect re-runs, a new session that show()s progress-default before the hidden toast's onClose settles could have that id deleted from under it, re-opening the exact duplicate-id case in miniature. Hiding makes this window sub-second instead of 5s, so it's a real improvement and fine to ship — just noting the onClose-mutates-a-shared-ref shape is the same one, only narrower. If you ever want it airtight, having onClose guard on "is this still the current session" (or keying the set per client instance) would eliminate it entirely.

#1 (toasts collapse without a token) — agree, leave as-is. One call at a time from the Tools view today; per-token keying is already in place for when/if multi-call progress lands. The comment flags it.

#3 (update resets auto-close) — confirmed. Documented Mantine behavior; correct load-bearing assumption.

#4 (fresh {} each render) — confirmed moot. After the {screen}Ui collapse, ToolsScreen/AppsScreen destructure formValues straight off the ui prop with no ?? {} / = {} fallback, so identity is stable. Nice — that also addresses the original observation more cleanly than a memo would have.

#5 (running app, no stale App-level state) — confirmed. No App-level "open" flag; appRendererRef nulls on AppRenderer unmount and onCloseApp only calls teardown(). running/maximized stay AppsScreen-local; selectedAppName/formValues persist in appsUi, so return shows the re-open form. Matches documented intent.

Also re-confirmed the "things I checked" list survives the {screen}Ui refactor: ALL_*_VISIBLE seeds never mutated, resetSessionScopedUiState clears all lifted state + clearScrollMemory(), seven distinct scroll keys. No blockers from me — LGTM.
· feat/1414-progress-toasts-persist-tool-state

The Tools result panel renders `toolCallState` regardless of which tool is
selected, so selecting a new tool used to leave the previous tool's result
showing beneath it. Route tools UI changes through an App handler that drops
`toolCallState` whenever `selectedToolName` changes; search/form edits keep the
selection (and the result) intact. Tests cover both the clear-on-switch and
keep-on-search paths.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@cliffhall
cliffhall merged commit 8923a9b into v2/main Jun 3, 2026
1 check passed
@cliffhall
cliffhall deleted the feat/1414-progress-toasts-persist-tool-state branch June 3, 2026 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v2 Issues and PRs for v2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show tool progress notifications as toasts (and stop clearing tool selection/results on navigation)

1 participant