Skip to content

Persist search sheet state across close/reopen#5534

Draft
FadhlanR wants to merge 1 commit into
mainfrom
cs-12109-host-persist-search-sheet-state-query-filters-view-results
Draft

Persist search sheet state across close/reopen#5534
FadhlanR wants to merge 1 commit into
mainfrom
cs-12109-host-persist-search-sheet-state-query-filters-view-results

Conversation

@FadhlanR

Copy link
Copy Markdown
Contributor

Resolves CS-12109.

Problem

Closing the operator-mode search sheet discards the entire search — reopening starts from a blank slate. The @mode gate at search-sheet/index.gts destroys the whole SearchPanel → PanelContent → SearchResults → SearchEntriesResource subtree on close, dropping the query, filters, sort, view, pagination, and results.

Approach

A new in-memory, session-scoped SearchSheetState service holds the sheet's state (query text, selected types/realms, sort, view toggle, pagination) plus a snapshot of the last results.

  • The @mode-gated subtree is still destroyed on close, so there is no background work while the sheet is closed (the search resource and its realm subscriptions tear down).
  • On reopen the subtree remounts, rehydrates from the service, redisplays the cached results snapshot immediately (no blank flash), and re-runs the query to refresh — so newly-created cards show up. Stale-while-revalidate.
  • Persistence is opt-in via a @persist flag passed only by the search sheet, so the card choosers (which render their own SearchPanel instances) keep their own clean, per-invocation state.
  • The service registers with the reset service, so logout / realm reset clears it. A page reload also clears it (in-memory only, no localStorage).
  • resetState now runs only on explicit Cancel / Escape — removed from plain close/blur and from result-select, so those keep the search. Reopening a persisted search opens straight to the results view.

Files

  • services/search-sheet-state.ts (new) — the in-memory store + results snapshot, reset-registered.
  • search-sheet/index.gts — state backed by the service; reset only on explicit cancel.
  • card-search/panel.gts — additive initialActiveSort / onSortChange / persist args (choosers unaffected).
  • card-search/panel-content.gts — view + pagination behind @persist; main-results snapshot capture/redisplay.
  • operator-mode/submode-layout.gts — reopen to the results view when a search is persisted.

Verification

lint:types, lint:js, and lint:hbs pass in packages/host (with boxel-icons + boxel-ui built).

Remaining

  • Host acceptance tests: persist across close/reopen; result-select keeps the search; Cancel/Escape resets; choosers stay clean; in-memory (reset/reload) clears. Draft opened ahead of these per request.
  • Manual verification in the dev stack (snapshot → live handoff on reopen).

🤖 Generated with Claude Code

Add an in-memory, session-scoped SearchSheetState service that holds the
operator-mode search sheet's query, selected types/realms, sort, view, and
pagination, plus a snapshot of the last results. The sheet's @mode-gated
subtree is still destroyed on close (no background work while closed); on
reopen it rehydrates from the service, redisplays the cached results snapshot
immediately, and re-runs the query to refresh.

Persistence is opt-in via a `@persist` flag passed only by the search sheet,
so the card choosers keep their own ephemeral state. The service registers
with the reset service, so logout/realm reset clears it; a page reload also
clears it (in-memory, no localStorage).

resetState now runs only on explicit Cancel/Escape (removed from plain
close/blur and result-select), and reopening a persisted search opens straight
to the results view.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@FadhlanR
FadhlanR force-pushed the cs-12109-host-persist-search-sheet-state-query-filters-view-results branch from 6474fb0 to 48ab0d6 Compare July 17, 2026 07:31
@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Preview deployments

Host Test Results

    1 files      1 suites   2h 16m 23s ⏱️
2 931 tests 2 908 ✅ 13 💤  6 ❌ 4 🔥
2 950 runs  2 923 ✅ 13 💤 10 ❌ 4 🔥

Results for commit 48ab0d6.

For more details on these errors, see this check.

Realm Server Test Results

    1 files      1 suites   14m 25s ⏱️
1 620 tests 1 620 ✅ 0 💤 0 ❌
1 670 runs  1 670 ✅ 0 💤 0 ❌

Results for commit 48ab0d6.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant