feat: add terminal toggle button to chat header (#633)
Co-authored-by: Julius Marminge <[email protected]> Co-authored-by: codex <[email protected]>
This commit is contained in:
2 files changed
+41
-1
No files matched your search
@@ -1119,6 +1119,10 @@ export default function ChatView({ threadId }: ChatViewProps) {
|
||||
}, [activeProjectCwd, activeThreadWorktreePath]);
|
||||
// Default true while loading to avoid toolbar flicker.
|
||||
const isGitRepo = branchesQuery.data?.isRepo ?? true;
|
||||
const terminalToggleShortcutLabel = useMemo(
|
||||
() => shortcutLabelForCommand(keybindings, "terminal.toggle"),
|
||||
[keybindings],
|
||||
);
|
||||
const splitTerminalShortcutLabel = useMemo(
|
||||
() => shortcutLabelForCommand(keybindings, "terminal.split"),
|
||||
[keybindings],
|
||||
@@ -3474,6 +3478,9 @@ export default function ChatView({ threadId }: ChatViewProps) {
|
||||
}
|
||||
keybindings={keybindings}
|
||||
availableEditors={availableEditors}
|
||||
terminalAvailable={activeProject !== undefined}
|
||||
terminalOpen={terminalState.terminalOpen}
|
||||
terminalToggleShortcutLabel={terminalToggleShortcutLabel}
|
||||
diffToggleShortcutLabel={diffPanelShortcutLabel}
|
||||
gitCwd={gitCwd}
|
||||
diffOpen={diffOpen}
|
||||
@@ -3483,6 +3490,7 @@ export default function ChatView({ threadId }: ChatViewProps) {
|
||||
onAddProjectScript={saveProjectScript}
|
||||
onUpdateProjectScript={updateProjectScript}
|
||||
onDeleteProjectScript={deleteProjectScript}
|
||||
onToggleTerminal={toggleTerminalVisibility}
|
||||
onToggleDiff={onToggleDiff}
|
||||
/>
|
||||
</header>
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
} from "@t3tools/contracts";
|
||||
import { memo } from "react";
|
||||
import GitActionsControl from "../GitActionsControl";
|
||||
import { DiffIcon } from "lucide-react";
|
||||
import { DiffIcon, TerminalSquareIcon } from "lucide-react";
|
||||
import { Badge } from "../ui/badge";
|
||||
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
|
||||
import ProjectScriptsControl, { type NewProjectScriptInput } from "../ProjectScriptsControl";
|
||||
@@ -24,6 +24,9 @@ interface ChatHeaderProps {
|
||||
preferredScriptId: string | null;
|
||||
keybindings: ResolvedKeybindingsConfig;
|
||||
availableEditors: ReadonlyArray<EditorId>;
|
||||
terminalAvailable: boolean;
|
||||
terminalOpen: boolean;
|
||||
terminalToggleShortcutLabel: string | null;
|
||||
diffToggleShortcutLabel: string | null;
|
||||
gitCwd: string | null;
|
||||
diffOpen: boolean;
|
||||
@@ -31,6 +34,7 @@ interface ChatHeaderProps {
|
||||
onAddProjectScript: (input: NewProjectScriptInput) => Promise<void>;
|
||||
onUpdateProjectScript: (scriptId: string, input: NewProjectScriptInput) => Promise<void>;
|
||||
onDeleteProjectScript: (scriptId: string) => Promise<void>;
|
||||
onToggleTerminal: () => void;
|
||||
onToggleDiff: () => void;
|
||||
}
|
||||
|
||||
@@ -44,6 +48,9 @@ export const ChatHeader = memo(function ChatHeader({
|
||||
preferredScriptId,
|
||||
keybindings,
|
||||
availableEditors,
|
||||
terminalAvailable,
|
||||
terminalOpen,
|
||||
terminalToggleShortcutLabel,
|
||||
diffToggleShortcutLabel,
|
||||
gitCwd,
|
||||
diffOpen,
|
||||
@@ -51,6 +58,7 @@ export const ChatHeader = memo(function ChatHeader({
|
||||
onAddProjectScript,
|
||||
onUpdateProjectScript,
|
||||
onDeleteProjectScript,
|
||||
onToggleTerminal,
|
||||
onToggleDiff,
|
||||
}: ChatHeaderProps) {
|
||||
return (
|
||||
@@ -94,6 +102,30 @@ export const ChatHeader = memo(function ChatHeader({
|
||||
/>
|
||||
)}
|
||||
{activeProjectName && <GitActionsControl gitCwd={gitCwd} activeThreadId={activeThreadId} />}
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<Toggle
|
||||
className="shrink-0"
|
||||
pressed={terminalOpen}
|
||||
onPressedChange={onToggleTerminal}
|
||||
aria-label="Toggle terminal drawer"
|
||||
variant="outline"
|
||||
size="xs"
|
||||
disabled={!terminalAvailable}
|
||||
>
|
||||
<TerminalSquareIcon className="size-3" />
|
||||
</Toggle>
|
||||
}
|
||||
/>
|
||||
<TooltipPopup side="bottom">
|
||||
{!terminalAvailable
|
||||
? "Terminal is unavailable until this thread has an active project."
|
||||
: terminalToggleShortcutLabel
|
||||
? `Toggle terminal drawer (${terminalToggleShortcutLabel})`
|
||||
: "Toggle terminal drawer"}
|
||||
</TooltipPopup>
|
||||
</Tooltip>
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
|
||||
Reference in new issue
Block a user