Skip to content

Persist per-screen selection and search/filter across tab navigation; clear only on user action or disconnect #1417

Closed

Description

@cliffhall

Background / change of direction

Each screen currently keeps its selection and filter state local, so switching tabs unmounts the screen and discards it. The Tools screen even goes a step further: because the call result lives in App (so it survives pending → ok/error), ToolsScreen clears the result on unmount to avoid showing a result with no selected tool (see the onClearResult unmount effect / comment in ToolsScreen.tsx).

We're reversing that direction. Navigating away from a screen and back should retain what the user was doing. Session state should be cleared only:

  • explicitly by the user (a clear/reset affordance), or
  • on disconnect (the session ends).

Scope — what should persist across navigation

  • Tools — selected tool, its form values, and its result
  • Prompts — selected prompt, its argument values, and its result
  • Resources — selected resource and its read result (resource subscriptions already live in managed state)
  • Apps — selected app, its form values, and running/maximized state
  • Tasks — selected task
  • Logs — search text + level filters
  • History — search text + method filter
  • Network — search text + category filters

Desired behavior

  • Selecting/typing on a screen, switching tabs, and returning shows the same selection / result / search / filters.
  • A result is never shown without its originating selection (the bug the unmount-clear was guarding against) — because the selection now persists alongside the result.
  • State is cleared on disconnect and via an explicit user action; nothing clears it on plain tab navigation.

Implementation sketch

  • Lift the per-screen selected* / formValues / search / filter state out of the screen components into session-scoped state owned by App (alongside toolCallState / getPromptState / readResourceState), passed down as props.
  • Clear it in App's resetSessionScopedUiState() (already invoked on the InspectorClient disconnect event — see App.tsx), and from the explicit user clear action(s).
  • Remove ToolsScreen's clear-on-unmount effect — it's superseded once selection persists.
  • Keep each screen a controlled "dumb" component (state + callbacks via props), consistent with the v2 architecture.

Relationship to #1414

#1414's companion criterion ("persist tool selection + results across navigation") is the Tools-only slice of this. This issue generalizes it to every screen plus search/filters. Suggest implementing the persistence here and trimming #1414 down to its toasts-for-progress scope (or closing the overlap there) so the two don't conflict.

Acceptance criteria

  • Each screen above retains its selection / result / search / filters across tab navigation within a live session.
  • No screen clears that state on plain navigation.
  • Disconnect clears all of it; an explicit user action clears it too.
  • ToolsScreen's unmount result-clear is removed.
  • Tests cover persist-across-navigation and clear-on-disconnect for the lifted state.

Metadata

Metadata

Assignees

Labels

v2Issues and PRs for v2

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions