Skip to content

Commit d7abd7f

Browse files
authored
feat(web): refresh workspace layouts and tool activity
1 parent 57a299a commit d7abd7f

52 files changed

Lines changed: 3228 additions & 1727 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/desktop/src/electron/ElectronMenu.test.ts‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ describe("ElectronMenu", () => {
9898
const electronMenu = yield* ElectronMenu.ElectronMenu;
9999
const selectedItemId = yield* electronMenu.showContextMenu({
100100
window: makeWindow(2),
101-
items: [{ id: "copy", label: "Copy" }],
101+
items: [
102+
{ id: "copy", label: "Copy" },
103+
{ id: "delete", label: "Delete", destructive: true, separatorBefore: true },
104+
],
102105
position: Option.some({ x: 10.8, y: 20.2 }),
103106
});
104107

@@ -110,6 +113,12 @@ describe("ElectronMenu", () => {
110113
enabled: true,
111114
click: buildFromTemplateMock.mock.calls[0]?.[0][0].click,
112115
});
116+
assert.deepEqual(
117+
buildFromTemplateMock.mock.calls[0]?.[0].map(
118+
(item: Electron.MenuItemConstructorOptions) => item.type ?? item.label,
119+
),
120+
["Copy", "separator", "Delete"],
121+
);
113122
}).pipe(Effect.provide(TestLayer)),
114123
);
115124

‎apps/desktop/src/electron/ElectronMenu.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ function normalizeContextMenuItems(source: readonly ContextMenuItem[]): ContextM
7878
label: sourceItem.label,
7979
destructive: sourceItem.destructive === true,
8080
disabled: sourceItem.disabled === true,
81+
...(sourceItem.separatorBefore === true ? { separatorBefore: true } : {}),
8182
};
8283

