Skip to content

refactor(desktop): extract the chat surface from app-shell - #1169

Merged
Astro-Han merged 4 commits into
mainfrom
refactor/1043-extract-onboarding-empty-state
Jul 17, 2026
Merged

Astro-Han merged 4 commits into
mainfrom
refactor/1043-extract-onboarding-empty-state

Conversation

@Astro-Han

@Astro-Han Astro-Han commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #1043 (step 3c). Extracts the entire chat surface out of app-shell.tsx so the shell orchestrates rather than owns the chat JSX. Four seams, four commits, pure code motion - no behavior change.

Seam Component What moves out of AppShell
1 OnboardingEmptyState The empty-state stack (OnboardingHero + conditional FirstRunChecklist) wired into ChatView's emptyOverride
2a ChatMessageSurface ChatView plus the session-health notice (the sessions-section message view)
2b ChatComposerRegion The composer interaction slot (PermissionPrompt / UserQuestionPrompt) plus the always-mounted Composer
2c ChatWorkbar The workbar resize handle plus the lazy-mounted SessionWorkbar and its fallback

AppShell now renders <ChatMessageSurface>, <ChatComposerRegion>, and <ChatWorkbar> instead of owning ~250 lines of inline chat JSX. The shell shrinks from ~1655 to ~1562 lines; the mainColumn chat surface and the artifacts workbar are all component boundaries.

