Skip to content

Commit a19fe26

Browse files
chore(code): disable terminal tabs for cloud run (#1553)
1 parent 1ed460f commit a19fe26

File tree

4 files changed

+24
-12
lines changed

4 files changed

+24
-12
lines changed

apps/code/src/renderer/features/message-editor/components/MessageEditor.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { SessionConfigOption } from "@agentclientprotocol/sdk";
33
import { BranchSelector } from "@features/git-interaction/components/BranchSelector";
44
import { useGitQueries } from "@features/git-interaction/hooks/useGitQueries";
55
import { getUserPromptsForTask } from "@features/sessions/stores/sessionStore";
6+
import { useIsWorkspaceCloudRun } from "@features/workspace/hooks/useWorkspace";
67
import { useConnectivity } from "@hooks/useConnectivity";
78
import { ArrowUp, Circle, Stop } from "@phosphor-icons/react";
89
import { Flex, IconButton, Text, Tooltip } from "@radix-ui/themes";
@@ -169,6 +170,7 @@ export const MessageEditor = forwardRef<EditorHandle, MessageEditorProps>(
169170
const clearFocusRequest = useDraftStore((s) => s.actions.clearFocusRequest);
170171
const { isOnline } = useConnectivity();
171172
const taskId = context?.taskId;
173+
const isCloud = useIsWorkspaceCloudRun(taskId);
172174
const disabled = context?.disabled ?? false;
173175
const isLoading = context?.isLoading ?? false;
174176
const repoPath = context?.repoPath;
@@ -207,6 +209,7 @@ export const MessageEditor = forwardRef<EditorHandle, MessageEditorProps>(
207209
autoFocus,
208210
context: { taskId, repoPath },
209211
getPromptHistory,
212+
capabilities: { bashMode: !isCloud },
210213
onSubmit,
211214
onBashCommand,
212215
onBashModeChange,

apps/code/src/renderer/features/message-editor/tiptap/useTiptapEditor.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ export function useTiptapEditor(options: UseTiptapEditorOptions) {
464464

465465
const text = editor.getText().trim();
466466

467-
if (text.startsWith("!")) {
467+
if (enableBashMode && text.startsWith("!")) {
468468
// Bash mode requires immediate execution, can't be queued
469469
if (isLoading) {
470470
toast.error("Cannot run shell commands while agent is generating");
@@ -492,6 +492,7 @@ export function useTiptapEditor(options: UseTiptapEditorOptions) {
492492
draft,
493493
clearOnSubmit,
494494
attachments,
495+
enableBashMode,
495496
]);
496497

497498
submitRef.current = submit;

apps/code/src/renderer/features/panels/components/LeafNodeRenderer.tsx

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Cloud as CloudIcon } from "@phosphor-icons/react";
22
import { Flex, Text } from "@radix-ui/themes";
3-
import { useWorkspace } from "@renderer/features/workspace/hooks/useWorkspace";
3+
import { useIsWorkspaceCloudRun } from "@renderer/features/workspace/hooks/useWorkspace";
44
import type { Task } from "@shared/types";
55
import type React from "react";
66
import { useMemo } from "react";
@@ -40,16 +40,18 @@ export const LeafNodeRenderer: React.FC<LeafNodeRendererProps> = ({
4040
onAddTerminal,
4141
onSplitPanel,
4242
}) => {
43-
const tabs = useTabInjection(
44-
node.content.tabs,
45-
node.id,
46-
taskId,
47-
task,
48-
closeTab,
43+
const isCloud = useIsWorkspaceCloudRun(taskId);
44+
const inputTabs = useMemo(
45+
() =>
46+
isCloud
47+
? node.content.tabs.filter((t) => t.data.type !== "terminal")
48+
: node.content.tabs,
49+
[node.content.tabs, isCloud],
4950
);
50-
51-
const workspace = useWorkspace(taskId);
52-
const isCloud = workspace?.mode === "cloud";
51+
const tabs = useTabInjection(inputTabs, node.id, taskId, task, closeTab);
52+
const activeTabId = tabs.some((t) => t.id === node.content.activeTabId)
53+
? node.content.activeTabId
54+
: (tabs[0]?.id ?? node.content.activeTabId);
5355

5456
const cloudEmptyState = useMemo(
5557
() =>
@@ -74,6 +76,7 @@ export const LeafNodeRenderer: React.FC<LeafNodeRendererProps> = ({
7476
const contentWithComponents = {
7577
...node.content,
7678
tabs,
79+
activeTabId,
7780
};
7881

7982
return (
@@ -87,7 +90,7 @@ export const LeafNodeRenderer: React.FC<LeafNodeRendererProps> = ({
8790
onPanelFocus={onPanelFocus}
8891
draggingTabId={draggingTabId}
8992
draggingTabPanelId={draggingTabPanelId}
90-
onAddTerminal={() => onAddTerminal(node.id)}
93+
onAddTerminal={isCloud ? undefined : () => onAddTerminal(node.id)}
9194
onSplitPanel={(direction) => onSplitPanel(node.id, direction)}
9295
emptyState={cloudEmptyState}
9396
/>

apps/code/src/renderer/features/workspace/hooks/useWorkspace.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ export function useWorkspace(taskId: string | undefined): Workspace | null {
5252
);
5353
}
5454

55+
export function useIsWorkspaceCloudRun(taskId: string | undefined): boolean {
56+
const workspace = useWorkspace(taskId);
57+
return workspace?.mode === "cloud";
58+
}
59+
5560
export function useWorkspaceLoaded(): boolean {
5661
const { isFetched } = useWorkspacesQuery();
5762
return isFetched;

0 commit comments

Comments
 (0)