@devries-cameron20 / t3code Mirror · read-only / commits / be1abc88fd
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 25, 07:30 UTC

feat: add terminal toggle button to chat header (#633)

Co-authored-by: Julius Marminge <julius0216@outlook.com> Co-authored-by: codex <codex@users.noreply.github.com>

ANTI committed Mar 24, 2026 at 05:28 UTC be1abc88fda0beacb606b2e7de6f4e82cc31155f
2 files changed +41 -1
apps/web/src/components/ChatView.tsx
+8
@@ -1119,6 +1119,10 @@ export default function ChatView({ threadId }: ChatViewProps) {
1119 }, [activeProjectCwd, activeThreadWorktreePath]);
1120 // Default true while loading to avoid toolbar flicker.
1121 const isGitRepo = branchesQuery.data?.isRepo ?? true;
1122 + const terminalToggleShortcutLabel = useMemo(
1123 + () => shortcutLabelForCommand(keybindings, "terminal.toggle"),
1124 + [keybindings],
1125 + );
1126 const splitTerminalShortcutLabel = useMemo(
1127 () => shortcutLabelForCommand(keybindings, "terminal.split"),
1128 [keybindings],
@@ -3474,6 +3478,9 @@ export default function ChatView({ threadId }: ChatViewProps) {
3478 }
3479 keybindings={keybindings}
3480 availableEditors={availableEditors}
3481 + terminalAvailable={activeProject !== undefined}
3482 + terminalOpen={terminalState.terminalOpen}
3483 + terminalToggleShortcutLabel={terminalToggleShortcutLabel}
3484 diffToggleShortcutLabel={diffPanelShortcutLabel}
3485 gitCwd={gitCwd}
3486 diffOpen={diffOpen}
@@ -3483,6 +3490,7 @@ export default function ChatView({ threadId }: ChatViewProps) {
3490 onAddProjectScript={saveProjectScript}
3491 onUpdateProjectScript={updateProjectScript}
3492 onDeleteProjectScript={deleteProjectScript}
3493 + onToggleTerminal={toggleTerminalVisibility}
3494 onToggleDiff={onToggleDiff}
3495 />
3496 </header>
apps/web/src/components/chat/ChatHeader.tsx
+33 -1
@@ -6,7 +6,7 @@ import {
6 } from "@t3tools/contracts";
7 import { memo } from "react";
8 import GitActionsControl from "../GitActionsControl";
9 -import { DiffIcon } from "lucide-react";
9 +import { DiffIcon, TerminalSquareIcon } from "lucide-react";
10 import { Badge } from "../ui/badge";
11 import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
12 import ProjectScriptsControl, { type NewProjectScriptInput } from "../ProjectScriptsControl";
@@ -24,6 +24,9 @@ interface ChatHeaderProps {
24 preferredScriptId: string | null;
25 keybindings: ResolvedKeybindingsConfig;
26 availableEditors: ReadonlyArray<EditorId>;
27 + terminalAvailable: boolean;
28 + terminalOpen: boolean;
29 + terminalToggleShortcutLabel: string | null;
30 diffToggleShortcutLabel: string | null;
31 gitCwd: string | null;
32 diffOpen: boolean;
@@ -31,6 +34,7 @@ interface ChatHeaderProps {
34 onAddProjectScript: (input: NewProjectScriptInput) => Promise<void>;
35 onUpdateProjectScript: (scriptId: string, input: NewProjectScriptInput) => Promise<void>;
36 onDeleteProjectScript: (scriptId: string) => Promise<void>;
37 + onToggleTerminal: () => void;
38 onToggleDiff: () => void;
39 }
40
@@ -44,6 +48,9 @@ export const ChatHeader = memo(function ChatHeader({
48 preferredScriptId,
49 keybindings,
50 availableEditors,
51 + terminalAvailable,
52 + terminalOpen,
53 + terminalToggleShortcutLabel,
54 diffToggleShortcutLabel,
55 gitCwd,
56 diffOpen,
@@ -51,6 +58,7 @@ export const ChatHeader = memo(function ChatHeader({
58 onAddProjectScript,
59 onUpdateProjectScript,
60 onDeleteProjectScript,
61 + onToggleTerminal,
62 onToggleDiff,
63 }: ChatHeaderProps) {
64 return (
@@ -94,6 +102,30 @@ export const ChatHeader = memo(function ChatHeader({
102 />
103 )}
104 {activeProjectName && <GitActionsControl gitCwd={gitCwd} activeThreadId={activeThreadId} />}
105 + <Tooltip>
106 + <TooltipTrigger
107 + render={
108 + <Toggle
109 + className="shrink-0"
110 + pressed={terminalOpen}
111 + onPressedChange={onToggleTerminal}
112 + aria-label="Toggle terminal drawer"
113 + variant="outline"
114 + size="xs"
115 + disabled={!terminalAvailable}
116 + >
117 + <TerminalSquareIcon className="size-3" />
118 + </Toggle>
119 + }
120 + />
121 + <TooltipPopup side="bottom">
122 + {!terminalAvailable
123 + ? "Terminal is unavailable until this thread has an active project."
124 + : terminalToggleShortcutLabel
125 + ? `Toggle terminal drawer (${terminalToggleShortcutLabel})`
126 + : "Toggle terminal drawer"}
127 + </TooltipPopup>
128 + </Tooltip>
129 <Tooltip>
130 <TooltipTrigger
131 render={