Invariants preserved

  • Always-mounted Composer (feat(ui): real-time status language across stages — connecting indicator + stable thinking/outputting signal #646 draft preservation, permission-composer-takeover): ChatComposerRegion is rendered as a stable sibling of the section switch, never conditionally mounted. hidden drives the native hidden state, exactly as before. The permission-takeover E2E and contract verify this.
  • Lazy workbar chunk: the lazy() boundary, SessionWorkbarFallback, and Suspense move into ChatWorkbar unchanged, so first-paint behavior is identical.
  • Section routing: AppShell still owns the navSelection.section switch; only the chat-surface JSX moved.

Contract updates

Each new file is registered in renderer-shell-source-helpers so combined-source contracts keep covering it. Direct-read contracts now point at the new files for the relocated patterns:

  • streaming-timeline-render: <ChatView liveTurn={activeLiveTurn}> -> <ChatMessageSurface liveTurn={activeLiveTurn}>.
  • session-health-notice-layout: the health notice now lives inside ChatMessageSurface; the layout contract checks the message-surface sits above the composer region.
  • first-run-task-suggestions: pins the openPlanReminderForm -> ChatMessageSurface -> OnboardingEmptyState -> FirstRunChecklist wiring chain.
  • permission-composer-takeover / permission-response-ipc-boundary: the Composer block, interaction slot, and PermissionPrompt/UserQuestionPrompt patterns now read from chat-composer-region.tsx; the hasModalOpen and activeQuestion derivation assertions stay on app-shell.
  • session-workbar / renderer-lazy-fallback: the <SessionWorkbar>, SessionWorkbarFallback, and Suspense patterns read from chat-workbar.tsx; the active-session gating condition stays asserted on app-shell.

Verification

  • tsc -p tsconfig.main.json and tsconfig.renderer.json - clean.
  • biome lint (the repo's CI lint command; the formatter is deliberately disabled per biome.jsonc / chore: introduce linter/formatter (Biome or ESLint) #415) - clean.
  • node --test dist/main/**/*.test.js - 2661/2661, 0 failures.
  • npm run build:renderer - clean.
  • Playwright e2e/permission-takeover.spec.ts, e2e/send-message.spec.ts, e2e/attachment.spec.ts, e2e/session-health-notice.spec.ts - all pass.

Review focus

This is the largest seam of the #1043 arc. The riskiest invariant is the always-mounted Composer (draft preservation across section switches and permission takeovers); it has no dedicated E2E, so the extraction preserves the exact render structure (Composer stays mounted, hidden prop controls visibility) and relies on the permission-composer-takeover contract plus the permission-takeover/attachment/send-message E2E to catch regressions. The ChatComposerRegion props use a ComponentProps<typeof Composer> spread for type safety; hidden, draftKey, and stopPending are derived inside the region to keep the Boolean(activeInteraction) gate the takeover contract pins.

The shell's orchestration logic (hooks, handlers, closeSettings cross-slice orchestration) stays in AppShell by design - this PR is scoped to the chat-surface JSX extraction, which is the core of "app-shell orchestrates rather than owns".

Step 3c (seam 1) of the #1043 plan. The inline empty-state JSX wired
into ChatView's emptyOverride - the OnboardingHero plus the conditional
FirstRunChecklist inside the maka-onboarding-stack wrapper - moves into a
presentational <OnboardingEmptyState> component.

The orchestration callbacks (skip milestone + toast, quick-chat submit,
open settings / sidebar module / plan-reminder form) stay with AppShell
and are passed in; OnboardingEmptyState only owns the JSX structure and
the ready_empty conditional. This is the first seam of the ChatWorkspace
extraction: the empty state is a distinct, unblocked slice that the
workspace component will render.

Pure code motion - no behavior change. onboarding-empty-state.tsx is
registered in renderer-shell-source-helpers so the combined-source
contract keeps covering it; the first-run-task-suggestions contract now
pins the openPlanReminderForm -> OnboardingEmptyState -> FirstRunChecklist
wiring chain instead of the old direct FirstRunChecklist prop.
@Astro-Han
Astro-Han marked this pull request as draft July 17, 2026 08:44
Step 3c (seam 2a) of the #1043 plan. The sessions-section message
surface - ChatView plus the session-health notice that sits above the
composer - moves into a presentational <ChatMessageSurface> component.

ChatView's props are forwarded via ComponentProps spread; the empty-state
stack (OnboardingEmptyState) and the health notice are constructed inside
the component from the onboarding snapshot and the sessionHealthNotice
view. AppShell renders this as the sessions branch of the section switch,
so it is conditionally mounted - the always-mounted Composer is unaffected
and stays in AppShell for now.

This is the message-view half of the chat-surface extraction; the composer
region (interaction slot + Composer) is the next seam. Pure code motion -
no behavior change. chat-message-surface.tsx is registered in the
source-helper so combined-source contracts keep covering it; the
streaming-timeline-render, session-health-notice-layout, and
first-run-task-suggestions contracts now pin the new wiring
(ChatMessageSurface liveTurn prop, the ChatMessageSurface -> OnboardingEmptyState
-> FirstRunChecklist reminder chain, and the health notice living inside
the message surface) instead of the inline app-shell JSX.
Step 3c (seam 2b) of the #1043 plan. The composer interaction slot
(PermissionPrompt / UserQuestionPrompt) plus the always-mounted Composer
move into a <ChatComposerRegion> component.

AppShell renders this as a stable sibling of the section switch, so it is
NEVER conditionally mounted - the Composer keeps its uncontrolled textarea
and draft across section switches and permission takeovers (#646 draft
preservation, permission-composer-takeover contract). The structure is
identical to the previous inline JSX: Composer stays mounted and uses the
native hidden state, so there is zero behavior change.

Composer props are forwarded via ComponentProps spread; hidden, draftKey,
and stopPending are derived inside the region from the active-session state
(hidden keeps the Boolean(activeInteraction) gate the takeover contract
pins). The workspace/branch picker and permission-mode-disabled-reason
objects stay constructed at the AppShell call site for now.

Pure code motion - no behavior change. chat-composer-region.tsx is
registered in the source helper; the permission-composer-takeover,
permission-response-ipc-boundary, and session-health-notice-layout
contracts now point at the new region for the Composer/interaction-slot
patterns while the hasModalOpen and activeQuestion derivation assertions
stay on app-shell.
Step 3c (seam 2c) of the #1043 plan. The workbar region of the
sessions surface - the resize handle plus the lazy-mounted SessionWorkbar
(task ledger, embedded browser, artifact pane) - moves into a <ChatWorkbar>
component, along with the SessionWorkbarFallback and the lazy import.

AppShell renders this conditionally (only beside an active session inside
the sessions module), so it is the artifacts-column counterpart to the
chat surface components. The lazy chunk boundary and fallback are preserved
exactly inside ChatWorkbar, so first-paint behavior is unchanged.

Pure code motion - no behavior change. chat-workbar.tsx is registered in
the source helper; the session-workbar and renderer-lazy-fallback contracts
now point at the new component for the SessionWorkbar / fallback / Suspense
patterns while the active-session gating condition stays asserted on
app-shell. With this, the mainColumn chat surface and the artifacts workbar
are all extracted: app-shell renders ChatMessageSurface, ChatComposerRegion,
and ChatWorkbar instead of owning their JSX inline.
@Astro-Han Astro-Han changed the title refactor(desktop): extract OnboardingEmptyState from the chat surface refactor(desktop): extract the chat surface from app-shell Jul 17, 2026
@Astro-Han
Astro-Han marked this pull request as ready for review July 17, 2026 09:19
@Astro-Han
Astro-Han merged commit 0fe0dba into main Jul 17, 2026
3 checks passed
@Astro-Han
Astro-Han deleted the refactor/1043-extract-onboarding-empty-state branch July 24, 2026 09:05
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.

refactor(desktop): break up the app-shell god component and stabilize action factories

1 participant