8384
if (sourceItem.children) {
@@ -141,10 +142,17 @@ export const make = Effect.gen(function* () {
141142
): Electron.MenuItemConstructorOptions[] => {
142143
const template: Electron.MenuItemConstructorOptions[] = [];
143144
let hasInsertedDestructiveSeparator = false;
145+
const appendSeparator = () => {
146+
if (template.length === 0 || template.at(-1)?.type === "separator") return;
147+
template.push({ type: "separator" });
148+
};
144149

145150
for (const item of entries) {
151+
if (item.separatorBefore) {
152+
appendSeparator();
153+
}
146154
if (item.destructive && !hasInsertedDestructiveSeparator && template.length > 0) {
147-
template.push({ type: "separator" });
155+
appendSeparator();
148156
hasInsertedDestructiveSeparator = true;
149157
}
150158

‎apps/server/src/orchestration/ActivityPayloadProjection.test.ts‎

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function activity(payload: Record<string, unknown>): OrchestrationThreadActivity
2020
* If slimming ever moves to an allowlist over the whole payload, these
2121
* assertions are the tripwire.
2222
*/
23-
describe("projectActivityPayload agent-field survival", () => {
23+
describe("projectActivityPayload", () => {
2424
it("preserves tool attribution (agentId/parentToolUseId) through data slimming", () => {
2525
const projected = projectActivityPayload(
2626
activity({
@@ -44,6 +44,45 @@ describe("projectActivityPayload agent-field survival", () => {
4444
expect(data.somethingClientNeverReads).toBeUndefined();
4545
});
4646

47+
it("normalizes Claude and OpenCode command inputs before slimming provider data", () => {
48+
const claude = projectActivityPayload(
49+
activity({
50+
itemType: "command_execution",
51+
toolCallId: "claude-call-1",
52+
data: {
53+
toolName: "Bash",
54+
input: { command: "vp test run" },
55+
result: { content: "x".repeat(5_000) },
56+
},
57+
}),
58+
);
59+
const openCode = projectActivityPayload(
60+
activity({
61+
itemType: "command_execution",
62+
toolCallId: "opencode-call-1",
63+
data: {
64+
tool: "bash",
65+
state: {
66+
status: "running",
67+
input: { command: "vp lint" },
68+
output: "x".repeat(5_000),
69+
},
70+
},
71+
}),
72+
);
73+
74+
expect(claude.payload).toMatchObject({
75+
toolCallId: "claude-call-1",
76+
data: { command: "vp test run" },
77+
});
78+
expect(openCode.payload).toMatchObject({
79+
toolCallId: "opencode-call-1",
80+
data: { command: "vp lint" },
81+
});
82+
expect(JSON.stringify(claude.payload).length).toBeLessThan(200);
83+
expect(JSON.stringify(openCode.payload).length).toBeLessThan(200);
84+
});
85+
4786
it("slims Codex-shaped mcp_tool_call items to rendered fields plus a result summary", () => {
4887
const projected = projectActivityPayload(
4988
activity({

‎apps/server/src/orchestration/ActivityPayloadProjection.ts‎

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,24 @@ function projectCommandData(data: Record<string, unknown>): Record<string, unkno
104104
return Object.keys(projectedItem).length > 0 ? projectedItem : undefined;
105105
}
106106

107+
function projectCommandValue(data: Record<string, unknown>): unknown {
108+
if (data.command !== undefined) {
109+
return data.command;
110+
}
111+
112+
const input = asRecord(data.input);
113+
if (input?.command !== undefined) {
114+
return input.command;
115+
}
116+
117+
const stateInput = asRecord(asRecord(data.state)?.input);
118+
if (stateInput?.command !== undefined) {
119+
return stateInput.command;
120+
}
121+
122+
return undefined;
123+
}
124+
107125
function summarizeToolTextOutput(value: string): string | null {
108126
const lines: string[] = [];
109127
for (const rawLine of value.split(/\r?\n/u)) {
@@ -287,8 +305,9 @@ export function projectActivityPayload(
287305
if (item) {
288306
projectedData.item = item;
289307
}
290-
if ("command" in data) {
291-
projectedData.command = data.command;
308+
const command = projectCommandValue(data);
309+
if (command !== undefined) {
310+
projectedData.command = command;
292311
}
293312

294313
const changedFiles: string[] = [];
@@ -368,18 +387,19 @@ function dropStaleContextWindowActivities(
368387
/**
369388
* Identity both clients use to fold a tool lifecycle row into the call it
370389
* belongs to (`deriveToolLifecycleCollapseKey` in web's `session-logic` and
371-
* mobile's `threadActivity`): an explicit `data.toolCallId` when the adapter
372-
* emits one, otherwise the itemType/title/detail triple. Returns null for rows
373-
* with no identity at all — those never collapse on the client either, so they
374-
* must not be dropped here.
390+
* mobile's `threadActivity`): the runtime item id ingestion stamps as
391+
* `toolCallId`, a legacy `data.toolCallId`, or the itemType/title/detail triple.
392+
* Returns null for rows with no identity at all — those never collapse on the
393+
* client either, so they must not be dropped here.
375394
*/
376395
function toolLifecycleIdentity(activity: OrchestrationThreadActivity): string | null {
377396
const payload = asRecord(activity.payload);
378397
if (!payload) {
379398
return null;
380399
}
381400

382-
const toolCallId = asTrimmedString(asRecord(payload.data)?.toolCallId);
401+
const toolCallId =
402+
asTrimmedString(payload.toolCallId) ?? asTrimmedString(asRecord(payload.data)?.toolCallId);
383403
if (toolCallId) {
384404
return `id:${toolCallId}`;
385405
}

‎apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.test.ts‎

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2811,11 +2811,16 @@ describe("ProviderRuntimeIngestion", () => {
28112811
createdAt: now,
28122812
threadId: asThreadId("thread-1"),
28132813
turnId: asTurnId("turn-9"),
2814+
itemId: asItemId("tool-call-9"),
28142815
payload: {
28152816
itemType: "command_execution",
2816-
status: "in_progress",
2817-
title: "Read file",
2818-
detail: "/tmp/file.ts",
2817+
status: "inProgress",
2818+
title: "Command run",
2819+
detail: "Bash: vp test run",
2820+
data: {
2821+
toolName: "Bash",
2822+
input: { command: "vp test run" },
2823+
},
28192824
},
28202825
});
28212826

@@ -2830,11 +2835,20 @@ describe("ProviderRuntimeIngestion", () => {
28302835
);
28312836

28322837
expect(thread.session?.status).toBe("ready");
2833-
expect(
2834-
thread.activities.some(
2835-
(activity: ProviderRuntimeTestActivity) => activity.kind === "tool.started",
2836-
),
2837-
).toBe(true);
2838+
const activity = thread.activities.find(
2839+
(entry: ProviderRuntimeTestActivity) => entry.kind === "tool.started",
2840+
);
2841+
const payload = activity?.payload as Record<string, unknown> | undefined;
2842+
expect(payload).toMatchObject({
2843+
itemType: "command_execution",
2844+
toolCallId: "tool-call-9",
2845+
status: "inProgress",
2846+
detail: "Bash: vp test run",
2847+
data: {
2848+
toolName: "Bash",
2849+
input: { command: "vp test run" },
2850+
},
2851+
});
28382852
});
28392853

28402854
it("consumes P1 runtime events into thread metadata, diff checkpoints, and activities", async () => {

‎apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,7 @@ export function runtimeEventToActivities(
794794
summary: event.payload.title ?? "Tool updated",
795795
payload: {
796796
itemType: event.payload.itemType,
797+
...(event.itemId !== undefined ? { toolCallId: event.itemId } : {}),
797798
...(event.payload.status ? { status: event.payload.status } : {}),
798799
...(event.payload.detail ? { detail: truncateDetail(event.payload.detail) } : {}),
799800
...(event.payload.data !== undefined ? { data: event.payload.data } : {}),
@@ -821,6 +822,8 @@ export function runtimeEventToActivities(
821822
summary: event.payload.title ?? "Tool",
822823
payload: {
823824
itemType: event.payload.itemType,
825+
...(event.itemId !== undefined ? { toolCallId: event.itemId } : {}),
826+
...(event.payload.status ? { status: event.payload.status } : {}),
824827
...(event.payload.detail ? { detail: truncateDetail(event.payload.detail) } : {}),
825828
...(event.payload.data !== undefined ? { data: event.payload.data } : {}),
826829
...(event.payload.agentId ? { agentId: event.payload.agentId } : {}),
@@ -847,7 +850,10 @@ export function runtimeEventToActivities(
847850
summary: `${event.payload.title ?? "Tool"} started`,
848851
payload: {
849852
itemType: event.payload.itemType,
853+
...(event.itemId !== undefined ? { toolCallId: event.itemId } : {}),
854+
...(event.payload.status ? { status: event.payload.status } : {}),
850855
...(event.payload.detail ? { detail: truncateDetail(event.payload.detail) } : {}),
856+
...(event.payload.data !== undefined ? { data: event.payload.data } : {}),
851857
...(event.payload.agentId ? { agentId: event.payload.agentId } : {}),
852858
...(event.payload.parentToolUseId
853859
? { parentToolUseId: event.payload.parentToolUseId }

‎apps/web/src/components/ChatView.tsx‎

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ import {
167167
WifiOffIcon,
168168
} from "lucide-react";
169169
import { cn, randomHex } from "~/lib/utils";
170-
import { COLLAPSED_SIDEBAR_TITLEBAR_INSET_CLASS } from "~/workspaceTitlebar";
171170
import { stackedThreadToast, toastManager } from "./ui/toast";
172171
import { decodeProjectScriptKeybindingRule } from "~/lib/projectScriptKeybindings";
173172
import { type NewProjectScriptInput } from "./ProjectScriptsControl";
@@ -220,7 +219,11 @@ import {
220219
import { appendPreviewAnnotationPrompt } from "../lib/previewAnnotation";
221220
import { appendReviewCommentsToPrompt, type ReviewCommentContext } from "../reviewCommentContext";
222221
import { environmentCatalog } from "../connection/catalog";
223-
import { selectThreadTerminalUiState, useTerminalUiStateStore } from "../terminalUiStateStore";
222+
import {
223+
selectThreadTerminalCustomLabels,
224+
selectThreadTerminalUiState,
225+
useTerminalUiStateStore,
226+
} from "../terminalUiStateStore";
224227
import { useKnownTerminalSessions, useThreadRunningTerminalIds } from "../state/terminalSessions";
225228
import { projectEnvironment } from "../state/projects";
226229
import { useEnvironmentQuery } from "../state/query";
@@ -256,6 +259,7 @@ import { ChatHeader } from "./chat/ChatHeader";
256259
import { PanelLayoutControls, RightPanelMaximizeControl } from "./chat/PanelLayoutControls";
257260
import { type ExpandedImagePreview } from "./chat/ExpandedImagePreview";
258261
import { NoActiveThreadState } from "./NoActiveThreadState";
262+
import { WorkspacePageHeader } from "./WorkspacePageContainer";
259263
import {
260264
resolveEffectiveEnvMode,
261265
resolveLocalCheckoutBranchMismatch,
@@ -653,6 +657,7 @@ interface PersistentThreadTerminalDrawerProps {
653657
newShortcutLabel: string | undefined;
654658
closeShortcutLabel: string | undefined;
655659
keybindings: ResolvedKeybindingsConfig;
660+
onHide: () => void;
656661
onAddTerminalContext: (selection: TerminalContextSelection) => void;
657662
}
658663

@@ -667,6 +672,7 @@ const PersistentThreadTerminalDrawer = memo(function PersistentThreadTerminalDra
667672
newShortcutLabel,
668673
closeShortcutLabel,
669674
keybindings,
675+
onHide,
670676
onAddTerminalContext,
671677
}: PersistentThreadTerminalDrawerProps) {
672678
const openTerminal = useAtomCommand(terminalEnvironment.open, "terminal open");
@@ -990,6 +996,7 @@ const PersistentThreadTerminalDrawer = memo(function PersistentThreadTerminalDra
990996
onSplitTerminal={splitTerminal}
991997
onSplitTerminalVertical={splitTerminalVertical}
992998
onNewTerminal={createNewTerminal}
999+
onHide={onHide}
9931000
splitShortcutLabel={visible ? splitShortcutLabel : undefined}
9941001
splitVerticalShortcutLabel={visible ? splitVerticalShortcutLabel : undefined}
9951002
newShortcutLabel={visible ? newShortcutLabel : undefined}
@@ -1540,6 +1547,16 @@ function ChatViewContent(props: ChatViewProps) {
15401547
const canCheckoutPullRequestIntoThread = isLocalDraftThread;
15411548
const activeThreadId = activeThread?.id ?? null;
15421549
const activeThreadEnvironmentId = activeThread?.environmentId ?? null;
1550+
const activeThreadRef = useMemo(
1551+
() =>
1552+
activeThreadEnvironmentId && activeThreadId
1553+
? scopeThreadRef(activeThreadEnvironmentId, activeThreadId)
1554+
: null,
1555+
[activeThreadEnvironmentId, activeThreadId],
1556+
);
1557+
const activeTerminalCustomLabels = useTerminalUiStateStore((state) =>
1558+
selectThreadTerminalCustomLabels(state.terminalCustomLabelsByThreadKey, activeThreadRef),
1559+
);
15431560
const runningTerminalIds = useThreadRunningTerminalIds({
15441561
environmentId: activeThread?.environmentId ?? null,
15451562
threadId: activeThreadId,
@@ -1569,18 +1586,15 @@ function ChatViewContent(props: ChatViewProps) {
15691586
for (const session of activeThreadKnownSessions) {
15701587
labels.set(
15711588
session.target.terminalId,
1572-
resolveTerminalSessionLabel(session.target.terminalId, session.state.summary),
1589+
activeTerminalCustomLabels[session.target.terminalId] ??
1590+
resolveTerminalSessionLabel(session.target.terminalId, session.state.summary),
15731591
);
15741592
}
1593+
for (const [terminalId, label] of Object.entries(activeTerminalCustomLabels)) {
1594+
if (!labels.has(terminalId)) labels.set(terminalId, label);
1595+
}
15751596
return labels;
1576-
}, [activeThreadKnownSessions]);
1577-
const activeThreadRef = useMemo(
1578-
() =>
1579-
activeThreadEnvironmentId && activeThreadId
1580-
? scopeThreadRef(activeThreadEnvironmentId, activeThreadId)
1581-
: null,
1582-
[activeThreadEnvironmentId, activeThreadId],
1583-
);
1597+
}, [activeTerminalCustomLabels, activeThreadKnownSessions]);
15841598
const activeThreadKey = activeThreadRef ? scopedThreadKey(activeThreadRef) : null;
15851599
const [timelineAnchor, setTimelineAnchor] = useState<{
15861600
readonly threadKey: string | null;
@@ -2808,6 +2822,7 @@ function ChatViewContent(props: ChatViewProps) {
28082822
},
28092823
[activeThreadRef, storeSetTerminalOpen],
28102824
);
2825+
const hideTerminal = useCallback(() => setTerminalOpen(false), [setTerminalOpen]);
28112826
const toggleTerminalVisibility = useCallback(() => {
28122827
if (!activeThreadRef) return;
28132828
const nextOpen = !terminalUiState.terminalOpen;
@@ -6114,7 +6129,6 @@ function ChatViewContent(props: ChatViewProps) {
61146129
? "thread"
61156130
: "page"
61166131
}
6117-
chromeVariant="collapse"
61186132
composerDraftTarget={composerDraftTarget}
61196133
onStateChange={handlePullRequestTabStatusChange}
61206134
/>
@@ -6160,20 +6174,11 @@ function ChatViewContent(props: ChatViewProps) {
61606174
data-chat-column-maximized-away={rightPanelMaximized ? "true" : "false"}
61616175
>
61626176
{/* Top bar */}
6163-
<header
6177+
<WorkspacePageHeader
61646178
data-chat-header
6165-
className={cn(
6166-
"bg-background transition-[padding-left] duration-200 ease-linear motion-reduce:transition-none",
6167-
isElectron
6168-
? cn(
6169-
"drag-region relative flex h-[var(--workspace-topbar-height)] min-h-[var(--workspace-topbar-height)] shrink-0 items-center px-3 sm:px-5",
6170-
reserveTitleBarControlInset &&
6171-
!inlineRightPanelOwnsTitleBar &&
6172-
"wco:pr-[var(--workspace-native-controls-inset)]",
6173-
)
6174-
: "flex h-[var(--workspace-topbar-height)] min-h-[var(--workspace-topbar-height)] shrink-0 items-center pl-[calc(env(safe-area-inset-left)+0.75rem)] pr-[calc(env(safe-area-inset-right)+0.75rem)] sm:pl-[calc(env(safe-area-inset-left)+1.25rem)] sm:pr-[calc(env(safe-area-inset-right)+1.25rem)]",
6175-
COLLAPSED_SIDEBAR_TITLEBAR_INSET_CLASS,
6176-
)}
6179+
electron={isElectron}
6180+
reserveNativeControls={reserveTitleBarControlInset && !inlineRightPanelOwnsTitleBar}
6181+
className="relative bg-background"
61776182
>
61786183
{!rightPanelOpen ? panelLayoutControls : null}
61796184
<ChatHeader
@@ -6204,7 +6209,7 @@ function ChatViewContent(props: ChatViewProps) {
62046209
onUpdateProjectScript={updateProjectScript}
62056210
onDeleteProjectScript={deleteProjectScript}
62066211
/>
6207-
</header>
6212+
</WorkspacePageHeader>
62086213

62096214
<ThreadErrorBanner
62106215
error={visibleThreadError}
@@ -6542,6 +6547,7 @@ function ChatViewContent(props: ChatViewProps) {
65426547
newShortcutLabel={newTerminalShortcutLabel ?? undefined}
65436548
closeShortcutLabel={closeTerminalShortcutLabel ?? undefined}
65446549
keybindings={keybindings}
6550+
onHide={hideTerminal}
65456551
onAddTerminalContext={addTerminalContextToDraft}
65466552
/>
65476553
))}

0 commit comments

Comments
 (0)