@stigmer/react 3.1.4 → 3.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/execution/FileReviewContext.d.ts +15 -1
- package/execution/FileReviewContext.d.ts.map +1 -1
- package/execution/FileReviewContext.js +20 -1
- package/execution/FileReviewContext.js.map +1 -1
- package/execution/MessageThread.d.ts +65 -2
- package/execution/MessageThread.d.ts.map +1 -1
- package/execution/MessageThread.js +42 -23
- package/execution/MessageThread.js.map +1 -1
- package/execution/TodoCard.d.ts +8 -0
- package/execution/TodoCard.d.ts.map +1 -1
- package/execution/TodoCard.js +6 -4
- package/execution/TodoCard.js.map +1 -1
- package/execution/TodoList.d.ts +20 -1
- package/execution/TodoList.d.ts.map +1 -1
- package/execution/TodoList.js +9 -6
- package/execution/TodoList.js.map +1 -1
- package/execution/ToolCallDetail.d.ts +3 -2
- package/execution/ToolCallDetail.d.ts.map +1 -1
- package/execution/ToolCallDetail.js +49 -16
- package/execution/ToolCallDetail.js.map +1 -1
- package/execution/WriteBackCard.d.ts +7 -1
- package/execution/WriteBackCard.d.ts.map +1 -1
- package/execution/WriteBackCard.js +10 -2
- package/execution/WriteBackCard.js.map +1 -1
- package/execution/file-review-status.d.ts +15 -0
- package/execution/file-review-status.d.ts.map +1 -1
- package/execution/file-review-status.js +22 -0
- package/execution/file-review-status.js.map +1 -1
- package/execution/index.d.ts +5 -5
- package/execution/index.d.ts.map +1 -1
- package/execution/index.js +3 -3
- package/execution/index.js.map +1 -1
- package/github/useGitHubFileReader.d.ts +4 -2
- package/github/useGitHubFileReader.d.ts.map +1 -1
- package/github/useGitHubFileReader.js +16 -3
- package/github/useGitHubFileReader.js.map +1 -1
- package/github/useGitHubTreeLister.d.ts +2 -1
- package/github/useGitHubTreeLister.d.ts.map +1 -1
- package/github/useGitHubTreeLister.js +7 -3
- package/github/useGitHubTreeLister.js.map +1 -1
- package/index.d.ts +3 -3
- package/index.d.ts.map +1 -1
- package/index.js +3 -3
- package/index.js.map +1 -1
- package/internal/VirtualizedThread.d.ts +3 -2
- package/internal/VirtualizedThread.d.ts.map +1 -1
- package/internal/VirtualizedThread.js +3 -2
- package/internal/VirtualizedThread.js.map +1 -1
- package/package.json +4 -4
- package/session/SessionViewer.d.ts +11 -1
- package/session/SessionViewer.d.ts.map +1 -1
- package/session/SessionViewer.js +24 -5
- package/session/SessionViewer.js.map +1 -1
- package/session/facets/ChangesTab.d.ts +24 -6
- package/session/facets/ChangesTab.d.ts.map +1 -1
- package/session/facets/ChangesTab.js +15 -6
- package/session/facets/ChangesTab.js.map +1 -1
- package/session/index.d.ts +1 -0
- package/session/index.d.ts.map +1 -1
- package/session/index.js +1 -0
- package/session/index.js.map +1 -1
- package/session/useSessionRailViews.d.ts +16 -1
- package/session/useSessionRailViews.d.ts.map +1 -1
- package/session/useSessionRailViews.js +9 -4
- package/session/useSessionRailViews.js.map +1 -1
- package/session/useWorkspaceReadRefs.d.ts +45 -0
- package/session/useWorkspaceReadRefs.d.ts.map +1 -0
- package/session/useWorkspaceReadRefs.js +104 -0
- package/session/useWorkspaceReadRefs.js.map +1 -0
- package/src/execution/FileReviewContext.ts +27 -1
- package/src/execution/MessageThread.tsx +110 -22
- package/src/execution/TodoCard.tsx +20 -4
- package/src/execution/TodoList.tsx +26 -4
- package/src/execution/ToolCallDetail.tsx +69 -16
- package/src/execution/WriteBackCard.tsx +18 -4
- package/src/execution/__tests__/ToolCallDetail.test.tsx +188 -2
- package/src/execution/__tests__/WriteBackCard.test.tsx +83 -0
- package/src/execution/__tests__/file-review-status.test.ts +47 -0
- package/src/execution/__tests__/message-thread-slots.test.tsx +463 -0
- package/src/execution/file-review-status.ts +24 -0
- package/src/execution/index.ts +13 -3
- package/src/github/__tests__/useGitHubFileReader.test.ts +35 -2
- package/src/github/__tests__/useGitHubTreeLister.test.ts +14 -0
- package/src/github/useGitHubFileReader.ts +19 -6
- package/src/github/useGitHubTreeLister.ts +7 -3
- package/src/index.ts +4 -0
- package/src/internal/VirtualizedThread.tsx +5 -1
- package/src/session/SessionViewer.tsx +42 -2
- package/src/session/__tests__/useSessionRailViews.test.tsx +12 -0
- package/src/session/__tests__/useWorkspaceReadRefs.test.ts +245 -0
- package/src/session/facets/ChangesTab.tsx +43 -6
- package/src/session/facets/__tests__/ChangesTab.test.tsx +23 -0
- package/src/session/index.ts +2 -0
- package/src/session/useSessionRailViews.tsx +31 -3
- package/src/session/useWorkspaceReadRefs.ts +118 -0
- package/src/workflow/picker/__tests__/recents.test.ts +4 -4
- package/src/workspace/FileViewer.tsx +144 -38
- package/src/workspace/WorkspaceFileReader.ts +21 -0
- package/src/workspace/__tests__/FileViewer.test.tsx +138 -3
- package/src/workspace/__tests__/useWorkspaceFileContent.test.tsx +20 -0
- package/src/workspace/__tests__/workspaceListingCache.test.ts +114 -0
- package/src/workspace/index.ts +4 -1
- package/src/workspace/useWorkspaceEntries.ts +11 -0
- package/src/workspace/useWorkspaceFileContent.ts +4 -1
- package/src/workspace/useWorkspaceFileSearch.ts +8 -3
- package/src/workspace/useWorkspaceFiles.ts +3 -2
- package/src/workspace/workspaceListingCache.ts +21 -7
- package/styles.css +1 -1
- package/workspace/FileViewer.d.ts +1 -1
- package/workspace/FileViewer.d.ts.map +1 -1
- package/workspace/FileViewer.js +55 -5
- package/workspace/FileViewer.js.map +1 -1
- package/workspace/WorkspaceFileReader.d.ts +17 -0
- package/workspace/WorkspaceFileReader.d.ts.map +1 -1
- package/workspace/WorkspaceFileReader.js +18 -0
- package/workspace/WorkspaceFileReader.js.map +1 -1
- package/workspace/index.d.ts +1 -1
- package/workspace/index.d.ts.map +1 -1
- package/workspace/index.js +1 -1
- package/workspace/index.js.map +1 -1
- package/workspace/useWorkspaceEntries.d.ts +11 -0
- package/workspace/useWorkspaceEntries.d.ts.map +1 -1
- package/workspace/useWorkspaceEntries.js.map +1 -1
- package/workspace/useWorkspaceFileContent.d.ts.map +1 -1
- package/workspace/useWorkspaceFileContent.js +4 -1
- package/workspace/useWorkspaceFileContent.js.map +1 -1
- package/workspace/useWorkspaceFileSearch.d.ts.map +1 -1
- package/workspace/useWorkspaceFileSearch.js +8 -3
- package/workspace/useWorkspaceFileSearch.js.map +1 -1
- package/workspace/useWorkspaceFiles.d.ts +2 -1
- package/workspace/useWorkspaceFiles.d.ts.map +1 -1
- package/workspace/useWorkspaceFiles.js +3 -2
- package/workspace/useWorkspaceFiles.js.map +1 -1
- package/workspace/workspaceListingCache.d.ts +1 -1
- package/workspace/workspaceListingCache.d.ts.map +1 -1
- package/workspace/workspaceListingCache.js +20 -7
- package/workspace/workspaceListingCache.js.map +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { lazy, memo, Suspense, useCallback, useMemo, useState } from "react";
|
|
3
|
+
import { lazy, memo, Suspense, useCallback, useMemo, useState, type ComponentType } from "react";
|
|
4
4
|
import { create } from "@bufbuild/protobuf";
|
|
5
5
|
import type { AgentExecution } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/api_pb";
|
|
6
6
|
import type { AgentMessage, ToolCall } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/message_pb";
|
|
@@ -21,18 +21,19 @@ import type { WorkspaceEntry } from "@stigmer/protos/ai/stigmer/agentic/session/
|
|
|
21
21
|
import { displayFileChangeSets } from "@stigmer/sdk";
|
|
22
22
|
import { cn } from "@stigmer/theme";
|
|
23
23
|
import { isTerminalPhase } from "./execution-phases.js";
|
|
24
|
-
import { MessageEntry } from "./MessageEntry.js";
|
|
24
|
+
import { MessageEntry, type MessageEntryProps } from "./MessageEntry.js";
|
|
25
25
|
import { ToolCallGroup } from "./ToolCallGroup.js";
|
|
26
26
|
import { SubAgentSection } from "./SubAgentSection.js";
|
|
27
27
|
import { ExecutionPhaseBadge } from "./ExecutionPhaseBadge.js";
|
|
28
|
-
import { SetupProgress } from "./SetupProgress.js";
|
|
29
|
-
import { ApprovalCard } from "./ApprovalCard.js";
|
|
28
|
+
import { SetupProgress, type SetupProgressProps } from "./SetupProgress.js";
|
|
29
|
+
import { ApprovalCard, type ApprovalCardProps } from "./ApprovalCard.js";
|
|
30
30
|
import { FileReviewCard } from "./FileReviewCard.js";
|
|
31
31
|
import { SummarizationCard } from "./SummarizationCard.js";
|
|
32
|
-
import { PlanCompletionCard } from "./PlanCompletionCard.js";
|
|
33
|
-
import { PlanArtifactCard } from "./PlanArtifactCard.js";
|
|
34
|
-
import { PlanStreamingCard } from "./PlanStreamingCard.js";
|
|
35
|
-
import { TodoCard } from "./TodoCard.js";
|
|
32
|
+
import { PlanCompletionCard, type PlanCompletionCardProps } from "./PlanCompletionCard.js";
|
|
33
|
+
import { PlanArtifactCard, type PlanArtifactCardProps } from "./PlanArtifactCard.js";
|
|
34
|
+
import { PlanStreamingCard, type PlanStreamingCardProps } from "./PlanStreamingCard.js";
|
|
35
|
+
import { TodoCard, type TodoCardProps } from "./TodoCard.js";
|
|
36
|
+
import type { TodoRowProps } from "./TodoList.js";
|
|
36
37
|
import { findPlanArtifact } from "../library/detect-plan-artifact.js";
|
|
37
38
|
import { findStreamingPlan } from "../library/detect-streaming-plan.js";
|
|
38
39
|
import type { SummarizationEventView } from "./useContextWindow.js";
|
|
@@ -63,6 +64,49 @@ const EMPTY_APPROVALS: readonly PendingApproval[] = [];
|
|
|
63
64
|
const EMPTY_SUBMITTING_IDS: ReadonlySet<string> = new Set();
|
|
64
65
|
const EMPTY_APPROVAL_ERRORS: ReadonlyMap<string, Error> = new Map();
|
|
65
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Component overrides for the chrome {@link MessageThread} renders — the
|
|
69
|
+
* adaptation surface for hosts whose design system needs different
|
|
70
|
+
* *structure*, not just different `--stgm-*` token values (stigmer#187).
|
|
71
|
+
*
|
|
72
|
+
* Each slot is keyed by the built-in component it replaces and receives
|
|
73
|
+
* exactly that component's exported props interface, so an override can
|
|
74
|
+
* always delegate to the built-in for the cases it does not customize
|
|
75
|
+
* (e.g. a `MessageEntry` slot that restyles `MESSAGE_HUMAN` bubbles and
|
|
76
|
+
* renders the default `MessageEntry` for everything else).
|
|
77
|
+
*
|
|
78
|
+
* Define slot components at module level (or memoize them). The thread's
|
|
79
|
+
* rows rely on `React.memo` + structural sharing to skip re-renders during
|
|
80
|
+
* streaming (DD-009/DD-010); a slot component recreated on every host
|
|
81
|
+
* render defeats that for its rows.
|
|
82
|
+
*/
|
|
83
|
+
export interface MessageThreadSlots {
|
|
84
|
+
/**
|
|
85
|
+
* All message bubbles — human, assistant, thinking, and system entries.
|
|
86
|
+
* Also wraps the failed-send bubble (the inline Retry chrome around it
|
|
87
|
+
* stays built-in).
|
|
88
|
+
*/
|
|
89
|
+
readonly MessageEntry?: ComponentType<MessageEntryProps>;
|
|
90
|
+
/** The HITL tool-approval gate card. */
|
|
91
|
+
readonly ApprovalCard?: ComponentType<ApprovalCardProps>;
|
|
92
|
+
/** The collapsible in-thread to-dos card. */
|
|
93
|
+
readonly TodoCard?: ComponentType<TodoCardProps>;
|
|
94
|
+
/**
|
|
95
|
+
* One to-do row inside the built-in {@link TodoCard}'s list. Ignored
|
|
96
|
+
* when `TodoCard` is also overridden (the replacement receives it via
|
|
97
|
+
* {@link TodoCardProps.TodoRow} and may forward or ignore it).
|
|
98
|
+
*/
|
|
99
|
+
readonly TodoRow?: ComponentType<TodoRowProps>;
|
|
100
|
+
/** Completed Plan turn that published a plan artifact. */
|
|
101
|
+
readonly PlanArtifactCard?: ComponentType<PlanArtifactCardProps>;
|
|
102
|
+
/** Completed Plan turn without an artifact — the bare Implement CTA. */
|
|
103
|
+
readonly PlanCompletionCard?: ComponentType<PlanCompletionCardProps>;
|
|
104
|
+
/** Live stand-in card while a Plan turn is writing its document. */
|
|
105
|
+
readonly PlanStreamingCard?: ComponentType<PlanStreamingCardProps>;
|
|
106
|
+
/** Pre-first-token setup / "Thinking…" indicator. */
|
|
107
|
+
readonly SetupProgress?: ComponentType<SetupProgressProps>;
|
|
108
|
+
}
|
|
109
|
+
|
|
66
110
|
/** Props for {@link MessageThread}. */
|
|
67
111
|
export interface MessageThreadProps {
|
|
68
112
|
/** Completed executions in chronological order. */
|
|
@@ -261,6 +305,12 @@ export interface MessageThreadProps {
|
|
|
261
305
|
* existing consumers see no layout change.
|
|
262
306
|
*/
|
|
263
307
|
readonly contentColumn?: ThreadContentColumn;
|
|
308
|
+
/**
|
|
309
|
+
* Component overrides for the thread's chrome — see
|
|
310
|
+
* {@link MessageThreadSlots}. Omitted slots render the built-ins;
|
|
311
|
+
* omitting the prop entirely changes nothing (DD-011).
|
|
312
|
+
*/
|
|
313
|
+
readonly slots?: MessageThreadSlots;
|
|
264
314
|
}
|
|
265
315
|
|
|
266
316
|
/** Reading-column alignment for {@link MessageThread} content. */
|
|
@@ -1020,6 +1070,7 @@ export function MessageThread({
|
|
|
1020
1070
|
planActionsDisabled,
|
|
1021
1071
|
planBuildPending,
|
|
1022
1072
|
contentColumn,
|
|
1073
|
+
slots,
|
|
1023
1074
|
}: MessageThreadProps) {
|
|
1024
1075
|
useRenderTracer("MessageThread", { executions, activeStreamExecution });
|
|
1025
1076
|
|
|
@@ -1124,6 +1175,7 @@ export function MessageThread({
|
|
|
1124
1175
|
onRetrySend={onRetrySend}
|
|
1125
1176
|
onRetryExecution={onRetryExecution}
|
|
1126
1177
|
onEditMessage={onEditMessage}
|
|
1178
|
+
slots={slots}
|
|
1127
1179
|
/>
|
|
1128
1180
|
</Suspense>
|
|
1129
1181
|
</div>
|
|
@@ -1152,6 +1204,7 @@ export function MessageThread({
|
|
|
1152
1204
|
onRetrySend={onRetrySend}
|
|
1153
1205
|
onRetryExecution={onRetryExecution}
|
|
1154
1206
|
onEditMessage={onEditMessage}
|
|
1207
|
+
slots={slots}
|
|
1155
1208
|
/>
|
|
1156
1209
|
);
|
|
1157
1210
|
}
|
|
@@ -1186,6 +1239,7 @@ interface NonVirtualizedThreadProps {
|
|
|
1186
1239
|
readonly onRetrySend?: () => void;
|
|
1187
1240
|
readonly onRetryExecution?: (message: string) => void;
|
|
1188
1241
|
readonly onEditMessage?: (text: string) => void;
|
|
1242
|
+
readonly slots?: MessageThreadSlots;
|
|
1189
1243
|
}
|
|
1190
1244
|
|
|
1191
1245
|
function NonVirtualizedThread({
|
|
@@ -1209,6 +1263,7 @@ function NonVirtualizedThread({
|
|
|
1209
1263
|
onRetrySend,
|
|
1210
1264
|
onRetryExecution,
|
|
1211
1265
|
onEditMessage,
|
|
1266
|
+
slots,
|
|
1212
1267
|
}: NonVirtualizedThreadProps) {
|
|
1213
1268
|
const { scrollRef, sentinelRef, contentRef, isFollowing, jumpToLatest } =
|
|
1214
1269
|
useAutoScroll();
|
|
@@ -1252,6 +1307,7 @@ function NonVirtualizedThread({
|
|
|
1252
1307
|
onRetrySend={onRetrySend}
|
|
1253
1308
|
onRetryExecution={onRetryExecution}
|
|
1254
1309
|
onEditMessage={onEditMessage}
|
|
1310
|
+
slots={slots}
|
|
1255
1311
|
/>
|
|
1256
1312
|
</ThreadItemWrapper>
|
|
1257
1313
|
))}
|
|
@@ -1307,6 +1363,7 @@ export interface ThreadItemRendererProps {
|
|
|
1307
1363
|
readonly onRetrySend?: () => void;
|
|
1308
1364
|
readonly onRetryExecution?: (message: string) => void;
|
|
1309
1365
|
readonly onEditMessage?: (text: string) => void;
|
|
1366
|
+
readonly slots?: MessageThreadSlots;
|
|
1310
1367
|
}
|
|
1311
1368
|
|
|
1312
1369
|
/**
|
|
@@ -1314,6 +1371,11 @@ export interface ThreadItemRendererProps {
|
|
|
1314
1371
|
* the non-virtualized `items.map()` path and the virtualized
|
|
1315
1372
|
* `Virtuoso.itemContent` callback.
|
|
1316
1373
|
*
|
|
1374
|
+
* Slot resolution happens here, per case, as `slots?.X ?? X` — no merged
|
|
1375
|
+
* defaults object, no allocation, and the memoized row wrappers below
|
|
1376
|
+
* (`ApprovalCardRow`, `FileReviewRecordRow`) keep their DD-010 callback
|
|
1377
|
+
* stabilization around whichever component renders inside them.
|
|
1378
|
+
*
|
|
1317
1379
|
* Does not receive a `key` prop — the caller is responsible for
|
|
1318
1380
|
* keying (either via `items.map` or `computeItemKey`).
|
|
1319
1381
|
*
|
|
@@ -1334,16 +1396,22 @@ export function ThreadItemRenderer({
|
|
|
1334
1396
|
onRetrySend,
|
|
1335
1397
|
onRetryExecution,
|
|
1336
1398
|
onEditMessage,
|
|
1399
|
+
slots,
|
|
1337
1400
|
}: ThreadItemRendererProps) {
|
|
1338
1401
|
switch (item.kind) {
|
|
1339
|
-
case "message":
|
|
1402
|
+
case "message": {
|
|
1403
|
+
const Entry = slots?.MessageEntry ?? MessageEntry;
|
|
1340
1404
|
if (item.isFailed) {
|
|
1341
1405
|
return (
|
|
1342
|
-
<FailedUserMessage
|
|
1406
|
+
<FailedUserMessage
|
|
1407
|
+
message={item.message}
|
|
1408
|
+
onRetry={onRetrySend}
|
|
1409
|
+
MessageEntryComponent={Entry}
|
|
1410
|
+
/>
|
|
1343
1411
|
);
|
|
1344
1412
|
}
|
|
1345
1413
|
return (
|
|
1346
|
-
<
|
|
1414
|
+
<Entry
|
|
1347
1415
|
message={item.message}
|
|
1348
1416
|
className={item.isPending ? "opacity-70" : undefined}
|
|
1349
1417
|
isPlanDocument={item.isPlanDocument}
|
|
@@ -1355,6 +1423,7 @@ export function ThreadItemRenderer({
|
|
|
1355
1423
|
}
|
|
1356
1424
|
/>
|
|
1357
1425
|
);
|
|
1426
|
+
}
|
|
1358
1427
|
case "tool-group":
|
|
1359
1428
|
return (
|
|
1360
1429
|
<ToolCallGroup
|
|
@@ -1392,30 +1461,37 @@ export function ThreadItemRenderer({
|
|
|
1392
1461
|
onApprovalSubmit={onApprovalSubmit!}
|
|
1393
1462
|
isSubmitting={submittingApprovalIds?.has(item.pendingApproval.toolCallId) ?? false}
|
|
1394
1463
|
error={approvalErrors?.get(item.pendingApproval.toolCallId) ?? null}
|
|
1464
|
+
ApprovalCardComponent={slots?.ApprovalCard ?? ApprovalCard}
|
|
1395
1465
|
/>
|
|
1396
1466
|
);
|
|
1397
1467
|
case "file-review-record":
|
|
1398
1468
|
return <FileReviewRecordRow fileChangeSet={item.fileChangeSet} />;
|
|
1399
|
-
case "setup-progress":
|
|
1469
|
+
case "setup-progress": {
|
|
1470
|
+
const Setup = slots?.SetupProgress ?? SetupProgress;
|
|
1400
1471
|
return (
|
|
1401
|
-
<
|
|
1472
|
+
<Setup
|
|
1402
1473
|
workspaceEntries={item.workspaceEntries}
|
|
1403
1474
|
serverPhase={item.serverPhase}
|
|
1404
1475
|
isAwaitingResponse={item.isAwaitingResponse}
|
|
1405
1476
|
/>
|
|
1406
1477
|
);
|
|
1478
|
+
}
|
|
1407
1479
|
case "context-compacted":
|
|
1408
1480
|
return <SummarizationCard event={item.event} />;
|
|
1409
|
-
case "todos":
|
|
1410
|
-
|
|
1411
|
-
|
|
1481
|
+
case "todos": {
|
|
1482
|
+
const Todos = slots?.TodoCard ?? TodoCard;
|
|
1483
|
+
return <Todos todos={item.todos} className="mx-4" TodoRow={slots?.TodoRow} />;
|
|
1484
|
+
}
|
|
1485
|
+
case "plan-completion": {
|
|
1412
1486
|
// When the plan was published as an artifact, show the richer reviewable
|
|
1413
1487
|
// card (preview / copy / download / implement). Otherwise fall back to the
|
|
1414
1488
|
// bare Implement CTA (older executions, or a plan that failed to publish).
|
|
1415
1489
|
// Only the latest plan receives the build action — a superseded plan's
|
|
1416
1490
|
// card is review-only, so a stale plan can never be implemented from it.
|
|
1491
|
+
const Artifact = slots?.PlanArtifactCard ?? PlanArtifactCard;
|
|
1492
|
+
const Completion = slots?.PlanCompletionCard ?? PlanCompletionCard;
|
|
1417
1493
|
return item.planArtifact && item.executionId ? (
|
|
1418
|
-
<
|
|
1494
|
+
<Artifact
|
|
1419
1495
|
executionId={item.executionId}
|
|
1420
1496
|
artifact={item.planArtifact}
|
|
1421
1497
|
title={item.planTitle}
|
|
@@ -1432,17 +1508,19 @@ export function ThreadItemRenderer({
|
|
|
1432
1508
|
buildPending={planBuildPending}
|
|
1433
1509
|
/>
|
|
1434
1510
|
) : (
|
|
1435
|
-
<
|
|
1511
|
+
<Completion
|
|
1436
1512
|
onImplement={item.isLatestPlan ? onBuildFromPlan : undefined}
|
|
1437
1513
|
disabled={planActionsDisabled}
|
|
1438
1514
|
/>
|
|
1439
1515
|
);
|
|
1440
|
-
|
|
1516
|
+
}
|
|
1517
|
+
case "plan-writing": {
|
|
1441
1518
|
// The live stand-in for a plan the active turn is writing. Emitted only
|
|
1442
1519
|
// when onOpenPlan is wired (see buildThreadItems' collapseStreamingPlan
|
|
1443
1520
|
// gate), so the action is always available in practice.
|
|
1521
|
+
const Streaming = slots?.PlanStreamingCard ?? PlanStreamingCard;
|
|
1444
1522
|
return (
|
|
1445
|
-
<
|
|
1523
|
+
<Streaming
|
|
1446
1524
|
title={item.planTitle}
|
|
1447
1525
|
sizeBytes={item.planSize}
|
|
1448
1526
|
onOpenPlan={
|
|
@@ -1450,6 +1528,7 @@ export function ThreadItemRenderer({
|
|
|
1450
1528
|
}
|
|
1451
1529
|
/>
|
|
1452
1530
|
);
|
|
1531
|
+
}
|
|
1453
1532
|
}
|
|
1454
1533
|
}
|
|
1455
1534
|
|
|
@@ -1462,17 +1541,22 @@ export function ThreadItemRenderer({
|
|
|
1462
1541
|
* (so the typed text is never lost) with an inline, actionable error beneath
|
|
1463
1542
|
* it. The error copy is intentionally short — the full reason is surfaced by
|
|
1464
1543
|
* the consumer's send-error banner; this is the in-thread "Retry" affordance.
|
|
1544
|
+
*
|
|
1545
|
+
* The bubble renders through the caller-resolved MessageEntry slot so an
|
|
1546
|
+
* overridden bubble style also applies to failed sends.
|
|
1465
1547
|
*/
|
|
1466
1548
|
function FailedUserMessage({
|
|
1467
1549
|
message,
|
|
1468
1550
|
onRetry,
|
|
1551
|
+
MessageEntryComponent,
|
|
1469
1552
|
}: {
|
|
1470
1553
|
message: AgentMessage;
|
|
1471
1554
|
onRetry?: () => void;
|
|
1555
|
+
MessageEntryComponent: ComponentType<MessageEntryProps>;
|
|
1472
1556
|
}) {
|
|
1473
1557
|
return (
|
|
1474
1558
|
<div className="flex flex-col gap-1">
|
|
1475
|
-
<
|
|
1559
|
+
<MessageEntryComponent message={message} />
|
|
1476
1560
|
<div
|
|
1477
1561
|
role="alert"
|
|
1478
1562
|
className="mx-4 flex items-center gap-2 text-xs text-destructive"
|
|
@@ -1587,6 +1671,9 @@ interface ApprovalCardRowProps {
|
|
|
1587
1671
|
// This gate's last failed decision, or null — a stable ref from the
|
|
1588
1672
|
// approvalErrors map, so the row re-renders only when its error appears/clears.
|
|
1589
1673
|
readonly error?: Error | null;
|
|
1674
|
+
// The (possibly slotted) card component. The row's callback stabilization
|
|
1675
|
+
// wraps whichever card renders, so a slot override keeps the memo behavior.
|
|
1676
|
+
readonly ApprovalCardComponent: ComponentType<ApprovalCardProps>;
|
|
1590
1677
|
}
|
|
1591
1678
|
|
|
1592
1679
|
const ApprovalCardRow = memo(function ApprovalCardRow({
|
|
@@ -1594,6 +1681,7 @@ const ApprovalCardRow = memo(function ApprovalCardRow({
|
|
|
1594
1681
|
onApprovalSubmit,
|
|
1595
1682
|
isSubmitting,
|
|
1596
1683
|
error = null,
|
|
1684
|
+
ApprovalCardComponent,
|
|
1597
1685
|
}: ApprovalCardRowProps) {
|
|
1598
1686
|
const handleSubmit = useCallback(
|
|
1599
1687
|
(action: ApprovalAction, comment?: string) => {
|
|
@@ -1603,7 +1691,7 @@ const ApprovalCardRow = memo(function ApprovalCardRow({
|
|
|
1603
1691
|
);
|
|
1604
1692
|
|
|
1605
1693
|
return (
|
|
1606
|
-
<
|
|
1694
|
+
<ApprovalCardComponent
|
|
1607
1695
|
pendingApproval={pendingApproval}
|
|
1608
1696
|
onSubmit={handleSubmit}
|
|
1609
1697
|
isSubmitting={isSubmitting}
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { memo, useMemo } from "react";
|
|
3
|
+
import { memo, useMemo, type ComponentType } from "react";
|
|
4
4
|
import type { TodoItem } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/todo_pb";
|
|
5
5
|
import { TodoStatus } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
|
|
6
6
|
import { cn } from "@stigmer/theme";
|
|
7
7
|
import { useRenderTracer } from "../internal/dev/index.js";
|
|
8
8
|
import { useAutoDisclosure } from "../internal/useAutoDisclosure.js";
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
TodoList,
|
|
11
|
+
findActiveTodo,
|
|
12
|
+
todoCompletionSummary,
|
|
13
|
+
type TodoRowProps,
|
|
14
|
+
} from "./TodoList.js";
|
|
10
15
|
|
|
11
16
|
/** Props for {@link TodoCard}. */
|
|
12
17
|
export interface TodoCardProps {
|
|
@@ -18,6 +23,12 @@ export interface TodoCardProps {
|
|
|
18
23
|
readonly todos: { readonly [key: string]: TodoItem };
|
|
19
24
|
/** Additional CSS class names for the root container. */
|
|
20
25
|
readonly className?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Replacement row component, forwarded to the inner {@link TodoList}.
|
|
28
|
+
* Lets a host restyle individual rows while keeping the card's
|
|
29
|
+
* collapse/progress chrome. Defaults to the built-in {@link TodoRow}.
|
|
30
|
+
*/
|
|
31
|
+
readonly TodoRow?: ComponentType<TodoRowProps>;
|
|
21
32
|
}
|
|
22
33
|
|
|
23
34
|
/**
|
|
@@ -52,6 +63,7 @@ export interface TodoCardProps {
|
|
|
52
63
|
export const TodoCard = memo(function TodoCard({
|
|
53
64
|
todos,
|
|
54
65
|
className,
|
|
66
|
+
TodoRow,
|
|
55
67
|
}: TodoCardProps) {
|
|
56
68
|
useRenderTracer("TodoCard", { todos });
|
|
57
69
|
|
|
@@ -121,7 +133,7 @@ export const TodoCard = memo(function TodoCard({
|
|
|
121
133
|
|
|
122
134
|
{expanded && (
|
|
123
135
|
<div className="border-t border-border-muted px-2.5 py-2">
|
|
124
|
-
<TodoList todos={todos} />
|
|
136
|
+
<TodoList todos={todos} TodoRow={TodoRow} />
|
|
125
137
|
</div>
|
|
126
138
|
)}
|
|
127
139
|
</div>
|
|
@@ -139,7 +151,11 @@ export function todoCardPropsEqual(
|
|
|
139
151
|
prev: Readonly<TodoCardProps>,
|
|
140
152
|
next: Readonly<TodoCardProps>,
|
|
141
153
|
): boolean {
|
|
142
|
-
return
|
|
154
|
+
return (
|
|
155
|
+
prev.todos === next.todos &&
|
|
156
|
+
prev.className === next.className &&
|
|
157
|
+
prev.TodoRow === next.TodoRow
|
|
158
|
+
);
|
|
143
159
|
}
|
|
144
160
|
|
|
145
161
|
// ---------------------------------------------------------------------------
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { useMemo } from "react";
|
|
3
|
+
import { useMemo, type ComponentType } from "react";
|
|
4
4
|
import type { TodoItem } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/todo_pb";
|
|
5
5
|
import { TodoStatus } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
|
|
6
6
|
import { cn } from "@stigmer/theme";
|
|
@@ -14,6 +14,12 @@ export interface TodoListProps {
|
|
|
14
14
|
readonly todos: { readonly [key: string]: TodoItem };
|
|
15
15
|
/** Additional CSS class names for the root container. */
|
|
16
16
|
readonly className?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Replacement row component. Receives {@link TodoRowProps} for each
|
|
19
|
+
* item; defaults to the built-in {@link TodoRow}. Renders inside a
|
|
20
|
+
* `<ul role="list">`, so the component must produce an `<li>`.
|
|
21
|
+
*/
|
|
22
|
+
readonly TodoRow?: ComponentType<TodoRowProps>;
|
|
17
23
|
}
|
|
18
24
|
|
|
19
25
|
const STATUS_SORT_ORDER: ReadonlyMap<TodoStatus, number> = new Map([
|
|
@@ -47,7 +53,11 @@ function todoSortKey(item: TodoItem): number {
|
|
|
47
53
|
* <TodoList todos={todos} />
|
|
48
54
|
* ```
|
|
49
55
|
*/
|
|
50
|
-
export function TodoList({
|
|
56
|
+
export function TodoList({
|
|
57
|
+
todos,
|
|
58
|
+
className,
|
|
59
|
+
TodoRow: RowComponent = TodoRow,
|
|
60
|
+
}: TodoListProps) {
|
|
51
61
|
const sortedTodos = useMemo(() => {
|
|
52
62
|
const items = Object.values(todos);
|
|
53
63
|
if (items.length === 0) return [];
|
|
@@ -63,7 +73,7 @@ export function TodoList({ todos, className }: TodoListProps) {
|
|
|
63
73
|
aria-label="Tasks"
|
|
64
74
|
>
|
|
65
75
|
{sortedTodos.map((item) => (
|
|
66
|
-
<
|
|
76
|
+
<RowComponent key={item.id} item={item} />
|
|
67
77
|
))}
|
|
68
78
|
</ul>
|
|
69
79
|
);
|
|
@@ -108,7 +118,19 @@ export function todoCompletionSummary(
|
|
|
108
118
|
// TodoRow — single todo item with status icon
|
|
109
119
|
// ---------------------------------------------------------------------------
|
|
110
120
|
|
|
111
|
-
|
|
121
|
+
/** Props for {@link TodoRow}. */
|
|
122
|
+
export interface TodoRowProps {
|
|
123
|
+
/** The todo item to render. */
|
|
124
|
+
readonly item: TodoItem;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* One to-do checklist row: status icon plus task description, rendered as
|
|
129
|
+
* an `<li>`. The default row for {@link TodoList} — replace it via the
|
|
130
|
+
* `TodoRow` prop (or `MessageThread`'s `slots.TodoRow`) to restyle rows or
|
|
131
|
+
* bring host iconography while keeping the built-in card chrome.
|
|
132
|
+
*/
|
|
133
|
+
export function TodoRow({ item }: TodoRowProps) {
|
|
112
134
|
const Icon = TODO_ICONS[item.status] ?? TodoPendingIcon;
|
|
113
135
|
const colorClass = TODO_COLORS[item.status] ?? "text-muted-foreground";
|
|
114
136
|
const cancelled = item.status === TodoStatus.TODO_CANCELLED;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import type { CapturedFileChange } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/filereview_pb";
|
|
3
5
|
import type { ToolCall } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/message_pb";
|
|
6
|
+
import { toDisplayFileChange } from "@stigmer/sdk";
|
|
4
7
|
import type { ToolResultView } from "@stigmer/sdk";
|
|
5
8
|
import { cn } from "@stigmer/theme";
|
|
6
9
|
import { BoundedContent } from "../internal/BoundedContent.js";
|
|
10
|
+
import { FileChangeDiff } from "./FileChangesView.js";
|
|
11
|
+
import { useFileReviewRowChange } from "./FileReviewContext.js";
|
|
7
12
|
import { McpToolDetail } from "./McpToolDetail.js";
|
|
8
13
|
import { ToolArgsView } from "./ToolArgsView.js";
|
|
9
14
|
import { ResultView } from "./ResultView.js";
|
|
@@ -43,8 +48,9 @@ export interface ToolCallDetailProps {
|
|
|
43
48
|
* degrade to readable JSON instead of a raw dump.
|
|
44
49
|
*
|
|
45
50
|
* Composition varies by category to avoid redundancy: an edit shows only the
|
|
46
|
-
* diff (which already names the file and quantifies the change); a
|
|
47
|
-
* its
|
|
51
|
+
* diff (which already names the file and quantifies the change); a stamped
|
|
52
|
+
* write shows its change set's captured diff, degrading to the proposed
|
|
53
|
+
* content when no capture resolves; a read shows just the path.
|
|
48
54
|
*
|
|
49
55
|
* Importable on its own by platform builders composing custom tool UIs.
|
|
50
56
|
*
|
|
@@ -60,6 +66,16 @@ export function ToolCallDetail({
|
|
|
60
66
|
}: ToolCallDetailProps) {
|
|
61
67
|
const { category, result, primaryArg } = useToolPresentation(toolCall);
|
|
62
68
|
|
|
69
|
+
// The captured net change a stamped write row renders as its inline diff
|
|
70
|
+
// (see the write branch below). Resolved here unconditionally (Rules of
|
|
71
|
+
// Hooks); null for every other category's rows — they are never stamped —
|
|
72
|
+
// and for every honest-degradation case, so this costs nothing outside the
|
|
73
|
+
// stamped-write path.
|
|
74
|
+
const capturedChange = useFileReviewRowChange(
|
|
75
|
+
toolCall.fileChangeSetId,
|
|
76
|
+
primaryArg,
|
|
77
|
+
);
|
|
78
|
+
|
|
63
79
|
return (
|
|
64
80
|
<div className={cn("space-y-2 text-xs", className)}>
|
|
65
81
|
<CategoryDetail
|
|
@@ -68,6 +84,7 @@ export function ToolCallDetail({
|
|
|
68
84
|
result={result}
|
|
69
85
|
primaryArg={primaryArg}
|
|
70
86
|
primaryArgTruncated={primaryArgTruncated}
|
|
87
|
+
capturedChange={capturedChange}
|
|
71
88
|
/>
|
|
72
89
|
</div>
|
|
73
90
|
);
|
|
@@ -90,12 +107,14 @@ function CategoryDetail({
|
|
|
90
107
|
result,
|
|
91
108
|
primaryArg,
|
|
92
109
|
primaryArgTruncated,
|
|
110
|
+
capturedChange,
|
|
93
111
|
}: {
|
|
94
112
|
toolCall: ToolCall;
|
|
95
113
|
category: ToolCategory;
|
|
96
114
|
result: ToolResultView;
|
|
97
115
|
primaryArg: string | null;
|
|
98
116
|
primaryArgTruncated: boolean;
|
|
117
|
+
capturedChange: CapturedFileChange | null;
|
|
99
118
|
}) {
|
|
100
119
|
const args = <ArgsSection toolCall={toolCall} />;
|
|
101
120
|
|
|
@@ -128,27 +147,50 @@ function CategoryDetail({
|
|
|
128
147
|
);
|
|
129
148
|
|
|
130
149
|
case "edit":
|
|
131
|
-
case "write":
|
|
150
|
+
case "write": {
|
|
132
151
|
// The diff already names the file and quantifies the change, so it stands
|
|
133
|
-
// alone — showing the written content as an argument would duplicate it.
|
|
134
|
-
//
|
|
135
|
-
// (ResultView shows the content), so the input is never lost. The owning
|
|
136
|
-
// row already names the file, so the body suppresses the path.
|
|
152
|
+
// alone — showing the written content as an argument would duplicate it.
|
|
153
|
+
// The owning row already names the file, so the body suppresses the path.
|
|
137
154
|
//
|
|
138
|
-
//
|
|
139
|
-
//
|
|
140
|
-
//
|
|
141
|
-
//
|
|
142
|
-
//
|
|
143
|
-
//
|
|
155
|
+
// An EDIT's diff is reconstructed per-call from its own args (old/new
|
|
156
|
+
// strings, or the Cursor envelope's unified diff). A whole-file WRITE has
|
|
157
|
+
// no per-call before-image in its args, so a stamped write renders the
|
|
158
|
+
// captured NET change from its change set instead — the same artifact the
|
|
159
|
+
// row's review badge refers to, resolved through the same path matcher so
|
|
160
|
+
// the two can never disagree. An unresolvable write (still streaming
|
|
161
|
+
// before the turn-boundary capture, no capture mode, legacy session, or a
|
|
162
|
+
// non-reviewable change) keeps the honest fallback: the proposed content
|
|
163
|
+
// from the args, as a `file` view.
|
|
164
|
+
if (category === "write" && capturedChange) {
|
|
165
|
+
return (
|
|
166
|
+
<>
|
|
167
|
+
<ProvenanceNote toolCall={toolCall} />
|
|
168
|
+
<CapturedRowDiff change={capturedChange} />
|
|
169
|
+
</>
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
// Bounding is keyed on the VIEW, not the category: BoundedContent is for
|
|
173
|
+
// bodies with no internal truncation of their own — the diff and a FAILED
|
|
174
|
+
// call's error `<pre>` — giving a large or still-streaming edit the same
|
|
175
|
+
// scannable clamp the approval gate uses. The `file` view self-truncates
|
|
176
|
+
// (CollapsibleCode's line cap), so wrapping it would stack two reveal
|
|
177
|
+
// controls on one block — exactly what BoundedContent's contract forbids.
|
|
178
|
+
const body = (
|
|
179
|
+
<ResultView view={result} showFileName={false} showStats={false} />
|
|
180
|
+
);
|
|
144
181
|
return (
|
|
145
182
|
<>
|
|
146
183
|
<ProvenanceNote toolCall={toolCall} />
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
184
|
+
{result.type === "file" ? (
|
|
185
|
+
body
|
|
186
|
+
) : (
|
|
187
|
+
<BoundedContent cursorTarget="tool-detail-expand">
|
|
188
|
+
{body}
|
|
189
|
+
</BoundedContent>
|
|
190
|
+
)}
|
|
150
191
|
</>
|
|
151
192
|
);
|
|
193
|
+
}
|
|
152
194
|
|
|
153
195
|
case "read":
|
|
154
196
|
case "delete":
|
|
@@ -245,6 +287,17 @@ function ThinkToolDetail({ toolCall }: { toolCall: ToolCall }) {
|
|
|
245
287
|
// Shared sub-components
|
|
246
288
|
// ---------------------------------------------------------------------------
|
|
247
289
|
|
|
290
|
+
// A stamped write row's inline diff: the captured change projected onto the
|
|
291
|
+
// display FileChange and rendered through the same bounded FileChangeDiff the
|
|
292
|
+
// review card's body uses — offloaded-body fetch, binary notices, and
|
|
293
|
+
// truncation states included. The file name is suppressed (the owning row
|
|
294
|
+
// header names it); the `+N −M` stats stay because a write row's header
|
|
295
|
+
// summary carries none.
|
|
296
|
+
function CapturedRowDiff({ change }: { change: CapturedFileChange }) {
|
|
297
|
+
const adapted = useMemo(() => toDisplayFileChange(change), [change]);
|
|
298
|
+
return <FileChangeDiff change={adapted} bounded showFileName={false} />;
|
|
299
|
+
}
|
|
300
|
+
|
|
248
301
|
// The detail body's only metadata. Duration and the MCP slug live in the owning
|
|
249
302
|
// row header (ToolCallItem / ApprovalCardHeader), so the body never restates
|
|
250
303
|
// them; it surfaces the authorization provenance the runner stamped onto the
|
|
@@ -17,7 +17,13 @@ export interface WriteBackCardProps {
|
|
|
17
17
|
*
|
|
18
18
|
* Shows the workspace entry name, branch, diff summary, phase
|
|
19
19
|
* indicator, and a "View PR" link when the pull request was
|
|
20
|
-
* successfully created.
|
|
20
|
+
* successfully created.
|
|
21
|
+
*
|
|
22
|
+
* Error rendering follows the record's phase honestly (DD-006):
|
|
23
|
+
* a FAILED record's error is destructive (the work did not reach the
|
|
24
|
+
* remote), while a PUSHED record carrying an error renders it as a
|
|
25
|
+
* degraded notice — the branch is live and its info stays usable; only
|
|
26
|
+
* the PR step failed.
|
|
21
27
|
*
|
|
22
28
|
* Themed via standard semantic tokens — no hardcoded colors, no
|
|
23
29
|
* Console dependencies. Embedders can theme this card through
|
|
@@ -85,9 +91,17 @@ export function WriteBackCard({ writeBack, className }: WriteBackCardProps) {
|
|
|
85
91
|
</div>
|
|
86
92
|
)}
|
|
87
93
|
|
|
88
|
-
{/* Error message
|
|
89
|
-
|
|
90
|
-
|
|
94
|
+
{/* Error message: destructive when the write-back itself failed,
|
|
95
|
+
degraded when the branch pushed but a later step (the PR) did not. */}
|
|
96
|
+
{writeBack.error && (
|
|
97
|
+
<div
|
|
98
|
+
className={cn(
|
|
99
|
+
"mt-1.5 rounded px-2 py-1 text-xs",
|
|
100
|
+
isFailed
|
|
101
|
+
? "bg-destructive-subtle text-destructive"
|
|
102
|
+
: "bg-status-degraded-subtle text-status-degraded",
|
|
103
|
+
)}
|
|
104
|
+
>
|
|
91
105
|
{writeBack.error}
|
|
92
106
|
</div>
|
|
93
107
|
)}
|