Skip to content

refactor(desktop): extract Workbar as a feature slice - #3444

Merged
Astro-Han merged 6 commits into
apache:mainfrom
chihumyum:refactor/workbar-controller
Aug 22, 2026
Merged

refactor(desktop): extract Workbar as a feature slice#3444
Astro-Han merged 6 commits into
apache:mainfrom
chihumyum:refactor/workbar-controller

Conversation

@chihumyum

Copy link
Copy Markdown
Contributor

Summary

  • Extract Workbar layout, tools, and dynamic-resource lifecycles into a feature-owned vertical slice.
  • Keep Electron bridge access in a Desktop adapter; the Workbar feature no longer imports AppShell, preload, or main, and does not access window.maka.
  • Reduce AppShell to Workbar host inputs plus the host / commands / selectors surface while preserving storage, IPC, layout, mounting, and cleanup behavior.

Refs #3439

Verification

  • npm run lint — passed (2,513 files)
  • npm run format:check — passed (1,565 files)
  • npm run build — passed
  • npm run typecheck — passed
  • npm --workspace @maka/desktop test — passed (1,061 tests, 124 suites)
  • npx knip --workspace apps/desktop — passed
  • npx knip --workspace packages/ui — passed
  • npm run astryx:surface-inventory — passed (199 files, 1 exclusion)
  • npm --workspace @maka/desktop run build-storybook — passed
  • npm --workspace @maka/desktop run smoke:storybook — passed (162 stories)
  • npm --workspace @maka/desktop run e2e — passed (41 passed, 1 skipped)

Review focus

  • v1/v2 to v3 Workbar storage hydration and transient-field filtering
  • Terminal ownership, stale-start fencing, close/session-switch cleanup, and RAF disposal
  • Side Chat collapse/close/source-switch behavior and late fork/send disposal fencing
  • Desktop service mapping and subscription disposal, especially Inspector pagination and Session usage authority
  • CSS relocation/import order and right/bottom/narrow Workbar visual parity

AI use

Select exactly one:

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: Codex — architecture analysis, implementation, tests, latest-main replay, lifecycle race review, and pull request preparation. The human contributor reviewed the contribution and accepts responsibility for it.

All substantive commits include Generated-by: Codex; retain the trailer in the final squash commit.

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

@chihumyum
chihumyum marked this pull request as ready for review August 21, 2026 17:25
@chihumyum
chihumyum force-pushed the refactor/workbar-controller branch from e42f8c2 to 13d9b75 Compare August 22, 2026 07:00

@Astro-Han Astro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for extracting Workbar into a coherent feature slice. The production boundary looks clean: topology and persistence have one owner, Desktop IO stays behind the existing adapter seam, and the Terminal and side-chat lifecycle paths retain their stale-result and disposal fencing.

I found no blocking production issue. I left one non-blocking P2 inline because the narrow side-chat regression test currently does not resize the overlay it intends to exercise.

AI-assisted review disclosure: Codex coordinated independent architecture, lifecycle, and UI/test review passes against exact head 13d9b75cb3d0ed4d2bd44e4e4f3c16d837f70337; I reviewed the consolidated evidence and approve this exact head.

Comment thread apps/desktop/src/renderer/styles/workbar/shell.css
@chihumyum
chihumyum requested a review from Astro-Han August 22, 2026 08:06

@Astro-Han Astro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for simplifying the Workbar into a real feature slice. The latest layout regression is fixed, the current-head test is green, and two independent passes found the extraction behavior-preserving across the major state, Side Chat, and Terminal boundaries. One recoverable Terminal cleanup edge remains in the extracted owner, noted inline.

AI-assisted review disclosure: OpenAI Codex coordinated two independent exact-head reviews. I verified the retained failure path, resolved prior thread, current-head CI, mergeability, and review state, and I made the final review decision.

Comment thread apps/desktop/src/renderer/features/workbar/controller/use-workbar-controller.ts Outdated
@chihumyum
chihumyum force-pushed the refactor/workbar-controller branch 3 times, most recently from ecbe4d5 to 08aa100 Compare August 22, 2026 11:33

@Astro-Han Astro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking this on — 83 files and +5813/-2957 of pure relocation is a lot of careful work, and the slice boundary you landed on reads well.

Reviewed at exact head 08aa1007b842e207ebf8c647d5382944b70f3c99 against base f2722fd143a575bb18e54ba30985fca16e2a7e2c. No blocking findings.

