Skip to content

feat(web): list-changed handling — indicator, pull-on-demand default, and per-server auto-refresh opt-in (#1402) - #1443

Merged
cliffhall merged 9 commits into
v2/mainfrom
feat/sidebar-listchanged-1402
Jun 8, 2026
Merged

cliffhall merged 9 commits into
v2/mainfrom
feat/sidebar-listchanged-1402

Conversation

@cliffhall

@cliffhall cliffhall commented Jun 8, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes #1402.

This started as "wire the listChanged sidebar indicator across all screens" and grew into the full list-changed handling story for Tools, Apps, Prompts, and Resources. The throughline: make the list-changed indicator meaningful (the server changed its list since you last looked), make manual Refresh the default way to pull the new list, and give servers/users an opt-in to restore eager auto-refresh.

What changed

1. Wire the listChanged indicator across all screens

InspectorView hardcoded listChanged={false} for Tools, Apps, Prompts, and Resources, so the indicator could never light up. The flag is now sourced from the managed-state layer:

  • Each ManagedXState tracks a listChanged boolean — exposed via getListChanged() + a listChangedChange event, cleared by clearListChanged() or on disconnect.
  • The useManagedX hooks surface the flag and clear it on a user-initiated refresh() (clearing before the awaited fetch so a notification arriving mid-fetch isn't lost — race fix).
  • App threads the three flags to InspectorView, which maps them to screens. Apps shares the Tools flag (apps are a filtered view of tools); Resources uses resourcesListChanged (the single server notification that covers resources + templates).

2. Drop the duplicate Refresh on the Apps screen

AppControls uniquely had a standalone toolbar Refresh and the indicator on a separate row — so once the indicator could appear, Apps showed two Refresh buttons. Aligned it with the other three controls: the indicator is the single header-right refresh affordance.

3. Pull-on-demand by default (stop auto-invoking */list on list_changed)

With auto-refresh on, the list was already current by the time "List updated" appeared, making Refresh a no-op re-fetch (confirmed by capturing two tools/list calls — byte-identical results). Now the managed Tools/Prompts/Resources state only flags the change; the list stays as-is until the user pulls it. The connect-time initial load is unchanged. Resource templates stop auto-refreshing too; onRefreshResources refreshes both resources and templates (templates had no user-facing refresh wired before — gap closed). Tasks are intentionally left auto-refreshing (no indicator, need live status).

4. Per-server "Auto Refresh on List Changed Notifications" opt-in

A new Options section in ServerSettingsForm with a single checkbox (default off) restores eager auto-refresh per server. Plumbed end-to-end:

  • autoRefreshOnListChanged on InspectorServerSettings + StoredMCPServer, round-tripped through serverList (lift-default false, persist only when true, added to the exhaustive INSPECTOR_FIELD_KEY_MAP) and the server-side validateSettings write path.
  • InspectorClient.getServerSettings() added to InspectorClientProtocol; the state managers read it live at notification time to choose auto-refresh vs flag-only.
  • The toggle takes effect on the next (re)connect, consistent with how headers/timeouts/OAuth already behave (only roots applies live).

5. Default the Server Settings modal to the Options section

The modal now opens to Options instead of Custom Headers, surfacing the new toggle first.

Testing

  • State managers: flag set/clear/no-op/disconnect, on/off auto-refresh branch, and a mid-flight race regression.
  • Hooks: initial value, event subscription, refresh-clears, null-state.
  • InspectorView routing for all four screens + no-cross-wiring; AppControls/AppsScreen single-Refresh; ServerSettingsForm Options section (render/checked/toggle); modal default-section.
  • serverList round-trip (true persists / false omitted) and integration tests over the real PUT /api/servers path (the unit round-trip bypassed validateSettings, where the persistence bug lived).
  • npm run validate (lint/build/format/typecheck + unit & integration coverage gate) and npm run test:storybook green.

Notes / deliberate trade-offs

  • Apps and Tools share one flag (refreshing one clears the other's indicator).
  • Optimistic clear: a rejected refresh leaves the indicator cleared (these refreshes are fire-and-forget; no UI error today).
  • Lists can be stale until Refresh — the intended consequence of pull-on-demand.
  • The auto-refresh toggle applies on next (re)connect, not live; a setServerSettings-on-the-live-client follow-up is a reasonable future enhancement.

🤖 Generated with Claude Code

The per-screen list-changed indicator was hardcoded false in
InspectorView for Tools, Apps, Prompts, and Resources, so it could
never light up. Source it from the managed-state layer instead.

Each ManagedXState now tracks a listChanged flag: set true when its
*/list_changed notification arrives (the existing auto-refresh leaves
it set), exposed via getListChanged()/a listChangedChange event, and
cleared by clearListChanged() or on disconnect. The useManagedX hooks
surface the flag and clear it on a user-initiated refresh (the
indicator's Refresh button = acknowledge). App threads the three flags
to InspectorView, which maps them to the screens — Apps shares the
tools flag since apps are a filtered view of tools.

Tests cover set/clear/disconnect at the state-manager layer, the hook
subscription + refresh-clears behavior, and the InspectorView routing
(including Apps sharing the tools flag and no cross-wiring between
screens).

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

Copy link
Copy Markdown
Member Author

@claude review

@claude

claude Bot commented Jun 8, 2026 •

Copy link
Copy Markdown
Contributor

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


Review: wire the listChanged indicator across all screens (#1402)

  • Read changed source files (state managers, hooks, App, InspectorView)
  • Review state-manager changes
  • Review hook changes
  • Review App/InspectorView wiring
  • Review tests

Overall this is a clean, well-scoped, and well-tested change. The design — source the flag in the managed-state layer, set on notification, clear on user refresh or disconnect — matches what #1402 asks for, and the set-on-notification / leave-set-through-auto-refresh / clear-on-user-refresh semantics are implemented consistently across all three managers and hooks. The setListChanged no-op guard avoids redundant listChangedChange events and re-renders, which is a nice touch. 👍

Things I checked and liked

  • Apps shares the tools flag, and the refresh handler agrees. onRefreshApps={onRefreshTools} (App.tsx:2195) means refreshing on either Tools or Apps clears the shared flag — the wiring is internally consistent with the "apps are a filtered view of tools" decision, not just the listChanged prop. Good.
  • Disconnect clears the flag, and reconnect leaves it false (the onConnect auto-refresh doesn't re-set it). Correct.
  • Hook refresh() only clears after a real refresh — it returns early (return []) before clearListChanged() when there's no state/client, so it won't spuriously clear. Good.
  • No-cross-wiring test (tools changed ≠ prompts indicator) is a valuable assertion to have.

Minor observations (non-blocking)

  1. Clear-after-await race in the hooks. In each hook's refresh():

    const next = await managedToolsState.refresh();
    setTools(next);
    managedToolsState.clearListChanged();

    If a */list_changed notification arrives during the awaited refresh, the state's own handler sets the flag true (and kicks an auto-refresh), and then this clearListChanged() wipes that genuinely-new flag — the user would miss the indicator for that change. It's a narrow window and arguably acceptable, but worth a comment acknowledging it. Capturing the flag value before the await and only clearing if it hasn't re-fired would close it.

  2. Shared-flag UX side effect. Because Apps and Tools share toolsListChanged, refreshing Tools clears the indicator on Apps even if the user never visited Apps (and vice versa). This is documented as intentional in the PR, so just flagging it as a known behavior, not a defect.

  3. Triplication. The getListChanged/clearListChanged/setListChanged block is copy-pasted identically across the three state managers, and the hook wiring (useState + effect listener + cleanup) is likewise near-identical across the three hooks. This faithfully follows the existing pattern in these files, so it's consistent — but if these three managers/hooks ever get a shared base or factory, this flag logic is a prime candidate to hoist.

  4. Resources screen vs. resource templates. The Resources screen renders both resources and resource templates, and its indicator is driven solely by resourcesListChanged. That's correct per the MCP spec (a single notifications/resources/list_changed covers both), and the PR notes it — no change needed, just confirming the reasoning holds.

Tests

Coverage is thorough: state-manager set/clear/no-op/disconnect, hook initial/event/refresh-clears/null-state, and InspectorView routing for all four screens plus the negative case. Nothing obviously missing for this change.

No blocking issues — the minor race in (1) is the only item I'd consider tightening, and it's optional.
· feat/sidebar-listchanged-1402

…review)

The useManagedX refresh() callbacks cleared the listChanged flag AFTER
awaiting the fetch. If a */list_changed arrived mid-fetch, the state
re-set the flag (and auto-refreshed), then the trailing clear wiped that
genuinely-new signal. Clear BEFORE the await instead: the user's refresh
acknowledges only the change in hand, and a mid-fetch change re-sets the
flag and survives. Adds a race regression test on the tools hook.

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

Copy link
Copy Markdown
Member Author

Thanks for the thorough review! Addressed the actionable item; notes on the rest below.

1. Clear-after-await race — fixed (fac5e0ab)

Good catch — this was a real gap. Rather than capture-and-conditionally-clear, I moved the clearListChanged() to before the awaited fetch in all three hooks:

managedToolsState.clearListChanged();        // acknowledge the change in hand
const next = await managedToolsState.refresh();
setTools(next);

The user's refresh acknowledges only the change they're looking at; if a */list_changed arrives mid-fetch, the state re-sets the flag (and auto-refreshes) and it now survives, so the indicator correctly reappears. Added a race regression test on the tools hook (hang the fetch, fire a notification mid-flight, assert the flag stays set after the refresh resolves). It's the same logic in all three hooks, so one representative test covers the semantics.

Minor observations — acknowledged, no change:

  • 2. Shared-flag UX (refresh on Tools clears Apps' indicator). Intentional and documented — apps are a filtered view of the same tools list, and onRefreshApps deliberately maps to onRefreshTools, so a single acknowledge across both is the correct mental model.
  • 3. Triplication of the flag block / hook wiring. Agreed it's copy-paste, but it faithfully follows the existing per-manager/per-hook pattern in these files. If these three ever get a shared base/factory, the flag logic (and the existing *Change wiring) would hoist together — out of scope here.
  • 4. Resources vs. resource templates. Confirmed: a single notifications/resources/list_changed covers both per spec, so resourcesListChanged alone is correct. No change.

validate (incl. coverage gate) and test:storybook green.

@cliffhall

Copy link
Copy Markdown
Member Author

@claude review

@claude

claude Bot commented Jun 8, 2026 •

Copy link
Copy Markdown
Contributor

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


Re-review: wire the listChanged indicator across all screens (#1402)

  • Read state-manager changes
  • Read hook changes (race fix fac5e0ab)
  • Read App/InspectorView wiring
  • Review tests

The race fix from the prior round is correct and the right call. Moving clearListChanged() to before the awaited fetch is cleaner than capture-and-conditionally-clear: the user acknowledges the change in hand up front, and any */list_changed that lands mid-fetch re-sets the flag through the state manager's own handler — so it survives and the indicator reappears. The semantics are now consistent across all three managers/hooks, and the comment block on each refresh() explains exactly why the ordering matters. 👍

The new race-regression test (useManagedTools.test.tsx) is well-built — it hangs the fetch via mockImplementationOnce, asserts the optimistic clear, fires a fresh notification mid-flight, then asserts the flag survives the refresh resolving. That's precisely the window that was at risk, and one representative test for shared logic is the right scope.

Things I re-verified

  • Set on notification, left set through auto-refresh, cleared on user-refresh/disconnect — the onXListChanged handlers call setListChanged(true) then void this.refresh(), and refresh() itself never clears. Disconnect clears via onStatusChange. Correct end to end.
  • setListChanged no-op guard still prevents redundant listChangedChange dispatches / re-renders.
  • Wiring: toolsListChanged drives both Tools and Apps (Apps = filtered tools view, onRefreshApps→onRefreshTools), promptsListChanged→Prompts, resourcesListChanged→Resources. All listChanged={false} hardcodes are gone.

One small optional note (non-blocking)

  • Clearing before the await is optimistic. If managedToolsState.refresh() rejects (e.g. the fetch errors), the indicator has already been cleared even though the list wasn't actually refreshed — the user sees "caught up" over stale data. The old ordering happened to leave the indicator on in that case. This is a narrow edge and the trade-off is clearly worth it for closing the race; just flagging it. If you wanted to be strict you could re-set on failure, but I wouldn't bother unless refresh() is known to surface errors to the UI.

Nothing blocking — the prior observations (shared-flag UX, triplication, resources-vs-templates) were all addressed/acknowledged appropriately. LGTM. ✅
· feat/sidebar-listchanged-1402

@cliffhall

Copy link
Copy Markdown
Member Author

Thanks — glad the race fix landed cleanly.

On the optional note (optimistic clear over a rejected refresh): I considered restore-on-failure but decided to leave it as-is, which matches your own criterion ("I wouldn't bother unless refresh() is known to surface errors to the UI"). For these three primitives it doesn't — onRefreshTools/Prompts/Resources are deliberately fire-and-forget (void refreshX()), unlike onRefreshTasks, which is the one that surfaces list failures via notifications.show. So today a failed refresh produces no user-facing error regardless, and the optimistic clear matches that posture and typical refresh-button UX.

Restoring the flag on failure also has its own small wrinkle: the indicator label is literally "List updated", so re-showing it after a fetch that failed (the list did not update) would itself be slightly misleading. The clean time to add restore-on-failure is if/when these refreshes start surfacing errors to the UI the way tasks does — at which point the indicator and the error toast would be designed together. Flagging that as the natural follow-up rather than pre-building it here.

No code change for this one. Everything else from the prior rounds remains addressed.

@cliffhall

Copy link
Copy Markdown
Member Author

@claude review

@claude

claude Bot commented Jun 8, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @cliffhall's task in 52s —— View job


Re-review: wire the listChanged indicator across all screens (#1402)

  • Read state-manager changes
  • Read hook changes
  • Read App/InspectorView wiring
  • Review tests

This is the third pass, and the current state of the branch is solid — the two prior rounds' items are all landed or consciously deferred. Nothing new to flag. Re-verifying the end-to-end behavior against origin/v2/main:

State managers (managedToolsState / managedPromptsState / managedResourcesState) — identical, correct pattern in all three:

  • on*ListChanged → setListChanged(true) then void this.refresh(); the auto-refresh never touches the flag, so the indicator survives until acknowledged.
  • clearListChanged() is the only public reset (plus disconnect via onStatusChange).
  • setListChanged no-op guard (if (this.listChanged === value) return) prevents redundant listChangedChange dispatches/re-renders. 👍

Hooks — the race fix (fac5e0ab) is in place across all three: clearListChanged() runs before the awaited refresh(), so a */list_changed landing mid-fetch re-sets the flag through the state manager and the indicator correctly reappears. The comment on each refresh() explains the ordering. Initial value, event listener, and ?? false null-state fallback are all wired symmetrically.

Wiring — all four listChanged={false} hardcodes in InspectorView.tsx are gone:

  • toolsListChanged → Tools and Apps (Apps is the filtered tools view, onRefreshApps→onRefreshTools),
  • promptsListChanged → Prompts,
  • resourcesListChanged → Resources (single resources/list_changed covers templates per spec).

App.tsx threads the three flags via the renamed destructures; the prop block in InspectorViewProps is documented.

Tests — manager set/clear/no-op/disconnect, hook initial/event/refresh-clears/null-state + the mid-flight race regression on the tools hook, and InspectorView routing for all four screens plus the no-cross-wiring negative case. Thorough and appropriately scoped (one representative race test for shared logic).

Standing trade-offs (already discussed, no change expected)

  • Shared-flag UX: refreshing Tools clears the Apps indicator and vice-versa — intentional, since both reflect the same tools list.
  • Optimistic clear over a rejected refresh(): leaves the indicator cleared if the fetch errors. Acceptable because these three refreshes are fire-and-forget today (unlike tasks, which surfaces errors via notifications.show); the natural time to add restore-on-failure is when/if these refreshes start surfacing errors to the UI.
  • Triplication of the flag block / hook wiring: faithful to the existing per-manager/per-hook pattern; a candidate to hoist alongside the existing *Change wiring if these ever get a shared base.

No blocking issues. LGTM. ✅
· feat/sidebar-listchanged-1402

@cliffhall cliffhall linked an issue Jun 8, 2026 that may be closed by this pull request
4 tasks
AppControls uniquely had a standalone toolbar Refresh button AND the
ListChangedIndicator on a separate row, so once the indicator could
actually appear (this PR), the Apps screen showed two Refresh buttons.
Match the other three controls (Tools/Prompts/Resources): the indicator
is the single header-right refresh affordance. Updates AppControls and
AppsScreen tests to assert exactly one Refresh (and none when the list
hasn't changed).

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

Copy link
Copy Markdown
Member Author

Pushed 9a6d0270 to address a duplicate-Refresh bug surfaced by manual testing: AppControls uniquely had a standalone toolbar Refresh button and the ListChangedIndicator on its own row, so once the indicator could actually appear (this PR), the Apps screen showed two Refresh buttons. Aligned it with the other three controls — the indicator is now the single header-right refresh affordance. Updated AppControls + AppsScreen tests to assert exactly one Refresh (and none when the list hasn't changed).

@claude review

@claude

claude Bot commented Jun 8, 2026 •

Copy link
Copy Markdown
Contributor

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


Re-review: drop duplicate Refresh on the Apps screen (9a6d0270)

  • Read the AppControls + AppsScreen changes
  • Verify the Apps screen now has a single Refresh affordance
  • Review updated tests
  • Post review

The fix is correct, minimal, and lands the Apps screen exactly on the pattern the other three controls already use. 👍

What changed

  • AppControls drops the standalone ToolbarButton (and the now-unused Button import) and moves ListChangedIndicator up into the <Group justify="space-between"> header next to the <Title>.
  • That's a byte-for-byte match with ToolControls (ToolControls.tsx:43-45), PromptControls (:42-44), and ResourceControls (:120-122) — all four now render <Group justify="space-between"><Title/><ListChangedIndicator visible={listChanged} onRefresh={onRefreshList} /></Group>. Consistency restored.

Behavior verified

  • ListChangedIndicator returns null when visible is false (ListChangedIndicator.tsx:29), so when listChanged is false there is no Refresh button rendered — eliminating the duplicate that appeared once the indicator could light up. The single button case (indicator visible) routes to onRefreshList, same handler as before, so onRefreshApps→onRefreshTools wiring is untouched.

Tests

  • AppControls.test.tsx: the old "toolbar Refresh" test is replaced; the false case now asserts queryByRole("button", { name: "Refresh" }) is absent, and the true case asserts exactly one Refresh that drives onRefreshList. Correct.
  • AppsScreen.test.tsx: mirrors the same — one Refresh when changed, none when not. The previous "always-on toolbar Refresh" test is appropriately retired.

One intentional behavior change worth calling out (non-blocking)

  • The Apps screen previously had an always-available manual Refresh button; now, like the other three screens, there's no way to manually re-fetch the apps list unless the indicator is showing (i.e. unless the server fired tools/list_changed). This is the explicit goal of the commit ("match the other three controls") and is internally consistent, so no change needed — just noting that Apps loses its standalone manual-refresh, which is the deliberate trade for uniformity.

No blocking issues. The duplicate-Refresh bug is resolved and the screen is now consistent with its siblings. LGTM. ✅
· feat/sidebar-listchanged-1402

… Refresh (#1402)

With auto-refresh on, the list was already current by the time the
list-changed indicator appeared, making its Refresh button moot. Now the
managed Tools/Prompts/Resources state managers only flag the change on
*/list_changed (they no longer auto-refresh); the list stays as-is until
the user clicks Refresh, which fetches the new list and clears the
indicator. The connect-time initial load is unchanged.

Resource templates (no own indicator, part of the Resources screen) also
stop auto-refreshing; onRefreshResources now refreshes both resources and
templates, since a single resources/list_changed covers both. Tasks are
left auto-refreshing — they have no list-changed indicator and need live
status updates.

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

Copy link
Copy Markdown
Member Author

Pushed e4011dc4 — a behavior change that makes the indicator meaningful (per maintainer feedback): stop auto-invoking */list on list_changed.

Previously the managed state auto-refreshed on every */list_changed, so the list was already current by the time the "List updated" indicator appeared — the Refresh button just re-fetched the same data. Now:

  • Tools / Prompts / Resources managed state only flags the change on */list_changed; it no longer auto-refreshes. The list stays as-is until the user clicks the indicator's Refresh, which fetches the new list and clears the indicator. The connect-time initial load is unchanged.
  • Resource templates (no own indicator; part of the Resources screen) also stop auto-refreshing. Since a single notifications/resources/list_changed covers both resources and templates, onRefreshResources now refreshes both — templates previously had no user-facing refresh wired at all, so this also closes that gap.
  • Tasks are intentionally left auto-refreshing — they have no list-changed indicator and need live status updates (taskStatusChange), so they're outside this change.

Tests: the four "*ListChanged triggers a refresh" state-manager tests are rewritten to assert the list method is not called and the list stays empty; the existing flag/clear/disconnect, hook, and InspectorView routing tests are unchanged and still green. validate (incl. coverage gate) and test:storybook pass.

@claude review

@claude

claude Bot commented Jun 8, 2026 •

Copy link
Copy Markdown
Contributor

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


Re-review: stop auto-invoking */list on list_changed (e4011dc4)

  • Read the e4011dc4 diff (state managers, App, tests)
  • Verify auto-refresh removed for Tools/Prompts/Resources/templates
  • Verify Tasks still auto-refresh
  • Verify onRefreshResources now refreshes both resources + templates
  • Review tests

This is the right call, and it's what makes the indicator earn its place. With auto-refresh on, the list was already current before "List updated" ever appeared, so Refresh was a no-op re-fetch. Now the notification only flags, and the user pulls — set-on-notification / clear-on-user-refresh finally describes a real before/after. The change is minimal and symmetric across the three managers. 👍

Verified end-to-end

  • Tools / Prompts / Resources — on*ListChanged now does only setListChanged(true); the void this.refresh() is gone in all three (managedToolsState.ts:42, managedPromptsState.ts:42, managedResourcesState.ts:43). The connect-time onConnect → refresh() is untouched, so the initial load still happens. Correct.
  • Resource templates — the resourceTemplatesListChanged subscription (and its removeEventListener in unsubscribe) is fully removed; onConnect and onStatusChange remain. No dangling listener, no leak.
  • onRefreshResources covers both (App.tsx:1680) — now calls refreshResources() and refreshResourceTemplates(), with refreshResourceTemplates destructured from the hook and added to the dep array. As the comment notes, this also closes a real pre-existing gap: templates previously had no user-facing refresh wired at all, so before this they'd only ever update on (re)connect. Good catch to fold in.
  • Tasks left auto-refreshing — confirmed untouched; correct, since they have no list-changed indicator and rely on live taskStatusChange.

Tests

The four rewritten state-manager tests now assert the negative correctly — fire the notification, yield twice (await Promise.resolve() ×2) so any stray microtask-scheduled refresh would have landed, then assert the list method was not called and the list stayed []. The double-yield is the right way to prove a non-event. The existing flag/clear/disconnect, hook, and InspectorView routing tests are untouched and still valid. App.test.tsx mock updated to surface refresh on useManagedResourceTemplates.

One minor nit (non-blocking)

  • Stale docstrings in managedResourceTemplatesState.ts. The class no longer subscribes to resourceTemplatesListChanged, but the file/class headers still say it does:

    • line 2-3: "holds full resource template list, syncs on resourceTemplatesListChanged."
    • line 21-22: "Subscribes to connect, resourceTemplatesListChanged, and statusChange."

    Both now overstate the subscriptions (it's connect + statusChange only). The inline comment you added at the removal site is excellent — these two header comments just didn't get the same update. Fix this →

Standing trade-off worth noting

  • Lists can now be stale until the user refreshes. This is the deliberate intent (the indicator means "the server changed its list since you last looked"), but it does mean a removed/renamed tool can be invoked from a stale list and error out until Refresh is clicked. That's an acceptable and expected consequence of pull-on-demand, and arguably better UX than the list silently changing under the user — just flagging it as the behavioral shift this introduces.

No blocking issues. The only actionable item is the two stale doc comments. LGTM. ✅
· feat/sidebar-listchanged-1402

 review)

The class no longer subscribes to resourceTemplatesListChanged; update
the stale file/class docstrings that still claimed it syncs on that
notification to reflect connect + statusChange only.

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

Copy link
Copy Markdown
Member Author

Fixed the stale docstrings in `managedResourceTemplatesState.ts` (`19692cc9`) — the file header and class docstring no longer claim a `resourceTemplatesListChanged` subscription; they now describe connect + statusChange only, with a note that templates are pulled on demand via the Resources Refresh.

On the standing trade-off you noted (lists can be stale until Refresh — e.g. invoking a removed tool from a stale list errors until the user refreshes): agreed it's the deliberate, expected consequence of pull-on-demand, and as you say arguably better than the list silently changing under the user. No change.

@claude review

@claude

claude Bot commented Jun 8, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @cliffhall's task in 33s —— View job


Re-review: correct ManagedResourceTemplatesState docstrings (19692cc9)

  • Read the 19692cc9 docstring fix
  • Verify headers now match actual subscriptions
  • Post review

The only outstanding actionable item from the prior round is now resolved correctly. The two stale docstrings in core/mcp/state/managedResourceTemplatesState.ts no longer overstate the subscriptions:

  • File header (lines 2-3) now reads "holds the full resource template list, loaded on connect and on demand via refresh()" — accurate.
  • Class docstring (lines 19-24) now says it "Subscribes to connect (initial load) and statusChange (clear on disconnect)" and goes a step further with an explicit "deliberately does NOT subscribe to resourceTemplatesListChanged" note explaining the pull-on-demand rationale (Wire the sidebar listChanged indicator across all screens #1402). That's better than just dropping the stale line — it documents the intent, so a future reader doesn't "helpfully" re-add the subscription.

I verified the docstrings against the actual code: the constructor (managedResourceTemplatesState.ts:35-58) wires only connect → refresh() and statusChange → clear-on-disconnect, and unsubscribe (lines 52-58) removes exactly those two. No resourceTemplatesListChanged listener anywhere, no dangling removal. Headers and code now agree end-to-end. 👍

On the standing trade-off (lists stale until Refresh): agreed, nothing to change — it's the deliberate, documented consequence of pull-on-demand and the better UX than mutating the list under the user.

This was a docs-only commit; no logic touched, so the prior LGTM stands. All review items across the five rounds are now landed or consciously deferred. Nothing left to flag. ✅
· feat/sidebar-listchanged-1402

…' option (#1402)

New Options section in ServerSettingsForm with a single checkbox. When
checked, the managed Tools/Prompts/Resources (and resource templates)
state auto-refreshes on */list_changed notifications; when unchecked
(default) the notification only lights the list-changed indicator and the
user pulls via Refresh.

Plumbing: new optional autoRefreshOnListChanged on InspectorServerSettings
and StoredMCPServer, round-tripped through serverList (lifted with a false
default, persisted only when true, added to the exhaustive field-key map);
surfaced from InspectorClient via a new getServerSettings() on the protocol;
the state managers read it live at notification time to decide auto-refresh
vs flag-only. Resource templates re-subscribe to their list_changed but only
auto-refresh when the option is on (they have no indicator of their own).

Tests cover the round-trip (true persists, false omitted), the form
section (render/checked/toggle), and each state manager's on/off branch.

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

Copy link
Copy Markdown
Member Author

Pushed 68862e0e — a new per-server Options section in ServerSettingsForm with one checkbox, Auto Refresh on List Changed Notifications (default off). When checked, it re-enables auto-refresh of lists on list_changed; unchecked keeps the pull-on-demand + indicator behavior from this PR.

End-to-end plumbing:

  • Setting: optional autoRefreshOnListChanged on InspectorServerSettings and StoredMCPServer, round-tripped through serverList — lifted with a false default, persisted to disk only when true, and added to the exhaustive INSPECTOR_FIELD_KEY_MAP (the satisfies constraint forces the converters to stay in sync).
  • Form/modal: new "Options" accordion section with a Mantine Checkbox; onAutoRefreshChange threaded through ServerSettingsModal (which already owns the full-settings spread).
  • Client: InspectorClient.getServerSettings() added to InspectorClientProtocol (and the fake), mirroring the existing getter pattern.
  • State managers: Tools/Prompts/Resources read getServerSettings()?.autoRefreshOnListChanged live at notification time — auto-refresh when on, flag-only when off. Resource templates re-subscribe to their list_changed but auto-refresh only when the option is on (no indicator of their own; the Resources Refresh still covers them when off).

Tests: serverList round-trip (true persists / false omitted, with the lift-default cases updated), the form section (renders, reflects checked state, fires onAutoRefreshChange), and an on/off branch test for each state manager. validate (incl. coverage gate) and test:storybook green.

@claude review

@claude

claude Bot commented Jun 8, 2026 •

Copy link
Copy Markdown
Contributor

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


Re-review: per-server "Auto Refresh on List Changed Notifications" option (68862e0e)

  • Read the 68862e0e diff (serverList, types, client protocol, state managers, form/modal)
  • Review the setting plumbing & round-trip
  • Review the state-manager auto-refresh branching
  • Review the form/modal UI
  • Review tests

This is a clean, well-scoped addition that gives the user the escape hatch back to the old auto-refresh behavior without giving up the indicator as the default. The implementation is symmetric across the three managers, the plumbing is type-safe end-to-end, and the tests cover both branches. 👍

Verified end-to-end

  • Setting plumbing — autoRefreshOnListChanged is added to StoredInspectorFields (serverList.ts:95), the hasAny guard (:121), the lift-with-default (:138, ?? false), the persist-only-when-true write (:202), and the exhaustive INSPECTOR_FIELD_KEY_MAP (:250). The satisfies Record<keyof StoredInspectorFields, true> constraint is exactly what forces all four sites to stay in sync — adding the key to the Pick would fail compilation until the map got it too. Good use of the existing pattern.
  • Getter — getServerSettings() added to InspectorClientProtocol, the real InspectorClient (returns the constructor-injected serverSettings), and the FakeInspectorClient (new serverSettings option). Mirrors the existing getter pattern cleanly.
  • State managers — Tools/Prompts/Resources branch identically: getServerSettings()?.autoRefreshOnListChanged → void this.refresh() (auto), else setListChanged(true) (flag-only). Note the auto branch deliberately does not also call setListChanged(true), so the indicator stays dark when auto-refresh is on — correct, since there's nothing to acknowledge.
  • Resource templates — re-subscribes to resourceTemplatesListChanged (added back with a matching removeEventListener in unsubscribe, no leak) but auto-refreshes only when the option is on; off keeps the "Resources Refresh covers templates" behavior. The header/class docstrings were updated to match. Consistent.

One behavioral note worth calling out (non-blocking)

  • The toggle takes effect on the next (re)connect, not live. getServerSettings() returns the serverSettings captured at client construction (inspectorClient.ts:233 — set only in the constructor, no setter), and the client is rebuilt only on (re)connect (App.tsx:1283-1288). So a user who opens settings on the currently connected server, ticks the box, and closes the modal will keep seeing flag-only behavior until they disconnect/reconnect — the persisted value is picked up on the next setupClientForServer. This is consistent with how headers / timeouts / OAuth already behave (only roots is special-cased to apply live on modal close), so it's the expected pattern, not a defect — just flagging it because the surrounding comments describe the value as "read live at notification time," which is true of the getter call but the value itself is frozen per-connection. If mid-session toggling-without-reconnect is ever desired, that'd be a follow-up (a setServerSettings on the live client), and out of scope here.

Standing trade-off (unchanged)

  • Triplication — the if (autoRefresh) refresh() else setListChanged(true) branch is copy-pasted across the three managers, same as the prior *Change/flag logic. Faithful to the existing per-manager pattern; a candidate to hoist if these ever get a shared base.

Tests

Thorough and correctly scoped:

  • serverList.test.ts: true round-trips (lifts to settings + writes back), false is omitted from disk (asserted via "autoRefreshOnListChanged" in … being false), and the lift-default case updated to expect false in memory.
  • ServerSettingsForm.test.tsx: renders unchecked by default, reflects true as checked, and fires onAutoRefreshChange(true) on click.
  • Each state-manager test adds an opts-in auto-refreshes case (asserts list* was called and the list populated) alongside the renamed default-off case (asserts it was not). Both branches covered for all three managers + templates.

No blocking issues. The setting is plumbed correctly, the managers branch as documented, and coverage is complete. The only thing I'd note for awareness is the connect-time-vs-live application of the toggle, which matches the rest of the settings surface. LGTM. ✅
· feat/sidebar-listchanged-1402

#1402)

The PUT /api/servers write path runs settings through validateSettings,
which rebuilds the value from explicitly-named fields and silently drops
unknown keys — so autoRefreshOnListChanged never reached disk (the
serverList round-trip test passed because it calls
inspectorSettingsToStoredFields directly, bypassing this path). Validate
it as an optional boolean and include it in the built value; false is
omitted on disk by inspectorSettingsToStoredFields as before.

Adds integration tests over the real PUT path: true persists, false is
omitted, and a non-boolean is rejected (400).

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

Copy link
Copy Markdown
Member Author

Good LGTM, but a real bug slipped past both of us: the setting wasn't actually persisting (caught by manual testing). Fixed in 8c42f6e1.

Root cause: the PUT /api/servers write path runs settings through validateSettings (server.ts:1055), which deliberately rebuilds the value from explicitly-named fields and silently drops unknown keys ("so a misconfigured client can't smuggle stowaways onto disk"). autoRefreshOnListChanged wasn't one of the named fields, so it was dropped before reaching inspectorSettingsToStoredFields — and the serverList round-trip unit test passed because it calls inspectorSettingsToStoredFields directly, bypassing the server validator. So the round-trip looked correct in isolation but the real write path ate the field.

Fix: validateSettings now validates autoRefreshOnListChanged as an optional boolean and includes it in the built value (obj.autoRefreshOnListChanged === true); false is omitted on disk by inspectorSettingsToStoredFields as before. Added integration tests over the real PUT path: true persists to disk, false is omitted, and a non-boolean returns 400 — these would have caught the original gap.

On your connect-time-vs-live note: agreed and confirmed — the persisted value is picked up on the next setupClientForServer, consistent with headers/timeouts/OAuth (only roots applies live). Now that persistence works, the toggle takes effect on the next (re)connect. If live mid-session application is wanted, that's a setServerSettings follow-up, out of scope here.

validate (incl. the integration project + coverage gate) and test:storybook green.

@claude review

@claude

claude Bot commented Jun 8, 2026 •

Copy link
Copy Markdown
Contributor

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


Re-review: persist autoRefreshOnListChanged through validateSettings (8c42f6e1)

  • Read the validateSettings change in server.ts
  • Verify autoRefreshOnListChanged flows through the real PUT path
  • Review the new integration tests
  • Post review

Good catch, and the fix is in exactly the right place. This was the one gap the unit-level round-trip couldn't see: serverList.test.ts exercises inspectorSettingsToStoredFields directly, but the real wire path goes PUT /api/servers → validateSettings → inspectorSettingsToStoredFields, and validateSettings rebuilds the value from explicitly-named fields (the deliberate "no stowaways onto disk" design, server.ts:1142-1148). A field that isn't named there is dropped before inspectorSettingsToStoredFields ever sees it — so the persistence layer was correct and the validator was silently eating the field. Closing the gap at the validator is the right layer.

Verified end-to-end

  • Validation guard (server.ts:1112-1122) — optional-on-the-wire, boolean-when-present, mirroring the taskTtl pattern directly above it. Older clients that don't send the field still pass. Correct.
  • Build step (server.ts:1160-1162) — autoRefreshOnListChanged: obj.autoRefreshOnListChanged === true always produces a concrete boolean (absent → false), matching the read side. Since InspectorServerSettings.autoRefreshOnListChanged is optional (types.ts:113), an always-present false is type-safe, and inspectorSettingsToStoredFields (serverList.ts:202-203) only writes when truthy — so false still writes nothing to disk. The "absent → false → omitted" chain holds end-to-end.
  • No double-write / drift — the omit-on-false logic stays solely in inspectorSettingsToStoredFields; the validator just normalizes to a boolean. The two paths (validate-on-write, normalize-on-read) now agree on this field the same way they do for taskTtl and roots.

Tests

The three new integration tests close the gap precisely, over the real route this time:

  • true persists to disk (stored.autoRefreshOnListChanged === true) — would have failed before this commit. ✅
  • false is omitted (not.toHaveProperty), and the fixture seeds an existing true on disk first, so it also proves the PUT actively clears a previously-true value rather than just never writing it — nice touch, that's the stronger assertion. ✅
  • non-boolean ("yes") → 400. ✅

These would have caught the original miss, which is the right bar for a regression test.

On the connect-time-vs-live note

Confirmed and agreed — now that persistence works, the toggle is picked up on the next setupClientForServer, consistent with headers/timeouts/OAuth (only roots applies live). A setServerSettings for live mid-session application remains a reasonable follow-up, out of scope here.

No blocking issues. The persistence bug is fixed at the correct layer, the validator stays consistent with the existing optional-field pattern, and the regression tests exercise the real write path that the unit test bypassed. LGTM. ✅
· feat/sidebar-listchanged-1402

…1402)

Open 'Options' instead of 'Custom Headers' when the Server Settings modal
first opens, so the new Auto Refresh toggle is the first thing surfaced.
Updates the modal default-expanded section, the modal test's initial-state
assertions, the three header tests (now expand 'Custom Headers' first since
it's no longer open by default), and the story defaults.

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

Copy link
Copy Markdown
Member Author

Pushed 83076441 — the Server Settings modal now opens to the Options section by default instead of Custom Headers, so the new Auto Refresh toggle is the first thing surfaced. Updated the modal's default-expanded state, its initial-state test assertions, the three header tests (they now expand 'Custom Headers' first, since it's no longer open by default — matching the existing metadata-test pattern), and the story defaults (WithHeaders gets an explicit expandedSections so it still showcases headers).

validate + test:storybook green.

@claude review

@claude

claude Bot commented Jun 8, 2026 •

Copy link
Copy Markdown
Contributor

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


Re-review: default Server Settings modal to the Options section (83076441)

  • Read the 83076441 diff (modal default-expanded, tests, stories)
  • Verify default-open section is now Options
  • Review test/story updates
  • Post review

The functional change is clean, minimal, and correct — but this commit also accidentally committed a debug artifact to the repo root that should be removed (details below).

⚠️ Stray file committed — should be removed

inspector-history-pinned-everything-server-2026-06-08T15-19-48.465Z.json (880 lines / ~31KB) was added in this commit. It's an exported Inspector message-history dump from manual testing (tools/list request/response traffic for the everything server), not source. It is not gitignored, so it'll keep getting re-added.

This is exactly the class of file .gitignore already guards against — there's a precedent block at the bottom for /*.png ("Local debugging screenshots dropped at the repo root … should never be part of the source tree"). I'd git rm the file and extend that block to cover these history exports.

Fix this →

The actual feature change — verified, LGTM

  • Modal default flips from ["headers"] → ["options"] (ServerSettingsModal.tsx:37). "options" is the first Accordion.Item in the form (ServerSettingsForm.tsx:180, ahead of headers at :194), so the new Auto Refresh toggle is genuinely the first thing surfaced. ✓
  • ALL_SECTIONS already includes "options" (ServerSettingsModal.tsx:13-20), so the expand-all/collapse-all count (allExpanded = expandedSections.length === ALL_SECTIONS.length) stays correct — no off-by-one introduced by changing the default. ✓
  • Modal tests — the three header tests now click "Custom Headers" to expand it first (it's no longer open by default), matching the existing metadata-test pattern; the test name was updated to say so. The initial-state assertion now checks options is expanded / headers collapsed, and the expand-all path adds an explicit headers === "true" assertion. Consistent and correct. ✓
  • Stories — the meta default expands ["options"]; WithHeaders gets an explicit expandedSections: ["headers"] so it still showcases the headers UI. Good — keeps the story meaningful rather than silently regressing to Options. ✓

No logic concerns with the modal change itself. The one actionable item is the stray history JSON — once that's removed (and ideally gitignored), this is good to go. ✅
· feat/sidebar-listchanged-1402

…the class

8307644 swept an exported Inspector message-history JSON (manual-testing
artifact at the repo root) into the tree via git add -A. Untrack it and
extend the existing repo-root debug-artifact .gitignore block (alongside
/*.png) to cover /inspector-history-*.json so these can't be re-added.

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

Copy link
Copy Markdown
Member Author

Good catch — that was a real mistake. My git add -A for the default-section change swept in the exported history dump that was sitting untracked at the repo root. Fixed in 281d4e0a: git rm --cached to untrack it (kept the local copy, just out of the tree) and extended the existing repo-root debug-artifact .gitignore block — right alongside /*.png — with /inspector-history-*.json so these exports can't be re-added.

Thanks for verifying the actual modal change too (default → Options as the first accordion item, ALL_SECTIONS count unaffected, tests/stories consistent). validate + test:storybook still green.

@claude review

@claude

claude Bot commented Jun 8, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @cliffhall's task in 38s —— View job


Re-review: drop accidentally-committed history dump; gitignore the class (281d4e0a)

  • Verify the history dump is untracked
  • Verify the .gitignore block extension actually matches the file
  • Confirm the modal change from 83076441 is unaffected

The cleanup is correct and complete — the one actionable item from the prior round is resolved. 👍

Verified

  • File untracked — git ls-files | grep inspector-history returns nothing; the 880-line inspector-history-pinned-everything-server-…json dump is gone from the tree. git rm --cached was the right call (keeps your local copy, just out of source).
  • .gitignore pattern works — git check-ignore confirms the exact filename is now ignored by the new /inspector-history-*.json rule, so it can't be re-added by a future git add -A. It's placed right alongside /*.png under the repo-root debug-artifact block, and the comment was generalized ("screenshots and exported Inspector history dumps") to explain the broader intent. Exactly the fix I suggested, at the right layer.
  • Modal change intact — this commit only touches .gitignore + removes the JSON, so the 83076441 default-to-Options change (Options as the first accordion item, ALL_SECTIONS count unaffected, tests/stories consistent) is untouched.

Stepping back — the full PR

Across the seven review rounds, everything raised is now landed or consciously deferred:

  • listChanged wired across Tools/Apps/Prompts/Resources; all four listChanged={false} hardcodes gone.
  • Clear-after-await race closed (fac5e0ab); duplicate Apps Refresh removed (9a6d0270); auto-refresh dropped so the indicator is meaningful (e4011dc4); stale templates docstrings fixed (19692cc9).
  • Per-server Auto Refresh opt-in plumbed end-to-end (68862e0e) and the real-PUT-path persistence bug fixed at the validateSettings layer with regression tests (8c42f6e1).
  • Modal defaults to Options (83076441); stray artifact cleaned up (281d4e0a).

Standing trade-offs (all discussed, no change expected): shared Tools/Apps flag, optimistic clear over a rejected refresh, connect-time-vs-live toggle application, lists stale-until-Refresh, and the triplicated flag block. Each is the deliberate, documented choice.

No blocking issues. Clean to merge. ✅
· feat/sidebar-listchanged-1402

@cliffhall cliffhall changed the title feat(web): wire the listChanged indicator across all screens (#1402) feat(web): list-changed handling — indicator, pull-on-demand default, and per-server auto-refresh opt-in (#1402) Jun 8, 2026
@cliffhall
cliffhall merged commit b0a0242 into v2/main Jun 8, 2026
1 check passed
@cliffhall
cliffhall deleted the feat/sidebar-listchanged-1402 branch June 8, 2026 16:58
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.

Wire the sidebar listChanged indicator across all screens

1 participant