From 400b5abccfdf878b8c912973174d31df89122608 Mon Sep 17 00:00:00 2001 From: lyx-tec Date: Fri, 17 Jul 2026 21:25:08 +0800 Subject: [PATCH] refactor: rename staticTabId -> currentTabId, clarify tab id semantics --- frontend/app/aipanel/waveai-model.tsx | 2 +- frontend/app/app-bg.tsx | 2 +- frontend/app/app.tsx | 8 +-- frontend/app/store/focusManager.ts | 6 +- frontend/app/store/global-atoms.ts | 8 +-- frontend/app/store/global.ts | 16 ++--- frontend/app/store/keymodel.ts | 66 +++++++++---------- frontend/app/store/tabrpcclient.ts | 8 +-- frontend/app/tab/tabbar.tsx | 2 +- frontend/app/tab/tabbarenv.ts | 2 +- frontend/app/tab/vtabbar.tsx | 2 +- frontend/app/tab/vtabbarenv.ts | 2 +- frontend/app/view/term/term-model.ts | 4 +- frontend/app/view/term/term-wsh.tsx | 2 +- .../app/workspace/workspace-layout-model.ts | 6 +- frontend/app/workspace/workspace.tsx | 2 +- frontend/layout/index.ts | 4 +- frontend/layout/lib/layoutModelHooks.ts | 8 +-- frontend/preview/mock/mockwaveenv.ts | 4 +- frontend/preview/mock/tabbar-mock.tsx | 10 +-- frontend/types/custom.d.ts | 2 +- frontend/wave.ts | 8 +-- 22 files changed, 87 insertions(+), 87 deletions(-) diff --git a/frontend/app/aipanel/waveai-model.tsx b/frontend/app/aipanel/waveai-model.tsx index 194005adc6..4c3abed756 100644 --- a/frontend/app/aipanel/waveai-model.tsx +++ b/frontend/app/aipanel/waveai-model.tsx @@ -181,7 +181,7 @@ export class WaveAIModel { const builderId = globalStore.get(atoms.builderId); orefContext = WOS.makeORef("builder", builderId); } else { - const tabId = globalStore.get(atoms.staticTabId); + const tabId = globalStore.get(atoms.currentTabId); orefContext = WOS.makeORef("tab", tabId); } WaveAIModel.instance = new WaveAIModel(orefContext, isBuilderWindow()); diff --git a/frontend/app/app-bg.tsx b/frontend/app/app-bg.tsx index 2956e36d58..480437c8aa 100644 --- a/frontend/app/app-bg.tsx +++ b/frontend/app/app-bg.tsx @@ -18,7 +18,7 @@ type AppBgEnv = WaveEnvSubset<{ export function AppBackground() { const bgRef = useRef(null); - const tabId = useAtomValue(atoms.staticTabId); + const tabId = useAtomValue(atoms.currentTabId); const [tabData] = useWaveObjectValue(WOS.makeORef("tab", tabId)); const env = useWaveEnv(); const tabBg = useAtomValue(env.getTabMetaKeyAtom(tabId, "tab:background")); diff --git a/frontend/app/app.tsx b/frontend/app/app.tsx index 62cad4ed23..0604373f59 100644 --- a/frontend/app/app.tsx +++ b/frontend/app/app.tsx @@ -15,7 +15,7 @@ import { getTabModelByTabId, TabModelContext } from "@/app/store/tab-model"; import { WaveEnvContext } from "@/app/waveenv/waveenv"; import { makeWaveEnvImpl } from "@/app/waveenv/waveenvimpl"; import { Workspace } from "@/app/workspace/workspace"; -import { getLayoutModelForStaticTab } from "@/layout/index"; +import { getLayoutModelForCurrentTab } from "@/layout/index"; import { ContextMenuModel } from "@/store/contextmenu"; import { atoms, createBlock, getSettingsPrefixAtom, refocusNode } from "@/store/global"; import { appHandleKeyDown, keyboardMouseDownHandler } from "@/store/keymodel"; @@ -51,7 +51,7 @@ const App = ({ onFirstRender }: { onFirstRender: () => void }) => { }; const AppContextProviders = ({ onFirstRender }: { onFirstRender: () => void }) => { - const tabId = useAtomValue(atoms.staticTabId); + const tabId = useAtomValue(atoms.currentTabId); const waveEnvRef = useRef(makeWaveEnvImpl()); useEffect(() => { onFirstRender(); @@ -307,9 +307,9 @@ const AppKeyHandlers = () => { }; const BadgeAutoClearing = () => { - const tabId = useAtomValue(atoms.staticTabId); + const tabId = useAtomValue(atoms.currentTabId); const documentHasFocus = useAtomValue(atoms.documentHasFocus); - const layoutModel = getLayoutModelForStaticTab(); + const layoutModel = getLayoutModelForCurrentTab(); const focusedNode = useAtomValue(layoutModel.focusedNode); const focusedBlockId = focusedNode?.data?.blockId; const badge = useAtomValue(getBlockBadgeAtom(focusedBlockId)); diff --git a/frontend/app/store/focusManager.ts b/frontend/app/store/focusManager.ts index 30af3d825a..5533e47379 100644 --- a/frontend/app/store/focusManager.ts +++ b/frontend/app/store/focusManager.ts @@ -9,7 +9,7 @@ import { RpcApi } from "@/app/store/wshclientapi"; import { TabRpcClient } from "@/app/store/wshrpcutil"; import { termLog } from "@/util/termlog"; import { fireAndForget } from "@/util/util"; -import { getLayoutModelForStaticTab } from "@/layout/index"; +import { getLayoutModelForCurrentTab } from "@/layout/index"; import { focusedBlockId } from "@/util/focusutil"; import { Atom, atom, type PrimitiveAtom } from "jotai"; @@ -26,7 +26,7 @@ export class FocusManager { if (get(this.focusType) == "waveai") { return null; } - const layoutModel = getLayoutModelForStaticTab(); + const layoutModel = getLayoutModelForCurrentTab(); const lnode = get(layoutModel.focusedNode); return lnode?.data?.blockId; }); @@ -104,7 +104,7 @@ export class FocusManager { WaveAIModel.getInstance().focusInput(); return; } - const layoutModel = getLayoutModelForStaticTab(); + const layoutModel = getLayoutModelForCurrentTab(); const lnode = globalStore.get(layoutModel.focusedNode); if (lnode == null || lnode.data?.blockId == null) { return; diff --git a/frontend/app/store/global-atoms.ts b/frontend/app/store/global-atoms.ts index f8a16f82d3..816a482a0c 100644 --- a/frontend/app/store/global-atoms.ts +++ b/frontend/app/store/global-atoms.ts @@ -15,13 +15,13 @@ function initGlobalAtoms(initOpts: GlobalInitOptions) { const builderIdAtom = atom(initOpts.builderId) as PrimitiveAtom; const builderAppIdAtom = atom(null) as PrimitiveAtom; setWaveWindowType(initOpts.isPreview ? "preview" : initOpts.builderId != null ? "builder" : "tab"); - // Tab views are reused across workspace switches, so reinit updates this to the workspace active tab. - const staticTabIdAtom = atom(initOpts.tabId) as PrimitiveAtom; + // Tab views are reused across workspace switches, so reinit updates this to the new workspace's tab context. + const currentTabIdAtom = atom(initOpts.tabId) as PrimitiveAtom; const windowIdAtom = atom(initOpts.windowId) as PrimitiveAtom; const uiContextAtom = atom((get) => { const uiContext: UIContext = { windowid: get(windowIdAtom), - activetabid: get(staticTabIdAtom), + activetabid: get(currentTabIdAtom), }; return uiContext; }) as Atom; @@ -144,7 +144,7 @@ function initGlobalAtoms(initOpts: GlobalInitOptions) { settingsAtom, hasCustomAIPresetsAtom, hasConfigErrors, - staticTabId: staticTabIdAtom, + currentTabId: currentTabIdAtom, isFullScreen: isFullScreenAtom, zoomFactorAtom, controlShiftDelayAtom, diff --git a/frontend/app/store/global.ts b/frontend/app/store/global.ts index 9922e51431..c01835932c 100644 --- a/frontend/app/store/global.ts +++ b/frontend/app/store/global.ts @@ -4,7 +4,7 @@ import { RpcApi } from "@/app/store/wshclientapi"; import { TabRpcClient } from "@/app/store/wshrpcutil"; import { - getLayoutModelForStaticTab, + getLayoutModelForCurrentTab, LayoutTreeActionType, LayoutTreeInsertNodeAction, newLayoutNode, @@ -396,7 +396,7 @@ async function createBlockSplitHorizontally( targetBlockId: string, position: "before" | "after" ): Promise { - const layoutModel = getLayoutModelForStaticTab(); + const layoutModel = getLayoutModelForCurrentTab(); const rtOpts: RuntimeOpts = { termsize: { rows: 25, cols: 80 } }; blockDef = applyWorkspaceDefaultsToBlockDef(blockDef); const newBlockId = await ObjectService.CreateBlock(blockDef, rtOpts); @@ -420,7 +420,7 @@ async function createBlockSplitVertically( targetBlockId: string, position: "before" | "after" ): Promise { - const layoutModel = getLayoutModelForStaticTab(); + const layoutModel = getLayoutModelForCurrentTab(); const rtOpts: RuntimeOpts = { termsize: { rows: 25, cols: 80 } }; blockDef = applyWorkspaceDefaultsToBlockDef(blockDef); const newBlockId = await ObjectService.CreateBlock(blockDef, rtOpts); @@ -440,7 +440,7 @@ async function createBlockSplitVertically( } async function createBlock(blockDef: BlockDef, magnified = false, ephemeral = false): Promise { - const layoutModel = getLayoutModelForStaticTab(); + const layoutModel = getLayoutModelForCurrentTab(); const rtOpts: RuntimeOpts = { termsize: { rows: 25, cols: 80 } }; blockDef = applyWorkspaceDefaultsToBlockDef(blockDef); const blockId = await ObjectService.CreateBlock(blockDef, rtOpts); @@ -459,7 +459,7 @@ async function createBlock(blockDef: BlockDef, magnified = false, ephemeral = fa } async function replaceBlock(blockId: string, blockDef: BlockDef, focus: boolean): Promise { - const layoutModel = getLayoutModelForStaticTab(); + const layoutModel = getLayoutModelForCurrentTab(); const rtOpts: RuntimeOpts = { termsize: { rows: 25, cols: 80 } }; blockDef = applyWorkspaceDefaultsToBlockDef(blockDef); const newBlockId = await ObjectService.CreateBlock(blockDef, rtOpts); @@ -513,7 +513,7 @@ async function fetchWaveFile( function setNodeFocus(nodeId: string) { termLog("[block]", "setNodeFocus", nodeId); - const layoutModel = getLayoutModelForStaticTab(); + const layoutModel = getLayoutModelForCurrentTab(); layoutModel.focusNode(nodeId); } @@ -601,7 +601,7 @@ function getAllBlockComponentModels(): BlockComponentModel[] { } function getFocusedBlockId(): string { - const layoutModel = getLayoutModelForStaticTab(); + const layoutModel = getLayoutModelForCurrentTab(); if (layoutModel?.focusedNode == null) return null; const focusedLayoutNode = globalStore.get(layoutModel.focusedNode); return focusedLayoutNode?.data?.blockId; @@ -616,7 +616,7 @@ function refocusNode(blockId: string) { } } termLog("[block]", "refocusNode", blockId); - const layoutModel = getLayoutModelForStaticTab(); + const layoutModel = getLayoutModelForCurrentTab(); const layoutNodeId = layoutModel.getNodeByBlockId(blockId); if (layoutNodeId?.id == null) { return; diff --git a/frontend/app/store/keymodel.ts b/frontend/app/store/keymodel.ts index 10f026958f..225b70973f 100644 --- a/frontend/app/store/keymodel.ts +++ b/frontend/app/store/keymodel.ts @@ -22,7 +22,7 @@ import { } from "@/app/store/global"; import { getActiveTabModel } from "@/app/store/tab-model"; import { WorkspaceLayoutModel } from "@/app/workspace/workspace-layout-model"; -import { deleteLayoutModelForTab, getLayoutModelForStaticTab, NavigateDirection } from "@/layout/index"; +import { deleteLayoutModelForTab, getLayoutModelForCurrentTab, NavigateDirection } from "@/layout/index"; import * as keyutil from "@/util/keyutil"; import { isWindows } from "@/util/platformutil"; import { termLog } from "@/util/termlog"; @@ -67,8 +67,8 @@ export function keyboardMouseDownHandler(e: MouseEvent) { } } -function getFocusedBlockInStaticTab(): string { - const layoutModel = getLayoutModelForStaticTab(); +function getFocusedBlockInCurrentTab(): string { + const layoutModel = getLayoutModelForCurrentTab(); const focusedNode = globalStore.get(layoutModel.focusedNode); return focusedNode.data?.blockId; } @@ -122,17 +122,17 @@ function shouldDispatchToBlock(e: WaveKeyboardEvent): boolean { return true; } -function getStaticTabBlockCount(): number { - const tabId = globalStore.get(atoms.staticTabId); +function getCurrentTabBlockCount(): number { + const tabId = globalStore.get(atoms.currentTabId); const tabORef = WOS.makeORef("tab", tabId); const tabAtom = WOS.getWaveObjectAtom(tabORef); const tabData = globalStore.get(tabAtom); return tabData?.blockids?.length ?? 0; } -function simpleCloseStaticTab() { +function simpleCloseCurrentTab() { const workspaceId = globalStore.get(atoms.workspaceId); - const tabId = globalStore.get(atoms.staticTabId); + const tabId = globalStore.get(atoms.currentTabId); const confirmClose = globalStore.get(getSettingsKeyAtom("tab:confirmclose")) ?? false; getApi() .closeTab(workspaceId, tabId, confirmClose) @@ -149,7 +149,7 @@ function simpleCloseStaticTab() { function uxCloseBlock(blockId: string) { const workspaceLayoutModel = WorkspaceLayoutModel.getInstance(); const isAIPanelOpen = workspaceLayoutModel.getAIPanelVisible(); - if (isAIPanelOpen && getStaticTabBlockCount() === 1) { + if (isAIPanelOpen && getCurrentTabBlockCount() === 1) { const aiModel = WaveAIModel.getInstance(); const shouldSwitchToAI = !globalStore.get(aiModel.isChatEmptyAtom) || aiModel.hasNonEmptyInput(); if (shouldSwitchToAI) { @@ -163,14 +163,14 @@ function uxCloseBlock(blockId: string) { const blockData = globalStore.get(blockAtom); const isAIFileDiff = blockData?.meta?.view === "aifilediff"; - // If this is the last block, closing it will close the tab — route through simpleCloseStaticTab + // If this is the last block, closing it will close the tab — route through simpleCloseCurrentTab // so the tab:confirmclose setting is respected. - if (getStaticTabBlockCount() === 1) { - simpleCloseStaticTab(); + if (getCurrentTabBlockCount() === 1) { + simpleCloseCurrentTab(); return; } - const layoutModel = getLayoutModelForStaticTab(); + const layoutModel = getLayoutModelForCurrentTab(); const node = layoutModel.getNodeByBlockId(blockId); if (node) { fireAndForget(() => layoutModel.closeNode(node.id)); @@ -190,11 +190,11 @@ function genericClose() { const workspaceLayoutModel = WorkspaceLayoutModel.getInstance(); const isAIPanelOpen = workspaceLayoutModel.getAIPanelVisible(); - if (isAIPanelOpen && getStaticTabBlockCount() === 1) { + if (isAIPanelOpen && getCurrentTabBlockCount() === 1) { const aiModel = WaveAIModel.getInstance(); const shouldSwitchToAI = !globalStore.get(aiModel.isChatEmptyAtom) || aiModel.hasNonEmptyInput(); if (shouldSwitchToAI) { - const layoutModel = getLayoutModelForStaticTab(); + const layoutModel = getLayoutModelForCurrentTab(); const focusedNode = globalStore.get(layoutModel.focusedNode); if (focusedNode) { replaceBlock(focusedNode.data.blockId, { meta: { view: "launcher" } }, false); @@ -203,20 +203,20 @@ function genericClose() { } } } - const blockCount = getStaticTabBlockCount(); + const blockCount = getCurrentTabBlockCount(); if (blockCount === 0) { - simpleCloseStaticTab(); + simpleCloseCurrentTab(); return; } - // If this is the last block, closing it will close the tab — route through simpleCloseStaticTab + // If this is the last block, closing it will close the tab — route through simpleCloseCurrentTab // so the tab:confirmclose setting is respected. if (blockCount === 1) { - simpleCloseStaticTab(); + simpleCloseCurrentTab(); return; } - const layoutModel = getLayoutModelForStaticTab(); + const layoutModel = getLayoutModelForCurrentTab(); const focusedNode = globalStore.get(layoutModel.focusedNode); const blockId = focusedNode?.data?.blockId; const blockAtom = blockId ? WOS.getWaveObjectAtom(WOS.makeORef("block", blockId)) : null; @@ -232,7 +232,7 @@ function genericClose() { function switchBlockByBlockNum(index: number) { termLog("[block]", "switchBlockByBlockNum", index); - const layoutModel = getLayoutModelForStaticTab(); + const layoutModel = getLayoutModelForCurrentTab(); if (!layoutModel) { return; } @@ -244,7 +244,7 @@ function switchBlockByBlockNum(index: number) { function switchBlockInDirection(direction: NavigateDirection) { termLog("[block]", "switchBlockInDirection", direction); - const layoutModel = getLayoutModelForStaticTab(); + const layoutModel = getLayoutModelForCurrentTab(); const focusType = FocusManager.getInstance().getFocusType(); if (direction === NavigateDirection.Left) { @@ -299,7 +299,7 @@ function switchTabAbs(index: number) { function switchTab(offset: number) { termLog("[tab]", "switchTab", offset); const ws = globalStore.get(atoms.workspace); - const curTabId = globalStore.get(atoms.staticTabId); + const curTabId = globalStore.get(atoms.currentTabId); let tabIdx = -1; const tabids = getAllTabs(ws); for (let i = 0; i < tabids.length; i++) { @@ -331,7 +331,7 @@ function globalRefocus() { return; } - const layoutModel = getLayoutModelForStaticTab(); + const layoutModel = getLayoutModelForCurrentTab(); const focusedNode = globalStore.get(layoutModel.focusedNode); if (focusedNode == null) { termLog("[block]", "globalRefocus: no focused node, focus first"); @@ -363,7 +363,7 @@ function getDefaultNewBlockDef(): BlockDef { controller: "shell", }, }; - const layoutModel = getLayoutModelForStaticTab(); + const layoutModel = getLayoutModelForCurrentTab(); const focusedNode = globalStore.get(layoutModel.focusedNode); let hasExplicitConn = false; let hasExplicitCwd = false; @@ -398,7 +398,7 @@ async function handleCmdN() { } async function handleSplitHorizontal(position: "before" | "after") { - const layoutModel = getLayoutModelForStaticTab(); + const layoutModel = getLayoutModelForCurrentTab(); const focusedNode = globalStore.get(layoutModel.focusedNode); if (focusedNode == null) { return; @@ -408,7 +408,7 @@ async function handleSplitHorizontal(position: "before" | "after") { } async function handleSplitVertical(position: "before" | "after") { - const layoutModel = getLayoutModelForStaticTab(); + const layoutModel = getLayoutModelForCurrentTab(); const focusedNode = globalStore.get(layoutModel.focusedNode); if (focusedNode == null) { return; @@ -467,7 +467,7 @@ function appHandleKeyDown(waveEvent: WaveKeyboardEvent): boolean { } } if (isTabWindow()) { - const layoutModel = getLayoutModelForStaticTab(); + const layoutModel = getLayoutModelForCurrentTab(); const focusedNode = globalStore.get(layoutModel.focusedNode); const blockId = focusedNode?.data?.blockId; if (blockId != null && shouldDispatchToBlock(waveEvent)) { @@ -559,11 +559,11 @@ function registerGlobalKeys() { return true; }); globalKeyMap.set("Cmd:Shift:w", () => { - simpleCloseStaticTab(); + simpleCloseCurrentTab(); return true; }); globalKeyMap.set("Cmd:m", () => { - const layoutModel = getLayoutModelForStaticTab(); + const layoutModel = getLayoutModelForCurrentTab(); const focusedNode = globalStore.get(layoutModel.focusedNode); if (focusedNode != null) { const ephemeralNode = globalStore.get(layoutModel.ephemeralNode); @@ -665,7 +665,7 @@ function registerGlobalKeys() { return false; }); globalKeyMap.set("Cmd:g", () => { - const bcm = getBlockComponentModel(getFocusedBlockInStaticTab()); + const bcm = getBlockComponentModel(getFocusedBlockInCurrentTab()); if (bcm.openSwitchConnection != null) { recordTEvent("action:other", { "action:type": "conndropdown", "action:initiator": "keyboard" }); bcm.openSwitchConnection(); @@ -720,7 +720,7 @@ function registerGlobalKeys() { } function getSelectedText(): string { // Check for terminal selection first - const bcm = getBlockComponentModel(getFocusedBlockInStaticTab()); + const bcm = getBlockComponentModel(getFocusedBlockInCurrentTab()); if (bcm?.viewModel?.viewType === "term") { const termViewModel = bcm.viewModel as TermViewModel; if (termViewModel.termRef?.current?.terminal) { @@ -743,7 +743,7 @@ function registerGlobalKeys() { } function activateSearch(event: WaveKeyboardEvent): boolean { - const bcm = getBlockComponentModel(getFocusedBlockInStaticTab()); + const bcm = getBlockComponentModel(getFocusedBlockInCurrentTab()); // Ctrl+f is reserved in most shells if (event.control && bcm.viewModel.viewType == "term") { return false; @@ -763,7 +763,7 @@ function registerGlobalKeys() { return false; } function deactivateSearch(): boolean { - const bcm = getBlockComponentModel(getFocusedBlockInStaticTab()); + const bcm = getBlockComponentModel(getFocusedBlockInCurrentTab()); if (bcm.viewModel.searchAtoms && globalStore.get(bcm.viewModel.searchAtoms.isOpen)) { globalStore.set(bcm.viewModel.searchAtoms.isOpen, false); return true; diff --git a/frontend/app/store/tabrpcclient.ts b/frontend/app/store/tabrpcclient.ts index 2c7a4e290c..a276f3db84 100644 --- a/frontend/app/store/tabrpcclient.ts +++ b/frontend/app/store/tabrpcclient.ts @@ -5,7 +5,7 @@ import { WaveAIModel } from "@/app/aipanel/waveai-model"; import { getApi, getBlockComponentModel, getConnStatusAtom, globalStore, WOS } from "@/app/store/global"; import type { TermViewModel } from "@/app/view/term/term-model"; import { WorkspaceLayoutModel } from "@/app/workspace/workspace-layout-model"; -import { getLayoutModelForStaticTab } from "@/layout/index"; +import { getLayoutModelForCurrentTab } from "@/layout/index"; import { termLog } from "@/util/termlog"; import { base64ToArrayBuffer } from "@/util/util"; import { RpcResponseHelper, WshClient } from "./wshclient"; @@ -21,7 +21,7 @@ export class TabClient extends WshClient { } async captureBlockScreenshot(blockId: string): Promise { - const layoutModel = getLayoutModelForStaticTab(); + const layoutModel = getLayoutModelForCurrentTab(); if (!layoutModel) { throw new Error("Layout model not found"); } @@ -95,7 +95,7 @@ export class TabClient extends WshClient { async handle_setblockfocus(rh: RpcResponseHelper, blockId: string): Promise { termLog("[block]", "handle_setblockfocus (RPC)", blockId); - const layoutModel = getLayoutModelForStaticTab(); + const layoutModel = getLayoutModelForCurrentTab(); if (!layoutModel) { throw new Error("Layout model not found"); } @@ -109,7 +109,7 @@ export class TabClient extends WshClient { } async handle_getfocusedblockdata(rh: RpcResponseHelper): Promise { - const layoutModel = getLayoutModelForStaticTab(); + const layoutModel = getLayoutModelForCurrentTab(); if (!layoutModel) { throw new Error("Layout model not found"); } diff --git a/frontend/app/tab/tabbar.tsx b/frontend/app/tab/tabbar.tsx index b404afcb7e..bc09f5decf 100644 --- a/frontend/app/tab/tabbar.tsx +++ b/frontend/app/tab/tabbar.tsx @@ -127,7 +127,7 @@ const TabBar = memo(({ workspace, noTabs }: TabBarProps) => { const tabWidthRef = useRef(TabDefaultWidth); const scrollableRef = useRef(false); const prevAllLoadedRef = useRef(false); - const activeTabId = useAtomValue(env.atoms.staticTabId); + const activeTabId = useAtomValue(env.atoms.currentTabId); const isFullScreen = useAtomValue(env.atoms.isFullScreen); const zoomFactor = useAtomValue(env.atoms.zoomFactorAtom); const showMenuBar = useAtomValue(env.getSettingsKeyAtom("window:showmenubar")); diff --git a/frontend/app/tab/tabbarenv.ts b/frontend/app/tab/tabbarenv.ts index e44b344b6b..16a0e6a0af 100644 --- a/frontend/app/tab/tabbarenv.ts +++ b/frontend/app/tab/tabbarenv.ts @@ -21,7 +21,7 @@ export type TabBarEnv = WaveEnvSubset<{ atoms: { fullConfigAtom: WaveEnv["atoms"]["fullConfigAtom"]; hasConfigErrors: WaveEnv["atoms"]["hasConfigErrors"]; - staticTabId: WaveEnv["atoms"]["staticTabId"]; + currentTabId: WaveEnv["atoms"]["currentTabId"]; isFullScreen: WaveEnv["atoms"]["isFullScreen"]; zoomFactorAtom: WaveEnv["atoms"]["zoomFactorAtom"]; reinitVersion: WaveEnv["atoms"]["reinitVersion"]; diff --git a/frontend/app/tab/vtabbar.tsx b/frontend/app/tab/vtabbar.tsx index e40bcfb374..4ff6c6416d 100644 --- a/frontend/app/tab/vtabbar.tsx +++ b/frontend/app/tab/vtabbar.tsx @@ -186,7 +186,7 @@ function VTabWrapper({ export function VTabBar({ workspace, className }: VTabBarProps) { const env = useWaveEnv(); - const activeTabId = useAtomValue(env.atoms.staticTabId); + const activeTabId = useAtomValue(env.atoms.currentTabId); const reinitVersion = useAtomValue(env.atoms.reinitVersion); const documentHasFocus = useAtomValue(env.atoms.documentHasFocus); const tabIds = workspace?.tabids ?? []; diff --git a/frontend/app/tab/vtabbarenv.ts b/frontend/app/tab/vtabbarenv.ts index 2533780776..ffbd8e24a1 100644 --- a/frontend/app/tab/vtabbarenv.ts +++ b/frontend/app/tab/vtabbarenv.ts @@ -21,7 +21,7 @@ export type VTabBarEnv = WaveEnvSubset<{ SetMetaCommand: WaveEnv["rpc"]["SetMetaCommand"]; }; atoms: { - staticTabId: WaveEnv["atoms"]["staticTabId"]; + currentTabId: WaveEnv["atoms"]["currentTabId"]; fullConfigAtom: WaveEnv["atoms"]["fullConfigAtom"]; reinitVersion: WaveEnv["atoms"]["reinitVersion"]; documentHasFocus: WaveEnv["atoms"]["documentHasFocus"]; diff --git a/frontend/app/view/term/term-model.ts b/frontend/app/view/term/term-model.ts index 44b47b1db9..1471eff5b8 100644 --- a/frontend/app/view/term/term-model.ts +++ b/frontend/app/view/term/term-model.ts @@ -801,7 +801,7 @@ export class TermViewModel implements ViewModel { cols: this.termRef.current?.terminal?.cols, }; await RpcApi.ControllerResyncCommand(TabRpcClient, { - tabid: globalStore.get(atoms.staticTabId), + tabid: globalStore.get(atoms.currentTabId), blockid: this.blockId, forcerestart: true, rtopts: { termsize: termsize }, @@ -819,7 +819,7 @@ export class TermViewModel implements ViewModel { cols: this.termRef.current?.terminal?.cols, }; await RpcApi.ControllerResyncCommand(TabRpcClient, { - tabid: globalStore.get(atoms.staticTabId), + tabid: globalStore.get(atoms.currentTabId), blockid: this.blockId, forcerestart: true, rtopts: { termsize: termsize }, diff --git a/frontend/app/view/term/term-wsh.tsx b/frontend/app/view/term/term-wsh.tsx index c1b4aa5478..4a2c64d4f8 100644 --- a/frontend/app/view/term/term-wsh.tsx +++ b/frontend/app/view/term/term-wsh.tsx @@ -29,7 +29,7 @@ export class TermWshClient extends WshClient { throw new Error("source cannot be blank"); } console.log("vdom-create", source, data); - const tabId = globalStore.get(atoms.staticTabId); + const tabId = globalStore.get(atoms.currentTabId); if (data.target?.newblock) { const oref = await RpcApi.CreateBlockCommand(this, { tabid: tabId, diff --git a/frontend/app/workspace/workspace-layout-model.ts b/frontend/app/workspace/workspace-layout-model.ts index eb7065f90c..9b1a3d999a 100644 --- a/frontend/app/workspace/workspace-layout-model.ts +++ b/frontend/app/workspace/workspace-layout-model.ts @@ -7,7 +7,7 @@ import { isBuilderWindow } from "@/app/store/windowtype"; import * as WOS from "@/app/store/wos"; import { RpcApi } from "@/app/store/wshclientapi"; import { TabRpcClient } from "@/app/store/wshrpcutil"; -import { getLayoutModelForStaticTab } from "@/layout/lib/layoutModelHooks"; +import { getLayoutModelForCurrentTab } from "@/layout/lib/layoutModelHooks"; import { atoms, getApi, getOrefMetaKeyAtom, getSettingsKeyAtom, recordTEvent, refocusNode } from "@/store/global"; import debug from "debug"; import * as jotai from "jotai"; @@ -122,7 +122,7 @@ class WorkspaceLayoutModel { // ---- Meta / persistence helpers ---- private getTabId(): string { - return globalStore.get(atoms.staticTabId); + return globalStore.get(atoms.currentTabId); } private getWorkspaceId(): string { @@ -413,7 +413,7 @@ class WorkspaceLayoutModel { }, 350); } } else { - const layoutModel = getLayoutModelForStaticTab(); + const layoutModel = getLayoutModelForCurrentTab(); const focusedNode = globalStore.get(layoutModel.focusedNode); if (focusedNode == null) { layoutModel.focusFirstNode(); diff --git a/frontend/app/workspace/workspace.tsx b/frontend/app/workspace/workspace.tsx index 08278a4eed..61b484e373 100644 --- a/frontend/app/workspace/workspace.tsx +++ b/frontend/app/workspace/workspace.tsx @@ -41,7 +41,7 @@ MacOSTabBarSpacer.displayName = "MacOSTabBarSpacer"; const WorkspaceElem = memo(() => { const workspaceLayoutModel = WorkspaceLayoutModel.getInstance(); - const tabId = useAtomValue(atoms.staticTabId); + const tabId = useAtomValue(atoms.currentTabId); const ws = useAtomValue(atoms.workspace); const tabBarPosition = useAtomValue(getSettingsKeyAtom("app:tabbar")) ?? "top"; const showLeftTabBar = tabBarPosition === "left"; diff --git a/frontend/layout/index.ts b/frontend/layout/index.ts index 96eb985e39..7c59a6225f 100644 --- a/frontend/layout/index.ts +++ b/frontend/layout/index.ts @@ -3,7 +3,7 @@ import { TileLayout } from "./lib/TileLayout"; import { LayoutModel } from "./lib/layoutModel"; -import { deleteLayoutModelForTab, getLayoutModelForStaticTab, useDebouncedNodeInnerRect } from "./lib/layoutModelHooks"; +import { deleteLayoutModelForTab, getLayoutModelForCurrentTab, useDebouncedNodeInnerRect } from "./lib/layoutModelHooks"; import { newLayoutNode } from "./lib/layoutNode"; import type { ContentRenderer, @@ -30,7 +30,7 @@ import { DropDirection, LayoutTreeActionType, NavigateDirection } from "./lib/ty export { deleteLayoutModelForTab, DropDirection, - getLayoutModelForStaticTab, + getLayoutModelForCurrentTab, LayoutModel, LayoutTreeActionType, NavigateDirection, diff --git a/frontend/layout/lib/layoutModelHooks.ts b/frontend/layout/lib/layoutModelHooks.ts index f1491e1b4b..e5c0d2eee6 100644 --- a/frontend/layout/lib/layoutModelHooks.ts +++ b/frontend/layout/lib/layoutModelHooks.ts @@ -24,8 +24,8 @@ function getLayoutModelForTab(tabAtom: Atom): LayoutModel { } const layoutModel = new LayoutModel(tabAtom, globalStore.get, globalStore.set); - const staticTabId = globalStore.get(atoms.staticTabId); - if (tabId === staticTabId) { + const currentTabId = globalStore.get(atoms.currentTabId); + if (tabId === currentTabId) { const layoutStateAtom = getLayoutStateAtomFromTab(tabAtom, globalStore.get); globalStore.sub(layoutStateAtom, () => { layoutModel.onBackendUpdate(); @@ -42,8 +42,8 @@ function getLayoutModelForTabById(tabId: string) { return getLayoutModelForTab(tabAtom); } -export function getLayoutModelForStaticTab() { - const tabId = globalStore.get(atoms.staticTabId); +export function getLayoutModelForCurrentTab() { + const tabId = globalStore.get(atoms.currentTabId); return getLayoutModelForTabById(tabId); } diff --git a/frontend/preview/mock/mockwaveenv.ts b/frontend/preview/mock/mockwaveenv.ts index ab659f770b..1bc391ffac 100644 --- a/frontend/preview/mock/mockwaveenv.ts +++ b/frontend/preview/mock/mockwaveenv.ts @@ -190,7 +190,7 @@ function makeMockGlobalAtoms( const c = get(fullConfigAtom); return c?.configerrors != null && c.configerrors.length > 0; }), - staticTabId: atom(tabId ?? ""), + currentTabId: atom(tabId ?? ""), isFullScreen: atom(false) as any, zoomFactorAtom: atom(1.0) as any, controlShiftDelayAtom: atom(false) as any, @@ -436,7 +436,7 @@ export function makeMockWaveEnv(mockEnv?: MockEnv): MockWaveEnv { }; const defaultAtoms: Partial = { uiContext: atom({ windowid: PreviewWindowId, activetabid: PreviewTabId } as UIContext), - staticTabId: atom(PreviewTabId), + currentTabId: atom(PreviewTabId), workspaceId: atom(PreviewWorkspaceId), }; const mergedOverrides: MockEnv = { diff --git a/frontend/preview/mock/tabbar-mock.tsx b/frontend/preview/mock/tabbar-mock.tsx index c4a811f6e4..3b245b8c4c 100644 --- a/frontend/preview/mock/tabbar-mock.tsx +++ b/frontend/preview/mock/tabbar-mock.tsx @@ -107,7 +107,7 @@ export function makeTabBarMockEnv( mockWaveObjs, atoms: { workspaceId: atom(TabBarMockWorkspaceId), - staticTabId: atom(TabBarMockTabs[1].tabId), + currentTabId: atom(TabBarMockTabs[1].tabId), }, rpc: { GetAllBadgesCommand: () => Promise.resolve(makeMockBadgeEvents()), @@ -130,7 +130,7 @@ export function makeTabBarMockEnv( ...ws, tabids: [...(ws.tabids ?? []), newTabId], }); - globalStore.set(e.atoms.staticTabId as any, newTabId); + globalStore.set(e.atoms.currentTabId as any, newTabId); }, closeTab: (_workspaceId: string, tabId: string) => { const e = envRef.current; @@ -141,15 +141,15 @@ export function makeTabBarMockEnv( return Promise.resolve(false); } e.mockSetWaveObj(`workspace:${TabBarMockWorkspaceId}`, { ...ws, tabids: newTabIds }); - if (globalStore.get(e.atoms.staticTabId) === tabId) { - globalStore.set(e.atoms.staticTabId as any, newTabIds[0]); + if (globalStore.get(e.atoms.currentTabId) === tabId) { + globalStore.set(e.atoms.currentTabId as any, newTabIds[0]); } return Promise.resolve(true); }, setActiveTab: (tabId: string) => { const e = envRef.current; if (e == null) return; - globalStore.set(e.atoms.staticTabId as any, tabId); + globalStore.set(e.atoms.currentTabId as any, tabId); }, showWorkspaceAppMenu: () => { console.log("[preview] showWorkspaceAppMenu"); diff --git a/frontend/types/custom.d.ts b/frontend/types/custom.d.ts index aa7b057306..71d69ebc7d 100644 --- a/frontend/types/custom.d.ts +++ b/frontend/types/custom.d.ts @@ -20,7 +20,7 @@ declare global { settingsAtom: jotai.Atom; // derrived from fullConfig hasCustomAIPresetsAtom: jotai.Atom; // derived from fullConfig hasConfigErrors: jotai.Atom; // derived from fullConfig - staticTabId: jotai.PrimitiveAtom; + currentTabId: jotai.PrimitiveAtom; isFullScreen: jotai.PrimitiveAtom; zoomFactorAtom: jotai.PrimitiveAtom; controlShiftDelayAtom: jotai.PrimitiveAtom; diff --git a/frontend/wave.ts b/frontend/wave.ts index 8e69b9aaad..a32c3e62eb 100644 --- a/frontend/wave.ts +++ b/frontend/wave.ts @@ -17,7 +17,7 @@ import { RpcApi } from "@/app/store/wshclientapi"; import { makeBuilderRouteId, makeTabRouteId } from "@/app/store/wshrouter"; import { initWshrpc, TabRpcClient } from "@/app/store/wshrpcutil"; import { BuilderApp } from "@/builder/builder-app"; -import { getLayoutModelForStaticTab } from "@/layout/index"; +import { getLayoutModelForCurrentTab } from "@/layout/index"; import { countersClear, countersPrint } from "@/store/counters"; import { atoms, @@ -88,7 +88,7 @@ function waitForNextPaint(): Promise { (window as any).isFullScreen = false; (window as any).countersPrint = countersPrint; (window as any).countersClear = countersClear; -(window as any).getLayoutModelForStaticTab = getLayoutModelForStaticTab; +(window as any).getLayoutModelForCurrentTab = getLayoutModelForCurrentTab; (window as any).modalsModel = modalsModel; async function loadWorkspaceContext(opts: { @@ -151,7 +151,7 @@ function applyWorkspaceContext(ctx: WorkspaceContext, opts: { tabContext: "own" globalStore.set(atoms.windowId, ctx.waveWindow.oid); globalStore.set(atoms.workspaceId, ctx.workspace.oid); globalStore.set(activeTabIdAtom, ctx.activeTabId); - globalStore.set(atoms.staticTabId, tabIdForRenderer); + globalStore.set(atoms.currentTabId, tabIdForRenderer); globalStore.set(atoms.updaterStatusAtom, getApi().getUpdaterStatus()); } @@ -186,7 +186,7 @@ async function initWaveWrap(initOpts: WaveInitOpts) { try { if (savedInitOpts) { globalStore.set(activeTabIdAtom, initOpts.tabId); - globalStore.set(atoms.staticTabId, initOpts.tabId); + globalStore.set(atoms.currentTabId, initOpts.tabId); await reinitWave(); return; }