Skip to content

refactor(ui-react): consolidate app shell session state - #508

Merged
Astro-Han merged 3 commits into
mainfrom
codex/app-shell-session-state-reducer-pr7
Jul 4, 2026
Merged

refactor(ui-react): consolidate app shell session state#508
Astro-Han merged 3 commits into
mainfrom
codex/app-shell-session-state-reducer-pr7

Conversation

@Astro-Han

@Astro-HanAstro-Han commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add a local AppShell session UI state controller for the per-session UI maps.
  • Move AppShell to the controller-backed hook while preserving same-frame refs for streaming and session-event health handlers.
  • Fix nested map updates so thinking_delta / thinking_complete can update thinking text and truncated flags atomically from the caller's point of view.
  • Update source contracts so they protect retry/model/permission/cleanup behavior without pinning direct useState placement.

Why

Refs #477

AppShell kept 11 per-session UI maps as separate top-level state entries. Every new per-session UI concern had to touch the AppShell top level, and archive/delete cleanup had to remember every individual map. This PR gives those maps one local owner without introducing an external store.

Scope

Changed:

  • app-shell-session-ui-state.ts owns the AppShell per-session UI controller, setters, same-frame refs, and centralized session cleanup.
  • app-shell.tsx reads/writes those maps through useAppShellSessionUiState().
  • Session retry, row action cleanup, permission mode, and sticky model contracts now assert the controller-backed behavior instead of direct useState placement.
  • The controller uses a single map-key list plus generic map update/clear helpers, avoiding the previous 11-case action switch and duplicated cleanup list.
  • A regression test covers the nested thinking updater shape: a truncated thinking_delta sets the flag, and a short thinking_complete replaces text and clears the flag.

Not included:

  • No visual redesign.
  • No external state store.
  • No targeted memo work.
  • No effect dependency rewrite beyond preserving the existing ref-stability behavior.

Verification

  • GREEN: npm run -w @maka/desktop test (1847 passed)
  • GREEN: npm run -w @maka/desktop build:renderer (passes; existing Vite large chunk warning remains)

User-facing impact

None expected. This is a React state-ownership refactor; UI copy, layout, and behavior should remain unchanged.

Reviewer notes

The PR is split into rollback-sized commits:

  • refactor(ui-react): add app shell session ui reducer
  • refactor(ui-react): use reducer for app shell session state
  • fix(ui-react): preserve nested session ui updates

@Astro-Han
Astro-Han merged commit e4690e1 into mainJul 4, 2026
@Astro-Han
Astro-Han deleted the codex/app-shell-session-state-reducer-pr7 branch July 4, 2026 11:49
Sign up for freeto 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

@Astro-Han