Skip to content

refactor(desktop): extract Session Navigation feature slice - #3719

Open
chihumyum wants to merge 1 commit into
apache:mainfrom
chihumyum:refactor/session-navigation-feature-slice
Open

refactor(desktop): extract Session Navigation feature slice#3719
chihumyum wants to merge 1 commit into
apache:mainfrom
chihumyum:refactor/session-navigation-feature-slice

Conversation

@chihumyum

Copy link
Copy Markdown
Contributor

Summary

  • Extract Session rail projection, layout persistence, navigation intents, and row-mutation lifecycle into features/session-navigation.
  • Add a narrow Desktop services adapter, feature host/controller, and architecture tests while preserving existing routes, storage keys, revision-family semantics, and UI behavior.

Refs #3439

Verification

  • npm ci
  • npm run check:asf-headers
  • npm run lint
  • npm run format:check
  • npm run typecheck
  • npm run build
  • npm run astryx:theme -- --check
  • npm run astryx:surface-inventory
  • Desktop tests: 1419 passed
  • Desktop and UI Knip checks passed
  • Storybook build and render smoke: 189 stories passed
  • Electron E2E: 62 passed, 1 conditionally skipped
  • Browser observe/act smoke: 17/17 passed
  • Astryx alignment audit: all fixtures clean
  • git merge-tree --write-tree upstream/main HEAD

Review focus

Session catalog authority remains in the existing AppShell session-list boundary. The feature owns rail/view/mutation behavior; AppShell keeps explicit cross-feature intents.

AI use

Select exactly one:

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

Tool(s) and scope: Codex implemented the renderer feature extraction, tests, and red/blue review under human direction.

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

@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.

Approving on eff7627bdcb336d973125cf8ed1417d908c6fe32, with test terminal green on that exact head.

For a move of this size the only question worth answering is whether anything changed semantics under cover of changing location, so I checked it mechanically rather than by reading. Comparing each moved file against its original with the licence header stripped:

  • session-rail.ts, session-revisions.ts, session-nav-filter.ts, branch-banner.ts — byte-identical.
  • session-list-layout.ts and session-project-grouping.ts — import paths only.
  • session-row-actions.ts — the one file with real edits, and every one is mechanical: window.maka.sessions.* becomes the injected service.*, and setMessages([]) becomes clearActiveMessages(), which app-shell.tsx:1660 defines as useCallback(() => setMessages([]), [setMessages]). The revisionFamily semantics, the requireArchived and restored branches, the pending de-duplication, and the list read-back verification are all unchanged.

The three persisted layout keys and the 200 ms trailing debounce moved without modification, and openSession keeps its original ordering — exit WorkHub, select, activate, then set or clear the scroll target — including the suppression of activeId while WorkHub is active.

One incidental fix worth calling out in the description. deriveBranchBanner's memo dependencies were [activeSession?.parentSessionId, sessions] and are now [activeSession, sessions]. The old list was incomplete: switching between two sessions that share a parentSessionId did not recompute, so the banner could keep showing the previous parent's name after it changed. The new list is correct. That is a behaviour change — a fix, not a regression — and it should be mentioned rather than left inside a refactor.

The boundary is clean: no imports of app-shell, preload or main from inside the feature, the Desktop bridge is touched only in platform/desktop/create-session-navigation-services.ts, and the new boundary tests pin the "external code enters through index/testing only" rule rather than leaving it as a convention.

On merge order, not a blocker: this PR rewrites large parts of app-shell.tsx and deletes six files from the renderer root. Two sibling slice extractions are open against the same code. Whichever lands first will force the others to redo path-level work, so they should go in one at a time with a rebase between, rather than in parallel.

简体中文

已在 eff7627bdcb336d973125cf8ed1417d908c6fe32 上 approve,该 exact head 的 test 为终态绿。

这种规模的搬运,唯一值得回答的问题是「有没有借着换位置改语义」,所以我用机械方式核对,而不是靠通读。把每个被移动的文件与其原文件在剥掉 licence 头后逐一比对:

  • session-rail.tssession-revisions.tssession-nav-filter.tsbranch-banner.ts——逐字节相同。
  • session-list-layout.tssession-project-grouping.ts——只改了 import 路径。
  • session-row-actions.ts——唯一有实际改动的文件,而每一处都是机械的:window.maka.sessions.* 换成注入的 service.*setMessages([]) 换成 clearActiveMessages(),后者在 app-shell.tsx:1660 定义为 useCallback(() => setMessages([]), [setMessages])revisionFamily 语义、requireArchivedrestored 分支、pending 去重、list 回读校验,全部未变。

三个持久化布局键与 200 ms trailing debounce 原样搬入;openSession 保持原有顺序——退出 WorkHub、选中、激活、再设置或清除 scroll target——包括 WorkHub 激活时对 activeId 的抑制。

有一处顺带的修复,建议写进正文。 deriveBranchBanner 的 memo 依赖由 [activeSession?.parentSessionId, sessions] 改为 [activeSession, sessions]。旧的依赖列表是不完整的:在两个共享同一 parentSessionId 的 session 之间切换时不会重算,因此父级名称变化后横幅可能仍显示旧名字。新的依赖是对的。这是一处行为变化——是修复而非回归——应当明说,而不是留在重构里。

边界是干净的:feature 内部没有对 app-shellpreloadmain 的导入;Desktop bridge 只在 platform/desktop/create-session-navigation-services.ts 触碰;新增的边界测试把「外部只能经 index/testing 进入」这条规则用机器锁住,而不是留作约定。

关于合并顺序,不构成阻塞:本 PR 重写了 app-shell.tsx 的大段内容,并删除了 renderer 根目录下的六个文件。另有两个同类切片 PR 正对着同一片代码开着。谁先合,都会迫使其余两个重做路径级的调整,因此应当串行合并、中间让作者 rebase,而不是并行推进。

@chihumyum
chihumyum force-pushed the refactor/session-navigation-feature-slice branch from eff7627 to 8ee8545 Compare August 24, 2026 16:03
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