Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/app/aipanel/waveai-model.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/app-bg.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type AppBgEnv = WaveEnvSubset<{

export function AppBackground() {
const bgRef = useRef<HTMLDivElement>(null);
const tabId = useAtomValue(atoms.staticTabId);
const tabId = useAtomValue(atoms.currentTabId);
const [tabData] = useWaveObjectValue<Tab>(WOS.makeORef("tab", tabId));
const env = useWaveEnv<AppBgEnv>();
const tabBg = useAtomValue(env.getTabMetaKeyAtom(tabId, "tab:background"));
Expand Down
8 changes: 4 additions & 4 deletions frontend/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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));
Expand Down
6 changes: 3 additions & 3 deletions frontend/app/store/focusManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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;
});
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions frontend/app/store/global-atoms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ function initGlobalAtoms(initOpts: GlobalInitOptions) {
const builderIdAtom = atom(initOpts.builderId) as PrimitiveAtom<string>;
const builderAppIdAtom = atom<string>(null) as PrimitiveAtom<string>;
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<string>;
// 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<string>;
const windowIdAtom = atom(initOpts.windowId) as PrimitiveAtom<string>;
const uiContextAtom = atom((get) => {
const uiContext: UIContext = {
windowid: get(windowIdAtom),
activetabid: get(staticTabIdAtom),
activetabid: get(currentTabIdAtom),
};
return uiContext;
}) as Atom<UIContext>;
Expand Down Expand Up @@ -144,7 +144,7 @@ function initGlobalAtoms(initOpts: GlobalInitOptions) {
settingsAtom,
hasCustomAIPresetsAtom,
hasConfigErrors,
staticTabId: staticTabIdAtom,
currentTabId: currentTabIdAtom,
isFullScreen: isFullScreenAtom,
zoomFactorAtom,
controlShiftDelayAtom,
Expand Down
16 changes: 8 additions & 8 deletions frontend/app/store/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { RpcApi } from "@/app/store/wshclientapi";
import { TabRpcClient } from "@/app/store/wshrpcutil";
import {
getLayoutModelForStaticTab,
getLayoutModelForCurrentTab,
LayoutTreeActionType,
LayoutTreeInsertNodeAction,
newLayoutNode,
Expand Down Expand Up @@ -396,7 +396,7 @@ async function createBlockSplitHorizontally(
targetBlockId: string,
position: "before" | "after"
): Promise<string> {
const layoutModel = getLayoutModelForStaticTab();
const layoutModel = getLayoutModelForCurrentTab();
const rtOpts: RuntimeOpts = { termsize: { rows: 25, cols: 80 } };
blockDef = applyWorkspaceDefaultsToBlockDef(blockDef);
const newBlockId = await ObjectService.CreateBlock(blockDef, rtOpts);
Expand All @@ -420,7 +420,7 @@ async function createBlockSplitVertically(
targetBlockId: string,
position: "before" | "after"
): Promise<string> {
const layoutModel = getLayoutModelForStaticTab();
const layoutModel = getLayoutModelForCurrentTab();
const rtOpts: RuntimeOpts = { termsize: { rows: 25, cols: 80 } };
blockDef = applyWorkspaceDefaultsToBlockDef(blockDef);
const newBlockId = await ObjectService.CreateBlock(blockDef, rtOpts);
Expand All @@ -440,7 +440,7 @@ async function createBlockSplitVertically(
}

async function createBlock(blockDef: BlockDef, magnified = false, ephemeral = false): Promise<string> {
const layoutModel = getLayoutModelForStaticTab();
const layoutModel = getLayoutModelForCurrentTab();
const rtOpts: RuntimeOpts = { termsize: { rows: 25, cols: 80 } };
blockDef = applyWorkspaceDefaultsToBlockDef(blockDef);
const blockId = await ObjectService.CreateBlock(blockDef, rtOpts);
Expand All @@ -459,7 +459,7 @@ async function createBlock(blockDef: BlockDef, magnified = false, ephemeral = fa
}

async function replaceBlock(blockId: string, blockDef: BlockDef, focus: boolean): Promise<string> {
const layoutModel = getLayoutModelForStaticTab();
const layoutModel = getLayoutModelForCurrentTab();
const rtOpts: RuntimeOpts = { termsize: { rows: 25, cols: 80 } };
blockDef = applyWorkspaceDefaultsToBlockDef(blockDef);
const newBlockId = await ObjectService.CreateBlock(blockDef, rtOpts);
Expand Down Expand Up @@ -513,7 +513,7 @@ async function fetchWaveFile(

function setNodeFocus(nodeId: string) {
termLog("[block]", "setNodeFocus", nodeId);
const layoutModel = getLayoutModelForStaticTab();
const layoutModel = getLayoutModelForCurrentTab();
layoutModel.focusNode(nodeId);
}

Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Loading
Loading