Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c0aed107dc | ||
|
|
b5281f994e | ||
|
|
5c8504d602 |
No files matched your search
@@ -188,6 +188,21 @@ it.layer(NodeServices.layer)("keybindings", (it) => {
|
||||
DEFAULT_KEYBINDINGS.map((binding) => [binding.command, binding.key] as const),
|
||||
);
|
||||
|
||||
assert.equal(defaultsByCommand.get("workspace.pane.splitRight"), "mod+d");
|
||||
assert.equal(defaultsByCommand.get("workspace.pane.splitDown"), "mod+shift+d");
|
||||
assert.equal(defaultsByCommand.get("workspace.pane.close"), "mod+w");
|
||||
assert.equal(defaultsByCommand.get("workspace.focus.previous"), "mod+[");
|
||||
assert.equal(defaultsByCommand.get("workspace.focus.next"), "mod+]");
|
||||
assert.equal(defaultsByCommand.get("workspace.focus.left"), "mod+alt+arrowleft");
|
||||
assert.equal(defaultsByCommand.get("workspace.focus.right"), "mod+alt+arrowright");
|
||||
assert.equal(defaultsByCommand.get("workspace.focus.up"), "mod+alt+arrowup");
|
||||
assert.equal(defaultsByCommand.get("workspace.focus.down"), "mod+alt+arrowdown");
|
||||
assert.equal(defaultsByCommand.get("workspace.pane.toggleZoom"), "mod+shift+enter");
|
||||
assert.equal(defaultsByCommand.get("workspace.pane.resizeLeft"), "mod+ctrl+arrowleft");
|
||||
assert.equal(defaultsByCommand.get("workspace.pane.resizeRight"), "mod+ctrl+arrowright");
|
||||
assert.equal(defaultsByCommand.get("workspace.pane.resizeUp"), "mod+ctrl+arrowup");
|
||||
assert.equal(defaultsByCommand.get("workspace.pane.resizeDown"), "mod+ctrl+arrowdown");
|
||||
assert.equal(defaultsByCommand.get("workspace.pane.equalize"), "mod+ctrl+=");
|
||||
assert.equal(defaultsByCommand.get("thread.previous"), "mod+shift+[");
|
||||
assert.equal(defaultsByCommand.get("thread.next"), "mod+shift+]");
|
||||
assert.equal(defaultsByCommand.get("thread.jump.1"), "mod+1");
|
||||
|
||||
@@ -60,7 +60,22 @@ export const DEFAULT_KEYBINDINGS: ReadonlyArray<KeybindingRule> = [
|
||||
{ key: "mod+d", command: "terminal.split", when: "terminalFocus" },
|
||||
{ key: "mod+n", command: "terminal.new", when: "terminalFocus" },
|
||||
{ key: "mod+w", command: "terminal.close", when: "terminalFocus" },
|
||||
{ key: "mod+d", command: "diff.toggle", when: "!terminalFocus" },
|
||||
{ key: "mod+d", command: "workspace.pane.splitRight", when: "!terminalFocus" },
|
||||
{ key: "mod+shift+d", command: "workspace.pane.splitDown", when: "!terminalFocus" },
|
||||
{ key: "mod+w", command: "workspace.pane.close", when: "!terminalFocus" },
|
||||
{ key: "mod+[", command: "workspace.focus.previous" },
|
||||
{ key: "mod+]", command: "workspace.focus.next" },
|
||||
{ key: "mod+alt+arrowup", command: "workspace.focus.up" },
|
||||
{ key: "mod+alt+arrowdown", command: "workspace.focus.down" },
|
||||
{ key: "mod+alt+arrowleft", command: "workspace.focus.left" },
|
||||
{ key: "mod+alt+arrowright", command: "workspace.focus.right" },
|
||||
{ key: "mod+shift+enter", command: "workspace.pane.toggleZoom" },
|
||||
{ key: "mod+ctrl+arrowup", command: "workspace.pane.resizeUp" },
|
||||
{ key: "mod+ctrl+arrowdown", command: "workspace.pane.resizeDown" },
|
||||
{ key: "mod+ctrl+arrowleft", command: "workspace.pane.resizeLeft" },
|
||||
{ key: "mod+ctrl+arrowright", command: "workspace.pane.resizeRight" },
|
||||
{ key: "mod+ctrl+=", command: "workspace.pane.equalize" },
|
||||
{ key: "mod+alt+d", command: "diff.toggle", when: "!terminalFocus" },
|
||||
{ key: "mod+k", command: "commandPalette.toggle", when: "!terminalFocus" },
|
||||
{ key: "mod+n", command: "chat.new", when: "!terminalFocus" },
|
||||
{ key: "mod+shift+o", command: "chat.new", when: "!terminalFocus" },
|
||||
|
||||
@@ -99,8 +99,7 @@ describe("clientPersistenceStorage", () => {
|
||||
windowsById: {
|
||||
"window-1": {
|
||||
id: "window-1",
|
||||
tabIds: ["surface-1"],
|
||||
activeTabId: "surface-1",
|
||||
surfaceId: "surface-1",
|
||||
},
|
||||
},
|
||||
surfacesById: {
|
||||
|
||||
@@ -18,10 +18,10 @@ export const useCommandPaletteStore = create<CommandPaletteStore>((set) => ({
|
||||
workspaceTarget: null,
|
||||
setOpen: (open) => set({ open, ...(open ? {} : { workspaceTarget: null }) }),
|
||||
toggleOpen: () =>
|
||||
set((state) => ({
|
||||
open: !state.open,
|
||||
...(!state.open ? {} : { workspaceTarget: null }),
|
||||
})),
|
||||
set((state) => {
|
||||
const next = !state.open;
|
||||
return { open: next, ...(next ? {} : { workspaceTarget: null }) };
|
||||
}),
|
||||
openWorkspaceTarget: (target) => set({ open: true, workspaceTarget: target }),
|
||||
clearWorkspaceTarget: () => set({ workspaceTarget: null }),
|
||||
}));
|
||||
@@ -24,7 +24,7 @@ import { applyClaudePromptEffortPrefix } from "@t3tools/shared/model";
|
||||
import { projectScriptCwd, projectScriptRuntimeEnv } from "@t3tools/shared/projectScripts";
|
||||
import { truncate } from "@t3tools/shared/String";
|
||||
import { Debouncer } from "@tanstack/react-pacer";
|
||||
import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
||||
import { useNavigate, useSearch } from "@tanstack/react-router";
|
||||
import { useShallow } from "zustand/react/shallow";
|
||||
import { useGitStatus } from "~/lib/gitStatusState";
|
||||
@@ -120,6 +120,7 @@ import {
|
||||
import {
|
||||
appendTerminalContextsToPrompt,
|
||||
formatTerminalContextLabel,
|
||||
type TerminalContextSelection,
|
||||
type TerminalContextDraft,
|
||||
} from "../lib/terminalContext";
|
||||
import { selectThreadTerminalState, useTerminalStateStore } from "../terminalStateStore";
|
||||
@@ -133,6 +134,7 @@ import { NoActiveThreadState } from "./NoActiveThreadState";
|
||||
import { resolveEffectiveEnvMode, resolveEnvironmentOptionLabel } from "./BranchToolbar.logic";
|
||||
import { ProviderStatusBanner } from "./chat/ProviderStatusBanner";
|
||||
import { ThreadErrorBanner } from "./chat/ThreadErrorBanner";
|
||||
import ThreadTerminalDrawer from "./ThreadTerminalDrawer";
|
||||
import {
|
||||
buildExpiredTerminalContextToastCopy,
|
||||
buildLocalDraftThread,
|
||||
@@ -147,7 +149,6 @@ import {
|
||||
cloneComposerImageForRetry,
|
||||
deriveLockedProvider,
|
||||
readFileAsDataUrl,
|
||||
reconcileMountedTerminalThreadIds,
|
||||
resolveSendEnvMode,
|
||||
revokeBlobPreviewUrl,
|
||||
revokeUserMessagePreviewUrls,
|
||||
@@ -163,7 +164,6 @@ import {
|
||||
} from "~/rpc/serverState";
|
||||
import { sanitizeThreadErrorMessage } from "~/rpc/transportError";
|
||||
import { retainThreadDetailSubscription } from "../environments/runtime/service";
|
||||
import { useWorkspaceStore, useWorkspaceThreadTerminalOpen } from "../workspace/store";
|
||||
|
||||
const IMAGE_ONLY_BOOTSTRAP_PROMPT =
|
||||
"[User attached one or more images without additional text. Respond using the conversation context and the attached image(s).]";
|
||||
@@ -305,6 +305,7 @@ const SCRIPT_TERMINAL_ROWS = 30;
|
||||
|
||||
type ChatViewProps =
|
||||
| {
|
||||
activationFocusRequestId?: number;
|
||||
bindSharedComposerHandle?: boolean;
|
||||
environmentId: EnvironmentId;
|
||||
threadId: ThreadId;
|
||||
@@ -314,6 +315,7 @@ type ChatViewProps =
|
||||
draftId?: never;
|
||||
}
|
||||
| {
|
||||
activationFocusRequestId?: number;
|
||||
bindSharedComposerHandle?: boolean;
|
||||
environmentId: EnvironmentId;
|
||||
threadId: ThreadId;
|
||||
@@ -392,6 +394,7 @@ function useLocalDispatchState(input: {
|
||||
|
||||
export default function ChatView(props: ChatViewProps) {
|
||||
const {
|
||||
activationFocusRequestId,
|
||||
bindSharedComposerHandle = true,
|
||||
environmentId,
|
||||
threadId,
|
||||
@@ -470,9 +473,7 @@ export default function ChatView(props: ChatViewProps) {
|
||||
const composerTerminalContextsRef = useRef<TerminalContextDraft[]>([]);
|
||||
const localComposerRef = useRef<ChatComposerHandle | null>(null);
|
||||
const sharedComposerRef = useComposerHandleContext();
|
||||
const composerRef = bindSharedComposerHandle
|
||||
? (sharedComposerRef ?? localComposerRef)
|
||||
: localComposerRef;
|
||||
const composerRef = localComposerRef;
|
||||
const [showScrollToBottom, setShowScrollToBottom] = useState(false);
|
||||
const [expandedImage, setExpandedImage] = useState<ExpandedImagePreview | null>(null);
|
||||
const [optimisticUserMessages, setOptimisticUserMessages] = useState<ChatMessage[]>([]);
|
||||
@@ -499,7 +500,6 @@ export default function ChatView(props: ChatViewProps) {
|
||||
// Used by "Implement in a new thread" to carry the sidebar-open intent across navigation.
|
||||
const planSidebarOpenOnNextThreadRef = useRef(false);
|
||||
const [terminalFocusRequestId, setTerminalFocusRequestId] = useState(0);
|
||||
const [nowTick, setNowTick] = useState(() => Date.now());
|
||||
const [pullRequestDialogState, setPullRequestDialogState] =
|
||||
useState<PullRequestDialogState | null>(null);
|
||||
const [attachmentPreviewHandoffByMessageId, setAttachmentPreviewHandoffByMessageId] = useState<
|
||||
@@ -520,9 +520,32 @@ export default function ChatView(props: ChatViewProps) {
|
||||
const sendInFlightRef = useRef(false);
|
||||
const terminalOpenByThreadRef = useRef<Record<string, boolean>>({});
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (!sharedComposerRef) {
|
||||
return;
|
||||
}
|
||||
|
||||
const localComposerHandle = localComposerRef.current;
|
||||
if (bindSharedComposerHandle) {
|
||||
sharedComposerRef.current = localComposerHandle;
|
||||
return () => {
|
||||
if (sharedComposerRef.current === localComposerHandle) {
|
||||
sharedComposerRef.current = null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if (sharedComposerRef.current === localComposerHandle) {
|
||||
sharedComposerRef.current = null;
|
||||
}
|
||||
});
|
||||
|
||||
const terminalState = useTerminalStateStore((state) =>
|
||||
selectThreadTerminalState(state.terminalStateByThreadKey, routeThreadRef),
|
||||
);
|
||||
const storeEnsureTerminal = useTerminalStateStore((s) => s.ensureTerminal);
|
||||
const storeSetTerminalOpen = useTerminalStateStore((s) => s.setTerminalOpen);
|
||||
const storeSetTerminalHeight = useTerminalStateStore((s) => s.setTerminalHeight);
|
||||
const storeSplitTerminal = useTerminalStateStore((s) => s.splitTerminal);
|
||||
const storeNewTerminal = useTerminalStateStore((s) => s.newTerminal);
|
||||
const storeSetActiveTerminal = useTerminalStateStore((s) => s.setActiveTerminal);
|
||||
@@ -534,6 +557,7 @@ export default function ChatView(props: ChatViewProps) {
|
||||
const storeClearTerminalLaunchContext = useTerminalStateStore(
|
||||
(s) => s.clearTerminalLaunchContext,
|
||||
);
|
||||
const addTerminalContext = useComposerDraftStore((state) => state.addTerminalContext);
|
||||
|
||||
const fallbackDraftProjectRef = draftThread
|
||||
? scopeProjectRef(draftThread.environmentId, draftThread.projectId)
|
||||
@@ -574,16 +598,6 @@ export default function ChatView(props: ChatViewProps) {
|
||||
[activeThread],
|
||||
);
|
||||
const activeThreadKey = activeThreadRef ? scopedThreadKey(activeThreadRef) : null;
|
||||
const terminalSurfaceOpen = useWorkspaceThreadTerminalOpen(routeThreadRef);
|
||||
const ensureTerminalSurfaceForThread = useWorkspaceStore(
|
||||
(state) => state.ensureTerminalSurfaceForThread,
|
||||
);
|
||||
const toggleTerminalSurfaceForThread = useWorkspaceStore(
|
||||
(state) => state.toggleTerminalSurfaceForThread,
|
||||
);
|
||||
const closeTerminalSurfacesForThread = useWorkspaceStore(
|
||||
(state) => state.closeTerminalSurfacesForThread,
|
||||
);
|
||||
const activeLatestTurn = activeThread?.latestTurn ?? null;
|
||||
const threadPlanCatalog = useThreadPlanCatalog(
|
||||
useMemo(() => {
|
||||
@@ -1193,10 +1207,10 @@ export default function ChatView(props: ChatViewProps) {
|
||||
() => ({
|
||||
context: {
|
||||
terminalFocus: false,
|
||||
terminalOpen: terminalSurfaceOpen,
|
||||
terminalOpen: terminalState.terminalOpen,
|
||||
},
|
||||
}),
|
||||
[terminalSurfaceOpen],
|
||||
[terminalState.terminalOpen],
|
||||
);
|
||||
const terminalToggleShortcutLabel = useMemo(
|
||||
() => shortcutLabelForCommand(keybindings, "terminal.toggle"),
|
||||
@@ -1295,22 +1309,40 @@ export default function ChatView(props: ChatViewProps) {
|
||||
focusComposer();
|
||||
});
|
||||
}, [focusComposer]);
|
||||
const terminalDrawerOpen = terminalState.terminalOpen;
|
||||
const toggleTerminalVisibility = useCallback(() => {
|
||||
if (!activeThreadRef) return;
|
||||
toggleTerminalSurfaceForThread(activeThreadRef);
|
||||
}, [activeThreadRef, toggleTerminalSurfaceForThread]);
|
||||
const nextOpen = !terminalDrawerOpen;
|
||||
if (nextOpen) {
|
||||
const terminalId =
|
||||
terminalState.activeTerminalId ||
|
||||
terminalState.terminalIds[0] ||
|
||||
DEFAULT_THREAD_TERMINAL_ID;
|
||||
storeEnsureTerminal(activeThreadRef, terminalId, { open: true, active: true });
|
||||
setTerminalFocusRequestId((current) => current + 1);
|
||||
return;
|
||||
}
|
||||
storeSetTerminalOpen(activeThreadRef, false);
|
||||
}, [
|
||||
activeThreadRef,
|
||||
storeEnsureTerminal,
|
||||
storeSetTerminalOpen,
|
||||
terminalDrawerOpen,
|
||||
terminalState.activeTerminalId,
|
||||
terminalState.terminalIds,
|
||||
]);
|
||||
const splitTerminal = useCallback(() => {
|
||||
if (!activeThreadRef || hasReachedSplitLimit) return;
|
||||
const terminalId = `terminal-${randomUUID()}`;
|
||||
storeSplitTerminal(activeThreadRef, terminalId);
|
||||
ensureTerminalSurfaceForThread(activeThreadRef);
|
||||
}, [activeThreadRef, ensureTerminalSurfaceForThread, hasReachedSplitLimit, storeSplitTerminal]);
|
||||
setTerminalFocusRequestId((current) => current + 1);
|
||||
}, [activeThreadRef, hasReachedSplitLimit, storeSplitTerminal]);
|
||||
const createNewTerminal = useCallback(() => {
|
||||
if (!activeThreadRef) return;
|
||||
const terminalId = `terminal-${randomUUID()}`;
|
||||
storeNewTerminal(activeThreadRef, terminalId);
|
||||
ensureTerminalSurfaceForThread(activeThreadRef);
|
||||
}, [activeThreadRef, ensureTerminalSurfaceForThread, storeNewTerminal]);
|
||||
setTerminalFocusRequestId((current) => current + 1);
|
||||
}, [activeThreadRef, storeNewTerminal]);
|
||||
const closeTerminal = useCallback(
|
||||
(terminalId: string) => {
|
||||
const api = readEnvironmentApi(environmentId);
|
||||
@@ -1338,20 +1370,30 @@ export default function ChatView(props: ChatViewProps) {
|
||||
}
|
||||
if (activeThreadRef) {
|
||||
storeCloseTerminal(activeThreadRef, terminalId);
|
||||
if (isFinalTerminal) {
|
||||
closeTerminalSurfacesForThread(activeThreadRef);
|
||||
}
|
||||
}
|
||||
if (!isFinalTerminal) {
|
||||
setTerminalFocusRequestId((current) => current + 1);
|
||||
}
|
||||
},
|
||||
[
|
||||
activeThreadId,
|
||||
activeThreadRef,
|
||||
closeTerminalSurfacesForThread,
|
||||
environmentId,
|
||||
storeCloseTerminal,
|
||||
terminalState.terminalIds.length,
|
||||
],
|
||||
);
|
||||
const handleAddTerminalContext = useCallback(
|
||||
(selection: TerminalContextSelection) => {
|
||||
addTerminalContext(routeThreadRef, {
|
||||
...selection,
|
||||
id: randomUUID(),
|
||||
threadId: routeThreadRef.threadId,
|
||||
createdAt: new Date().toISOString(),
|
||||
});
|
||||
},
|
||||
[addTerminalContext, routeThreadRef],
|
||||
);
|
||||
const runProjectScript = useCallback(
|
||||
async (
|
||||
script: ProjectScript,
|
||||
@@ -1391,12 +1433,13 @@ export default function ChatView(props: ChatViewProps) {
|
||||
cwd: targetCwd,
|
||||
worktreePath: targetWorktreePath,
|
||||
});
|
||||
ensureTerminalSurfaceForThread(activeThreadRef);
|
||||
if (shouldCreateNewTerminal) {
|
||||
storeNewTerminal(activeThreadRef, targetTerminalId);
|
||||
} else {
|
||||
storeSetActiveTerminal(activeThreadRef, targetTerminalId);
|
||||
storeEnsureTerminal(activeThreadRef, targetTerminalId, { open: true, active: true });
|
||||
}
|
||||
storeSetTerminalOpen(activeThreadRef, true);
|
||||
setTerminalFocusRequestId((current) => current + 1);
|
||||
|
||||
const runtimeEnv = projectScriptRuntimeEnv({
|
||||
project: {
|
||||
@@ -1442,12 +1485,12 @@ export default function ChatView(props: ChatViewProps) {
|
||||
activeThread,
|
||||
activeThreadId,
|
||||
activeThreadRef,
|
||||
ensureTerminalSurfaceForThread,
|
||||
gitCwd,
|
||||
setThreadError,
|
||||
storeEnsureTerminal,
|
||||
storeNewTerminal,
|
||||
storeSetTerminalLaunchContext,
|
||||
storeSetActiveTerminal,
|
||||
storeSetTerminalOpen,
|
||||
setLastInvokedScriptByProjectId,
|
||||
environmentId,
|
||||
terminalState.activeTerminalId,
|
||||
@@ -1455,6 +1498,26 @@ export default function ChatView(props: ChatViewProps) {
|
||||
terminalState.terminalIds,
|
||||
],
|
||||
);
|
||||
const terminalDrawerWorktreePath =
|
||||
storeServerTerminalLaunchContext?.worktreePath ?? activeThread?.worktreePath ?? null;
|
||||
const terminalDrawerCwd =
|
||||
storeServerTerminalLaunchContext?.cwd ??
|
||||
(activeProject
|
||||
? projectScriptCwd({
|
||||
project: { cwd: activeProject.cwd },
|
||||
worktreePath: terminalDrawerWorktreePath,
|
||||
})
|
||||
: null);
|
||||
const terminalDrawerRuntimeEnv = useMemo(
|
||||
() =>
|
||||
activeProject
|
||||
? projectScriptRuntimeEnv({
|
||||
project: { cwd: activeProject.cwd },
|
||||
worktreePath: terminalDrawerWorktreePath,
|
||||
})
|
||||
: {},
|
||||
[activeProject, terminalDrawerWorktreePath],
|
||||
);
|
||||
|
||||
const persistProjectScripts = useCallback(
|
||||
async (input: {
|
||||
@@ -1738,14 +1801,21 @@ export default function ChatView(props: ChatViewProps) {
|
||||
}, [activeThread?.id]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!activeThread?.id || terminalSurfaceOpen) return;
|
||||
if (!activeThread?.id || terminalDrawerOpen) return;
|
||||
const frame = window.requestAnimationFrame(() => {
|
||||
focusComposer();
|
||||
});
|
||||
return () => {
|
||||
window.cancelAnimationFrame(frame);
|
||||
};
|
||||
}, [activeThread?.id, focusComposer, terminalSurfaceOpen]);
|
||||
}, [activeThread?.id, focusComposer, terminalDrawerOpen]);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (activationFocusRequestId === undefined) {
|
||||
return;
|
||||
}
|
||||
focusComposer();
|
||||
}, [activationFocusRequestId, focusComposer]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!activeThread?.id) return;
|
||||
@@ -1861,18 +1931,18 @@ export default function ChatView(props: ChatViewProps) {
|
||||
]);
|
||||
|
||||
useEffect(() => {
|
||||
if (terminalSurfaceOpen) {
|
||||
if (terminalDrawerOpen) {
|
||||
return;
|
||||
}
|
||||
if (activeThreadRef) {
|
||||
storeClearTerminalLaunchContext(activeThreadRef);
|
||||
}
|
||||
}, [activeThreadRef, storeClearTerminalLaunchContext, terminalSurfaceOpen]);
|
||||
}, [activeThreadRef, storeClearTerminalLaunchContext, terminalDrawerOpen]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!activeThreadKey) return;
|
||||
const previous = terminalOpenByThreadRef.current[activeThreadKey] ?? false;
|
||||
const current = terminalSurfaceOpen;
|
||||
const current = terminalDrawerOpen;
|
||||
|
||||
if (!previous && current) {
|
||||
terminalOpenByThreadRef.current[activeThreadKey] = current;
|
||||
@@ -1888,7 +1958,7 @@ export default function ChatView(props: ChatViewProps) {
|
||||
}
|
||||
|
||||
terminalOpenByThreadRef.current[activeThreadKey] = current;
|
||||
}, [activeThreadKey, focusComposer, terminalSurfaceOpen]);
|
||||
}, [activeThreadKey, focusComposer, terminalDrawerOpen]);
|
||||
|
||||
useEffect(() => {
|
||||
const handler = (event: globalThis.KeyboardEvent) => {
|
||||
@@ -1897,7 +1967,7 @@ export default function ChatView(props: ChatViewProps) {
|
||||
}
|
||||
const shortcutContext = {
|
||||
terminalFocus: isTerminalFocused(),
|
||||
terminalOpen: terminalSurfaceOpen,
|
||||
terminalOpen: terminalDrawerOpen,
|
||||
};
|
||||
|
||||
const command = resolveShortcutCommand(event, keybindings, {
|
||||
@@ -1922,8 +1992,8 @@ export default function ChatView(props: ChatViewProps) {
|
||||
if (command === "terminal.split") {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
if (!terminalSurfaceOpen && activeThreadRef) {
|
||||
ensureTerminalSurfaceForThread(activeThreadRef);
|
||||
if (!terminalDrawerOpen && activeThreadRef) {
|
||||
storeSetTerminalOpen(activeThreadRef, true);
|
||||
}
|
||||
splitTerminal();
|
||||
return;
|
||||
@@ -1932,7 +2002,7 @@ export default function ChatView(props: ChatViewProps) {
|
||||
if (command === "terminal.close") {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
if (!terminalSurfaceOpen) return;
|
||||
if (!terminalDrawerOpen) return;
|
||||
closeTerminal(terminalState.activeTerminalId);
|
||||
return;
|
||||
}
|
||||
@@ -1940,8 +2010,8 @@ export default function ChatView(props: ChatViewProps) {
|
||||
if (command === "terminal.new") {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
if (!terminalSurfaceOpen && activeThreadRef) {
|
||||
ensureTerminalSurfaceForThread(activeThreadRef);
|
||||
if (!terminalDrawerOpen && activeThreadRef) {
|
||||
storeSetTerminalOpen(activeThreadRef, true);
|
||||
}
|
||||
createNewTerminal();
|
||||
return;
|
||||
@@ -1972,12 +2042,12 @@ export default function ChatView(props: ChatViewProps) {
|
||||
closeTerminal,
|
||||
createNewTerminal,
|
||||
executeWorkspaceCommand,
|
||||
ensureTerminalSurfaceForThread,
|
||||
runProjectScript,
|
||||
splitTerminal,
|
||||
keybindings,
|
||||
onToggleDiff,
|
||||
terminalSurfaceOpen,
|
||||
storeSetTerminalOpen,
|
||||
terminalDrawerOpen,
|
||||
toggleTerminalVisibility,
|
||||
]);
|
||||
|
||||
@@ -2909,7 +2979,7 @@ export default function ChatView(props: ChatViewProps) {
|
||||
keybindings={keybindings}
|
||||
availableEditors={availableEditors}
|
||||
terminalAvailable={activeProject !== undefined}
|
||||
terminalOpen={terminalSurfaceOpen}
|
||||
terminalOpen={terminalDrawerOpen}
|
||||
terminalToggleShortcutLabel={terminalToggleShortcutLabel}
|
||||
diffToggleShortcutLabel={diffPanelShortcutLabel}
|
||||
gitCwd={gitCwd}
|
||||
@@ -2980,6 +3050,7 @@ export default function ChatView(props: ChatViewProps) {
|
||||
<div className={cn("px-3 pt-1.5 sm:px-5 sm:pt-2", isGitRepo ? "pb-1" : "pb-3 sm:pb-4")}>
|
||||
<ChatComposer
|
||||
ref={composerRef}
|
||||
{...(activationFocusRequestId === undefined ? {} : { activationFocusRequestId })}
|
||||
composerDraftTarget={composerDraftTarget}
|
||||
environmentId={environmentId}
|
||||
routeKind={routeKind}
|
||||
@@ -3045,6 +3116,36 @@ export default function ChatView(props: ChatViewProps) {
|
||||
/>
|
||||
</div>
|
||||
|
||||
{terminalDrawerOpen && activeThreadId && activeProject && terminalDrawerCwd ? (
|
||||
<div className="min-h-0 px-3 pb-3 sm:px-5">
|
||||
<ThreadTerminalDrawer
|
||||
threadRef={routeThreadRef}
|
||||
threadId={activeThreadId}
|
||||
cwd={terminalDrawerCwd}
|
||||
worktreePath={terminalDrawerWorktreePath}
|
||||
runtimeEnv={terminalDrawerRuntimeEnv}
|
||||
visible={terminalDrawerOpen}
|
||||
height={terminalState.terminalHeight}
|
||||
terminalIds={terminalState.terminalIds}
|
||||
activeTerminalId={terminalState.activeTerminalId}
|
||||
terminalGroups={terminalState.terminalGroups}
|
||||
activeTerminalGroupId={terminalState.activeTerminalGroupId}
|
||||
focusRequestId={terminalFocusRequestId}
|
||||
onSplitTerminal={splitTerminal}
|
||||
onNewTerminal={createNewTerminal}
|
||||
onActiveTerminalChange={(terminalId) => {
|
||||
storeSetActiveTerminal(routeThreadRef, terminalId);
|
||||
setTerminalFocusRequestId((current) => current + 1);
|
||||
}}
|
||||
onCloseTerminal={closeTerminal}
|
||||
onHeightChange={(height) => {
|
||||
storeSetTerminalHeight(routeThreadRef, height);
|
||||
}}
|
||||
onAddTerminalContext={handleAddTerminalContext}
|
||||
/>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{isGitRepo && (
|
||||
<BranchToolbar
|
||||
environmentId={activeThread.environmentId}
|
||||
|
||||
@@ -45,8 +45,9 @@ import {
|
||||
selectSidebarThreadsAcrossEnvironments,
|
||||
useStore,
|
||||
} from "../store";
|
||||
import { useThreadTerminalOpen } from "../terminalStateStore";
|
||||
import { buildThreadRouteParams, resolveThreadRouteTarget } from "../threadRoutes";
|
||||
import { useWorkspaceStore, useWorkspaceThreadTerminalOpen } from "../workspace/store";
|
||||
import { useWorkspaceStore } from "../workspace/store";
|
||||
import { serverThreadSurfaceInput } from "../workspace/types";
|
||||
import {
|
||||
ADDON_ICON_CLASS,
|
||||
@@ -90,7 +91,7 @@ export function CommandPalette({ children }: { children: ReactNode }) {
|
||||
select: (params) => resolveThreadRouteTarget(params),
|
||||
});
|
||||
const routeThreadRef = routeTarget?.kind === "server" ? routeTarget.threadRef : null;
|
||||
const terminalOpen = useWorkspaceThreadTerminalOpen(routeThreadRef);
|
||||
const terminalOpen = useThreadTerminalOpen(routeThreadRef);
|
||||
|
||||
useEffect(() => {
|
||||
const onKeyDown = (event: globalThis.KeyboardEvent) => {
|
||||
@@ -406,17 +407,6 @@ function OpenCommandPaletteDialog() {
|
||||
await executeWorkspaceCommand("workspace.terminal.splitDown");
|
||||
},
|
||||
});
|
||||
actionItems.push({
|
||||
kind: "action",
|
||||
value: "action:workspace-terminal-tab",
|
||||
searchTerms: WORKSPACE_COMMAND_METADATA["workspace.terminal.newTab"].searchTerms,
|
||||
title: WORKSPACE_COMMAND_METADATA["workspace.terminal.newTab"].title,
|
||||
icon: <TerminalSquareIcon className={ITEM_ICON_CLASS} />,
|
||||
shortcutCommand: "workspace.terminal.newTab",
|
||||
run: async () => {
|
||||
await executeWorkspaceCommand("workspace.terminal.newTab");
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (canSplitFocusedPane) {
|
||||
@@ -453,9 +443,42 @@ function OpenCommandPaletteDialog() {
|
||||
await executeWorkspaceCommand("workspace.pane.close");
|
||||
},
|
||||
});
|
||||
actionItems.push({
|
||||
kind: "action",
|
||||
value: "action:workspace-pane-toggle-zoom",
|
||||
searchTerms: WORKSPACE_COMMAND_METADATA["workspace.pane.toggleZoom"].searchTerms,
|
||||
title: WORKSPACE_COMMAND_METADATA["workspace.pane.toggleZoom"].title,
|
||||
icon: <Columns2Icon className={ITEM_ICON_CLASS} />,
|
||||
shortcutCommand: "workspace.pane.toggleZoom",
|
||||
run: async () => {
|
||||
await executeWorkspaceCommand("workspace.pane.toggleZoom");
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (canUseSpatialWorkspaceCommands) {
|
||||
actionItems.push({
|
||||
kind: "action",
|
||||
value: "action:workspace-focus-previous",
|
||||
searchTerms: WORKSPACE_COMMAND_METADATA["workspace.focus.previous"].searchTerms,
|
||||
title: WORKSPACE_COMMAND_METADATA["workspace.focus.previous"].title,
|
||||
icon: <ArrowLeftIcon className={ITEM_ICON_CLASS} />,
|
||||
shortcutCommand: "workspace.focus.previous",
|
||||
run: async () => {
|
||||
await executeWorkspaceCommand("workspace.focus.previous");
|
||||
},
|
||||
});
|
||||
actionItems.push({
|
||||
kind: "action",
|
||||
value: "action:workspace-focus-next",
|
||||
searchTerms: WORKSPACE_COMMAND_METADATA["workspace.focus.next"].searchTerms,
|
||||
title: WORKSPACE_COMMAND_METADATA["workspace.focus.next"].title,
|
||||
icon: <ArrowRightIcon className={ITEM_ICON_CLASS} />,
|
||||
shortcutCommand: "workspace.focus.next",
|
||||
run: async () => {
|
||||
await executeWorkspaceCommand("workspace.focus.next");
|
||||
},
|
||||
});
|
||||
actionItems.push({
|
||||
kind: "action",
|
||||
value: "action:workspace-focus-left",
|
||||
@@ -500,6 +523,61 @@ function OpenCommandPaletteDialog() {
|
||||
await executeWorkspaceCommand("workspace.focus.down");
|
||||
},
|
||||
});
|
||||
actionItems.push({
|
||||
kind: "action",
|
||||
value: "action:workspace-pane-resize-left",
|
||||
searchTerms: WORKSPACE_COMMAND_METADATA["workspace.pane.resizeLeft"].searchTerms,
|
||||
title: WORKSPACE_COMMAND_METADATA["workspace.pane.resizeLeft"].title,
|
||||
icon: <ArrowLeftIcon className={ITEM_ICON_CLASS} />,
|
||||
shortcutCommand: "workspace.pane.resizeLeft",
|
||||
run: async () => {
|
||||
await executeWorkspaceCommand("workspace.pane.resizeLeft");
|
||||
},
|
||||
});
|
||||
actionItems.push({
|
||||
kind: "action",
|
||||
value: "action:workspace-pane-resize-right",
|
||||
searchTerms: WORKSPACE_COMMAND_METADATA["workspace.pane.resizeRight"].searchTerms,
|
||||
title: WORKSPACE_COMMAND_METADATA["workspace.pane.resizeRight"].title,
|
||||
icon: <ArrowRightIcon className={ITEM_ICON_CLASS} />,
|
||||
shortcutCommand: "workspace.pane.resizeRight",
|
||||
run: async () => {
|
||||
await executeWorkspaceCommand("workspace.pane.resizeRight");
|
||||
},
|
||||
});
|
||||
actionItems.push({
|
||||
kind: "action",
|
||||
value: "action:workspace-pane-resize-up",
|
||||
searchTerms: WORKSPACE_COMMAND_METADATA["workspace.pane.resizeUp"].searchTerms,
|
||||
title: WORKSPACE_COMMAND_METADATA["workspace.pane.resizeUp"].title,
|
||||
icon: <ArrowUpIcon className={ITEM_ICON_CLASS} />,
|
||||
shortcutCommand: "workspace.pane.resizeUp",
|
||||
run: async () => {
|
||||
await executeWorkspaceCommand("workspace.pane.resizeUp");
|
||||
},
|
||||
});
|
||||
actionItems.push({
|
||||
kind: "action",
|
||||
value: "action:workspace-pane-resize-down",
|
||||
searchTerms: WORKSPACE_COMMAND_METADATA["workspace.pane.resizeDown"].searchTerms,
|
||||
title: WORKSPACE_COMMAND_METADATA["workspace.pane.resizeDown"].title,
|
||||
icon: <ArrowDownIcon className={ITEM_ICON_CLASS} />,
|
||||
shortcutCommand: "workspace.pane.resizeDown",
|
||||
run: async () => {
|
||||
await executeWorkspaceCommand("workspace.pane.resizeDown");
|
||||
},
|
||||
});
|
||||
actionItems.push({
|
||||
kind: "action",
|
||||
value: "action:workspace-pane-equalize",
|
||||
searchTerms: WORKSPACE_COMMAND_METADATA["workspace.pane.equalize"].searchTerms,
|
||||
title: WORKSPACE_COMMAND_METADATA["workspace.pane.equalize"].title,
|
||||
icon: <Rows2Icon className={ITEM_ICON_CLASS} />,
|
||||
shortcutCommand: "workspace.pane.equalize",
|
||||
run: async () => {
|
||||
await executeWorkspaceCommand("workspace.pane.equalize");
|
||||
},
|
||||
});
|
||||
actionItems.push({
|
||||
kind: "action",
|
||||
value: "action:workspace-pane-move-left",
|
||||
@@ -544,50 +622,6 @@ function OpenCommandPaletteDialog() {
|
||||
await executeWorkspaceCommand("workspace.pane.moveDown");
|
||||
},
|
||||
});
|
||||
actionItems.push({
|
||||
kind: "action",
|
||||
value: "action:workspace-tab-move-left",
|
||||
searchTerms: WORKSPACE_COMMAND_METADATA["workspace.tab.moveLeft"].searchTerms,
|
||||
title: WORKSPACE_COMMAND_METADATA["workspace.tab.moveLeft"].title,
|
||||
icon: <ArrowLeftIcon className={ITEM_ICON_CLASS} />,
|
||||
shortcutCommand: "workspace.tab.moveLeft",
|
||||
run: async () => {
|
||||
await executeWorkspaceCommand("workspace.tab.moveLeft");
|
||||
},
|
||||
});
|
||||
actionItems.push({
|
||||
kind: "action",
|
||||
value: "action:workspace-tab-move-right",
|
||||
searchTerms: WORKSPACE_COMMAND_METADATA["workspace.tab.moveRight"].searchTerms,
|
||||
title: WORKSPACE_COMMAND_METADATA["workspace.tab.moveRight"].title,
|
||||
icon: <ArrowRightIcon className={ITEM_ICON_CLASS} />,
|
||||
shortcutCommand: "workspace.tab.moveRight",
|
||||
run: async () => {
|
||||
await executeWorkspaceCommand("workspace.tab.moveRight");
|
||||
},
|
||||
});
|
||||
actionItems.push({
|
||||
kind: "action",
|
||||
value: "action:workspace-tab-move-up",
|
||||
searchTerms: WORKSPACE_COMMAND_METADATA["workspace.tab.moveUp"].searchTerms,
|
||||
title: WORKSPACE_COMMAND_METADATA["workspace.tab.moveUp"].title,
|
||||
icon: <ArrowUpIcon className={ITEM_ICON_CLASS} />,
|
||||
shortcutCommand: "workspace.tab.moveUp",
|
||||
run: async () => {
|
||||
await executeWorkspaceCommand("workspace.tab.moveUp");
|
||||
},
|
||||
});
|
||||
actionItems.push({
|
||||
kind: "action",
|
||||
value: "action:workspace-tab-move-down",
|
||||
searchTerms: WORKSPACE_COMMAND_METADATA["workspace.tab.moveDown"].searchTerms,
|
||||
title: WORKSPACE_COMMAND_METADATA["workspace.tab.moveDown"].title,
|
||||
icon: <ArrowDownIcon className={ITEM_ICON_CLASS} />,
|
||||
shortcutCommand: "workspace.tab.moveDown",
|
||||
run: async () => {
|
||||
await executeWorkspaceCommand("workspace.tab.moveDown");
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
actionItems.push({
|
||||
|
||||
@@ -890,6 +890,7 @@ export interface ComposerPromptEditorHandle {
|
||||
focus: () => void;
|
||||
focusAt: (cursor: number) => void;
|
||||
focusAtEnd: () => void;
|
||||
isFocused: () => boolean;
|
||||
readSnapshot: () => {
|
||||
value: string;
|
||||
cursor: number;
|
||||
@@ -1383,7 +1384,6 @@ function ComposerSurroundSelectionPlugin(props: {
|
||||
const onCompositionEnd = () => {
|
||||
tryApplyDeadKeyBacktickSurround({ finalAttempt: true });
|
||||
};
|
||||
|
||||
let activeRootElement: HTMLElement | null = null;
|
||||
const unregisterRootListener = editor.registerRootListener((rootElement, prevRootElement) => {
|
||||
prevRootElement?.removeEventListener("keydown", onKeyDown);
|
||||
@@ -1493,7 +1493,7 @@ function ComposerPromptEditorInner({
|
||||
if (shouldRewriteEditorState) {
|
||||
$setComposerEditorPrompt(value, terminalContexts, skillMetadataRef.current);
|
||||
}
|
||||
if (shouldRewriteEditorState || isFocused) {
|
||||
if (isFocused) {
|
||||
$setSelectionAtComposerOffset(normalizedCursor);
|
||||
}
|
||||
});
|
||||
@@ -1508,22 +1508,19 @@ function ComposerPromptEditorInner({
|
||||
if (!rootElement) return;
|
||||
const boundedCursor = clampCollapsedComposerCursor(snapshotRef.current.value, nextCursor);
|
||||
rootElement.focus();
|
||||
isApplyingControlledUpdateRef.current = true;
|
||||
editor.update(() => {
|
||||
$setSelectionAtComposerOffset(boundedCursor);
|
||||
});
|
||||
queueMicrotask(() => {
|
||||
isApplyingControlledUpdateRef.current = false;
|
||||
});
|
||||
snapshotRef.current = {
|
||||
value: snapshotRef.current.value,
|
||||
cursor: boundedCursor,
|
||||
expandedCursor: expandCollapsedComposerCursor(snapshotRef.current.value, boundedCursor),
|
||||
terminalContextIds: snapshotRef.current.terminalContextIds,
|
||||
};
|
||||
onChangeRef.current(
|
||||
snapshotRef.current.value,
|
||||
boundedCursor,
|
||||
snapshotRef.current.expandedCursor,
|
||||
false,
|
||||
snapshotRef.current.terminalContextIds,
|
||||
);
|
||||
},
|
||||
[editor],
|
||||
);
|
||||
@@ -1577,9 +1574,13 @@ function ComposerPromptEditorInner({
|
||||
),
|
||||
);
|
||||
},
|
||||
isFocused: () => {
|
||||
const rootElement = editor.getRootElement();
|
||||
return Boolean(rootElement && document.activeElement === rootElement);
|
||||
},
|
||||
readSnapshot,
|
||||
}),
|
||||
[focusAt, readSnapshot],
|
||||
[editor, focusAt, readSnapshot],
|
||||
);
|
||||
|
||||
const handleEditorChange = useCallback((editorState: EditorState) => {
|
||||
|
||||
@@ -68,7 +68,11 @@ import {
|
||||
selectThreadByRef,
|
||||
useStore,
|
||||
} from "../store";
|
||||
import { selectThreadTerminalState, useTerminalStateStore } from "../terminalStateStore";
|
||||
import {
|
||||
selectThreadTerminalState,
|
||||
useTerminalStateStore,
|
||||
useThreadTerminalOpen,
|
||||
} from "../terminalStateStore";
|
||||
import { useUiStateStore } from "../uiStateStore";
|
||||
import {
|
||||
resolveShortcutCommand,
|
||||
@@ -150,8 +154,9 @@ import {
|
||||
useSavedEnvironmentRegistryStore,
|
||||
useSavedEnvironmentRuntimeStore,
|
||||
} from "../environments/runtime";
|
||||
import { serverThreadSurfaceInput } from "../workspace/types";
|
||||
import { useWorkspaceStore, useWorkspaceThreadTerminalOpen } from "../workspace/store";
|
||||
import { serverThreadSurfaceInput, type WorkspaceLayoutEngine } from "../workspace/types";
|
||||
import { useWorkspaceDragStore } from "../workspace/dragStore";
|
||||
import { useWorkspaceLayoutEngine, useWorkspaceStore } from "../workspace/store";
|
||||
import type { Project, SidebarThreadSummary } from "../types";
|
||||
const THREAD_PREVIEW_LIMIT = 6;
|
||||
const SIDEBAR_SORT_LABELS: Record<SidebarProjectSortOrder, string> = {
|
||||
@@ -572,6 +577,24 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP
|
||||
},
|
||||
[],
|
||||
);
|
||||
const handleDragStart = useCallback(
|
||||
(event: React.DragEvent<HTMLElement>) => {
|
||||
if (renamingThreadKey === threadKey) {
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
event.dataTransfer.effectAllowed = "move";
|
||||
event.dataTransfer.setData("text/plain", thread.id);
|
||||
useWorkspaceDragStore.getState().setItem({
|
||||
kind: "thread",
|
||||
input: serverThreadSurfaceInput(threadRef),
|
||||
});
|
||||
},
|
||||
[renamingThreadKey, thread.id, threadKey, threadRef],
|
||||
);
|
||||
const handleDragEnd = useCallback(() => {
|
||||
useWorkspaceDragStore.getState().clearItem();
|
||||
}, []);
|
||||
const handleConfirmArchiveClick = useCallback(
|
||||
(event: React.MouseEvent<HTMLButtonElement>) => {
|
||||
event.preventDefault();
|
||||
@@ -618,7 +641,10 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP
|
||||
isActive,
|
||||
isSelected,
|
||||
})} relative isolate`}
|
||||
draggable={renamingThreadKey !== threadKey}
|
||||
onClick={handleRowClick}
|
||||
onDragEnd={handleDragEnd}
|
||||
onDragStart={handleDragStart}
|
||||
onKeyDown={handleRowKeyDown}
|
||||
onContextMenu={handleRowContextMenu}
|
||||
>
|
||||
@@ -1010,7 +1036,6 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
|
||||
const removeFromSelection = useThreadSelectionStore((state) => state.removeFromSelection);
|
||||
const setSelectionAnchor = useThreadSelectionStore((state) => state.setAnchor);
|
||||
const selectedThreadCount = useThreadSelectionStore((state) => state.selectedThreadKeys.size);
|
||||
const openThreadInNewTab = useWorkspaceStore((state) => state.openThreadInNewTab);
|
||||
const openThreadInSplit = useWorkspaceStore((state) => state.openThreadInSplit);
|
||||
const clearComposerDraftForThread = useComposerDraftStore((state) => state.clearDraftThread);
|
||||
const getDraftThreadByProjectRef = useComposerDraftStore(
|
||||
@@ -1640,7 +1665,6 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
|
||||
const threadWorkspacePath = thread.worktreePath ?? project.cwd ?? null;
|
||||
const clicked = await api.contextMenu.show(
|
||||
[
|
||||
{ id: "open-new-tab", label: "Open in new tab" },
|
||||
{ id: "open-split-right", label: "Open in split right" },
|
||||
{ id: "open-split-down", label: "Open in split down" },
|
||||
{ id: "rename", label: "Rename thread" },
|
||||
@@ -1652,15 +1676,6 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
|
||||
position,
|
||||
);
|
||||
|
||||
if (clicked === "open-new-tab") {
|
||||
openThreadInNewTab(serverThreadSurfaceInput(threadRef));
|
||||
void router.navigate({
|
||||
to: "/$environmentId/$threadId",
|
||||
params: buildThreadRouteParams(threadRef),
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (clicked === "open-split-right") {
|
||||
openThreadInSplit(serverThreadSurfaceInput(threadRef), "x");
|
||||
void router.navigate({
|
||||
@@ -1726,7 +1741,6 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
|
||||
copyThreadIdToClipboard,
|
||||
deleteThread,
|
||||
markThreadUnread,
|
||||
openThreadInNewTab,
|
||||
openThreadInSplit,
|
||||
project.cwd,
|
||||
router,
|
||||
@@ -2038,6 +2052,8 @@ const SidebarChromeHeader = memo(function SidebarChromeHeader({
|
||||
|
||||
const SidebarChromeFooter = memo(function SidebarChromeFooter() {
|
||||
const navigate = useNavigate();
|
||||
const layoutEngine = useWorkspaceLayoutEngine();
|
||||
const setLayoutEngine = useWorkspaceStore((state) => state.setLayoutEngine);
|
||||
const handleSettingsClick = useCallback(() => {
|
||||
void navigate({ to: "/settings" });
|
||||
}, [navigate]);
|
||||
@@ -2057,10 +2073,41 @@ const SidebarChromeFooter = memo(function SidebarChromeFooter() {
|
||||
</SidebarMenuButton>
|
||||
</SidebarMenuItem>
|
||||
</SidebarMenu>
|
||||
<div className="mt-2 flex items-center gap-1 px-2">
|
||||
<span className="text-[11px] text-muted-foreground/70">Layout</span>
|
||||
<WorkspaceLayoutToggle
|
||||
layoutEngine={layoutEngine}
|
||||
onSelect={(engine) => setLayoutEngine(engine)}
|
||||
/>
|
||||
</div>
|
||||
</SidebarFooter>
|
||||
);
|
||||
});
|
||||
|
||||
const WorkspaceLayoutToggle = memo(function WorkspaceLayoutToggle(props: {
|
||||
layoutEngine: WorkspaceLayoutEngine;
|
||||
onSelect: (engine: WorkspaceLayoutEngine) => void;
|
||||
}) {
|
||||
return (
|
||||
<div className="ml-auto flex items-center gap-1">
|
||||
{(["split", "paper"] as const).map((engine) => (
|
||||
<button
|
||||
key={engine}
|
||||
type="button"
|
||||
className={
|
||||
props.layoutEngine === engine
|
||||
? "rounded-md border border-border bg-accent px-2 py-1 text-[11px] text-foreground"
|
||||
: "rounded-md border border-border/60 px-2 py-1 text-[11px] text-muted-foreground transition hover:bg-accent hover:text-foreground"
|
||||
}
|
||||
onClick={() => props.onSelect(engine)}
|
||||
>
|
||||
{engine === "split" ? "Split" : "Paper"}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
||||
interface SidebarProjectsContentProps {
|
||||
showArm64IntelBuildWarning: boolean;
|
||||
arm64IntelBuildWarningDescription: string | null;
|
||||
@@ -2427,7 +2474,7 @@ export default function Sidebar() {
|
||||
select: (params) => resolveThreadRouteRef(params),
|
||||
});
|
||||
const routeThreadKey = routeThreadRef ? scopedThreadKey(routeThreadRef) : null;
|
||||
const routeThreadTerminalOpen = useWorkspaceThreadTerminalOpen(routeThreadRef);
|
||||
const routeThreadTerminalOpen = useThreadTerminalOpen(routeThreadRef);
|
||||
const keybindings = useServerKeybindings();
|
||||
const setCommandPaletteOpen = useCommandPaletteStore((state) => state.setOpen);
|
||||
const [addingProject, setAddingProject] = useState(false);
|
||||
|
||||
@@ -339,6 +339,7 @@ export interface ChatComposerHandle {
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
export interface ChatComposerProps {
|
||||
activationFocusRequestId?: number;
|
||||
composerDraftTarget: ScopedThreadRef | DraftId;
|
||||
environmentId: EnvironmentId;
|
||||
routeKind: "server" | "draft";
|
||||
@@ -447,6 +448,7 @@ export interface ChatComposerProps {
|
||||
export const ChatComposer = memo(
|
||||
forwardRef<ChatComposerHandle, ChatComposerProps>(function ChatComposer(props, ref) {
|
||||
const {
|
||||
activationFocusRequestId,
|
||||
composerDraftTarget,
|
||||
environmentId,
|
||||
routeKind,
|
||||
@@ -653,6 +655,7 @@ export const ChatComposer = memo(
|
||||
// Refs
|
||||
// ------------------------------------------------------------------
|
||||
const composerEditorRef = useRef<ComposerPromptEditorHandle>(null);
|
||||
const pendingActivationFocusRepairRef = useRef(false);
|
||||
const composerFormRef = useRef<HTMLFormElement>(null);
|
||||
const composerFormHeightRef = useRef(0);
|
||||
const composerSelectLockRef = useRef(false);
|
||||
@@ -661,6 +664,13 @@ export const ChatComposer = memo(
|
||||
const activeComposerMenuItemRef = useRef<ComposerCommandItem | null>(null);
|
||||
const dragDepthRef = useRef(0);
|
||||
|
||||
useEffect(() => {
|
||||
if (activationFocusRequestId === undefined) {
|
||||
return;
|
||||
}
|
||||
pendingActivationFocusRepairRef.current = true;
|
||||
}, [activationFocusRequestId]);
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Derived: composer send state
|
||||
// ------------------------------------------------------------------
|
||||
@@ -1227,8 +1237,11 @@ export const ChatComposer = memo(
|
||||
);
|
||||
return;
|
||||
}
|
||||
const previousPrompt = promptRef.current;
|
||||
promptRef.current = nextPrompt;
|
||||
setPrompt(nextPrompt);
|
||||
if (previousPrompt !== nextPrompt) {
|
||||
setPrompt(nextPrompt);
|
||||
}
|
||||
if (!terminalContextIdListsEqual(composerTerminalContexts, terminalContextIds)) {
|
||||
setComposerDraftTerminalContexts(
|
||||
composerDraftTarget,
|
||||
@@ -1239,6 +1252,20 @@ export const ChatComposer = memo(
|
||||
setComposerTrigger(
|
||||
cursorAdjacentToMention ? null : detectComposerTrigger(nextPrompt, expandedCursor),
|
||||
);
|
||||
if (pendingActivationFocusRepairRef.current) {
|
||||
const repairCursor = nextCursor;
|
||||
window.requestAnimationFrame(() => {
|
||||
const composerEditor = composerEditorRef.current;
|
||||
if (!composerEditor) {
|
||||
pendingActivationFocusRepairRef.current = false;
|
||||
return;
|
||||
}
|
||||
if (!composerEditor.isFocused()) {
|
||||
composerEditor.focusAt(repairCursor);
|
||||
}
|
||||
pendingActivationFocusRepairRef.current = false;
|
||||
});
|
||||
}
|
||||
},
|
||||
[
|
||||
activePendingProgress?.activeQuestion,
|
||||
|
||||
@@ -1,68 +1,53 @@
|
||||
import { scopedThreadKey, scopeProjectRef } from "@t3tools/client-runtime";
|
||||
import type { ScopedThreadRef } from "@t3tools/contracts";
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { useEffect, useMemo, useRef, useState } from "react";
|
||||
|
||||
import { useComposerDraftStore } from "../../composerDraftStore";
|
||||
import { randomUUID } from "../../lib/utils";
|
||||
import { createProjectSelectorByRef, createThreadSelectorByRef } from "../../storeSelectors";
|
||||
import { selectThreadTerminalState, useTerminalStateStore } from "../../terminalStateStore";
|
||||
import ThreadTerminalDrawer from "../ThreadTerminalDrawer";
|
||||
import { projectScriptCwd, projectScriptRuntimeEnv } from "@t3tools/shared/projectScripts";
|
||||
import { readEnvironmentApi } from "../../environmentApi";
|
||||
import { useStore } from "../../store";
|
||||
import type { TerminalContextSelection } from "../../lib/terminalContext";
|
||||
import { useTerminalStateStore } from "../../terminalStateStore";
|
||||
import { projectScriptCwd, projectScriptRuntimeEnv } from "@t3tools/shared/projectScripts";
|
||||
import { TerminalViewport } from "../ThreadTerminalDrawer";
|
||||
import { useWorkspaceStore } from "../../workspace/store";
|
||||
|
||||
export function ThreadTerminalSurface(props: { threadRef: ScopedThreadRef }) {
|
||||
const { threadRef } = props;
|
||||
export function ThreadTerminalSurface(props: {
|
||||
surfaceId: string;
|
||||
terminalId: string;
|
||||
threadRef: ScopedThreadRef;
|
||||
activationFocusRequestId?: number;
|
||||
}) {
|
||||
const { activationFocusRequestId, surfaceId, terminalId, threadRef } = props;
|
||||
const thread = useStore(useMemo(() => createThreadSelectorByRef(threadRef), [threadRef]));
|
||||
const draftThread = useComposerDraftStore((store) => store.getDraftThreadByRef(threadRef));
|
||||
const projectRef = thread
|
||||
? scopeProjectRef(thread.environmentId, thread.projectId)
|
||||
: draftThread
|
||||
? scopeProjectRef(draftThread.environmentId, draftThread.projectId)
|
||||
: null;
|
||||
const projectRef = thread ? scopeProjectRef(thread.environmentId, thread.projectId) : null;
|
||||
const project = useStore(useMemo(() => createProjectSelectorByRef(projectRef), [projectRef]));
|
||||
const terminalState = useTerminalStateStore((state) =>
|
||||
selectThreadTerminalState(state.terminalStateByThreadKey, threadRef),
|
||||
);
|
||||
const storeSetActiveTerminal = useTerminalStateStore((state) => state.setActiveTerminal);
|
||||
const storeNewTerminal = useTerminalStateStore((state) => state.newTerminal);
|
||||
const storeSplitTerminal = useTerminalStateStore((state) => state.splitTerminal);
|
||||
const storeCloseTerminal = useTerminalStateStore((state) => state.closeTerminal);
|
||||
const storeSetTerminalHeight = useTerminalStateStore((state) => state.setTerminalHeight);
|
||||
const closeTerminal = useTerminalStateStore((state) => state.closeTerminal);
|
||||
const terminalLaunchContext = useTerminalStateStore(
|
||||
(state) => state.terminalLaunchContextByThreadKey[scopedThreadKey(threadRef)] ?? null,
|
||||
);
|
||||
const addTerminalContext = useComposerDraftStore((state) => state.addTerminalContext);
|
||||
const closeTerminalSurfacesForThread = useWorkspaceStore(
|
||||
(state) => state.closeTerminalSurfacesForThread,
|
||||
);
|
||||
const [containerHeight, setContainerHeight] = useState(320);
|
||||
const [focusRequestId, setFocusRequestId] = useState(1);
|
||||
const closeSurface = useWorkspaceStore((state) => state.closeSurface);
|
||||
const containerRef = useRef<HTMLDivElement | null>(null);
|
||||
const worktreePath = thread?.worktreePath ?? draftThread?.worktreePath ?? null;
|
||||
const effectiveWorktreePath = terminalLaunchContext?.worktreePath ?? worktreePath;
|
||||
const worktreePath = terminalLaunchContext?.worktreePath ?? thread?.worktreePath ?? null;
|
||||
const cwd = useMemo(
|
||||
() =>
|
||||
terminalLaunchContext?.cwd ??
|
||||
(project
|
||||
? projectScriptCwd({
|
||||
project: { cwd: project.cwd },
|
||||
worktreePath: effectiveWorktreePath,
|
||||
worktreePath,
|
||||
})
|
||||
: null),
|
||||
[effectiveWorktreePath, project, terminalLaunchContext?.cwd],
|
||||
[project, terminalLaunchContext?.cwd, worktreePath],
|
||||
);
|
||||
const runtimeEnv = useMemo(
|
||||
() =>
|
||||
project
|
||||
? projectScriptRuntimeEnv({
|
||||
project: { cwd: project.cwd },
|
||||
worktreePath: effectiveWorktreePath,
|
||||
worktreePath,
|
||||
})
|
||||
: {},
|
||||
[effectiveWorktreePath, project],
|
||||
[project, worktreePath],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -80,102 +65,35 @@ export function ThreadTerminalSurface(props: { threadRef: ScopedThreadRef }) {
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (activationFocusRequestId === undefined) {
|
||||
return;
|
||||
}
|
||||
setFocusRequestId((current) => current + 1);
|
||||
}, [terminalState.activeTerminalId]);
|
||||
}, [activationFocusRequestId]);
|
||||
|
||||
const closeTerminal = useCallback(
|
||||
(terminalId: string) => {
|
||||
const api = readEnvironmentApi(threadRef.environmentId);
|
||||
if (!api) {
|
||||
return;
|
||||
}
|
||||
|
||||
const isFinalTerminal = terminalState.terminalIds.length <= 1;
|
||||
const fallbackExitWrite = () =>
|
||||
api.terminal
|
||||
.write({ threadId: threadRef.threadId, terminalId, data: "exit\n" })
|
||||
.catch(() => undefined);
|
||||
|
||||
if ("close" in api.terminal && typeof api.terminal.close === "function") {
|
||||
void (async () => {
|
||||
if (isFinalTerminal) {
|
||||
await api.terminal
|
||||
.clear({ threadId: threadRef.threadId, terminalId })
|
||||
.catch(() => undefined);
|
||||
}
|
||||
await api.terminal.close({
|
||||
threadId: threadRef.threadId,
|
||||
terminalId,
|
||||
deleteHistory: true,
|
||||
});
|
||||
})().catch(() => fallbackExitWrite());
|
||||
} else {
|
||||
void fallbackExitWrite();
|
||||
}
|
||||
|
||||
storeCloseTerminal(threadRef, terminalId);
|
||||
if (isFinalTerminal) {
|
||||
closeTerminalSurfacesForThread(threadRef);
|
||||
}
|
||||
setFocusRequestId((current) => current + 1);
|
||||
},
|
||||
[
|
||||
closeTerminalSurfacesForThread,
|
||||
storeCloseTerminal,
|
||||
terminalState.terminalIds.length,
|
||||
threadRef,
|
||||
],
|
||||
);
|
||||
|
||||
const handleAddTerminalContext = useCallback(
|
||||
(selection: TerminalContextSelection) => {
|
||||
addTerminalContext(threadRef, {
|
||||
...selection,
|
||||
id: randomUUID(),
|
||||
threadId: threadRef.threadId,
|
||||
createdAt: new Date().toISOString(),
|
||||
});
|
||||
},
|
||||
[addTerminalContext, threadRef],
|
||||
);
|
||||
|
||||
if (!project || !cwd) {
|
||||
if (!thread || !project || !cwd) {
|
||||
return <div ref={containerRef} className="min-h-0 flex-1 bg-background" />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div ref={containerRef} className="min-h-0 flex-1 overflow-hidden bg-background">
|
||||
<ThreadTerminalDrawer
|
||||
<TerminalViewport
|
||||
threadRef={threadRef}
|
||||
threadId={threadRef.threadId}
|
||||
threadId={thread.id}
|
||||
terminalId={terminalId}
|
||||
terminalLabel={thread.title}
|
||||
cwd={cwd}
|
||||
worktreePath={effectiveWorktreePath}
|
||||
worktreePath={worktreePath}
|
||||
runtimeEnv={runtimeEnv}
|
||||
visible
|
||||
height={containerHeight}
|
||||
terminalIds={terminalState.terminalIds}
|
||||
activeTerminalId={terminalState.activeTerminalId}
|
||||
terminalGroups={terminalState.terminalGroups}
|
||||
activeTerminalGroupId={terminalState.activeTerminalGroupId}
|
||||
focusRequestId={focusRequestId}
|
||||
onSplitTerminal={() => {
|
||||
storeSplitTerminal(threadRef, `terminal-${randomUUID()}`);
|
||||
setFocusRequestId((current) => current + 1);
|
||||
autoFocus
|
||||
resizeEpoch={0}
|
||||
drawerHeight={containerHeight}
|
||||
onAddTerminalContext={() => undefined}
|
||||
onSessionExited={() => {
|
||||
closeTerminal(threadRef, terminalId);
|
||||
closeSurface(surfaceId);
|
||||
}}
|
||||
onNewTerminal={() => {
|
||||
storeNewTerminal(threadRef, `terminal-${randomUUID()}`);
|
||||
setFocusRequestId((current) => current + 1);
|
||||
}}
|
||||
onActiveTerminalChange={(terminalId) => {
|
||||
storeSetActiveTerminal(threadRef, terminalId);
|
||||
setFocusRequestId((current) => current + 1);
|
||||
}}
|
||||
onCloseTerminal={closeTerminal}
|
||||
onHeightChange={(height) => {
|
||||
storeSetTerminalHeight(threadRef, height);
|
||||
}}
|
||||
onAddTerminalContext={handleAddTerminalContext}
|
||||
showResizeHandle={false}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -74,7 +74,7 @@ export function WorkspaceRouteSync() {
|
||||
}
|
||||
|
||||
if (!focusedRouteTarget || pathnameChanged) {
|
||||
openThreadSurface(currentRouteSurfaceInput, "focus-or-tab");
|
||||
openThreadSurface(currentRouteSurfaceInput, "focus-or-replace");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -2158,6 +2158,9 @@ const composerDraftStore = create<ComposerDraftStoreState>()(
|
||||
}
|
||||
set((state) => {
|
||||
const existing = state.draftsByThreadKey[threadKey] ?? createEmptyThreadDraft();
|
||||
if (existing.prompt === prompt) {
|
||||
return state;
|
||||
}
|
||||
const nextDraft: ComposerThreadDraftState = {
|
||||
...existing,
|
||||
prompt,
|
||||
|
||||
@@ -12,22 +12,25 @@ import type { WorkspaceSurfaceInstance } from "../workspace/types";
|
||||
export const WORKSPACE_COMMAND_IDS = [
|
||||
"workspace.terminal.splitRight",
|
||||
"workspace.terminal.splitDown",
|
||||
"workspace.terminal.newTab",
|
||||
"workspace.pane.splitRight",
|
||||
"workspace.pane.splitDown",
|
||||
"workspace.focus.previous",
|
||||
"workspace.focus.next",
|
||||
"workspace.focus.left",
|
||||
"workspace.focus.right",
|
||||
"workspace.focus.up",
|
||||
"workspace.focus.down",
|
||||
"workspace.pane.close",
|
||||
"workspace.pane.toggleZoom",
|
||||
"workspace.pane.resizeLeft",
|
||||
"workspace.pane.resizeRight",
|
||||
"workspace.pane.resizeUp",
|
||||
"workspace.pane.resizeDown",
|
||||
"workspace.pane.equalize",
|
||||
"workspace.pane.moveLeft",
|
||||
"workspace.pane.moveRight",
|
||||
"workspace.pane.moveUp",
|
||||
"workspace.pane.moveDown",
|
||||
"workspace.tab.moveLeft",
|
||||
"workspace.tab.moveRight",
|
||||
"workspace.tab.moveUp",
|
||||
"workspace.tab.moveDown",
|
||||
] as const satisfies readonly KeybindingCommand[];
|
||||
|
||||
export type WorkspaceCommandId = (typeof WORKSPACE_COMMAND_IDS)[number];
|
||||
@@ -47,10 +50,6 @@ export const WORKSPACE_COMMAND_METADATA: Record<
|
||||
title: "Open terminal in split down",
|
||||
searchTerms: ["terminal", "split", "down", "bottom", "pane", "workspace"],
|
||||
},
|
||||
"workspace.terminal.newTab": {
|
||||
title: "Open terminal as tab",
|
||||
searchTerms: ["terminal", "tab", "pane", "workspace"],
|
||||
},
|
||||
"workspace.pane.splitRight": {
|
||||
title: "Open in split right",
|
||||
searchTerms: ["split", "pane", "right", "open", "workspace"],
|
||||
@@ -63,6 +62,14 @@ export const WORKSPACE_COMMAND_METADATA: Record<
|
||||
title: "Focus pane left",
|
||||
searchTerms: ["focus", "pane", "left", "workspace"],
|
||||
},
|
||||
"workspace.focus.previous": {
|
||||
title: "Focus previous pane",
|
||||
searchTerms: ["focus", "previous", "pane", "workspace"],
|
||||
},
|
||||
"workspace.focus.next": {
|
||||
title: "Focus next pane",
|
||||
searchTerms: ["focus", "next", "pane", "workspace"],
|
||||
},
|
||||
"workspace.focus.right": {
|
||||
title: "Focus pane right",
|
||||
searchTerms: ["focus", "pane", "right", "workspace"],
|
||||
@@ -79,6 +86,30 @@ export const WORKSPACE_COMMAND_METADATA: Record<
|
||||
title: "Close current pane",
|
||||
searchTerms: ["close", "pane", "window", "workspace"],
|
||||
},
|
||||
"workspace.pane.toggleZoom": {
|
||||
title: "Toggle pane zoom",
|
||||
searchTerms: ["zoom", "maximize", "pane", "workspace"],
|
||||
},
|
||||
"workspace.pane.resizeLeft": {
|
||||
title: "Resize pane left",
|
||||
searchTerms: ["resize", "pane", "left", "workspace"],
|
||||
},
|
||||
"workspace.pane.resizeRight": {
|
||||
title: "Resize pane right",
|
||||
searchTerms: ["resize", "pane", "right", "workspace"],
|
||||
},
|
||||
"workspace.pane.resizeUp": {
|
||||
title: "Resize pane up",
|
||||
searchTerms: ["resize", "pane", "up", "workspace"],
|
||||
},
|
||||
"workspace.pane.resizeDown": {
|
||||
title: "Resize pane down",
|
||||
searchTerms: ["resize", "pane", "down", "workspace"],
|
||||
},
|
||||
"workspace.pane.equalize": {
|
||||
title: "Equalize splits",
|
||||
searchTerms: ["equalize", "reset", "split", "pane", "workspace"],
|
||||
},
|
||||
"workspace.pane.moveLeft": {
|
||||
title: "Move pane left",
|
||||
searchTerms: ["move", "pane", "left", "workspace"],
|
||||
@@ -95,22 +126,6 @@ export const WORKSPACE_COMMAND_METADATA: Record<
|
||||
title: "Move pane down",
|
||||
searchTerms: ["move", "pane", "down", "workspace"],
|
||||
},
|
||||
"workspace.tab.moveLeft": {
|
||||
title: "Move tab left",
|
||||
searchTerms: ["move", "tab", "left", "workspace"],
|
||||
},
|
||||
"workspace.tab.moveRight": {
|
||||
title: "Move tab right",
|
||||
searchTerms: ["move", "tab", "right", "workspace"],
|
||||
},
|
||||
"workspace.tab.moveUp": {
|
||||
title: "Move tab up",
|
||||
searchTerms: ["move", "tab", "up", "workspace"],
|
||||
},
|
||||
"workspace.tab.moveDown": {
|
||||
title: "Move tab down",
|
||||
searchTerms: ["move", "tab", "down", "workspace"],
|
||||
},
|
||||
};
|
||||
|
||||
function threadRefForWorkspaceSurface(
|
||||
@@ -142,14 +157,15 @@ export function useWorkspaceCommandExecutor() {
|
||||
const focusedSurface = useFocusedWorkspaceSurface();
|
||||
const openWorkspaceTarget = useCommandPaletteStore((state) => state.openWorkspaceTarget);
|
||||
const closeFocusedWindow = useWorkspaceStore((state) => state.closeFocusedWindow);
|
||||
const equalizeSplits = useWorkspaceStore((state) => state.equalizeSplits);
|
||||
const focusWindowByStep = useWorkspaceStore((state) => state.focusWindowByStep);
|
||||
const focusAdjacentWindow = useWorkspaceStore((state) => state.focusAdjacentWindow);
|
||||
const moveActiveTabToAdjacentWindow = useWorkspaceStore(
|
||||
(state) => state.moveActiveTabToAdjacentWindow,
|
||||
);
|
||||
const moveFocusedWindow = useWorkspaceStore((state) => state.moveFocusedWindow);
|
||||
const openTerminalSurfaceForThread = useWorkspaceStore(
|
||||
(state) => state.openTerminalSurfaceForThread,
|
||||
);
|
||||
const resizeFocusedWindow = useWorkspaceStore((state) => state.resizeFocusedWindow);
|
||||
const toggleFocusedWindowZoom = useWorkspaceStore((state) => state.toggleFocusedWindowZoom);
|
||||
|
||||
const focusedWindowId = useMemo(() => {
|
||||
if (document.focusedWindowId && document.windowsById[document.focusedWindowId]) {
|
||||
@@ -179,12 +195,6 @@ export function useWorkspaceCommandExecutor() {
|
||||
}
|
||||
openTerminalSurfaceForThread(focusedThreadRef, "split-down");
|
||||
return true;
|
||||
case "workspace.terminal.newTab":
|
||||
if (!focusedThreadRef) {
|
||||
return false;
|
||||
}
|
||||
openTerminalSurfaceForThread(focusedThreadRef, "new-tab");
|
||||
return true;
|
||||
case "workspace.pane.splitRight":
|
||||
if (!focusedWindowId) {
|
||||
return false;
|
||||
@@ -200,6 +210,12 @@ export function useWorkspaceCommandExecutor() {
|
||||
case "workspace.focus.left":
|
||||
focusAdjacentWindow("left");
|
||||
return true;
|
||||
case "workspace.focus.previous":
|
||||
focusWindowByStep(-1);
|
||||
return true;
|
||||
case "workspace.focus.next":
|
||||
focusWindowByStep(1);
|
||||
return true;
|
||||
case "workspace.focus.right":
|
||||
focusAdjacentWindow("right");
|
||||
return true;
|
||||
@@ -212,6 +228,24 @@ export function useWorkspaceCommandExecutor() {
|
||||
case "workspace.pane.close":
|
||||
closeFocusedWindow();
|
||||
return true;
|
||||
case "workspace.pane.toggleZoom":
|
||||
toggleFocusedWindowZoom();
|
||||
return true;
|
||||
case "workspace.pane.resizeLeft":
|
||||
resizeFocusedWindow("left");
|
||||
return true;
|
||||
case "workspace.pane.resizeRight":
|
||||
resizeFocusedWindow("right");
|
||||
return true;
|
||||
case "workspace.pane.resizeUp":
|
||||
resizeFocusedWindow("up");
|
||||
return true;
|
||||
case "workspace.pane.resizeDown":
|
||||
resizeFocusedWindow("down");
|
||||
return true;
|
||||
case "workspace.pane.equalize":
|
||||
equalizeSplits();
|
||||
return true;
|
||||
case "workspace.pane.moveLeft":
|
||||
moveFocusedWindow("left");
|
||||
return true;
|
||||
@@ -224,29 +258,20 @@ export function useWorkspaceCommandExecutor() {
|
||||
case "workspace.pane.moveDown":
|
||||
moveFocusedWindow("down");
|
||||
return true;
|
||||
case "workspace.tab.moveLeft":
|
||||
moveActiveTabToAdjacentWindow("left");
|
||||
return true;
|
||||
case "workspace.tab.moveRight":
|
||||
moveActiveTabToAdjacentWindow("right");
|
||||
return true;
|
||||
case "workspace.tab.moveUp":
|
||||
moveActiveTabToAdjacentWindow("up");
|
||||
return true;
|
||||
case "workspace.tab.moveDown":
|
||||
moveActiveTabToAdjacentWindow("down");
|
||||
return true;
|
||||
}
|
||||
},
|
||||
[
|
||||
closeFocusedWindow,
|
||||
equalizeSplits,
|
||||
focusAdjacentWindow,
|
||||
focusWindowByStep,
|
||||
focusedThreadRef,
|
||||
focusedWindowId,
|
||||
moveActiveTabToAdjacentWindow,
|
||||
moveFocusedWindow,
|
||||
openTerminalSurfaceForThread,
|
||||
openWorkspaceTarget,
|
||||
resizeFocusedWindow,
|
||||
toggleFocusedWindowZoom,
|
||||
],
|
||||
);
|
||||
|
||||
|
||||
@@ -98,6 +98,42 @@ const DEFAULT_BINDINGS = compile([
|
||||
},
|
||||
{
|
||||
shortcut: modShortcut("d"),
|
||||
command: "workspace.pane.splitRight",
|
||||
whenAst: whenNot(whenIdentifier("terminalFocus")),
|
||||
},
|
||||
{
|
||||
shortcut: modShortcut("d", { shiftKey: true }),
|
||||
command: "workspace.pane.splitDown",
|
||||
whenAst: whenNot(whenIdentifier("terminalFocus")),
|
||||
},
|
||||
{
|
||||
shortcut: modShortcut("w"),
|
||||
command: "workspace.pane.close",
|
||||
whenAst: whenNot(whenIdentifier("terminalFocus")),
|
||||
},
|
||||
{ shortcut: modShortcut("["), command: "workspace.focus.previous" },
|
||||
{ shortcut: modShortcut("]"), command: "workspace.focus.next" },
|
||||
{ shortcut: modShortcut("arrowup", { altKey: true }), command: "workspace.focus.up" },
|
||||
{ shortcut: modShortcut("arrowdown", { altKey: true }), command: "workspace.focus.down" },
|
||||
{ shortcut: modShortcut("arrowleft", { altKey: true }), command: "workspace.focus.left" },
|
||||
{ shortcut: modShortcut("arrowright", { altKey: true }), command: "workspace.focus.right" },
|
||||
{ shortcut: modShortcut("enter", { shiftKey: true }), command: "workspace.pane.toggleZoom" },
|
||||
{ shortcut: modShortcut("arrowup", { ctrlKey: true }), command: "workspace.pane.resizeUp" },
|
||||
{
|
||||
shortcut: modShortcut("arrowdown", { ctrlKey: true }),
|
||||
command: "workspace.pane.resizeDown",
|
||||
},
|
||||
{
|
||||
shortcut: modShortcut("arrowleft", { ctrlKey: true }),
|
||||
command: "workspace.pane.resizeLeft",
|
||||
},
|
||||
{
|
||||
shortcut: modShortcut("arrowright", { ctrlKey: true }),
|
||||
command: "workspace.pane.resizeRight",
|
||||
},
|
||||
{ shortcut: modShortcut("=", { ctrlKey: true }), command: "workspace.pane.equalize" },
|
||||
{
|
||||
shortcut: modShortcut("d", { altKey: true }),
|
||||
command: "diff.toggle",
|
||||
whenAst: whenNot(whenIdentifier("terminalFocus")),
|
||||
},
|
||||
@@ -253,7 +289,30 @@ describe("shortcutLabelForCommand", () => {
|
||||
|
||||
it("returns effective labels for non-terminal commands", () => {
|
||||
assert.strictEqual(shortcutLabelForCommand(DEFAULT_BINDINGS, "chat.new", "MacIntel"), "⇧⌘O");
|
||||
assert.strictEqual(shortcutLabelForCommand(DEFAULT_BINDINGS, "diff.toggle", "Linux"), "Ctrl+D");
|
||||
assert.strictEqual(
|
||||
shortcutLabelForCommand(DEFAULT_BINDINGS, "workspace.pane.splitRight", "MacIntel"),
|
||||
"⌘D",
|
||||
);
|
||||
assert.strictEqual(
|
||||
shortcutLabelForCommand(DEFAULT_BINDINGS, "workspace.focus.previous", "Linux"),
|
||||
"Ctrl+[",
|
||||
);
|
||||
assert.strictEqual(
|
||||
shortcutLabelForCommand(DEFAULT_BINDINGS, "workspace.pane.resizeLeft", "MacIntel"),
|
||||
"⌃⌘Left",
|
||||
);
|
||||
assert.strictEqual(
|
||||
shortcutLabelForCommand(DEFAULT_BINDINGS, "workspace.pane.equalize", "MacIntel"),
|
||||
"⌃⌘=",
|
||||
);
|
||||
assert.strictEqual(
|
||||
shortcutLabelForCommand(DEFAULT_BINDINGS, "workspace.pane.close", "MacIntel"),
|
||||
"⌘W",
|
||||
);
|
||||
assert.strictEqual(
|
||||
shortcutLabelForCommand(DEFAULT_BINDINGS, "diff.toggle", "Linux"),
|
||||
"Ctrl+Alt+D",
|
||||
);
|
||||
assert.strictEqual(
|
||||
shortcutLabelForCommand(DEFAULT_BINDINGS, "commandPalette.toggle", "MacIntel"),
|
||||
"⌘K",
|
||||
@@ -410,13 +469,13 @@ describe("chat/editor shortcuts", () => {
|
||||
|
||||
it("matches diff.toggle shortcut outside terminal focus", () => {
|
||||
assert.isTrue(
|
||||
isDiffToggleShortcut(event({ key: "d", metaKey: true }), DEFAULT_BINDINGS, {
|
||||
isDiffToggleShortcut(event({ key: "d", metaKey: true, altKey: true }), DEFAULT_BINDINGS, {
|
||||
platform: "MacIntel",
|
||||
context: { terminalFocus: false },
|
||||
}),
|
||||
);
|
||||
assert.isFalse(
|
||||
isDiffToggleShortcut(event({ key: "d", metaKey: true }), DEFAULT_BINDINGS, {
|
||||
isDiffToggleShortcut(event({ key: "d", metaKey: true, altKey: true }), DEFAULT_BINDINGS, {
|
||||
platform: "MacIntel",
|
||||
context: { terminalFocus: true },
|
||||
}),
|
||||
|
||||
@@ -3,5 +3,5 @@ export function isTerminalFocused(): boolean {
|
||||
if (!(activeElement instanceof HTMLElement)) return false;
|
||||
if (!activeElement.isConnected) return false;
|
||||
if (activeElement.classList.contains("xterm-helper-textarea")) return true;
|
||||
return activeElement.closest(".thread-terminal-drawer .xterm") !== null;
|
||||
return activeElement.closest(".xterm") !== null;
|
||||
}
|
||||
@@ -259,7 +259,7 @@ function ChatThreadRouteView() {
|
||||
scope: "server",
|
||||
threadRef,
|
||||
},
|
||||
"focus-or-tab",
|
||||
"focus-or-replace",
|
||||
);
|
||||
}, [bootstrapComplete, openThreadSurface, routeThreadExists, threadRef]);
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ function DraftChatThreadRouteView() {
|
||||
environmentId: draftSession.environmentId,
|
||||
threadId: draftSession.threadId,
|
||||
},
|
||||
"focus-or-tab",
|
||||
"focus-or-replace",
|
||||
);
|
||||
}, [canonicalThreadRef, draftId, draftSession, openThreadSurface]);
|
||||
|
||||
|
||||
@@ -14,8 +14,9 @@ import {
|
||||
} from "../lib/chatThreadActions";
|
||||
import { isTerminalFocused } from "../lib/terminalFocus";
|
||||
import { resolveShortcutCommand } from "../keybindings";
|
||||
import { useThreadTerminalOpen } from "../terminalStateStore";
|
||||
import { useThreadSelectionStore } from "../threadSelectionStore";
|
||||
import { useWorkspaceThreadTerminalOpen } from "../workspace/store";
|
||||
import { useFocusedWorkspaceSurface, useWorkspaceStore } from "../workspace/store";
|
||||
import { resolveSidebarNewThreadEnvMode } from "~/components/Sidebar.logic";
|
||||
import { useSettings } from "~/hooks/useSettings";
|
||||
import { useServerKeybindings } from "~/rpc/serverState";
|
||||
@@ -26,8 +27,10 @@ function ChatRouteGlobalShortcuts() {
|
||||
const { activeDraftThread, activeThread, defaultProjectRef, handleNewThread, routeThreadRef } =
|
||||
useHandleNewThread();
|
||||
const { executeWorkspaceCommand } = useWorkspaceCommandExecutor();
|
||||
const focusedWorkspaceSurface = useFocusedWorkspaceSurface();
|
||||
const closeFocusedWindow = useWorkspaceStore((state) => state.closeFocusedWindow);
|
||||
const keybindings = useServerKeybindings();
|
||||
const terminalOpen = useWorkspaceThreadTerminalOpen(routeThreadRef);
|
||||
const terminalOpen = useThreadTerminalOpen(routeThreadRef);
|
||||
const appSettings = useSettings();
|
||||
|
||||
useEffect(() => {
|
||||
@@ -39,6 +42,7 @@ function ChatRouteGlobalShortcuts() {
|
||||
terminalOpen,
|
||||
},
|
||||
});
|
||||
const isFocusedStandaloneTerminal = focusedWorkspaceSurface?.kind === "terminal";
|
||||
if (command && isWorkspaceCommandId(command)) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
@@ -46,6 +50,29 @@ function ChatRouteGlobalShortcuts() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isFocusedStandaloneTerminal) {
|
||||
if (command === "terminal.split") {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
void executeWorkspaceCommand("workspace.terminal.splitRight");
|
||||
return;
|
||||
}
|
||||
|
||||
if (command === "terminal.new") {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
void executeWorkspaceCommand("workspace.terminal.splitDown");
|
||||
return;
|
||||
}
|
||||
|
||||
if (command === "terminal.close") {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
closeFocusedWindow();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (useCommandPaletteStore.getState().open) {
|
||||
return;
|
||||
}
|
||||
@@ -94,10 +121,12 @@ function ChatRouteGlobalShortcuts() {
|
||||
activeDraftThread,
|
||||
activeThread,
|
||||
clearSelection,
|
||||
closeFocusedWindow,
|
||||
handleNewThread,
|
||||
keybindings,
|
||||
defaultProjectRef,
|
||||
executeWorkspaceCommand,
|
||||
focusedWorkspaceSurface,
|
||||
selectedThreadKeysSize,
|
||||
terminalOpen,
|
||||
appSettings.defaultThreadEnvMode,
|
||||
|
||||
@@ -519,6 +519,12 @@ export function selectThreadTerminalState(
|
||||
return terminalStateByThreadKey[terminalThreadKey(threadRef)] ?? getDefaultThreadTerminalState();
|
||||
}
|
||||
|
||||
export function useThreadTerminalOpen(threadRef: ScopedThreadRef | null | undefined): boolean {
|
||||
return useTerminalStateStore(
|
||||
(state) => selectThreadTerminalState(state.terminalStateByThreadKey, threadRef).terminalOpen,
|
||||
);
|
||||
}
|
||||
|
||||
function updateTerminalStateByThreadKey(
|
||||
terminalStateByThreadKey: Record<string, ThreadTerminalState>,
|
||||
threadRef: ScopedThreadRef,
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import { create } from "zustand";
|
||||
|
||||
import type { ThreadSurfaceInput } from "./types";
|
||||
|
||||
export type WorkspaceDragItem =
|
||||
| {
|
||||
kind: "surface";
|
||||
surfaceId: string;
|
||||
}
|
||||
| {
|
||||
kind: "thread";
|
||||
input: ThreadSurfaceInput;
|
||||
};
|
||||
|
||||
interface WorkspaceDragStoreState {
|
||||
item: WorkspaceDragItem | null;
|
||||
clearItem: () => void;
|
||||
setItem: (item: WorkspaceDragItem) => void;
|
||||
}
|
||||
|
||||
export const useWorkspaceDragStore = create<WorkspaceDragStoreState>()((set) => ({
|
||||
item: null,
|
||||
clearItem: () => set({ item: null }),
|
||||
setItem: (item) => set({ item }),
|
||||
}));
|
||||
@@ -52,14 +52,14 @@ describe("workspace store", () => {
|
||||
|
||||
const initialDocument = useWorkspaceStore.getState().document;
|
||||
const windowId = Object.keys(initialDocument.windowsById)[0]!;
|
||||
const initialSurfaceId = initialDocument.windowsById[windowId]!.activeTabId;
|
||||
const initialSurfaceId = initialDocument.windowsById[windowId]!.surfaceId;
|
||||
|
||||
useWorkspaceStore.getState().openThreadSurface(serverThreadSurfaceInput(threadRef));
|
||||
|
||||
const nextDocument = useWorkspaceStore.getState().document;
|
||||
expect(Object.keys(nextDocument.windowsById)).toHaveLength(1);
|
||||
expect(nextDocument.windowsById[windowId]!.tabIds).toEqual([initialSurfaceId]);
|
||||
expect(nextDocument.windowsById[windowId]!.activeTabId).toBe(initialSurfaceId);
|
||||
expect(nextDocument.windowsById[windowId]!.surfaceId).toBe(initialSurfaceId);
|
||||
expect(Object.keys(nextDocument.surfacesById)).toHaveLength(1);
|
||||
});
|
||||
|
||||
it("does not rewrite workspace state when refocusing the already active surface", async () => {
|
||||
@@ -77,7 +77,57 @@ describe("workspace store", () => {
|
||||
expect(useWorkspaceStore.getState().document).toBe(initialDocument);
|
||||
});
|
||||
|
||||
it("collapses the split tree when closing the last tab in a window", async () => {
|
||||
it("normalizes legacy persisted tab-based workspace documents on load", async () => {
|
||||
const testWindow = getTestWindow();
|
||||
const { WORKSPACE_DOCUMENT_STORAGE_KEY } = await import("../clientPersistenceStorage");
|
||||
|
||||
testWindow.localStorage.setItem(
|
||||
WORKSPACE_DOCUMENT_STORAGE_KEY,
|
||||
JSON.stringify({
|
||||
version: 1,
|
||||
layoutEngine: "split",
|
||||
rootNodeId: "node-1",
|
||||
nodesById: {
|
||||
"node-1": {
|
||||
id: "node-1",
|
||||
kind: "window",
|
||||
windowId: "window-1",
|
||||
},
|
||||
},
|
||||
windowsById: {
|
||||
"window-1": {
|
||||
id: "window-1",
|
||||
tabIds: ["surface-1"],
|
||||
activeTabId: "surface-1",
|
||||
},
|
||||
},
|
||||
surfacesById: {
|
||||
"surface-1": {
|
||||
id: "surface-1",
|
||||
kind: "thread",
|
||||
input: {
|
||||
scope: "server",
|
||||
threadRef: {
|
||||
environmentId: "environment-a",
|
||||
threadId: "thread-a",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
focusedWindowId: "window-1",
|
||||
mobileActiveWindowId: "window-1",
|
||||
}),
|
||||
);
|
||||
|
||||
const { useWorkspaceStore } = await import("./store");
|
||||
|
||||
expect(useWorkspaceStore.getState().document.windowsById["window-1"]).toEqual({
|
||||
id: "window-1",
|
||||
surfaceId: "surface-1",
|
||||
});
|
||||
});
|
||||
|
||||
it("collapses the split tree when closing the last pane in a window", async () => {
|
||||
getTestWindow();
|
||||
const { useWorkspaceStore } = await import("./store");
|
||||
const { serverThreadSurfaceInput } = await import("./types");
|
||||
@@ -94,7 +144,7 @@ describe("workspace store", () => {
|
||||
expect(splitDocument.nodesById[splitDocument.rootNodeId!]?.kind).toBe("split");
|
||||
|
||||
const closingWindowId = splitDocument.focusedWindowId!;
|
||||
const closingSurfaceId = splitDocument.windowsById[closingWindowId]!.activeTabId!;
|
||||
const closingSurfaceId = splitDocument.windowsById[closingWindowId]!.surfaceId!;
|
||||
useWorkspaceStore.getState().closeSurface(closingSurfaceId);
|
||||
|
||||
const collapsedDocument = useWorkspaceStore.getState().document;
|
||||
@@ -131,7 +181,7 @@ describe("workspace store", () => {
|
||||
).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("opens a terminal surface as a tab in the focused window", async () => {
|
||||
it("replaces the focused pane with a terminal surface by default", async () => {
|
||||
getTestWindow();
|
||||
const { useWorkspaceStore } = await import("./store");
|
||||
const { serverThreadSurfaceInput } = await import("./types");
|
||||
@@ -143,13 +193,16 @@ describe("workspace store", () => {
|
||||
const initialDocument = useWorkspaceStore.getState().document;
|
||||
const windowId = initialDocument.focusedWindowId!;
|
||||
|
||||
useWorkspaceStore.getState().openTerminalSurfaceForThread(threadRef, "new-tab");
|
||||
useWorkspaceStore.getState().openTerminalSurfaceForThread(threadRef);
|
||||
|
||||
const nextDocument = useWorkspaceStore.getState().document;
|
||||
expect(Object.keys(nextDocument.windowsById)).toHaveLength(1);
|
||||
expect(nextDocument.windowsById[windowId]!.tabIds).toHaveLength(2);
|
||||
const activeSurfaceId = nextDocument.windowsById[windowId]!.activeTabId!;
|
||||
expect(nextDocument.surfacesById[activeSurfaceId]?.kind).toBe("terminal");
|
||||
expect(nextDocument.windowsById[windowId]!.surfaceId).not.toBe(
|
||||
initialDocument.windowsById[windowId]!.surfaceId,
|
||||
);
|
||||
expect(nextDocument.surfacesById[nextDocument.windowsById[windowId]!.surfaceId!]?.kind).toBe(
|
||||
"terminal",
|
||||
);
|
||||
});
|
||||
|
||||
it("opens a terminal surface in a split when requested", async () => {
|
||||
@@ -165,10 +218,52 @@ describe("workspace store", () => {
|
||||
const nextDocument = useWorkspaceStore.getState().document;
|
||||
expect(Object.keys(nextDocument.windowsById)).toHaveLength(2);
|
||||
const activeWindowId = nextDocument.focusedWindowId!;
|
||||
const activeSurfaceId = nextDocument.windowsById[activeWindowId]!.activeTabId!;
|
||||
const activeSurfaceId = nextDocument.windowsById[activeWindowId]!.surfaceId!;
|
||||
expect(nextDocument.surfacesById[activeSurfaceId]?.kind).toBe("terminal");
|
||||
});
|
||||
|
||||
it("creates a new terminal split even when one already exists for the thread", async () => {
|
||||
getTestWindow();
|
||||
const { useWorkspaceStore } = await import("./store");
|
||||
const { serverThreadSurfaceInput } = await import("./types");
|
||||
const threadRef = scopeThreadRef("environment-a" as never, "thread-a" as never);
|
||||
|
||||
useWorkspaceStore.getState().resetWorkspace();
|
||||
useWorkspaceStore.getState().openThreadSurface(serverThreadSurfaceInput(threadRef));
|
||||
useWorkspaceStore.getState().openTerminalSurfaceForThread(threadRef, "split-right");
|
||||
useWorkspaceStore.getState().openTerminalSurfaceForThread(threadRef, "split-right");
|
||||
|
||||
const nextDocument = useWorkspaceStore.getState().document;
|
||||
const terminalSurfaces = Object.values(nextDocument.surfacesById).filter(
|
||||
(surface) => surface.kind === "terminal",
|
||||
);
|
||||
expect(Object.keys(nextDocument.windowsById)).toHaveLength(3);
|
||||
expect(terminalSurfaces).toHaveLength(2);
|
||||
expect(new Set(terminalSurfaces.map((surface) => surface.input.terminalId)).size).toBe(2);
|
||||
});
|
||||
|
||||
it("splits terminal panes into a new terminal session instead of duplicating the same one", async () => {
|
||||
getTestWindow();
|
||||
const { useWorkspaceStore } = await import("./store");
|
||||
const { serverThreadSurfaceInput } = await import("./types");
|
||||
const threadRef = scopeThreadRef("environment-a" as never, "thread-a" as never);
|
||||
|
||||
useWorkspaceStore.getState().resetWorkspace();
|
||||
useWorkspaceStore.getState().openThreadSurface(serverThreadSurfaceInput(threadRef));
|
||||
useWorkspaceStore.getState().openTerminalSurfaceForThread(threadRef);
|
||||
|
||||
const terminalWindowId = useWorkspaceStore.getState().document.focusedWindowId!;
|
||||
useWorkspaceStore.getState().splitWindowSurface(terminalWindowId, "x");
|
||||
|
||||
const nextDocument = useWorkspaceStore.getState().document;
|
||||
const terminalSurfaces = Object.values(nextDocument.surfacesById).filter(
|
||||
(surface) => surface.kind === "terminal",
|
||||
);
|
||||
|
||||
expect(terminalSurfaces).toHaveLength(2);
|
||||
expect(new Set(terminalSurfaces.map((surface) => surface.input.terminalId)).size).toBe(2);
|
||||
});
|
||||
|
||||
it("splits the active surface in the selected window", async () => {
|
||||
getTestWindow();
|
||||
const { useWorkspaceStore } = await import("./store");
|
||||
@@ -180,7 +275,7 @@ describe("workspace store", () => {
|
||||
|
||||
const initialDocument = useWorkspaceStore.getState().document;
|
||||
const sourceWindowId = initialDocument.focusedWindowId!;
|
||||
const sourceSurfaceId = initialDocument.windowsById[sourceWindowId]!.activeTabId!;
|
||||
const sourceSurfaceId = initialDocument.windowsById[sourceWindowId]!.surfaceId!;
|
||||
|
||||
useWorkspaceStore.getState().splitWindowSurface(sourceWindowId, "x");
|
||||
|
||||
@@ -188,7 +283,7 @@ describe("workspace store", () => {
|
||||
expect(Object.keys(nextDocument.windowsById)).toHaveLength(2);
|
||||
const newWindowId = nextDocument.focusedWindowId!;
|
||||
expect(newWindowId).not.toBe(sourceWindowId);
|
||||
const newSurfaceId = nextDocument.windowsById[newWindowId]!.activeTabId!;
|
||||
const newSurfaceId = nextDocument.windowsById[newWindowId]!.surfaceId!;
|
||||
expect(newSurfaceId).not.toBe(sourceSurfaceId);
|
||||
expect(nextDocument.surfacesById[newSurfaceId]?.kind).toBe("thread");
|
||||
expect(nextDocument.nodesById[nextDocument.rootNodeId!]?.kind).toBe("split");
|
||||
@@ -303,7 +398,7 @@ describe("workspace store", () => {
|
||||
if (!middleWindowId) {
|
||||
throw new Error("Expected middle window node");
|
||||
}
|
||||
const middleSurfaceId = document.windowsById[middleWindowId]!.activeTabId!;
|
||||
const middleSurfaceId = document.windowsById[middleWindowId]!.surfaceId!;
|
||||
|
||||
useWorkspaceStore.getState().closeSurface(middleSurfaceId);
|
||||
|
||||
@@ -346,7 +441,7 @@ describe("workspace store", () => {
|
||||
if (!middleWindowId) {
|
||||
throw new Error("Expected middle window node");
|
||||
}
|
||||
const middleSurfaceId = document.windowsById[middleWindowId]!.activeTabId!;
|
||||
const middleSurfaceId = document.windowsById[middleWindowId]!.surfaceId!;
|
||||
|
||||
useWorkspaceStore.getState().closeSurface(middleSurfaceId);
|
||||
|
||||
@@ -381,6 +476,100 @@ describe("workspace store", () => {
|
||||
expect(nextDocument.focusedWindowId).toBe(nextDocument.mobileActiveWindowId);
|
||||
});
|
||||
|
||||
it("cycles focus between panes in previous and next order", async () => {
|
||||
getTestWindow();
|
||||
const { useWorkspaceStore } = await import("./store");
|
||||
const { serverThreadSurfaceInput } = await import("./types");
|
||||
const threadA = scopeThreadRef("environment-a" as never, "thread-a" as never);
|
||||
const threadB = scopeThreadRef("environment-b" as never, "thread-b" as never);
|
||||
|
||||
useWorkspaceStore.getState().resetWorkspace();
|
||||
useWorkspaceStore.getState().openThreadSurface(serverThreadSurfaceInput(threadA));
|
||||
const leftWindowId = useWorkspaceStore.getState().document.focusedWindowId!;
|
||||
useWorkspaceStore.getState().openThreadInSplit(serverThreadSurfaceInput(threadB), "x");
|
||||
const rightWindowId = useWorkspaceStore.getState().document.focusedWindowId!;
|
||||
|
||||
useWorkspaceStore.getState().focusWindowByStep(-1);
|
||||
expect(useWorkspaceStore.getState().document.focusedWindowId).toBe(leftWindowId);
|
||||
|
||||
useWorkspaceStore.getState().focusWindowByStep(1);
|
||||
expect(useWorkspaceStore.getState().document.focusedWindowId).toBe(rightWindowId);
|
||||
});
|
||||
|
||||
it("resizes the focused pane toward an adjacent pane", async () => {
|
||||
getTestWindow();
|
||||
const { useWorkspaceStore } = await import("./store");
|
||||
const { serverThreadSurfaceInput } = await import("./types");
|
||||
const threadA = scopeThreadRef("environment-a" as never, "thread-a" as never);
|
||||
const threadB = scopeThreadRef("environment-b" as never, "thread-b" as never);
|
||||
|
||||
useWorkspaceStore.getState().resetWorkspace();
|
||||
useWorkspaceStore.getState().openThreadSurface(serverThreadSurfaceInput(threadA));
|
||||
useWorkspaceStore.getState().openThreadInSplit(serverThreadSurfaceInput(threadB), "x");
|
||||
|
||||
const beforeDocument = useWorkspaceStore.getState().document;
|
||||
const rootNode = beforeDocument.nodesById[beforeDocument.rootNodeId!];
|
||||
expect(rootNode?.kind).toBe("split");
|
||||
if (rootNode?.kind !== "split") {
|
||||
throw new Error("Expected split node");
|
||||
}
|
||||
const beforeSizes = [...rootNode.sizes];
|
||||
|
||||
useWorkspaceStore.getState().resizeFocusedWindow("left");
|
||||
|
||||
const nextDocument = useWorkspaceStore.getState().document;
|
||||
const nextRootNode = nextDocument.nodesById[nextDocument.rootNodeId!];
|
||||
expect(nextRootNode?.kind).toBe("split");
|
||||
if (nextRootNode?.kind !== "split") {
|
||||
throw new Error("Expected split node");
|
||||
}
|
||||
expect(nextRootNode.sizingMode).toBe("manual");
|
||||
expect(nextRootNode.sizes[1]).toBeGreaterThan(beforeSizes[1] ?? 0);
|
||||
expect(nextRootNode.sizes[0]).toBeLessThan(beforeSizes[0] ?? 0);
|
||||
});
|
||||
|
||||
it("equalizes splits back to auto sizing", async () => {
|
||||
getTestWindow();
|
||||
const { useWorkspaceStore } = await import("./store");
|
||||
const { serverThreadSurfaceInput } = await import("./types");
|
||||
const threadA = scopeThreadRef("environment-a" as never, "thread-a" as never);
|
||||
const threadB = scopeThreadRef("environment-b" as never, "thread-b" as never);
|
||||
|
||||
useWorkspaceStore.getState().resetWorkspace();
|
||||
useWorkspaceStore.getState().openThreadSurface(serverThreadSurfaceInput(threadA));
|
||||
useWorkspaceStore.getState().openThreadInSplit(serverThreadSurfaceInput(threadB), "x");
|
||||
const splitNodeId = useWorkspaceStore.getState().document.rootNodeId!;
|
||||
useWorkspaceStore.getState().setSplitNodeSizes(splitNodeId, [1, 3]);
|
||||
|
||||
useWorkspaceStore.getState().equalizeSplits();
|
||||
|
||||
const nextDocument = useWorkspaceStore.getState().document;
|
||||
const rootNode = nextDocument.nodesById[splitNodeId];
|
||||
expect(rootNode?.kind).toBe("split");
|
||||
if (rootNode?.kind !== "split") {
|
||||
throw new Error("Expected split node");
|
||||
}
|
||||
expect(rootNode.sizingMode).toBe("auto");
|
||||
expect(rootNode.sizes).toEqual([0.5, 0.5]);
|
||||
});
|
||||
|
||||
it("toggles zoom for the focused pane", async () => {
|
||||
getTestWindow();
|
||||
const { useWorkspaceStore } = await import("./store");
|
||||
const { serverThreadSurfaceInput } = await import("./types");
|
||||
const threadA = scopeThreadRef("environment-a" as never, "thread-a" as never);
|
||||
|
||||
useWorkspaceStore.getState().resetWorkspace();
|
||||
useWorkspaceStore.getState().openThreadSurface(serverThreadSurfaceInput(threadA));
|
||||
|
||||
const focusedWindowId = useWorkspaceStore.getState().document.focusedWindowId!;
|
||||
useWorkspaceStore.getState().toggleFocusedWindowZoom();
|
||||
expect(useWorkspaceStore.getState().zoomedWindowId).toBe(focusedWindowId);
|
||||
|
||||
useWorkspaceStore.getState().toggleFocusedWindowZoom();
|
||||
expect(useWorkspaceStore.getState().zoomedWindowId).toBeNull();
|
||||
});
|
||||
|
||||
it("closes the focused pane and keeps the remaining pane active", async () => {
|
||||
getTestWindow();
|
||||
const { useWorkspaceStore } = await import("./store");
|
||||
@@ -401,7 +590,7 @@ describe("workspace store", () => {
|
||||
expect(nextDocument.nodesById[nextDocument.rootNodeId!]?.kind).toBe("window");
|
||||
});
|
||||
|
||||
it("moves the active tab into the adjacent pane and collapses the source pane if empty", async () => {
|
||||
it("swaps an existing thread surface onto the target pane when placed in the center", async () => {
|
||||
getTestWindow();
|
||||
const { useWorkspaceStore } = await import("./store");
|
||||
const { serverThreadSurfaceInput } = await import("./types");
|
||||
@@ -410,18 +599,52 @@ describe("workspace store", () => {
|
||||
|
||||
useWorkspaceStore.getState().resetWorkspace();
|
||||
useWorkspaceStore.getState().openThreadSurface(serverThreadSurfaceInput(threadA));
|
||||
const leftWindowId = useWorkspaceStore.getState().document.focusedWindowId!;
|
||||
useWorkspaceStore.getState().openThreadInSplit(serverThreadSurfaceInput(threadB), "x");
|
||||
useWorkspaceStore.getState().focusAdjacentWindow("left");
|
||||
const rightWindowId = useWorkspaceStore.getState().document.focusedWindowId!;
|
||||
|
||||
const sourceWindowId = useWorkspaceStore.getState().document.focusedWindowId!;
|
||||
useWorkspaceStore.getState().moveActiveTabToAdjacentWindow("right");
|
||||
useWorkspaceStore.getState().placeThreadSurface(serverThreadSurfaceInput(threadA), {
|
||||
kind: "window",
|
||||
windowId: rightWindowId,
|
||||
placement: "center",
|
||||
});
|
||||
|
||||
const nextDocument = useWorkspaceStore.getState().document;
|
||||
const leftSurfaceId = nextDocument.windowsById[leftWindowId]!.surfaceId!;
|
||||
const rightSurfaceId = nextDocument.windowsById[rightWindowId]!.surfaceId!;
|
||||
expect(Object.keys(nextDocument.surfacesById)).toHaveLength(2);
|
||||
expect(nextDocument.surfacesById[rightSurfaceId]?.kind).toBe("thread");
|
||||
expect(nextDocument.surfacesById[rightSurfaceId]?.input).toEqual(
|
||||
serverThreadSurfaceInput(threadA),
|
||||
);
|
||||
expect(nextDocument.surfacesById[leftSurfaceId]?.input).toEqual(
|
||||
serverThreadSurfaceInput(threadB),
|
||||
);
|
||||
});
|
||||
|
||||
it("replaces the target pane with a new thread surface when placed in the center", async () => {
|
||||
getTestWindow();
|
||||
const { useWorkspaceStore } = await import("./store");
|
||||
const { serverThreadSurfaceInput } = await import("./types");
|
||||
const threadA = scopeThreadRef("environment-a" as never, "thread-a" as never);
|
||||
const threadB = scopeThreadRef("environment-b" as never, "thread-b" as never);
|
||||
|
||||
useWorkspaceStore.getState().resetWorkspace();
|
||||
useWorkspaceStore.getState().openThreadSurface(serverThreadSurfaceInput(threadA));
|
||||
|
||||
const targetWindowId = useWorkspaceStore.getState().document.focusedWindowId!;
|
||||
useWorkspaceStore.getState().placeThreadSurface(serverThreadSurfaceInput(threadB), {
|
||||
kind: "window",
|
||||
windowId: targetWindowId,
|
||||
placement: "center",
|
||||
});
|
||||
|
||||
const nextDocument = useWorkspaceStore.getState().document;
|
||||
expect(nextDocument.windowsById[sourceWindowId]).toBeUndefined();
|
||||
expect(Object.keys(nextDocument.windowsById)).toHaveLength(1);
|
||||
const remainingWindowId = nextDocument.focusedWindowId!;
|
||||
expect(nextDocument.windowsById[remainingWindowId]!.tabIds).toHaveLength(2);
|
||||
expect(nextDocument.nodesById[nextDocument.rootNodeId!]?.kind).toBe("window");
|
||||
expect(Object.keys(nextDocument.surfacesById)).toHaveLength(1);
|
||||
expect(
|
||||
nextDocument.surfacesById[nextDocument.windowsById[targetWindowId]!.surfaceId!]?.input,
|
||||
).toEqual(serverThreadSurfaceInput(threadB));
|
||||
});
|
||||
|
||||
it("moves the focused pane by swapping positions with the adjacent pane", async () => {
|
||||
@@ -476,6 +699,129 @@ describe("workspace store", () => {
|
||||
expect(Object.keys(nextDocument.surfacesById)).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("converts an existing split workspace into paper columns", async () => {
|
||||
getTestWindow();
|
||||
const { useWorkspaceStore } = await import("./store");
|
||||
const { serverThreadSurfaceInput } = await import("./types");
|
||||
const threadA = scopeThreadRef("environment-a" as never, "thread-a" as never);
|
||||
const threadB = scopeThreadRef("environment-b" as never, "thread-b" as never);
|
||||
|
||||
useWorkspaceStore.getState().resetWorkspace();
|
||||
useWorkspaceStore.getState().openThreadSurface(serverThreadSurfaceInput(threadA));
|
||||
useWorkspaceStore.getState().openThreadInSplit(serverThreadSurfaceInput(threadB), "x");
|
||||
useWorkspaceStore.getState().setLayoutEngine("paper");
|
||||
|
||||
const nextDocument = useWorkspaceStore.getState().document;
|
||||
expect(nextDocument.layoutEngine).toBe("paper");
|
||||
const rootNode = nextDocument.nodesById[nextDocument.rootNodeId!];
|
||||
expect(rootNode?.kind).toBe("paper-root");
|
||||
if (rootNode?.kind !== "paper-root") {
|
||||
throw new Error("Expected paper root");
|
||||
}
|
||||
expect(rootNode.childIds).toHaveLength(2);
|
||||
expect(rootNode.widths).toEqual([1, 1]);
|
||||
for (const columnId of rootNode.childIds) {
|
||||
const column = nextDocument.nodesById[columnId];
|
||||
expect(column?.kind).toBe("paper-column");
|
||||
if (column?.kind !== "paper-column") {
|
||||
throw new Error("Expected paper column");
|
||||
}
|
||||
expect(column.childIds).toHaveLength(1);
|
||||
}
|
||||
});
|
||||
|
||||
it("stacks split-down panes inside a paper column and split-right creates a new column", async () => {
|
||||
getTestWindow();
|
||||
const { useWorkspaceStore } = await import("./store");
|
||||
const { serverThreadSurfaceInput } = await import("./types");
|
||||
const threadA = scopeThreadRef("environment-a" as never, "thread-a" as never);
|
||||
const threadB = scopeThreadRef("environment-b" as never, "thread-b" as never);
|
||||
const threadC = scopeThreadRef("environment-c" as never, "thread-c" as never);
|
||||
|
||||
useWorkspaceStore.getState().resetWorkspace();
|
||||
useWorkspaceStore.getState().setLayoutEngine("paper");
|
||||
useWorkspaceStore.getState().openThreadSurface(serverThreadSurfaceInput(threadA));
|
||||
useWorkspaceStore.getState().openThreadInSplit(serverThreadSurfaceInput(threadB), "y");
|
||||
useWorkspaceStore.getState().focusAdjacentWindow("up");
|
||||
useWorkspaceStore.getState().openThreadInSplit(serverThreadSurfaceInput(threadC), "x");
|
||||
|
||||
const nextDocument = useWorkspaceStore.getState().document;
|
||||
const rootNode = nextDocument.nodesById[nextDocument.rootNodeId!];
|
||||
expect(rootNode?.kind).toBe("paper-root");
|
||||
if (rootNode?.kind !== "paper-root") {
|
||||
throw new Error("Expected paper root");
|
||||
}
|
||||
expect(rootNode.childIds).toHaveLength(2);
|
||||
|
||||
const firstColumn = nextDocument.nodesById[rootNode.childIds[0]!];
|
||||
const secondColumn = nextDocument.nodesById[rootNode.childIds[1]!];
|
||||
expect(firstColumn?.kind).toBe("paper-column");
|
||||
expect(secondColumn?.kind).toBe("paper-column");
|
||||
if (firstColumn?.kind !== "paper-column" || secondColumn?.kind !== "paper-column") {
|
||||
throw new Error("Expected paper columns");
|
||||
}
|
||||
|
||||
expect(firstColumn.childIds).toHaveLength(2);
|
||||
expect(secondColumn.childIds).toHaveLength(1);
|
||||
});
|
||||
|
||||
it("resizes paper columns by adjusting neighboring widths", async () => {
|
||||
getTestWindow();
|
||||
const { useWorkspaceStore } = await import("./store");
|
||||
const { serverThreadSurfaceInput } = await import("./types");
|
||||
const threadA = scopeThreadRef("environment-a" as never, "thread-a" as never);
|
||||
const threadB = scopeThreadRef("environment-b" as never, "thread-b" as never);
|
||||
|
||||
useWorkspaceStore.getState().resetWorkspace();
|
||||
useWorkspaceStore.getState().setLayoutEngine("paper");
|
||||
useWorkspaceStore.getState().openThreadSurface(serverThreadSurfaceInput(threadA));
|
||||
useWorkspaceStore.getState().openThreadInSplit(serverThreadSurfaceInput(threadB), "x");
|
||||
|
||||
const beforeDocument = useWorkspaceStore.getState().document;
|
||||
const beforeRoot = beforeDocument.nodesById[beforeDocument.rootNodeId!];
|
||||
expect(beforeRoot?.kind).toBe("paper-root");
|
||||
if (beforeRoot?.kind !== "paper-root") {
|
||||
throw new Error("Expected paper root");
|
||||
}
|
||||
|
||||
useWorkspaceStore.getState().resizeFocusedWindow("left");
|
||||
|
||||
const nextDocument = useWorkspaceStore.getState().document;
|
||||
const nextRoot = nextDocument.nodesById[nextDocument.rootNodeId!];
|
||||
expect(nextRoot?.kind).toBe("paper-root");
|
||||
if (nextRoot?.kind !== "paper-root") {
|
||||
throw new Error("Expected paper root");
|
||||
}
|
||||
expect(nextRoot.sizingMode).toBe("manual");
|
||||
expect(nextRoot.widths[1]).toBeGreaterThan(beforeRoot.widths[1] ?? 0);
|
||||
expect(nextRoot.widths[0]).toBeLessThan(beforeRoot.widths[0] ?? 0);
|
||||
});
|
||||
|
||||
it("removes an empty paper column when its last pane closes", async () => {
|
||||
getTestWindow();
|
||||
const { useWorkspaceStore } = await import("./store");
|
||||
const { serverThreadSurfaceInput } = await import("./types");
|
||||
const threadA = scopeThreadRef("environment-a" as never, "thread-a" as never);
|
||||
const threadB = scopeThreadRef("environment-b" as never, "thread-b" as never);
|
||||
|
||||
useWorkspaceStore.getState().resetWorkspace();
|
||||
useWorkspaceStore.getState().setLayoutEngine("paper");
|
||||
useWorkspaceStore.getState().openThreadSurface(serverThreadSurfaceInput(threadA));
|
||||
useWorkspaceStore.getState().openThreadInSplit(serverThreadSurfaceInput(threadB), "x");
|
||||
|
||||
useWorkspaceStore.getState().closeFocusedWindow();
|
||||
|
||||
const nextDocument = useWorkspaceStore.getState().document;
|
||||
expect(nextDocument.layoutEngine).toBe("paper");
|
||||
expect(Object.keys(nextDocument.windowsById)).toHaveLength(1);
|
||||
const rootNode = nextDocument.nodesById[nextDocument.rootNodeId!];
|
||||
expect(rootNode?.kind).toBe("paper-root");
|
||||
if (rootNode?.kind !== "paper-root") {
|
||||
throw new Error("Expected paper root");
|
||||
}
|
||||
expect(rootNode.childIds).toHaveLength(1);
|
||||
});
|
||||
|
||||
it("persists workspace documents after the debounce interval", async () => {
|
||||
vi.useFakeTimers();
|
||||
const testWindow = getTestWindow();
|
||||
|
||||
+1553
-162
File diff suppressed because it is too large.
Load diff
@@ -5,7 +5,8 @@ import type { ThreadRouteTarget } from "../threadRoutes";
|
||||
|
||||
export type WorkspaceAxis = "x" | "y";
|
||||
export type WorkspaceDirection = "left" | "right" | "up" | "down";
|
||||
export type WorkspaceLayoutEngine = "split";
|
||||
export type WorkspaceDropPlacement = "center" | "left" | "right" | "top" | "bottom";
|
||||
export type WorkspaceLayoutEngine = "split" | "paper";
|
||||
export type WorkspaceSurfaceKind = "thread" | "terminal";
|
||||
export type WorkspaceSplitSizingMode = "auto" | "manual";
|
||||
|
||||
@@ -24,6 +25,7 @@ export type ThreadSurfaceInput =
|
||||
export interface TerminalSurfaceInput {
|
||||
scope: "thread";
|
||||
threadRef: ScopedThreadRef;
|
||||
terminalId: string;
|
||||
}
|
||||
|
||||
export type WorkspaceSurfaceInstance =
|
||||
@@ -40,8 +42,13 @@ export type WorkspaceSurfaceInstance =
|
||||
|
||||
export interface WorkspaceWindow {
|
||||
id: string;
|
||||
tabIds: string[];
|
||||
activeTabId: string | null;
|
||||
surfaceId: string | null;
|
||||
}
|
||||
|
||||
export interface WorkspacePlacementTarget {
|
||||
kind: "window";
|
||||
windowId: string;
|
||||
placement: WorkspaceDropPlacement;
|
||||
}
|
||||
|
||||
export type WorkspaceNode =
|
||||
@@ -57,6 +64,20 @@ export type WorkspaceNode =
|
||||
childIds: string[];
|
||||
sizes: number[];
|
||||
sizingMode: WorkspaceSplitSizingMode;
|
||||
}
|
||||
| {
|
||||
id: string;
|
||||
kind: "paper-root";
|
||||
childIds: string[];
|
||||
widths: number[];
|
||||
sizingMode: WorkspaceSplitSizingMode;
|
||||
}
|
||||
| {
|
||||
id: string;
|
||||
kind: "paper-column";
|
||||
childIds: string[];
|
||||
sizes: number[];
|
||||
sizingMode: WorkspaceSplitSizingMode;
|
||||
};
|
||||
|
||||
export interface WorkspaceDocument {
|
||||
@@ -70,10 +91,12 @@ export interface WorkspaceDocument {
|
||||
mobileActiveWindowId: string | null;
|
||||
}
|
||||
|
||||
export function createEmptyWorkspaceDocument(): WorkspaceDocument {
|
||||
export function createEmptyWorkspaceDocument(
|
||||
layoutEngine: WorkspaceLayoutEngine = "split",
|
||||
): WorkspaceDocument {
|
||||
return {
|
||||
version: 1,
|
||||
layoutEngine: "split",
|
||||
layoutEngine,
|
||||
rootNodeId: null,
|
||||
nodesById: {},
|
||||
windowsById: {},
|
||||
@@ -105,13 +128,31 @@ export function normalizeWorkspaceSplitSizes(
|
||||
return finiteSizes.map((size) => size / total);
|
||||
}
|
||||
|
||||
export function normalizeWorkspacePaperColumnWidths(
|
||||
widths: number[] | null | undefined,
|
||||
childCount: number,
|
||||
): number[] {
|
||||
if (childCount <= 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (!widths || widths.length !== childCount) {
|
||||
return Array.from({ length: childCount }, () => 1);
|
||||
}
|
||||
|
||||
return widths.map((width) => (Number.isFinite(width) && width > 0 ? width : 1));
|
||||
}
|
||||
|
||||
export function isWorkspaceDocument(value: unknown): value is WorkspaceDocument {
|
||||
if (!value || typeof value !== "object") {
|
||||
return false;
|
||||
}
|
||||
|
||||
const candidate = value as Partial<WorkspaceDocument>;
|
||||
return candidate.version === 1 && candidate.layoutEngine === "split";
|
||||
return (
|
||||
candidate.version === 1 &&
|
||||
(candidate.layoutEngine === "split" || candidate.layoutEngine === "paper")
|
||||
);
|
||||
}
|
||||
|
||||
export function sameThreadSurfaceInput(
|
||||
@@ -151,7 +192,8 @@ export function sameTerminalSurfaceInput(
|
||||
return (
|
||||
left.scope === right.scope &&
|
||||
left.threadRef.environmentId === right.threadRef.environmentId &&
|
||||
left.threadRef.threadId === right.threadRef.threadId
|
||||
left.threadRef.threadId === right.threadRef.threadId &&
|
||||
left.terminalId === right.terminalId
|
||||
);
|
||||
}
|
||||
|
||||
@@ -234,9 +276,13 @@ export function draftThreadSurfaceInput(input: {
|
||||
};
|
||||
}
|
||||
|
||||
export function terminalSurfaceInput(threadRef: ScopedThreadRef): TerminalSurfaceInput {
|
||||
export function terminalSurfaceInput(
|
||||
threadRef: ScopedThreadRef,
|
||||
terminalId: string,
|
||||
): TerminalSurfaceInput {
|
||||
return {
|
||||
scope: "thread",
|
||||
threadRef,
|
||||
terminalId,
|
||||
};
|
||||
}
|
||||
@@ -34,22 +34,25 @@ const STATIC_KEYBINDING_COMMANDS = [
|
||||
"terminal.close",
|
||||
"workspace.terminal.splitRight",
|
||||
"workspace.terminal.splitDown",
|
||||
"workspace.terminal.newTab",
|
||||
"workspace.pane.splitRight",
|
||||
"workspace.pane.splitDown",
|
||||
"workspace.focus.previous",
|
||||
"workspace.focus.next",
|
||||
"workspace.focus.left",
|
||||
"workspace.focus.right",
|
||||
"workspace.focus.up",
|
||||
"workspace.focus.down",
|
||||
"workspace.pane.close",
|
||||
"workspace.pane.toggleZoom",
|
||||
"workspace.pane.resizeLeft",
|
||||
"workspace.pane.resizeRight",
|
||||
"workspace.pane.resizeUp",
|
||||
"workspace.pane.resizeDown",
|
||||
"workspace.pane.equalize",
|
||||
"workspace.pane.moveLeft",
|
||||
"workspace.pane.moveRight",
|
||||
"workspace.pane.moveUp",
|
||||
"workspace.pane.moveDown",
|
||||
"workspace.tab.moveLeft",
|
||||
"workspace.tab.moveRight",
|
||||
"workspace.tab.moveUp",
|
||||
"workspace.tab.moveDown",
|
||||
"diff.toggle",
|
||||
"commandPalette.toggle",
|
||||
"chat.new",
|
||||
|
||||
Reference in new issue
Block a user