Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 42 additions & 48 deletions apps/web/src/components/ThreadTerminalDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
import { type TerminalSessionState } from "@t3tools/client-runtime/state/terminal";
import {
Plus,
Square,
SquareSplitHorizontal,
SquareSplitVertical,
TerminalSquare,
Expand Down Expand Up @@ -1622,85 +1623,78 @@ export default function ThreadTerminalDrawer({
</div>

<div className="min-h-0 flex-1 overflow-y-auto px-1 py-1">
{resolvedTerminalGroups.map((terminalGroup, groupIndex) => {
{resolvedTerminalGroups.map((terminalGroup) => {
const isGroupActive =
terminalGroup.terminalIds.includes(resolvedActiveTerminalId);
const groupActiveTerminalId = isGroupActive
? resolvedActiveTerminalId
: (terminalGroup.terminalIds[0] ?? resolvedActiveTerminalId);
const terminalCount = terminalGroup.terminalIds.length;
const isSplitGroup = terminalCount > 1;
const groupLabel = !isSplitGroup
? "Single"
: terminalGroup.splitDirection === "vertical"
? "Stacked"
: "Side by side";
const GroupIcon = !isSplitGroup
? Square
: terminalGroup.splitDirection === "vertical"
? SquareSplitVertical
: SquareSplitHorizontal;

return (
<div key={terminalGroup.id} className="pb-0.5">
{showGroupHeaders && (
<button
type="button"
className={`flex w-full items-center rounded px-1 py-0.5 text-[10px] uppercase tracking-[0.08em] ${
className={`flex h-[22px] w-full items-center gap-1 rounded px-1.5 text-[11px] ${
Comment thread
macroscopeapp[bot] marked this conversation as resolved.
Outdated
isGroupActive
? "bg-accent/70 text-foreground"
: "text-muted-foreground hover:bg-accent/50 hover:text-foreground"
? "bg-accent/50 text-foreground"
: "text-muted-foreground hover:bg-accent/40 hover:text-foreground"
}`}
onClick={() => onActiveTerminalChange(groupActiveTerminalId)}
>
Group {groupIndex + 1}
<GroupIcon className="size-3 shrink-0" />
<span className="min-w-0 flex-1 truncate text-left">{groupLabel}</span>
<span className="text-muted-foreground/70 text-[10px] tabular-nums">
{terminalCount}
</span>
</button>
)}

<div
className={showGroupHeaders ? "ml-1 border-l border-border/60 pl-1.5" : ""}
>
<div className="flex flex-col gap-0.5">
{terminalGroup.terminalIds.map((terminalId) => {
const isActive = terminalId === resolvedActiveTerminalId;
const closeTerminalLabel = `Close ${
terminalLabelById.get(terminalId) ?? "terminal"
}${isActive && closeShortcutLabel ? ` (${closeShortcutLabel})` : ""}`;
const terminalLabel = terminalLabelById.get(terminalId) ?? "Terminal";
const closeTerminalLabel = `Close ${terminalLabel}${
isActive && closeShortcutLabel ? ` (${closeShortcutLabel})` : ""
}`;
return (
<div
key={terminalId}
className={`group flex items-center gap-1 rounded px-1 py-0.5 text-[11px] ${
className={cn(
"group/tab flex h-6 w-full items-center gap-0.5 rounded-md pr-2 pl-1.5 text-xs",
isActive
? "bg-accent text-foreground"
: "text-muted-foreground hover:bg-accent/50 hover:text-foreground"
}`}
>
{showGroupHeaders && (
<span className="text-[10px] text-muted-foreground/80">└</span>
: "text-muted-foreground hover:bg-accent/60 hover:text-foreground",
)}
>
<button
type="button"
className="flex min-w-0 flex-1 items-center gap-1 text-left"
className="group/close relative flex size-4 shrink-0 cursor-pointer items-center justify-center rounded-sm hover:bg-muted"
aria-label={closeTerminalLabel}
onClick={() => confirmCloseTerminal(terminalId)}
>
<TerminalSquare className="size-3 shrink-0 group-hover/tab:hidden group-focus-visible/close:hidden" />
<XIcon className="hidden size-3 group-hover/tab:block group-focus-visible/close:block" />
</button>
Comment thread
macroscopeapp[bot] marked this conversation as resolved.
Outdated
<button
type="button"
className="flex min-w-0 flex-1 cursor-pointer items-center gap-1 text-left"
onClick={() => onActiveTerminalChange(terminalId)}
>
<TerminalSquare className="size-3 shrink-0" />
<span className="truncate">
{terminalLabelById.get(terminalId) ?? "Terminal"}
</span>
<span className="truncate">{terminalLabel}</span>
</button>
{normalizedTerminalIds.length > 1 && (
<Popover>
<PopoverTrigger
openOnHover
render={
<button
type="button"
className="inline-flex size-3.5 items-center justify-center rounded text-xs font-medium leading-none text-muted-foreground opacity-0 transition hover:bg-accent hover:text-foreground group-hover:opacity-100"
onClick={() => confirmCloseTerminal(terminalId)}
aria-label={closeTerminalLabel}
/>
}
>
<XIcon className="size-2.5" />
</PopoverTrigger>
<PopoverPopup
tooltipStyle
side="bottom"
sideOffset={6}
align="center"
className="pointer-events-none select-none"
>
{closeTerminalLabel}
</PopoverPopup>
</Popover>
)}
</div>
);
})}
Expand Down
Loading