zidane-ui 9.2.2 → 9.3.1
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/dist/adapters/browser-keybindings-host.js +3 -1
- package/dist/adapters/live.d.ts +6 -0
- package/dist/adapters/live.js +16 -8
- package/dist/adapters/server-composer-host.js +22 -9
- package/dist/adapters/server-host.js +143 -18
- package/dist/adapters/server-media.d.ts +9 -1
- package/dist/adapters/server-media.js +14 -1
- package/dist/adapters/server-settings-host.js +30 -3
- package/dist/adapters/server-settings-sections.js +23 -1
- package/dist/adapters/server-sidebar-host.d.ts +3 -1
- package/dist/adapters/server-sidebar-host.js +10 -1
- package/dist/app/ModalProvider.js +1 -1
- package/dist/approvals/ApprovalShell.js +1 -1
- package/dist/chat/DaemonOrb.d.ts +29 -1
- package/dist/chat/DaemonOrb.js +25 -12
- package/dist/chat/HostTranscript.d.ts +0 -12
- package/dist/chat/HostTranscript.js +6 -1
- package/dist/chat/SessionStreamsProvider.d.ts +8 -0
- package/dist/chat/SessionStreamsProvider.js +11 -2
- package/dist/chat/StatusDot.js +8 -2
- package/dist/chat/Transcript.d.ts +20 -11
- package/dist/chat/Transcript.js +335 -162
- package/dist/chat/composer/ComposerEditor.js +1 -1
- package/dist/chat/headless/host.d.ts +43 -7
- package/dist/chat/headless/index.d.ts +8 -6
- package/dist/chat/headless/index.js +11 -9
- package/dist/chat/headless/labels.d.ts +30 -0
- package/dist/chat/headless/labels.js +29 -0
- package/dist/chat/headless/markdown-chunks.d.ts +2 -1
- package/dist/chat/headless/markdown-chunks.js +12 -20
- package/dist/chat/headless/markdown-scan.d.ts +66 -0
- package/dist/chat/headless/markdown-scan.js +124 -0
- package/dist/chat/headless/markdown-stream.d.ts +64 -0
- package/dist/chat/headless/markdown-stream.js +143 -0
- package/dist/chat/headless/output-pager.d.ts +68 -0
- package/dist/chat/headless/output-pager.js +113 -0
- package/dist/chat/headless/session-list.d.ts +20 -0
- package/dist/chat/headless/sidebar/activity.d.ts +14 -0
- package/dist/chat/headless/sidebar/activity.js +32 -0
- package/dist/chat/headless/sidebar/directory.d.ts +17 -2
- package/dist/chat/headless/sidebar/directory.js +50 -54
- package/dist/chat/headless/sidebar/environment.d.ts +5 -2
- package/dist/chat/headless/sidebar/environment.js +11 -2
- package/dist/chat/headless/sidebar/host.d.ts +15 -0
- package/dist/chat/headless/sidebar/inbox.d.ts +12 -3
- package/dist/chat/headless/sidebar/inbox.js +18 -9
- package/dist/chat/headless/sidebar/index.d.ts +2 -2
- package/dist/chat/headless/sidebar/index.js +2 -2
- package/dist/chat/headless/sidebar/labels.d.ts +38 -2
- package/dist/chat/headless/sidebar/labels.js +16 -0
- package/dist/chat/headless/sidebar/prewarm.d.ts +68 -0
- package/dist/chat/headless/sidebar/prewarm.js +114 -0
- package/dist/chat/headless/streams/actions.d.ts +2 -0
- package/dist/chat/headless/streams/actions.js +1 -0
- package/dist/chat/headless/streams/event-bytes.d.ts +6 -0
- package/dist/chat/headless/streams/event-bytes.js +34 -0
- package/dist/chat/headless/streams/live-events.d.ts +25 -1
- package/dist/chat/headless/streams/live-events.js +53 -2
- package/dist/chat/headless/streams/selectors.d.ts +3 -0
- package/dist/chat/headless/streams/selectors.js +8 -1
- package/dist/chat/headless/streams/session-streams.d.ts +15 -3
- package/dist/chat/headless/streams/session-streams.js +31 -3
- package/dist/chat/headless/streams/store.d.ts +24 -1
- package/dist/chat/headless/streams/store.js +51 -26
- package/dist/chat/headless/streams/transcript-map.d.ts +57 -0
- package/dist/chat/headless/streams/transcript-map.js +88 -0
- package/dist/chat/headless/streams/transcript.d.ts +4 -2
- package/dist/chat/headless/streams/transcript.js +19 -7
- package/dist/chat/headless/transcript/batch.js +5 -1
- package/dist/chat/headless/transcript/blob-media.d.ts +15 -0
- package/dist/chat/headless/transcript/blob-media.js +23 -0
- package/dist/chat/headless/transcript/collapse.d.ts +10 -0
- package/dist/chat/headless/transcript/collapse.js +32 -6
- package/dist/chat/headless/transcript/derive.d.ts +98 -0
- package/dist/chat/headless/transcript/derive.js +89 -0
- package/dist/chat/headless/transcript/exchange-media.d.ts +3 -1
- package/dist/chat/headless/transcript/exchange-media.js +8 -5
- package/dist/chat/headless/transcript/fold-actions.d.ts +8 -3
- package/dist/chat/headless/transcript/fold-actions.js +16 -0
- package/dist/chat/headless/transcript/fold-attachments.d.ts +2 -0
- package/dist/chat/headless/transcript/fold-attachments.js +3 -2
- package/dist/chat/headless/transcript/fold.d.ts +4 -2
- package/dist/chat/headless/transcript/fold.js +37 -7
- package/dist/chat/headless/transcript/incremental.d.ts +53 -0
- package/dist/chat/headless/transcript/incremental.js +181 -0
- package/dist/chat/headless/transcript/index.d.ts +2 -1
- package/dist/chat/headless/transcript/index.js +2 -1
- package/dist/chat/headless/transcript/nesting.js +2 -1
- package/dist/chat/headless/transcript/rail.d.ts +142 -0
- package/dist/chat/headless/transcript/rail.js +290 -0
- package/dist/chat/headless/transcript/rows.d.ts +11 -1
- package/dist/chat/headless/transcript/run-failures.d.ts +4 -0
- package/dist/chat/headless/transcript/run-failures.js +31 -2
- package/dist/chat/headless/transcript/seams.d.ts +78 -0
- package/dist/chat/headless/transcript/seams.js +116 -0
- package/dist/chat/headless/transcript/tool-media.d.ts +6 -7
- package/dist/chat/headless/transcript/tool-media.js +27 -9
- package/dist/chat/headless/transcript-labels.d.ts +1 -0
- package/dist/chat/headless/turn-labels.d.ts +1 -0
- package/dist/chat/headless/turn-labels.js +2 -1
- package/dist/chat/index.d.ts +10 -8
- package/dist/chat/index.js +9 -7
- package/dist/chat/interactions/ElicitationCard.js +1 -1
- package/dist/chat/interactions/InteractionCard.js +1 -1
- package/dist/chat/interactions/PlanCard.js +3 -3
- package/dist/chat/interactions/QuestionField.js +4 -4
- package/dist/chat/interactions/QuestionForm.js +3 -3
- package/dist/chat/interactions/SecretInput.js +1 -1
- package/dist/chat/sidebar/ProjectIcon.d.ts +1 -1
- package/dist/chat/sidebar/ProjectIcon.js +1 -1
- package/dist/chat/sidebar/RowChips.d.ts +3 -2
- package/dist/chat/sidebar/RowChips.js +6 -3
- package/dist/chat/sidebar/SessionSidebar.js +13 -14
- package/dist/chat/sidebar/SidebarFooter.d.ts +8 -5
- package/dist/chat/sidebar/SidebarFooter.js +6 -6
- package/dist/chat/sidebar/SidebarFrame.d.ts +2 -0
- package/dist/chat/sidebar/SidebarFrame.js +5 -2
- package/dist/chat/sidebar/SidebarSessionRow.d.ts +3 -1
- package/dist/chat/sidebar/SidebarSessionRow.js +3 -1
- package/dist/chat/sidebar/SpacesSection.d.ts +20 -1
- package/dist/chat/sidebar/SpacesSection.js +34 -13
- package/dist/chat/sidebar/index.d.ts +2 -2
- package/dist/chat/sidebar/session-menu.d.ts +11 -2
- package/dist/chat/sidebar/session-menu.js +50 -5
- package/dist/chat/sidebar/sidebar-live.js +1 -1
- package/dist/chat/sidebar/useInboxRows.js +43 -2
- package/dist/chat/sidebar/useInboxTriage.js +19 -14
- package/dist/chat/testing/contract.d.ts +5 -3
- package/dist/chat/testing/contract.js +66 -1
- package/dist/chat/testing/fixture-sidebar-host.d.ts +7 -1
- package/dist/chat/testing/fixture-sidebar-host.js +12 -0
- package/dist/chat/testing/sidebar.contract.d.ts +6 -0
- package/dist/chat/testing/sidebar.contract.js +24 -0
- package/dist/chat/transcript/DiffLines.d.ts +6 -1
- package/dist/chat/transcript/DiffLines.js +35 -20
- package/dist/chat/transcript/EditDiffBlock.d.ts +5 -1
- package/dist/chat/transcript/EditDiffBlock.js +89 -30
- package/dist/chat/transcript/InteractionToolBody.js +1 -1
- package/dist/chat/transcript/LazyRow.d.ts +40 -40
- package/dist/chat/transcript/LazyRow.js +101 -149
- package/dist/chat/transcript/MermaidDiagram.js +2 -1
- package/dist/chat/transcript/SelectCursor.d.ts +11 -1
- package/dist/chat/transcript/SelectCursor.js +10 -5
- package/dist/chat/transcript/SubagentBlock.js +3 -2
- package/dist/chat/transcript/TranscriptRail.d.ts +109 -0
- package/dist/chat/transcript/TranscriptRail.js +579 -0
- package/dist/chat/transcript/TranscriptRow.d.ts +4 -7
- package/dist/chat/transcript/TranscriptRow.js +9 -5
- package/dist/chat/transcript/actions.d.ts +43 -3
- package/dist/chat/transcript/actions.js +27 -1
- package/dist/chat/transcript/clipped-output.d.ts +58 -0
- package/dist/chat/transcript/clipped-output.js +131 -0
- package/dist/chat/transcript/fold-attachments.js +10 -5
- package/dist/chat/transcript/fold-worker.js +3 -2
- package/dist/chat/transcript/fold.js +21 -2
- package/dist/chat/transcript/index.d.ts +11 -9
- package/dist/chat/transcript/index.js +10 -8
- package/dist/chat/transcript/markdown-cache.d.ts +7 -1
- package/dist/chat/transcript/markdown-cache.js +12 -1
- package/dist/chat/transcript/markdown.js +116 -54
- package/dist/chat/transcript/media-gallery.d.ts +3 -2
- package/dist/chat/transcript/media-gallery.js +10 -7
- package/dist/chat/transcript/notices.d.ts +23 -1
- package/dist/chat/transcript/notices.js +110 -28
- package/dist/chat/transcript/prompt.js +6 -4
- package/dist/chat/transcript/prose.js +3 -1
- package/dist/chat/transcript/receipt-parts.d.ts +22 -0
- package/dist/chat/transcript/receipt-parts.js +87 -0
- package/dist/chat/transcript/root-items.d.ts +96 -0
- package/dist/chat/transcript/root-items.js +180 -0
- package/dist/chat/transcript/row-mount.d.ts +165 -0
- package/dist/chat/transcript/row-mount.js +498 -0
- package/dist/chat/transcript/row-parking.d.ts +125 -0
- package/dist/chat/transcript/row-parking.js +135 -0
- package/dist/chat/transcript/row-ui-state.d.ts +37 -0
- package/dist/chat/transcript/row-ui-state.js +53 -0
- package/dist/chat/transcript/run-rows.js +6 -78
- package/dist/chat/transcript/script-input.d.ts +1 -1
- package/dist/chat/transcript/scroll-clamp.js +1 -1
- package/dist/chat/transcript/tasks.js +3 -2
- package/dist/chat/transcript/tool-media.d.ts +4 -2
- package/dist/chat/transcript/tool-media.js +15 -7
- package/dist/chat/transcript/tool-parts.d.ts +27 -4
- package/dist/chat/transcript/tool-parts.js +31 -5
- package/dist/chat/transcript/tool-payload.js +26 -11
- package/dist/chat/transcript/tool-row.d.ts +2 -1
- package/dist/chat/transcript/tool-row.js +38 -19
- package/dist/chat/transcript/use-transcript-rows.d.ts +24 -7
- package/dist/chat/transcript/use-transcript-rows.js +28 -46
- package/dist/chat/transcript/useSettledReveal.js +15 -3
- package/dist/chat/transcript/useStickToBottom.js +4 -4
- package/dist/chat/transcript/useTranscriptSearch.js +30 -14
- package/dist/chat/transcript/view-scope.d.ts +26 -6
- package/dist/chat/transcript/view-scope.js +106 -20
- package/dist/components/ChoiceCards.js +1 -1
- package/dist/components/ConfirmDialog.js +1 -1
- package/dist/components/CopyValue.d.ts +33 -0
- package/dist/components/CopyValue.js +54 -0
- package/dist/components/Form.js +1 -1
- package/dist/components/HowItWorks.js +1 -1
- package/dist/components/Menu.js +1 -1
- package/dist/components/StepFrame.js +2 -2
- package/dist/components/SwatchPicker.js +1 -1
- package/dist/components/ToggleCard.js +1 -1
- package/dist/components/floating/HoverCard.js +2 -3
- package/dist/components/floating/hover-delay.d.ts +4 -0
- package/dist/components/floating/hover-delay.js +6 -0
- package/dist/core.css +14 -12
- package/dist/dist/{index-Betz0OWq.d.ts → index-C6-t1SS9.d.ts} +21 -2
- package/dist/dist/index-De9AbmxS.d.ts +1 -0
- package/dist/dist/index.d.ts +5 -5
- package/dist/dist/sandbox-CSUihARm.d.ts +2 -0
- package/dist/dist/{timeout-CyU7HLyz.d.ts → timeout-CmTx6V9y.d.ts} +1 -0
- package/dist/extensions/ExtensionDialogHost.js +1 -1
- package/dist/files/TreeColumn.js +3 -1
- package/dist/files/headless/host.d.ts +2 -2
- package/dist/git/ImportRepoDialog.js +1 -1
- package/dist/git/MoveSessionDialog.js +2 -2
- package/dist/git/SandboxManager.d.ts +42 -0
- package/dist/git/SandboxManager.js +297 -0
- package/dist/git/SyncChip.js +1 -1
- package/dist/git/headless/index.d.ts +2 -1
- package/dist/git/headless/index.js +2 -1
- package/dist/git/headless/labels.d.ts +29 -0
- package/dist/git/headless/labels.js +34 -1
- package/dist/git/headless/sandboxes.d.ts +43 -0
- package/dist/git/headless/sandboxes.js +52 -0
- package/dist/git/index.d.ts +2 -1
- package/dist/git/index.js +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/keybindings/headless/catalog.d.ts +1 -1
- package/dist/keybindings/headless/catalog.js +12 -0
- package/dist/machines/HostsSection.d.ts +1 -1
- package/dist/machines/headless/labels.js +2 -2
- package/dist/motion/flip-list.js +3 -10
- package/dist/motion/presence.d.ts +10 -0
- package/dist/motion/presence.js +20 -1
- package/dist/motion/swap.d.ts +8 -2
- package/dist/motion/swap.js +5 -2
- package/dist/onboarding/conversation.js +27 -15
- package/dist/onboarding/demos/how-it-works.js +1 -1
- package/dist/onboarding/skills/parts.js +4 -4
- package/dist/onboarding/sources/SourceBrowser.js +1 -1
- package/dist/onboarding/steps/ReadyStep.js +1 -1
- package/dist/onboarding/steps/connect/KeyForm.js +1 -1
- package/dist/palette/headless/app-sources.js +20 -0
- package/dist/palette/headless/labels.js +2 -0
- package/dist/session/PlanTracker.js +3 -3
- package/dist/session/SecretsPanel.js +1 -1
- package/dist/session/SessionHeader.d.ts +18 -6
- package/dist/session/SessionHeader.js +68 -12
- package/dist/session/SessionPlaceMenu.d.ts +35 -0
- package/dist/session/SessionPlaceMenu.js +299 -0
- package/dist/session/SessionShell.js +1 -1
- package/dist/session/TurnDetailsDialog.js +1 -1
- package/dist/session/headless/index.d.ts +2 -1
- package/dist/session/headless/index.js +2 -1
- package/dist/session/headless/labels.d.ts +73 -0
- package/dist/session/headless/labels.js +73 -0
- package/dist/session/headless/place.d.ts +49 -0
- package/dist/session/headless/place.js +57 -0
- package/dist/session/index.d.ts +2 -1
- package/dist/session/index.js +2 -1
- package/dist/settings/ConversationPresetsCard.js +1 -1
- package/dist/settings/SettingCard.js +2 -2
- package/dist/settings/SettingsRowsPage.js +1 -1
- package/dist/settings/headless/fixture-performance.js +4 -2
- package/dist/settings/headless/fixture-sections.js +7 -0
- package/dist/settings/headless/labels.d.ts +1 -1
- package/dist/settings/headless/labels.js +1 -1
- package/dist/settings/headless/layout.d.ts +4 -4
- package/dist/settings/headless/layout.js +1 -1
- package/dist/settings/headless/performance.d.ts +4 -0
- package/dist/settings/headless/search.d.ts +2 -2
- package/dist/settings/headless/sections-host.d.ts +20 -2
- package/dist/settings/sections/claude-import/ClaudeImportDialog.js +1 -1
- package/dist/settings/sections/enabled-list/EnabledListSection.js +2 -2
- package/dist/settings/sections/environments/EnvironmentsSection.d.ts +9 -3
- package/dist/settings/sections/environments/EnvironmentsSection.js +292 -52
- package/dist/settings/sections/environments/labels.d.ts +15 -0
- package/dist/settings/sections/environments/labels.js +18 -3
- package/dist/settings/sections/extensions/ChangeOriginDialog.js +1 -1
- package/dist/settings/sections/extensions/ExtensionSourceBrowser.js +1 -1
- package/dist/settings/sections/extensions/ExtensionsSection.d.ts +3 -2
- package/dist/settings/sections/extensions/ExtensionsSection.js +9 -3
- package/dist/settings/sections/host-catalog/HostCatalogSection.js +15 -5
- package/dist/settings/sections/keybindings/labels.d.ts +2 -0
- package/dist/settings/sections/keybindings/labels.js +2 -0
- package/dist/settings/sections/keybindings/rows.js +8 -0
- package/dist/settings/sections/models/SpacesDefaultsSection.d.ts +7 -3
- package/dist/settings/sections/models/SpacesDefaultsSection.js +11 -5
- package/dist/settings/sections/performance/PerformanceSection.js +8 -1
- package/dist/settings/sections/performance/labels.d.ts +2 -0
- package/dist/settings/sections/performance/labels.js +2 -0
- package/dist/settings/sections/skills/SkillGroups.js +1 -1
- package/dist/settings/server-app.d.ts +4 -2
- package/dist/settings/server-app.js +7 -3
- package/dist/settings/testing/sections.contract.d.ts +7 -1
- package/dist/settings/testing/sections.contract.js +37 -0
- package/dist/styles.css +243 -19
- package/dist/terminal/TerminalDrawer.js +3 -1
- package/dist/views/headless/answers.d.ts +8 -2
- package/dist/views/headless/answers.js +58 -1
- package/dist/views/headless/placement.d.ts +78 -0
- package/dist/views/headless/placement.js +154 -44
- package/dist/workspace/SidePanel.js +3 -1
- package/package.json +2 -2
- package/src/styles/base.css +13 -0
- package/src/styles/chat.css +30 -0
- package/src/styles/components.css +0 -10
- package/src/styles/files.css +5 -0
- package/src/styles/sidebar.css +29 -7
- package/src/styles/terminal.css +6 -0
- package/src/styles/tokens.css +5 -0
- package/src/styles/transcript.css +138 -0
- package/src/styles/workspace.css +6 -0
- package/dist/dist/index-QcFzZlao.d.ts +0 -1
- package/dist/dist/sandbox-D0zsW8I1.d.ts +0 -2
- /package/dist/dist/{types-_Dtoq_No.d.ts → execution-failure-SREfl-EZ.d.ts} +0 -0
|
@@ -1,10 +1,48 @@
|
|
|
1
1
|
import { usePersistedState } from "../../hooks/usePersistedState.js";
|
|
2
2
|
import { basename } from "../../path.js";
|
|
3
|
-
import { INBOX_SHELVES, INBOX_SHELVES_FOLDED, INBOX_SHELVES_KEY, buildInboxRows, inboxDockStart, inboxFolderOf, nextInboxChangeAt } from "../headless/sidebar/inbox.js";
|
|
3
|
+
import { INBOX_RUN_HOLD_MS, INBOX_SHELVES, INBOX_SHELVES_FOLDED, INBOX_SHELVES_KEY, buildInboxRows, inboxDockStart, inboxFolderOf, nextInboxChangeAt } from "../headless/sidebar/inbox.js";
|
|
4
4
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
5
5
|
// src/chat/sidebar/useInboxRows.ts
|
|
6
6
|
const DEFAULT_FOLDED = new Set(INBOX_SHELVES_FOLDED);
|
|
7
7
|
const NO_FOLDERS = /* @__PURE__ */ new Set();
|
|
8
|
+
const NO_HOLD = /* @__PURE__ */ new Set();
|
|
9
|
+
/**
|
|
10
|
+
* The sessions whose run ended less than {@link INBOX_RUN_HOLD_MS} ago: they stay on the Working shelf meanwhile,
|
|
11
|
+
* so a run that ends and another that starts right after (a queued message, a resume) move nothing. A session
|
|
12
|
+
* running again leaves the hold at once; each hold ends on its own timer.
|
|
13
|
+
*/
|
|
14
|
+
function useRunHold(sessions, on) {
|
|
15
|
+
const [seen, setSeen] = useState(() => ({
|
|
16
|
+
sessions,
|
|
17
|
+
running: new Set(sessions.filter((s) => s.status === "running").map((s) => s.id))
|
|
18
|
+
}));
|
|
19
|
+
const [held, setHeld] = useState(/* @__PURE__ */ new Map());
|
|
20
|
+
if (on && seen.sessions !== sessions) {
|
|
21
|
+
const now = new Set(sessions.filter((s) => s.status === "running").map((s) => s.id));
|
|
22
|
+
const ended = [...seen.running].filter((id) => !now.has(id));
|
|
23
|
+
const resumed = [...held.keys()].some((id) => now.has(id));
|
|
24
|
+
setSeen({
|
|
25
|
+
sessions,
|
|
26
|
+
running: now
|
|
27
|
+
});
|
|
28
|
+
if (ended.length > 0 || resumed) {
|
|
29
|
+
const next = new Map([...held].filter(([id]) => !now.has(id)));
|
|
30
|
+
const until = Date.now() + INBOX_RUN_HOLD_MS;
|
|
31
|
+
for (const id of ended) next.set(id, until);
|
|
32
|
+
setHeld(next);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (held.size === 0) return;
|
|
37
|
+
const first = Math.min(...held.values());
|
|
38
|
+
const timer = setTimeout(() => {
|
|
39
|
+
const at = Date.now();
|
|
40
|
+
setHeld((current) => new Map([...current].filter(([, until]) => until > at)));
|
|
41
|
+
}, Math.max(0, first - Date.now()));
|
|
42
|
+
return () => clearTimeout(timer);
|
|
43
|
+
}, [held]);
|
|
44
|
+
return useMemo(() => held.size === 0 ? NO_HOLD : new Set(held.keys()), [held]);
|
|
45
|
+
}
|
|
8
46
|
function toggled(set, item) {
|
|
9
47
|
const next = new Set(set);
|
|
10
48
|
if (next.has(item)) next.delete(item);
|
|
@@ -34,6 +72,7 @@ function useInboxRows({ on, sessions, groupBy, earlierAfterMs, needsYou, activeI
|
|
|
34
72
|
[shelf]: (shown[shelf] ?? 10) + 25
|
|
35
73
|
}));
|
|
36
74
|
}, []);
|
|
75
|
+
const holdRunning = useRunHold(sessions, on);
|
|
37
76
|
const [tick, setTick] = useState(0);
|
|
38
77
|
useEffect(() => {
|
|
39
78
|
if (!on) return;
|
|
@@ -55,6 +94,7 @@ function useInboxRows({ on, sessions, groupBy, earlierAfterMs, needsYou, activeI
|
|
|
55
94
|
shown: shelfShown,
|
|
56
95
|
activeId,
|
|
57
96
|
earlierAfterMs,
|
|
97
|
+
holdRunning,
|
|
58
98
|
...needsYou ? { needsYou } : {}
|
|
59
99
|
}) : [], [
|
|
60
100
|
on,
|
|
@@ -66,7 +106,8 @@ function useInboxRows({ on, sessions, groupBy, earlierAfterMs, needsYou, activeI
|
|
|
66
106
|
activeId,
|
|
67
107
|
tick,
|
|
68
108
|
earlierAfterMs,
|
|
69
|
-
needsYou
|
|
109
|
+
needsYou,
|
|
110
|
+
holdRunning
|
|
70
111
|
]);
|
|
71
112
|
const dockStart = inboxDockStart(rows);
|
|
72
113
|
return {
|
|
@@ -82,22 +82,27 @@ function useInboxTriage(options) {
|
|
|
82
82
|
const row = sessionRow(id);
|
|
83
83
|
return row ? [row.session] : [];
|
|
84
84
|
});
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
/** The sessions whose save went through. */
|
|
86
|
+
const saved = Promise.allSettled(before.map((s) => save(s.id, patchFor(s)))).then((results) => {
|
|
87
87
|
const rejected = results.find((r) => r.status === "rejected");
|
|
88
88
|
if (rejected) failed(rejected.reason);
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
89
|
+
return before.filter((_, i) => results[i].status === "fulfilled");
|
|
90
|
+
});
|
|
91
|
+
let done = false;
|
|
92
|
+
const revert = () => {
|
|
93
|
+
if (done) return;
|
|
94
|
+
done = true;
|
|
95
|
+
if (undo.current === revert) undo.current = null;
|
|
96
|
+
saved.then((ok) => {
|
|
97
|
+
for (const s of ok) save(s.id, inverseInboxPatch(s, now)).catch(failed);
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
undo.current = revert;
|
|
101
|
+
setTimeout(() => {
|
|
102
|
+
if (undo.current === revert) undo.current = null;
|
|
103
|
+
}, UNDO_MS);
|
|
104
|
+
saved.then((ok) => {
|
|
105
|
+
if (ok.length === 0 && undo.current === revert) undo.current = null;
|
|
101
106
|
});
|
|
102
107
|
setSelected(EMPTY);
|
|
103
108
|
}, [failed]);
|
|
@@ -19,9 +19,9 @@ import { ChatCommandFacts, ChatCommit, ChatContextFacts, ChatResolvedPath, ChatS
|
|
|
19
19
|
import { ComposerContractSession, ComposerHostCapability, ComposerHostContractBackend, ComposerHostContractControl, ComposerHostHarness, ComposerHostHarnessFactory, describeComposerHostContract } from "./composer.contract.js";
|
|
20
20
|
import { SidebarHostCapability, SidebarHostContractBackend, SidebarHostContractControl, SidebarHostHarness, SidebarHostHarnessFactory, describeSidebarHostContract } from "./sidebar.contract.js";
|
|
21
21
|
import { BadgeActionEffect, BadgeMenuItem, ExtensionReferenceView, ReferenceProviderWire } from "zidane/chat/pure";
|
|
22
|
-
import { InteractionRequest } from "zidane/chat";
|
|
22
|
+
import { InteractionRequest, ToolCallDetail as ToolCallDetail$1 } from "zidane/chat";
|
|
23
23
|
/** An optional `ChatHost` member, by its path. */
|
|
24
|
-
export type ChatHostCapability = 'sessions' | 'sessions.create' | 'sessions.rename' | 'sessions.setArchived' | 'sessions.setFavorite' | 'sessions.setInboxState' | 'sessions.remove' | 'sessions.query' | 'sessions.setSpace' | 'sessions.search' | 'sessions.onChanged' | 'sessions.views' | 'sessions.main' | 'send' | 'interrupt' | 'shell' | 'providerReady' | 'interactions' | 'interactions.cancel' | 'interactions.all' | 'models' | 'toolOutput' | 'cancelTool' | 'searchSync' | 'references' | 'paths' | 'chips' | 'chips.commit' | 'chips.sessions' | 'chips.context' | 'chips.skills' | 'chips.commands' | 'badges' | 'siteIcons' | 'blockRuns';
|
|
24
|
+
export type ChatHostCapability = 'sessions' | 'sessions.create' | 'sessions.rename' | 'sessions.setArchived' | 'sessions.setFavorite' | 'sessions.setInboxState' | 'sessions.remove' | 'sessions.query' | 'sessions.setSpace' | 'sessions.search' | 'sessions.onChanged' | 'sessions.views' | 'sessions.main' | 'send' | 'interrupt' | 'shell' | 'providerReady' | 'interactions' | 'interactions.cancel' | 'interactions.all' | 'models' | 'toolOutput' | 'toolOutputRange' | 'toolCall' | 'cancelTool' | 'searchSync' | 'references' | 'paths' | 'chips' | 'chips.commit' | 'chips.sessions' | 'chips.context' | 'chips.skills' | 'chips.commands' | 'badges' | 'siteIcons' | 'blockRuns';
|
|
25
25
|
/** One thing the backend does while it runs a prompt, in order. */
|
|
26
26
|
export type ChatHostScriptStep = {
|
|
27
27
|
kind: 'reply';
|
|
@@ -42,8 +42,10 @@ export interface ChatHostContractBackend {
|
|
|
42
42
|
sessions: readonly ChatSession[];
|
|
43
43
|
/** Stored events per session id (a session missing here has none). */
|
|
44
44
|
transcripts: Readonly<Record<string, readonly ChatEvent[]>>;
|
|
45
|
-
/** A tool call's full output, by call id (any session). */
|
|
45
|
+
/** A tool call's full output, by call id (any session). A range of it (`toolOutputRange`) is `{ text, offset, total }` in UTF-16 code units. */
|
|
46
46
|
toolOutputs: Readonly<Record<string, string>>;
|
|
47
|
+
/** The whole of a tool call (its input, its edit), by call id (any session). */
|
|
48
|
+
toolCalls?: Readonly<Record<string, ToolCallDetail$1>>;
|
|
47
49
|
/**
|
|
48
50
|
* What a run does with a sent prompt. The backend echoes the prompt into the transcript, starts the
|
|
49
51
|
* run, plays these steps, and ends the run when they are done (unless a step holds it).
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createToolOutputPager } from "../headless/output-pager.js";
|
|
1
2
|
import { describeComposerHostContract } from "./composer.contract.js";
|
|
2
3
|
import { describeSidebarHostContract } from "./sidebar.contract.js";
|
|
3
4
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
@@ -25,6 +26,8 @@ const CAPABILITIES = [
|
|
|
25
26
|
"interactions.all",
|
|
26
27
|
"models",
|
|
27
28
|
"toolOutput",
|
|
29
|
+
"toolOutputRange",
|
|
30
|
+
"toolCall",
|
|
28
31
|
"cancelTool",
|
|
29
32
|
"searchSync",
|
|
30
33
|
"references",
|
|
@@ -78,6 +81,8 @@ const SESSIONS = [{
|
|
|
78
81
|
createdAt: 3,
|
|
79
82
|
updatedAt: 4
|
|
80
83
|
}];
|
|
84
|
+
/** A result longer than a few pages, with characters of two code units (a page edge can split one). */
|
|
85
|
+
const LONG_OUTPUT = Array.from({ length: 300 }, (_, i) => `line ${i} é 🙂\n`).join("");
|
|
81
86
|
const CONTRACT_SHA = "abc1234def5678abc1234def5678abc1234def56";
|
|
82
87
|
function contractBackend() {
|
|
83
88
|
return {
|
|
@@ -89,7 +94,24 @@ function contractBackend() {
|
|
|
89
94
|
kind: "markdown",
|
|
90
95
|
text: "earlier reply"
|
|
91
96
|
}] },
|
|
92
|
-
toolOutputs: {
|
|
97
|
+
toolOutputs: {
|
|
98
|
+
"call-1": "the full output",
|
|
99
|
+
"call-long": LONG_OUTPUT
|
|
100
|
+
},
|
|
101
|
+
toolCalls: { "call-1": {
|
|
102
|
+
input: {
|
|
103
|
+
path: "a.ts",
|
|
104
|
+
content: "the whole file"
|
|
105
|
+
},
|
|
106
|
+
edit: {
|
|
107
|
+
tool: "write_file",
|
|
108
|
+
path: "a.ts",
|
|
109
|
+
hunks: [{
|
|
110
|
+
oldString: "",
|
|
111
|
+
newString: "the whole file"
|
|
112
|
+
}]
|
|
113
|
+
}
|
|
114
|
+
} },
|
|
93
115
|
script(prompt) {
|
|
94
116
|
if (prompt === "hold") return [{ kind: "hold" }];
|
|
95
117
|
if (prompt === "ask") return [{
|
|
@@ -443,6 +465,49 @@ function describeChatHostContract(name, makeHarness, capabilities) {
|
|
|
443
465
|
expect(await host.toolOutput("c-1", "call-1")).toBe("the full output");
|
|
444
466
|
expect(await host.toolOutput("c-1", "call-unknown")).toBeNull();
|
|
445
467
|
});
|
|
468
|
+
it.skipIf(!has("toolOutputRange"))("reads a tool call's output a range at a time", async () => {
|
|
469
|
+
const { host } = await setup();
|
|
470
|
+
const total = LONG_OUTPUT.length;
|
|
471
|
+
expect(await host.toolOutputRange("c-1", "call-long", {
|
|
472
|
+
offset: 0,
|
|
473
|
+
length: 10
|
|
474
|
+
})).toEqual({
|
|
475
|
+
text: LONG_OUTPUT.slice(0, 10),
|
|
476
|
+
offset: 0,
|
|
477
|
+
total
|
|
478
|
+
});
|
|
479
|
+
expect(await host.toolOutputRange("c-1", "call-long", {
|
|
480
|
+
offset: total - 5,
|
|
481
|
+
length: 100
|
|
482
|
+
})).toEqual({
|
|
483
|
+
text: LONG_OUTPUT.slice(total - 5),
|
|
484
|
+
offset: total - 5,
|
|
485
|
+
total
|
|
486
|
+
});
|
|
487
|
+
expect(await host.toolOutputRange("c-1", "call-unknown", {
|
|
488
|
+
offset: 0,
|
|
489
|
+
length: 10
|
|
490
|
+
})).toBeNull();
|
|
491
|
+
const pager = createToolOutputPager((range) => host.toolOutputRange("c-1", "call-long", range), { pageSize: 1e3 });
|
|
492
|
+
await pager.loadMore();
|
|
493
|
+
expect(pager.get()).toMatchObject({
|
|
494
|
+
text: LONG_OUTPUT.slice(0, 1e3),
|
|
495
|
+
total,
|
|
496
|
+
error: null
|
|
497
|
+
});
|
|
498
|
+
await pager.loadAll();
|
|
499
|
+
expect(pager.get()).toMatchObject({
|
|
500
|
+
text: LONG_OUTPUT,
|
|
501
|
+
total,
|
|
502
|
+
loading: false,
|
|
503
|
+
error: null
|
|
504
|
+
});
|
|
505
|
+
});
|
|
506
|
+
it.skipIf(!has("toolCall"))("reads the whole of a tool call", async () => {
|
|
507
|
+
const { host } = await setup();
|
|
508
|
+
expect(await host.toolCall("c-1", "call-1")).toEqual(contractBackend().toolCalls["call-1"]);
|
|
509
|
+
expect(await host.toolCall("c-1", "call-unknown")).toBeNull();
|
|
510
|
+
});
|
|
446
511
|
it.skipIf(!has("searchSync"))("shares a session's search with its other windows", async () => {
|
|
447
512
|
const harness = await makeHarness(contractBackend());
|
|
448
513
|
cleanup.push(() => harness.dispose?.());
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* An in-memory `SidebarHost` for docs, demos and tests: each session's
|
|
3
3
|
* environment commands and what running one answers, with every reveal,
|
|
4
|
-
* window, retry, run and opened host settings recorded for the caller to read.
|
|
4
|
+
* window, retry, wake, run and opened host settings recorded for the caller to read.
|
|
5
5
|
*/
|
|
6
6
|
import { SessionWindowMode, SidebarHost } from "../headless/sidebar/host.js";
|
|
7
7
|
import { EnvironmentActionResult, EnvironmentActionSummary } from "zidane/chat";
|
|
@@ -34,6 +34,12 @@ export interface FixtureSidebarCalls {
|
|
|
34
34
|
}[];
|
|
35
35
|
/** Every environment retried, in order. */
|
|
36
36
|
retried: string[];
|
|
37
|
+
/** Every paused environment woken, in order. */
|
|
38
|
+
woken: string[];
|
|
39
|
+
/** Every environment paused, in order. */
|
|
40
|
+
paused: string[];
|
|
41
|
+
/** Every sandbox deleted, in order. */
|
|
42
|
+
removed: string[];
|
|
37
43
|
/** Every environment command run, in order. */
|
|
38
44
|
ran: {
|
|
39
45
|
sessionId: string;
|
|
@@ -10,6 +10,9 @@ function createFixtureSidebarHost(options = {}) {
|
|
|
10
10
|
revealed: [],
|
|
11
11
|
windows: [],
|
|
12
12
|
retried: [],
|
|
13
|
+
woken: [],
|
|
14
|
+
paused: [],
|
|
15
|
+
removed: [],
|
|
13
16
|
ran: [],
|
|
14
17
|
hostSettings: []
|
|
15
18
|
};
|
|
@@ -41,6 +44,15 @@ function createFixtureSidebarHost(options = {}) {
|
|
|
41
44
|
},
|
|
42
45
|
retry: async (sessionId) => {
|
|
43
46
|
calls.retried.push(sessionId);
|
|
47
|
+
},
|
|
48
|
+
wake: async (sessionId) => {
|
|
49
|
+
calls.woken.push(sessionId);
|
|
50
|
+
},
|
|
51
|
+
pause: async (sessionId) => {
|
|
52
|
+
calls.paused.push(sessionId);
|
|
53
|
+
},
|
|
54
|
+
remove: async (sessionId) => {
|
|
55
|
+
calls.removed.push(sessionId);
|
|
44
56
|
}
|
|
45
57
|
} } : {}
|
|
46
58
|
};
|
|
@@ -37,6 +37,12 @@ export interface SidebarHostContractControl {
|
|
|
37
37
|
}[];
|
|
38
38
|
/** The environments set up again, in order. Only read with `environment`. */
|
|
39
39
|
retried?: () => readonly string[];
|
|
40
|
+
/** The paused environments woken, in order. Given exactly when the host's `environment` offers `wake`. */
|
|
41
|
+
woken?: () => readonly string[];
|
|
42
|
+
/** The environments paused, in order. Given exactly when the host's `environment` offers `pause`. */
|
|
43
|
+
paused?: () => readonly string[];
|
|
44
|
+
/** The sandboxes deleted, in order. Given exactly when the host's `environment` offers `remove`. */
|
|
45
|
+
removed?: () => readonly string[];
|
|
40
46
|
/** The hosts whose settings were opened, in order. Only read with `openHostSettings`. */
|
|
41
47
|
hostSettingsOpened?: () => readonly string[];
|
|
42
48
|
/** The backend records or changes an artifact of `sessionId`. Only called with `badges`. */
|
|
@@ -105,6 +105,30 @@ function describeSidebarHostContract(name, makeHarness, capabilities) {
|
|
|
105
105
|
await expect(host.environment.retry("s1")).resolves.toBeUndefined();
|
|
106
106
|
expect(control.retried?.()).toEqual(["s1"]);
|
|
107
107
|
});
|
|
108
|
+
it.skipIf(!has("environment"))("wakes a paused environment when it offers that", async () => {
|
|
109
|
+
const { host, control } = await setup();
|
|
110
|
+
const wake = host.environment.wake;
|
|
111
|
+
expect(wake === void 0).toBe(control.woken === void 0);
|
|
112
|
+
if (!wake) return;
|
|
113
|
+
await expect(wake("s1")).resolves.toBeUndefined();
|
|
114
|
+
expect(control.woken?.()).toEqual(["s1"]);
|
|
115
|
+
});
|
|
116
|
+
it.skipIf(!has("environment"))("pauses an environment when it offers that", async () => {
|
|
117
|
+
const { host, control } = await setup();
|
|
118
|
+
const pause = host.environment.pause;
|
|
119
|
+
expect(pause === void 0).toBe(control.paused === void 0);
|
|
120
|
+
if (!pause) return;
|
|
121
|
+
await expect(pause("s1")).resolves.toBeUndefined();
|
|
122
|
+
expect(control.paused?.()).toEqual(["s1"]);
|
|
123
|
+
});
|
|
124
|
+
it.skipIf(!has("environment"))("deletes a session's sandbox when it offers that", async () => {
|
|
125
|
+
const { host, control } = await setup();
|
|
126
|
+
const remove = host.environment.remove;
|
|
127
|
+
expect(remove === void 0).toBe(control.removed === void 0);
|
|
128
|
+
if (!remove) return;
|
|
129
|
+
await expect(remove("s1")).resolves.toBeUndefined();
|
|
130
|
+
expect(control.removed?.()).toEqual(["s1"]);
|
|
131
|
+
});
|
|
108
132
|
it.skipIf(!has("badges"))("reads several sessions' badges at once, none for a session without artifacts", async () => {
|
|
109
133
|
const { host } = await setup();
|
|
110
134
|
expect(await host.badges.read(["s1", "s2"])).toEqual({
|
|
@@ -35,6 +35,11 @@ export interface DiffLinesProps {
|
|
|
35
35
|
* ones) highlights as one text, so a token that spans lines colors right. Absent: plain text.
|
|
36
36
|
*/
|
|
37
37
|
language?: string;
|
|
38
|
+
/**
|
|
39
|
+
* A line number per line, 1:1 with `lines` (`null`: none for that line).
|
|
40
|
+
* Set, a gutter shows them before the `+` / `−` markers.
|
|
41
|
+
*/
|
|
42
|
+
lineNumbers?: readonly (number | null)[];
|
|
38
43
|
/** Extra classes on the root element. */
|
|
39
44
|
className?: string;
|
|
40
45
|
/** Inline styles on the root element, merged after the component's own. */
|
|
@@ -47,4 +52,4 @@ export interface DiffLinesProps {
|
|
|
47
52
|
* a 500-line hunk would otherwise be 1,500 elements to build, style and lay
|
|
48
53
|
* out every time its row scrolled into a long transcript.
|
|
49
54
|
*/
|
|
50
|
-
export declare const DiffLines: import("react").MemoExoticComponent<({ lines, maxHeight, language, className, style: styleProp }: DiffLinesProps) => import("react").JSX.Element>;
|
|
55
|
+
export declare const DiffLines: import("react").MemoExoticComponent<({ lines, maxHeight, language, lineNumbers, className, style: styleProp }: DiffLinesProps) => import("react").JSX.Element>;
|
|
@@ -12,28 +12,38 @@ const MARKER = {
|
|
|
12
12
|
};
|
|
13
13
|
/** Past this many lines a diff stays plain: two highlights of a huge hunk cost more than its colors give. */
|
|
14
14
|
const HIGHLIGHT_MAX_LINES = 2e3;
|
|
15
|
-
const DiffRun = memo(({ op, text, count, tokens }) => {
|
|
15
|
+
const DiffRun = memo(({ op, text, count, tokens, numbers, gutter }) => {
|
|
16
|
+
const bg = op === "add" ? "var(--zg-diff-add-bg)" : op === "remove" ? "var(--zg-diff-remove-bg)" : "transparent";
|
|
17
|
+
const markerColor = op === "add" ? "var(--zg-success)" : op === "remove" ? "var(--zg-danger)" : "var(--zg-text-muted)";
|
|
16
18
|
return /* @__PURE__ */ jsxs("div", {
|
|
17
19
|
className: "flex items-start gap-2 px-2",
|
|
18
|
-
style: { background:
|
|
19
|
-
children: [
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}), /* @__PURE__ */ jsx("span", {
|
|
27
|
-
className: "flex-1 whitespace-pre",
|
|
28
|
-
children: tokens ? tokens.map((line, i) => /* @__PURE__ */ jsxs("span", { children: [line.map((t, j) => /* @__PURE__ */ jsx("span", {
|
|
20
|
+
style: { background: bg },
|
|
21
|
+
children: [
|
|
22
|
+
numbers !== void 0 && /* @__PURE__ */ jsx("span", {
|
|
23
|
+
style: { width: `${gutter}ch` },
|
|
24
|
+
className: "select-none shrink-0 whitespace-pre text-right text-[var(--zg-text-muted)]",
|
|
25
|
+
children: numbers
|
|
26
|
+
}),
|
|
27
|
+
/* @__PURE__ */ jsx("span", {
|
|
29
28
|
style: {
|
|
30
|
-
color:
|
|
31
|
-
|
|
32
|
-
fontWeight: t.fontWeight
|
|
29
|
+
color: markerColor,
|
|
30
|
+
width: "1ch"
|
|
33
31
|
},
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
className: "select-none shrink-0 whitespace-pre",
|
|
33
|
+
children: Array.from({ length: count }).fill(MARKER[op]).join("\n")
|
|
34
|
+
}),
|
|
35
|
+
/* @__PURE__ */ jsx("span", {
|
|
36
|
+
className: "flex-1 whitespace-pre",
|
|
37
|
+
children: tokens ? tokens.map((line, i) => /* @__PURE__ */ jsxs("span", { children: [line.map((t, j) => /* @__PURE__ */ jsx("span", {
|
|
38
|
+
style: {
|
|
39
|
+
color: t.color,
|
|
40
|
+
fontStyle: t.fontStyle,
|
|
41
|
+
fontWeight: t.fontWeight
|
|
42
|
+
},
|
|
43
|
+
children: t.text
|
|
44
|
+
}, j)), i < tokens.length - 1 ? "\n" : line.length === 0 ? " " : ""] }, i)) : text.endsWith("\n") || text === "" ? `${text} ` : text
|
|
45
|
+
})
|
|
46
|
+
]
|
|
37
47
|
});
|
|
38
48
|
});
|
|
39
49
|
/**
|
|
@@ -43,9 +53,10 @@ const DiffRun = memo(({ op, text, count, tokens }) => {
|
|
|
43
53
|
* a 500-line hunk would otherwise be 1,500 elements to build, style and lay
|
|
44
54
|
* out every time its row scrolled into a long transcript.
|
|
45
55
|
*/
|
|
46
|
-
const DiffLines = memo(({ lines, maxHeight, language, className, style: styleProp }) => {
|
|
56
|
+
const DiffLines = memo(({ lines, maxHeight, language, lineNumbers, className, style: styleProp }) => {
|
|
47
57
|
const style = maxHeight ? { maxHeight: `${maxHeight}px` } : BASE_NO_CLAMP;
|
|
48
58
|
const runs = useMemo(() => toRuns(lines), [lines]);
|
|
59
|
+
const gutter = useMemo(() => lineNumbers?.reduce((width, n) => Math.max(width, n === null ? 0 : String(n).length), 0) ?? 0, [lineNumbers]);
|
|
49
60
|
const frameRef = useRef(null);
|
|
50
61
|
const tokens = useDiffTokens(lines, language, frameRef);
|
|
51
62
|
return /* @__PURE__ */ jsx("div", {
|
|
@@ -61,7 +72,11 @@ const DiffLines = memo(({ lines, maxHeight, language, className, style: stylePro
|
|
|
61
72
|
op: run.op,
|
|
62
73
|
text: run.text,
|
|
63
74
|
count: run.count,
|
|
64
|
-
...tokens ? { tokens: tokens.slice(run.start, run.start + run.count) } : {}
|
|
75
|
+
...tokens ? { tokens: tokens.slice(run.start, run.start + run.count) } : {},
|
|
76
|
+
...lineNumbers && gutter > 0 ? {
|
|
77
|
+
numbers: lineNumbers.slice(run.start, run.start + run.count).map((n) => n ?? "").join("\n"),
|
|
78
|
+
gutter
|
|
79
|
+
} : {}
|
|
65
80
|
}, run.start))
|
|
66
81
|
})
|
|
67
82
|
});
|
|
@@ -4,6 +4,10 @@ import { StreamEvent } from "zidane/chat";
|
|
|
4
4
|
export interface EditDiffBlockProps {
|
|
5
5
|
/** The edit to draw: its path, hunks and per-hunk approval outcomes. */
|
|
6
6
|
edit: NonNullable<StreamEvent['edit']>;
|
|
7
|
+
/** The call's id: with it, a diff the host cut (`edit.clipped`) offers to load the rest (`TranscriptActions.toolCall`). */
|
|
8
|
+
callId?: string;
|
|
9
|
+
/** The call's turn, a hint where the host looks first. */
|
|
10
|
+
turnId?: string;
|
|
7
11
|
/** Extra classes on the root element. */
|
|
8
12
|
className?: string;
|
|
9
13
|
/** Inline styles on the root element, merged after the component's own. */
|
|
@@ -17,4 +21,4 @@ export interface EditDiffBlockProps {
|
|
|
17
21
|
* edits with all-applied outcomes collapse back to the flat layout so
|
|
18
22
|
* the common case doesn't grow extra chrome.
|
|
19
23
|
*/
|
|
20
|
-
export declare const EditDiffBlock: import("react").MemoExoticComponent<({ edit, className, style }: EditDiffBlockProps) => import("react").JSX.Element>;
|
|
24
|
+
export declare const EditDiffBlock: import("react").MemoExoticComponent<({ edit: lean, callId, turnId, className, style }: EditDiffBlockProps) => import("react").JSX.Element>;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { CopyButton } from "../../components/CopyButton.js";
|
|
2
2
|
import { useDisplayPath } from "../../hooks/useDisplayPath.js";
|
|
3
|
+
import { useChatLabels } from "../useChatLabels.js";
|
|
3
4
|
import { DiffLines } from "./DiffLines.js";
|
|
5
|
+
import { LoadFullOutputButton, useFullToolCall } from "./tool-parts.js";
|
|
4
6
|
import { memo, useMemo } from "react";
|
|
5
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
import { computeLineDiff, summarizeOutcomes } from "zidane/chat/pure";
|
|
8
|
+
import { computeLineDiff, formatBytes, summarizeOutcomes } from "zidane/chat/pure";
|
|
7
9
|
// src/chat/transcript/EditDiffBlock.tsx
|
|
8
10
|
const HUNK_DIM_STYLE = { opacity: .55 };
|
|
9
11
|
const HUNK_FULL_STYLE = { opacity: 1 };
|
|
10
|
-
const HunkDiffCard = memo(({ language, index, total, lines, outcome }) => {
|
|
12
|
+
const HunkDiffCard = memo(({ language, index, total, lines, lineNumbers, outcome }) => {
|
|
11
13
|
const kind = outcome?.kind ?? "applied";
|
|
12
14
|
return /* @__PURE__ */ jsxs("div", {
|
|
13
15
|
className: "bg-[var(--zg-code-bg)]",
|
|
@@ -33,11 +35,43 @@ const HunkDiffCard = memo(({ language, index, total, lines, outcome }) => {
|
|
|
33
35
|
}), /* @__PURE__ */ jsx(DiffLines, {
|
|
34
36
|
lines,
|
|
35
37
|
maxHeight: 360,
|
|
36
|
-
language
|
|
38
|
+
language,
|
|
39
|
+
...lineNumbers ? { lineNumbers } : {}
|
|
37
40
|
})]
|
|
38
41
|
});
|
|
39
42
|
});
|
|
40
43
|
/**
|
|
44
|
+
* Each hunk's diff lines and, for a hunk the host placed in the file
|
|
45
|
+
* (`oldLine`), a line number per line: a removed line's in the old file,
|
|
46
|
+
* the others' in the new one. A `write_file`'s hunks are regions of one
|
|
47
|
+
* file, so each shifts the next one's new numbers by the lines it added or
|
|
48
|
+
* removed; an edit step's `oldLine` is in the file the earlier steps left.
|
|
49
|
+
*/
|
|
50
|
+
function hunkLines(edit) {
|
|
51
|
+
const lines = [];
|
|
52
|
+
const numbers = [];
|
|
53
|
+
let shift = 0;
|
|
54
|
+
for (const hunk of edit.hunks) {
|
|
55
|
+
const diff = computeLineDiff(hunk.oldString, hunk.newString);
|
|
56
|
+
lines.push(diff);
|
|
57
|
+
let delta = 0;
|
|
58
|
+
for (const line of diff) delta += line.op === "add" ? 1 : line.op === "remove" ? -1 : 0;
|
|
59
|
+
if (hunk.oldLine === void 0) {
|
|
60
|
+
numbers.push(void 0);
|
|
61
|
+
shift += delta;
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
let oldNo = hunk.oldLine;
|
|
65
|
+
let newNo = hunk.oldLine + (edit.tool === "write_file" ? shift : 0);
|
|
66
|
+
numbers.push(diff.map((line) => line.op === "remove" ? oldNo++ : line.op === "add" ? newNo++ : (oldNo++, newNo++)));
|
|
67
|
+
shift += delta;
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
lines,
|
|
71
|
+
numbers
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
41
75
|
* Per-hunk diff renderer with approval-outcome badges. When `edit.outcomes`
|
|
42
76
|
* is set (per-edit approval landed live, or replay re-parsed it off the
|
|
43
77
|
* tool result body), each hunk gets its own card with a ✓/✕/⊘/⚠/⋯ badge;
|
|
@@ -45,45 +79,70 @@ const HunkDiffCard = memo(({ language, index, total, lines, outcome }) => {
|
|
|
45
79
|
* edits with all-applied outcomes collapse back to the flat layout so
|
|
46
80
|
* the common case doesn't grow extra chrome.
|
|
47
81
|
*/
|
|
48
|
-
const EditDiffBlock = memo(({ edit, className, style }) => {
|
|
82
|
+
const EditDiffBlock = memo(({ edit: lean, callId, turnId, className, style }) => {
|
|
83
|
+
const labels = useChatLabels();
|
|
84
|
+
const { full, load, available, ready } = useFullToolCall({
|
|
85
|
+
...callId ? { callId } : {},
|
|
86
|
+
...turnId ? { turnId } : {}
|
|
87
|
+
});
|
|
88
|
+
const edit = full !== "loading" && full?.edit ? full.edit : lean;
|
|
49
89
|
const outcomes = edit.outcomes;
|
|
50
90
|
const counts = useMemo(() => summarizeOutcomes(outcomes), [outcomes]);
|
|
51
91
|
const hunks = edit.hunks;
|
|
52
92
|
const shownPath = useDisplayPath().path(edit.path);
|
|
53
93
|
const base = edit.path.split("/").pop() ?? "";
|
|
54
94
|
const language = base.includes(".") ? base.split(".").pop().toLowerCase() : "";
|
|
55
|
-
const perHunkLines = useMemo(() =>
|
|
95
|
+
const { lines: perHunkLines, numbers: perHunkNumbers } = useMemo(() => hunkLines(edit), [edit]);
|
|
96
|
+
const flatLines = useMemo(() => perHunkLines.flat(), [perHunkLines]);
|
|
97
|
+
const flatNumbers = useMemo(() => perHunkNumbers.some(Boolean) ? perHunkNumbers.flatMap((numbers, i) => numbers ?? perHunkLines[i].map(() => null)) : void 0, [perHunkLines, perHunkNumbers]);
|
|
98
|
+
const clipped = edit.clipped;
|
|
56
99
|
const hasMixedOutcomes = outcomes != null && (counts.denied > 0 || counts.skipped > 0 || counts.failed > 0 || counts.pending > 0);
|
|
57
100
|
const usePerHunkLayout = outcomes != null && (hunks.length > 1 || hasMixedOutcomes);
|
|
58
101
|
return /* @__PURE__ */ jsxs("div", {
|
|
59
102
|
className: ["group zg-tray mt-2 rounded-zg-md overflow-hidden", className].filter(Boolean).join(" "),
|
|
60
103
|
style,
|
|
61
|
-
children: [
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
104
|
+
children: [
|
|
105
|
+
/* @__PURE__ */ jsxs("div", {
|
|
106
|
+
className: `pl-2.5 border-b border-[var(--zg-hairline)] flex items-center gap-3 text-zg-meta ${hasMixedOutcomes ? "py-1.5 pr-2.5" : "h-8 pr-1"}`,
|
|
107
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
108
|
+
className: "zg-meta text-[var(--zg-text)] truncate",
|
|
109
|
+
title: edit.path,
|
|
110
|
+
children: shownPath
|
|
111
|
+
}), hasMixedOutcomes ? /* @__PURE__ */ jsx(OutcomeSummary, { counts }) : /* @__PURE__ */ jsx(CopyButton, {
|
|
112
|
+
text: edit.path,
|
|
113
|
+
label: "Copy file path",
|
|
114
|
+
reveal: true,
|
|
115
|
+
className: "ml-auto"
|
|
116
|
+
})]
|
|
117
|
+
}),
|
|
118
|
+
usePerHunkLayout ? /* @__PURE__ */ jsx("div", {
|
|
119
|
+
className: "flex flex-col gap-px bg-[var(--zg-hairline)]",
|
|
120
|
+
children: hunks.map((_hunk, idx) => /* @__PURE__ */ jsx(HunkDiffCard, {
|
|
121
|
+
language,
|
|
122
|
+
index: idx,
|
|
123
|
+
total: hunks.length,
|
|
124
|
+
lines: perHunkLines[idx] ?? [],
|
|
125
|
+
lineNumbers: perHunkNumbers[idx],
|
|
126
|
+
outcome: outcomes?.[idx]
|
|
127
|
+
}, idx))
|
|
128
|
+
}) : /* @__PURE__ */ jsx(DiffLines, {
|
|
129
|
+
lines: flatLines,
|
|
130
|
+
maxHeight: 420,
|
|
76
131
|
language,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
132
|
+
...flatNumbers ? { lineNumbers: flatNumbers } : {}
|
|
133
|
+
}),
|
|
134
|
+
clipped && /* @__PURE__ */ jsxs("div", {
|
|
135
|
+
className: "px-2.5 py-1.5 border-t border-[var(--zg-hairline)] flex items-center gap-3 text-zg-meta text-[var(--zg-text-muted)]",
|
|
136
|
+
children: [/* @__PURE__ */ jsx("span", { children: labels.diffNotShown(clipped.hunks - hunks.length, formatBytes(clipped.bytes)) }), available && /* @__PURE__ */ jsx(LoadFullOutputButton, {
|
|
137
|
+
loading: full === "loading",
|
|
138
|
+
disabled: !ready,
|
|
139
|
+
onClick: load,
|
|
140
|
+
className: "ml-auto",
|
|
141
|
+
label: labels.loadFullDiff,
|
|
142
|
+
loadingLabel: labels.loadingFullDiff
|
|
143
|
+
})]
|
|
144
|
+
})
|
|
145
|
+
]
|
|
87
146
|
});
|
|
88
147
|
});
|
|
89
148
|
const OUTCOME_GLYPH = {
|
|
@@ -99,7 +99,7 @@ function Outcome({ icon, tone, label, note }) {
|
|
|
99
99
|
className: `${icon} text-zg-body shrink-0`
|
|
100
100
|
}), label]
|
|
101
101
|
}), note && /* @__PURE__ */ jsx("div", {
|
|
102
|
-
className: "pl-[22px] text-zg-ui leading-5 text-[var(--zg-text)] whitespace-pre-wrap
|
|
102
|
+
className: "pl-[22px] text-zg-ui leading-5 text-[var(--zg-text)] whitespace-pre-wrap",
|
|
103
103
|
children: note
|
|
104
104
|
})]
|
|
105
105
|
});
|