For a refactor PR the only claim that matters is "this is just a move", so that is what we checked:

  • Old paths are actually gone. session-workbar-layout.ts is deleted, use-shell-layout.ts drops 224 lines, app-shell.tsx drops 596, app-shell-effects.ts drops 60. No second Workbar authority survives alongside the new slice.
  • CSS relocation is cascade-equivalent. 1416 lines leave chat-detail.css / quote-side-panel.css and 1418 arrive in styles/workbar/*.css. The six new workbar/* imports now sit before chat-detail.css rather than inside it, which would matter if the 26 lines left in chat-detail.css shared selectors with the moved rules — they do not (what remains is .maka-turn[data-search-highlight] plus comments). side-chat.css is imported immediately after quote-side-panel.css, preserving its position relative to everything downstream.
  • @xterm/xterm/css/xterm.css moved from two component-level TS imports to a single top-level @import. It is unlayered in both forms, so its precedence over the layer(components) rules that style .xterm is unchanged. The only difference is that it is now always loaded instead of loaded on first terminal mount, which is not a behaviour change worth flagging in a desktop app.
  • Failure paths were preserved, not simplified away. stopTerminal marks a terminal stopped and releases ownership only inside .then(); a rejected stop keeps ownership so a later cleanup can retry. Terminal registration precedes tab commit, stale generations stop, and the Side Chat path keeps its dispose fence after each await.

Not merge-ready yet, for reasons outside the code: the branch is CONFLICTING against main, and there are no checks on this head at all — statusCheckRollup is empty. The existing APPROVED decision belongs to an older head; this repository does not dismiss stale reviews, so that badge is not evidence anyone has read the current code. Please rebase and let CI run; given the size of this diff, a conflict resolution is exactly where an accidental behaviour change would slip in, so we will re-check the moved logic on the new head rather than carry this result forward.


This review was AI-assisted. Findings were verified against the exact head listed above; any mistakes are ours to correct — please push back where we got it wrong.

@chihumyum
chihumyum force-pushed the refactor/workbar-controller branch 3 times, most recently from 1ee4ab5 to d182a68 Compare August 22, 2026 15:48
@chihumyum
chihumyum requested a review from Astro-Han August 22, 2026 16:00
@chihumyum
chihumyum force-pushed the refactor/workbar-controller branch from d182a68 to 624c4c6 Compare August 22, 2026 17:37

@Astro-Han Astro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks — and thanks for the patience across four rounds. Re-reviewed at exact head 624c4c643f316aa05096c69aab19f3e7e50f6c04, freshly pulled. test is green and the PR is MERGEABLE / CLEAN.

Worth stating plainly: our earlier APPROVE sits on 13d9b75c, five heads back, so it didn't carry. This is a fresh pass over the current code.

Both of my earlier P2s are resolved:

  • Workbar width variable--maka-session-workbar-width now lives on the shared parent .maka-workbar-layout-vars rather than a sibling, and the E2E sets 320px there and asserts the overlay actually renders at ~320. That closes it at the cascade rather than by adjusting the selector.
  • Terminal stop ownershipstopTerminal only releases ownership once stop succeeds, with in-flight de-duplication and a finally that clears the stopping marker, so a failed stop leaves the resource for the next cleanup to retry. Releasing on the optimistic path was the actual bug; this fixes the ordering rather than adding a retry on top.

On the size. 6396 added lines invites the question of whether a refactor is carrying passengers, so I checked the split: roughly 1939 lines are tests, E2E and stories, plus ~128 of docs; the remainder is tool migration, service ports and the controller. The production entry consumes only the feature's public entry, with no Desktop global bridge reaching inside — which is the property that makes this a boundary extraction rather than a file shuffle. I found no unrelated product change riding along.

Behavioural equivalence is where I spent the most effort, since that's what a move of this size can quietly break. Session switching, StrictMode replay, late terminal starts, Side Chat collapse and source switching, and out-of-order browser selections all still have their guards and tests. Topology and resource lifetime moved out of AppShell without leaving a second reducer or a competing authority behind.

No findings. Approving.


This review was AI-assisted. Findings were verified against the exact head listed above; any mistakes are mine to correct — please push back where I got it wrong.

@Astro-Han
Astro-Han merged commit 9c15719 into apache:main Aug 22, 2026
1 check passed
@chihumyum
chihumyum deleted the refactor/workbar-controller branch August 22, 2026 18:31
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.

2 participants