# HAC-26 Workspace State Foundation Date: 2026-03-31 UTC Owner: Senior Frontend Engineer Issue: HAC-26 Scope: `apps/desktop` frontend foundation only ## Context - `apps/desktop/src/App.tsx` already owns the visible desktop-v1 shell, but it still contains repeated inline logic for key filtering, selected-key fallback, live key replacement, and paged append handling. - These state transitions are part of the browsing and inspector foundation, not one-off UI copy, and upcoming desktop-v1 slices will need them again. - The PM comment on `HAC-26` asked for the highest reusable foundation return, not a new visible feature. ## Decision - Do not expand product scope. - Extract reusable key-workspace state helpers from `App.tsx` into `src/lib`. - Cover the extracted state transitions with focused Vitest cases so future desktop-v1 changes can reuse the same behavior safely. ## Planned Implementation 1. Create a shared frontend utility for: - filtering visible keys by search text - resolving selected key fallback when visible results change - replacing a key record after live metadata/value refresh - appending paged browse results without duplicate rows 2. Update `App.tsx` to consume the shared utility instead of inline logic. 3. Add Vitest coverage for zero-result fallback, selection resolution, replacement merge behavior, and append deduplication. 4. Re-run `pnpm --filter @redis-gui/desktop test` and `pnpm run desktop:build`. ## Acceptance - `App.tsx` no longer owns the reusable key-workspace list and selection transitions inline. - The extracted helper is covered by focused tests. - Existing desktop frontend tests and production build remain green. - No backend contract or visible feature scope changes are introduced.