Skip to content

refactor: rename staticTabId → currentTabId, clarify tab id semantics (phase 3)#22

Merged
lyx-tec merged 1 commit into
mainfrom
refactor/workspace-switch-phase3
Jul 17, 2026
Merged

refactor: rename staticTabId → currentTabId, clarify tab id semantics (phase 3)#22
lyx-tec merged 1 commit into
mainfrom
refactor/workspace-switch-phase3

Conversation

@lyx-tec

@lyx-tec lyx-tec commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Summary

整理 tab id 语义,消除 staticTabId 这一误导性命名。Phase 3 of workspace-switch refactor.

Changes

命名修正

旧名 新名 语义
atoms.staticTabId atoms.currentTabId 当前 renderer context 绑定的 tab(每次 reinit/workspace switch 更新)
getLayoutModelForStaticTab() getLayoutModelForCurrentTab() 获取当前 tab 的 layout model
getStaticTabBlockCount() getCurrentTabBlockCount() 当前 tab 的 block 数量
simpleCloseStaticTab() simpleCloseCurrentTab() 关闭当前 tab
getFocusedBlockInStaticTab() getFocusedBlockInCurrentTab() 当前 tab 中 focus 的 block

staticTabId 的原语义是 "这个 renderer 永远代表某个固定 tab",但 Phase 1/2 已明确 renderer 在 workspace switch 时被复用,每次 reinit 都会更新这个值。"static" 前缀会让后续维护者误判它不应该被更新。

命名决策过程

初始 PR 使用了 activeTabId,但 Code Review 指出它与 tab-model.tsactiveTabIdAtom(workspace canonical active tab)名字过于相似,语义却不同:

Atom 位置
activeTabIdAtom tab-model.ts 总是 ctx.activeTabId(workspace 的 canonical active tab)
atoms.activeTabId(已废弃) global-atoms.ts 可能是 ctx.ownTabIdctx.activeTabId

最终选定 currentTabId——准确反映"当前 renderer context 正在使用的 tab",不与任何已有名字冲突。

Code Review 闭环

  • rg "StaticTab" frontend/ → 0 结果
  • rg "atoms\.activeTabId" frontend/ → 0 结果
  • 仅 3 个已知文件中的 17 个无关已有错误(processviewer.preview.tsx, defaultconfig.ts, preview-electron-api.ts)

测试 Note

  • 纯重命名,零逻辑变更
  • TS 类型检查确保所有引用已更新

@lyx-tec
lyx-tec merged commit f0b44f5 into main Jul 17, 2026
5 checks passed
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.

1 participant