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
|
@@ -0,0 +1,579 @@
|
|
|
1
|
+
import { FloatingSurface } from "../../components/floating/FloatingSurface.js";
|
|
2
|
+
import "../../components/floating/hover-delay.js";
|
|
3
|
+
import { useKeyCommands } from "../../keybindings/KeyCommands.js";
|
|
4
|
+
import { useReducedMotion } from "../../motion/reduced.js";
|
|
5
|
+
import { constant, useReadable } from "../headless/store.js";
|
|
6
|
+
import { EMPTY_RAIL, computeRailModel, computeRailModelParts, createTranscriptRailStore, dataRowSelector, railWithOutline } from "../headless/transcript/rail.js";
|
|
7
|
+
import { useChatLabels } from "../useChatLabels.js";
|
|
8
|
+
import { useModelName } from "./actions.js";
|
|
9
|
+
import { RUN_RECEIPT_TINT, ReceiptValue } from "./receipt-parts.js";
|
|
10
|
+
import { revealRow } from "./row-mount.js";
|
|
11
|
+
import { SelectCursor } from "./SelectCursor.js";
|
|
12
|
+
import { createContext, memo, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
13
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { formatRunReceiptCells } from "zidane/chat/pure";
|
|
15
|
+
// src/chat/transcript/TranscriptRail.tsx
|
|
16
|
+
/** The rail's width: its ticks' hit area. */
|
|
17
|
+
const RAIL_WIDTH_PX = 16;
|
|
18
|
+
/**
|
|
19
|
+
* The farthest the rail sits from the pane's left edge. In a narrow pane it centres in the space left of the text;
|
|
20
|
+
* once that space is wider than twice this, it stays this far from the edge, clear of the conversation.
|
|
21
|
+
*/
|
|
22
|
+
const RAIL_EDGE_INSET_PX = 16;
|
|
23
|
+
/** A tick's height: its hit area. */
|
|
24
|
+
const TICK_PX = 8;
|
|
25
|
+
/** How far the list's scrolling edges fade (`.zg-prompt-rail-ticks[data-fade-*]`). */
|
|
26
|
+
const FADE_PX = 24;
|
|
27
|
+
/** The space kept above and below the rail when its ticks fill the view's height. */
|
|
28
|
+
const RAIL_FIT_INSET_PX = 24;
|
|
29
|
+
/** Where a jump puts the prompt: this far below the view's top. */
|
|
30
|
+
const JUMP_MARGIN_PX = 16;
|
|
31
|
+
/** The exchange in view is the last one starting above this line: this share of the view down, at most `SPY_LINE_MAX_PX`. */
|
|
32
|
+
const SPY_LINE_SHARE = .3;
|
|
33
|
+
const SPY_LINE_MAX_PX = 160;
|
|
34
|
+
/** A jump farther than this many views goes there at once (a glide that long reads as lag). */
|
|
35
|
+
const FAR_VIEWS = 1.5;
|
|
36
|
+
/** A scroll still for this long ends a jump: the spy reads the view again. */
|
|
37
|
+
const JUMP_SETTLE_MS = 140;
|
|
38
|
+
/** A far jump aims again each frame until its target holds still this many frames, for at most `AIM_MAX_FRAMES`. */
|
|
39
|
+
const AIM_STILL_FRAMES = 2;
|
|
40
|
+
const AIM_MAX_FRAMES = 12;
|
|
41
|
+
const CARD_WIDTH_PX = 320;
|
|
42
|
+
/** A tick's accessible name: the prompt's start, cut at a word. */
|
|
43
|
+
const TICK_LABEL_CHARS = 80;
|
|
44
|
+
const RailContext = createContext(null);
|
|
45
|
+
const NO_RAIL = constant(createTranscriptRailStore().get());
|
|
46
|
+
/**
|
|
47
|
+
* Holds the rail's store for the transcript and the rail below it.
|
|
48
|
+
*
|
|
49
|
+
* @param props - The {@link TranscriptRailProviderProps}.
|
|
50
|
+
*/
|
|
51
|
+
function TranscriptRailProvider({ children }) {
|
|
52
|
+
const [store] = useState(createTranscriptRailStore);
|
|
53
|
+
return /* @__PURE__ */ jsx(RailContext.Provider, {
|
|
54
|
+
value: store,
|
|
55
|
+
children
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/** The rail store of the nearest {@link TranscriptRailProvider}, or `null` outside one. */
|
|
59
|
+
function useTranscriptRailStore() {
|
|
60
|
+
return useContext(RailContext);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The transcript's side of the rail: publishes its exchanges and the cursor's exchange to the provider's store.
|
|
64
|
+
* Outside a provider it computes nothing.
|
|
65
|
+
*
|
|
66
|
+
* @param clusters - The root clusters the transcript paints, or their settled and open parts (the settled ones fold once).
|
|
67
|
+
* @param isHidden - Whether a row paints nothing.
|
|
68
|
+
* @param receipts - The receipts docked on reply rows.
|
|
69
|
+
* @param selectedTurn - Select-turn mode's selected stop (a turn id), or `null`.
|
|
70
|
+
*/
|
|
71
|
+
function useRailPublish(clusters, isHidden, receipts, selectedTurn) {
|
|
72
|
+
const store = useContext(RailContext);
|
|
73
|
+
const model = useMemo(() => store ? Array.isArray(clusters) ? computeRailModel(clusters, {
|
|
74
|
+
isHidden,
|
|
75
|
+
receipts
|
|
76
|
+
}) : computeRailModelParts(clusters, {
|
|
77
|
+
isHidden,
|
|
78
|
+
receipts
|
|
79
|
+
}) : null, [
|
|
80
|
+
store,
|
|
81
|
+
clusters,
|
|
82
|
+
isHidden,
|
|
83
|
+
receipts
|
|
84
|
+
]);
|
|
85
|
+
useLayoutEffect(() => {
|
|
86
|
+
if (store && model) store.publish(model);
|
|
87
|
+
}, [store, model]);
|
|
88
|
+
useLayoutEffect(() => store ? () => store.publish(EMPTY_RAIL) : void 0, [store]);
|
|
89
|
+
const selected = selectedTurn && model ? model.exchangeOfTurn.get(selectedTurn) ?? null : null;
|
|
90
|
+
useLayoutEffect(() => {
|
|
91
|
+
store?.select(selected);
|
|
92
|
+
}, [store, selected]);
|
|
93
|
+
return store;
|
|
94
|
+
}
|
|
95
|
+
/** How long a jump to an unloaded prompt waits for its rows to be painted once its history is in. */
|
|
96
|
+
const LANDING_WAIT_MS = 3e3;
|
|
97
|
+
/**
|
|
98
|
+
* The transcript host's side of the rail: hands it the session's prompt outline while part of the history is not
|
|
99
|
+
* loaded, and how to load up to one of them. Read again when the session changes, when more history becomes
|
|
100
|
+
* loadable, and when the outline no longer matches the loaded rows (the history was rewritten).
|
|
101
|
+
*
|
|
102
|
+
* @param transcript - The session's transcript, from its host.
|
|
103
|
+
* @param hasEarlier - Older history is not loaded yet.
|
|
104
|
+
*/
|
|
105
|
+
function useRailOutline(transcript, hasEarlier) {
|
|
106
|
+
const store = useContext(RailContext);
|
|
107
|
+
const read = transcript.outline;
|
|
108
|
+
const loadThrough = transcript.loadThrough ?? null;
|
|
109
|
+
const [stale, setStale] = useState(0);
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
if (!store || !read || !hasEarlier) {
|
|
112
|
+
store?.publishOutline(null, null);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
let cancelled = false;
|
|
116
|
+
read().then((outline) => {
|
|
117
|
+
if (!cancelled) store.publishOutline(outline && outline.prompts.length > 0 ? outline.prompts : null, loadThrough);
|
|
118
|
+
}).catch(() => {
|
|
119
|
+
if (!cancelled) store.publishOutline(null, null);
|
|
120
|
+
});
|
|
121
|
+
return () => {
|
|
122
|
+
cancelled = true;
|
|
123
|
+
};
|
|
124
|
+
}, [
|
|
125
|
+
store,
|
|
126
|
+
read,
|
|
127
|
+
loadThrough,
|
|
128
|
+
hasEarlier,
|
|
129
|
+
stale
|
|
130
|
+
]);
|
|
131
|
+
useEffect(() => {
|
|
132
|
+
if (!store) return void 0;
|
|
133
|
+
let checked = null;
|
|
134
|
+
return store.subscribe(() => {
|
|
135
|
+
const { outline, exchanges, exchangeOfTurn } = store.get();
|
|
136
|
+
if (!outline || exchanges.length === 0 || checked === outline) return;
|
|
137
|
+
checked = outline;
|
|
138
|
+
if (!outline.some((p) => exchangeOfTurn.has(p.turnId))) setStale((n) => n + 1);
|
|
139
|
+
});
|
|
140
|
+
}, [store]);
|
|
141
|
+
useEffect(() => store ? () => store.publishOutline(null, null) : void 0, [store]);
|
|
142
|
+
}
|
|
143
|
+
/** The id of the exchange holding `turnId` once the transcript paints it, or `null` past {@link LANDING_WAIT_MS}. */
|
|
144
|
+
function exchangeOnceLoaded(store, turnId) {
|
|
145
|
+
const now = store.get().exchangeOfTurn.get(turnId);
|
|
146
|
+
if (now) return Promise.resolve(now);
|
|
147
|
+
return new Promise((resolve) => {
|
|
148
|
+
let timer = 0;
|
|
149
|
+
const off = store.subscribe(() => {
|
|
150
|
+
const id = store.get().exchangeOfTurn.get(turnId);
|
|
151
|
+
if (!id) return;
|
|
152
|
+
window.clearTimeout(timer);
|
|
153
|
+
off();
|
|
154
|
+
resolve(id);
|
|
155
|
+
});
|
|
156
|
+
timer = window.setTimeout(() => {
|
|
157
|
+
off();
|
|
158
|
+
resolve(null);
|
|
159
|
+
}, LANDING_WAIT_MS);
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* The hovered exchange's tint, behind the transcript's rows (the select cursor's element, without following).
|
|
164
|
+
*
|
|
165
|
+
* @param props - The rail's store.
|
|
166
|
+
*/
|
|
167
|
+
const RailTint = memo(({ store }) => {
|
|
168
|
+
const { exchanges, hovered, selected } = useReadable(store);
|
|
169
|
+
const exchange = hovered && selected === null ? exchanges.find((e) => e.id === hovered) : void 0;
|
|
170
|
+
const first = exchange?.firstRowId;
|
|
171
|
+
const last = exchange?.lastRowId;
|
|
172
|
+
const span = useMemo(() => first && last ? {
|
|
173
|
+
first,
|
|
174
|
+
last
|
|
175
|
+
} : null, [first, last]);
|
|
176
|
+
return /* @__PURE__ */ jsx(SelectCursor, {
|
|
177
|
+
selected: span ? hovered : null,
|
|
178
|
+
layout: exchanges,
|
|
179
|
+
span,
|
|
180
|
+
follow: false,
|
|
181
|
+
className: "zg-rail-tint"
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
RailTint.displayName = "RailTint";
|
|
185
|
+
/** The prompt row of an exchange in the scroller. */
|
|
186
|
+
function promptRow(scroller, id) {
|
|
187
|
+
return scroller.querySelector(dataRowSelector(id));
|
|
188
|
+
}
|
|
189
|
+
/** The rail's height: its ticks, at most `RAIL_MAX_TICKS` of them and whole ones that fit in `room`. */
|
|
190
|
+
function railHeight(ticks, room) {
|
|
191
|
+
return Math.min(ticks * TICK_PX, 320, Math.floor(room / TICK_PX) * TICK_PX);
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Where the rail's middle goes in its offset parent. Centred on the view when the view is at its tallest yet (or moved);
|
|
195
|
+
* as the view only gets shorter (the composer grows), it stays where it was while it fits between the view's edges
|
|
196
|
+
* (less `RAIL_FIT_INSET_PX`), and moves as little as it must when it doesn't.
|
|
197
|
+
*
|
|
198
|
+
* @param home - The kept centre, and the view it was taken in.
|
|
199
|
+
* @param viewTop - The view's top in the offset parent.
|
|
200
|
+
* @param viewHeight - The view's height.
|
|
201
|
+
* @param height - The rail's height.
|
|
202
|
+
*/
|
|
203
|
+
function holdTop(home, viewTop, viewHeight, height) {
|
|
204
|
+
const kept = home.current;
|
|
205
|
+
if (!kept || kept.viewTop !== viewTop || viewHeight >= kept.viewHeight) home.current = {
|
|
206
|
+
center: viewTop + viewHeight / 2,
|
|
207
|
+
viewTop,
|
|
208
|
+
viewHeight
|
|
209
|
+
};
|
|
210
|
+
const center = home.current.center;
|
|
211
|
+
const lowest = viewTop + RAIL_FIT_INSET_PX + height / 2;
|
|
212
|
+
const highest = viewTop + viewHeight - RAIL_FIT_INSET_PX - height / 2;
|
|
213
|
+
return lowest > highest ? viewTop + viewHeight / 2 : Math.min(Math.max(center, lowest), highest);
|
|
214
|
+
}
|
|
215
|
+
/** The exchanges whose rows are loaded: the ones the view can be in. */
|
|
216
|
+
function loadedOnly(exchanges) {
|
|
217
|
+
return exchanges.length > 0 && exchanges[0].unloaded ? exchanges.filter((e) => !e.unloaded) : exchanges;
|
|
218
|
+
}
|
|
219
|
+
/** A tick's accessible name: the prompt, past `TICK_LABEL_CHARS` cut at a word boundary with an ellipsis. */
|
|
220
|
+
function tickLabel(prompt) {
|
|
221
|
+
if (prompt.length <= TICK_LABEL_CHARS) return prompt;
|
|
222
|
+
const cut = prompt.slice(0, TICK_LABEL_CHARS);
|
|
223
|
+
const space = cut.lastIndexOf(" ");
|
|
224
|
+
return `${(space > TICK_LABEL_CHARS / 2 ? cut.slice(0, space) : cut).trimEnd()}…`;
|
|
225
|
+
}
|
|
226
|
+
/** The exchange in view: the last one whose prompt starts above the spy line (the last at the bottom). */
|
|
227
|
+
function spyExchange(scroller, exchanges) {
|
|
228
|
+
if (exchanges.length === 0) return null;
|
|
229
|
+
if (scroller.scrollHeight - scroller.scrollTop - scroller.clientHeight <= 2) return exchanges[exchanges.length - 1].id;
|
|
230
|
+
const line = scroller.getBoundingClientRect().top + Math.min(scroller.clientHeight * SPY_LINE_SHARE, SPY_LINE_MAX_PX);
|
|
231
|
+
let lo = 0;
|
|
232
|
+
let hi = exchanges.length - 1;
|
|
233
|
+
let found = 0;
|
|
234
|
+
while (lo <= hi) {
|
|
235
|
+
const mid = lo + hi >> 1;
|
|
236
|
+
const row = promptRow(scroller, exchanges[mid].id);
|
|
237
|
+
if (row && row.getBoundingClientRect().top <= line) {
|
|
238
|
+
found = mid;
|
|
239
|
+
lo = mid + 1;
|
|
240
|
+
} else hi = mid - 1;
|
|
241
|
+
}
|
|
242
|
+
return exchanges[found].id;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Renders the prompt rail left of a transcript's column: a tick per prompt, the one in view raised, a card on hover,
|
|
246
|
+
* a jump on click.
|
|
247
|
+
*
|
|
248
|
+
* @param props - The {@link TranscriptRailProps}.
|
|
249
|
+
*/
|
|
250
|
+
function TranscriptRail({ scroller, keys = false, className, style }) {
|
|
251
|
+
const store = useContext(RailContext);
|
|
252
|
+
const { exchanges: loaded, exchangeOfTurn, hovered, selected, outline, loadThrough } = useReadable(store ?? NO_RAIL);
|
|
253
|
+
const exchanges = useMemo(() => railWithOutline({
|
|
254
|
+
exchanges: loaded,
|
|
255
|
+
exchangeOfTurn
|
|
256
|
+
}, outline), [
|
|
257
|
+
loaded,
|
|
258
|
+
exchangeOfTurn,
|
|
259
|
+
outline
|
|
260
|
+
]);
|
|
261
|
+
const [pending, setPending] = useState(null);
|
|
262
|
+
const labels = useChatLabels();
|
|
263
|
+
const reduced = useReducedMotion();
|
|
264
|
+
const root = useRef(null);
|
|
265
|
+
const list = useRef(null);
|
|
266
|
+
const [place, setPlace] = useState(null);
|
|
267
|
+
const home = useRef(null);
|
|
268
|
+
const tickCount = useRef(exchanges.length);
|
|
269
|
+
tickCount.current = exchanges.length;
|
|
270
|
+
const any = exchanges.length > 0;
|
|
271
|
+
useLayoutEffect(() => {
|
|
272
|
+
const el = scroller.current;
|
|
273
|
+
const rail = root.current;
|
|
274
|
+
if (!el || !rail) return void 0;
|
|
275
|
+
const measure = () => {
|
|
276
|
+
const parent = rail.offsetParent;
|
|
277
|
+
const column = el.querySelector(".zg-transcript-column");
|
|
278
|
+
if (!parent || !column) {
|
|
279
|
+
setPlace(null);
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
const textLeft = column.getBoundingClientRect().left + (Number.parseFloat(getComputedStyle(column).paddingLeft) || 0);
|
|
283
|
+
const view = el.getBoundingClientRect();
|
|
284
|
+
const edge = view.left + el.clientLeft;
|
|
285
|
+
const room = textLeft - edge;
|
|
286
|
+
if (room < 24) {
|
|
287
|
+
setPlace(null);
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
const base = parent.getBoundingClientRect();
|
|
291
|
+
const left = Math.round(edge + Math.min((room - RAIL_WIDTH_PX) / 2, RAIL_EDGE_INSET_PX) - base.left);
|
|
292
|
+
const height = Math.max(16, el.clientHeight - 48);
|
|
293
|
+
const top = Math.round(holdTop(home, view.top - base.top, el.clientHeight, railHeight(tickCount.current, height)));
|
|
294
|
+
setPlace((prev) => prev && prev.left === left && prev.top === top && prev.room === height ? prev : {
|
|
295
|
+
left,
|
|
296
|
+
top,
|
|
297
|
+
room: height
|
|
298
|
+
});
|
|
299
|
+
};
|
|
300
|
+
measure();
|
|
301
|
+
const ro = new ResizeObserver(measure);
|
|
302
|
+
ro.observe(el);
|
|
303
|
+
const column = el.querySelector(".zg-transcript-column");
|
|
304
|
+
if (column) ro.observe(column);
|
|
305
|
+
return () => ro.disconnect();
|
|
306
|
+
}, [scroller, any]);
|
|
307
|
+
const [spied, setSpied] = useState(null);
|
|
308
|
+
const jumping = useRef(null);
|
|
309
|
+
const aimFrame = useRef(0);
|
|
310
|
+
const exchangesRef = useRef(exchanges);
|
|
311
|
+
exchangesRef.current = exchanges;
|
|
312
|
+
useEffect(() => {
|
|
313
|
+
const el = scroller.current;
|
|
314
|
+
if (!el) return void 0;
|
|
315
|
+
let frame = 0;
|
|
316
|
+
const read = () => {
|
|
317
|
+
frame = 0;
|
|
318
|
+
if (!jumping.current) setSpied(spyExchange(el, loadedOnly(exchangesRef.current)));
|
|
319
|
+
};
|
|
320
|
+
const onScroll = () => {
|
|
321
|
+
const jump = jumping.current;
|
|
322
|
+
if (jump) {
|
|
323
|
+
window.clearTimeout(jump.timer);
|
|
324
|
+
jump.timer = window.setTimeout(() => {
|
|
325
|
+
jumping.current = null;
|
|
326
|
+
read();
|
|
327
|
+
}, JUMP_SETTLE_MS);
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
if (!frame) frame = requestAnimationFrame(read);
|
|
331
|
+
};
|
|
332
|
+
read();
|
|
333
|
+
el.addEventListener("scroll", onScroll, { passive: true });
|
|
334
|
+
return () => {
|
|
335
|
+
el.removeEventListener("scroll", onScroll);
|
|
336
|
+
cancelAnimationFrame(frame);
|
|
337
|
+
};
|
|
338
|
+
}, [scroller, exchanges]);
|
|
339
|
+
useEffect(() => () => {
|
|
340
|
+
window.clearTimeout(jumping.current?.timer);
|
|
341
|
+
cancelAnimationFrame(aimFrame.current);
|
|
342
|
+
}, []);
|
|
343
|
+
const active = selected ?? spied;
|
|
344
|
+
const glide = (el, id, end, targetOf) => {
|
|
345
|
+
const target = targetOf();
|
|
346
|
+
const far = Math.abs(target - el.scrollTop) > el.clientHeight * FAR_VIEWS;
|
|
347
|
+
window.clearTimeout(jumping.current?.timer);
|
|
348
|
+
cancelAnimationFrame(aimFrame.current);
|
|
349
|
+
jumping.current = {
|
|
350
|
+
id,
|
|
351
|
+
end,
|
|
352
|
+
timer: window.setTimeout(() => {
|
|
353
|
+
jumping.current = null;
|
|
354
|
+
}, JUMP_SETTLE_MS)
|
|
355
|
+
};
|
|
356
|
+
setSpied(id);
|
|
357
|
+
el.scrollTo({
|
|
358
|
+
top: target,
|
|
359
|
+
behavior: far || reduced ? "auto" : "smooth"
|
|
360
|
+
});
|
|
361
|
+
if (!far) return;
|
|
362
|
+
let frames = 0;
|
|
363
|
+
let still = 0;
|
|
364
|
+
const aim = () => {
|
|
365
|
+
const off = targetOf() - el.scrollTop;
|
|
366
|
+
if (Math.abs(off) > 1) {
|
|
367
|
+
el.scrollTop += off;
|
|
368
|
+
still = 0;
|
|
369
|
+
} else still++;
|
|
370
|
+
aimFrame.current = still < AIM_STILL_FRAMES && ++frames < AIM_MAX_FRAMES ? requestAnimationFrame(aim) : 0;
|
|
371
|
+
};
|
|
372
|
+
aimFrame.current = requestAnimationFrame(aim);
|
|
373
|
+
};
|
|
374
|
+
const land = (id) => {
|
|
375
|
+
const el = scroller.current;
|
|
376
|
+
const row = el ? revealRow(el, id) : null;
|
|
377
|
+
if (!el || !row) return;
|
|
378
|
+
glide(el, id, false, () => el.scrollTop + row.getBoundingClientRect().top - el.getBoundingClientRect().top - JUMP_MARGIN_PX);
|
|
379
|
+
};
|
|
380
|
+
const reach = async (id, unloaded) => {
|
|
381
|
+
if (!store || !loadThrough || pending === id) return;
|
|
382
|
+
setPending(id);
|
|
383
|
+
const landing = await loadThrough(unloaded.index).catch(() => false) ? await exchangeOnceLoaded(store, unloaded.turnId) : null;
|
|
384
|
+
setPending((at) => at === id ? null : at);
|
|
385
|
+
if (landing) land(landing);
|
|
386
|
+
};
|
|
387
|
+
const jump = (id) => {
|
|
388
|
+
const unloaded = exchangesRef.current.find((e) => e.id === id)?.unloaded;
|
|
389
|
+
if (unloaded) reach(id, unloaded);
|
|
390
|
+
else land(id);
|
|
391
|
+
};
|
|
392
|
+
const step = (dir) => {
|
|
393
|
+
const el = scroller.current;
|
|
394
|
+
const all = exchangesRef.current;
|
|
395
|
+
if (!el || all.length === 0) return;
|
|
396
|
+
const inFlight = selected === null ? jumping.current : null;
|
|
397
|
+
const current = selected ?? inFlight?.id ?? spyExchange(el, loadedOnly(all));
|
|
398
|
+
let at = all.findIndex((e) => e.id === current);
|
|
399
|
+
if (dir > 0) at++;
|
|
400
|
+
else if (inFlight) {
|
|
401
|
+
if (!inFlight.end) at--;
|
|
402
|
+
} else if (at >= 0) {
|
|
403
|
+
const row = promptRow(el, all[at].id);
|
|
404
|
+
if (!(row ? row.getBoundingClientRect().top < el.getBoundingClientRect().top + JUMP_MARGIN_PX - 4 : false)) at--;
|
|
405
|
+
}
|
|
406
|
+
if (at < 0) return;
|
|
407
|
+
if (at < all.length) jump(all[at].id);
|
|
408
|
+
else glide(el, all[all.length - 1].id, true, () => el.scrollHeight - el.clientHeight);
|
|
409
|
+
};
|
|
410
|
+
useKeyCommands(keys ? {
|
|
411
|
+
previousPrompt: () => step(-1),
|
|
412
|
+
nextPrompt: () => step(1)
|
|
413
|
+
} : {});
|
|
414
|
+
const [card, setCard] = useState(null);
|
|
415
|
+
const cardOpen = useRef(false);
|
|
416
|
+
const cardTimer = useRef(void 0);
|
|
417
|
+
useEffect(() => () => window.clearTimeout(cardTimer.current), []);
|
|
418
|
+
const showCard = useCallback((next) => {
|
|
419
|
+
cardOpen.current = next !== null;
|
|
420
|
+
setCard(next);
|
|
421
|
+
}, []);
|
|
422
|
+
const point = useCallback((id, anchor) => {
|
|
423
|
+
store?.hover(id);
|
|
424
|
+
window.clearTimeout(cardTimer.current);
|
|
425
|
+
if (cardOpen.current) showCard({
|
|
426
|
+
id,
|
|
427
|
+
anchor
|
|
428
|
+
});
|
|
429
|
+
else cardTimer.current = window.setTimeout(showCard, 250, {
|
|
430
|
+
id,
|
|
431
|
+
anchor
|
|
432
|
+
});
|
|
433
|
+
}, [store, showCard]);
|
|
434
|
+
const leave = useCallback(() => {
|
|
435
|
+
store?.hover(null);
|
|
436
|
+
window.clearTimeout(cardTimer.current);
|
|
437
|
+
cardTimer.current = window.setTimeout(showCard, 150, null);
|
|
438
|
+
}, [store, showCard]);
|
|
439
|
+
const [edges, setEdges] = useState({
|
|
440
|
+
top: false,
|
|
441
|
+
bottom: false
|
|
442
|
+
});
|
|
443
|
+
const readEdges = useCallback(() => {
|
|
444
|
+
const box = list.current;
|
|
445
|
+
const next = box ? {
|
|
446
|
+
top: box.scrollTop > 1,
|
|
447
|
+
bottom: box.scrollTop + box.clientHeight < box.scrollHeight - 1
|
|
448
|
+
} : {
|
|
449
|
+
top: false,
|
|
450
|
+
bottom: false
|
|
451
|
+
};
|
|
452
|
+
setEdges((prev) => prev.top === next.top && prev.bottom === next.bottom ? prev : next);
|
|
453
|
+
}, []);
|
|
454
|
+
useLayoutEffect(readEdges, [
|
|
455
|
+
readEdges,
|
|
456
|
+
exchanges.length,
|
|
457
|
+
place
|
|
458
|
+
]);
|
|
459
|
+
useEffect(() => {
|
|
460
|
+
const box = list.current;
|
|
461
|
+
const tick = active ? [...box?.querySelectorAll("[data-exchange]") ?? []].find((el) => el.dataset.exchange === active) : null;
|
|
462
|
+
if (!box || !tick) return;
|
|
463
|
+
const margin = Math.min(FADE_PX, box.clientHeight / 4);
|
|
464
|
+
if (tick.offsetTop < box.scrollTop + margin || tick.offsetTop + tick.offsetHeight > box.scrollTop + box.clientHeight - margin) box.scrollTop = tick.offsetTop + tick.offsetHeight / 2 - box.clientHeight / 2;
|
|
465
|
+
readEdges();
|
|
466
|
+
}, [active, readEdges]);
|
|
467
|
+
const onKeyDown = (e) => {
|
|
468
|
+
if (e.key === "Escape") {
|
|
469
|
+
if (!cardOpen.current && hovered === null) return;
|
|
470
|
+
e.preventDefault();
|
|
471
|
+
e.stopPropagation();
|
|
472
|
+
window.clearTimeout(cardTimer.current);
|
|
473
|
+
showCard(null);
|
|
474
|
+
store?.hover(null);
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
if (e.key !== "ArrowUp" && e.key !== "ArrowDown" && e.key !== "Home" && e.key !== "End") return;
|
|
478
|
+
const ticks = [...list.current?.querySelectorAll("button") ?? []];
|
|
479
|
+
const at = ticks.indexOf(document.activeElement);
|
|
480
|
+
const to = e.key === "Home" ? 0 : e.key === "End" ? ticks.length - 1 : at + (e.key === "ArrowUp" ? -1 : 1);
|
|
481
|
+
const next = ticks[Math.max(0, Math.min(ticks.length - 1, to))];
|
|
482
|
+
if (!next) return;
|
|
483
|
+
e.preventDefault();
|
|
484
|
+
e.stopPropagation();
|
|
485
|
+
next.focus();
|
|
486
|
+
};
|
|
487
|
+
const shown = store !== null && exchanges.length >= 2 && place !== null;
|
|
488
|
+
const tabStop = active && exchanges.some((e) => e.id === active) ? active : exchanges[exchanges.length - 1]?.id;
|
|
489
|
+
const carded = card ? exchanges.find((e) => e.id === card.id) : void 0;
|
|
490
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("div", {
|
|
491
|
+
ref: root,
|
|
492
|
+
"aria-hidden": shown ? void 0 : true,
|
|
493
|
+
className: ["zg-prompt-rail", className].filter(Boolean).join(" "),
|
|
494
|
+
"data-on": shown,
|
|
495
|
+
style: {
|
|
496
|
+
...place ? {
|
|
497
|
+
left: place.left,
|
|
498
|
+
top: place.top
|
|
499
|
+
} : {},
|
|
500
|
+
width: RAIL_WIDTH_PX,
|
|
501
|
+
...style
|
|
502
|
+
},
|
|
503
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
504
|
+
ref: list,
|
|
505
|
+
role: "toolbar",
|
|
506
|
+
"aria-orientation": "vertical",
|
|
507
|
+
"aria-label": labels.promptRail,
|
|
508
|
+
className: "zg-prompt-rail-ticks",
|
|
509
|
+
style: place ? { maxHeight: Math.min(320, Math.floor(place.room / TICK_PX) * TICK_PX) } : void 0,
|
|
510
|
+
"data-fade-top": edges.top ? "" : void 0,
|
|
511
|
+
"data-fade-bottom": edges.bottom ? "" : void 0,
|
|
512
|
+
onScroll: readEdges,
|
|
513
|
+
onPointerLeave: leave,
|
|
514
|
+
onBlur: (e) => {
|
|
515
|
+
if (!e.currentTarget.contains(e.relatedTarget)) leave();
|
|
516
|
+
},
|
|
517
|
+
onKeyDown,
|
|
518
|
+
children: exchanges.length >= 2 && exchanges.map((exchange) => /* @__PURE__ */ jsx("button", {
|
|
519
|
+
type: "button",
|
|
520
|
+
className: "zg-prompt-rail-tick",
|
|
521
|
+
"data-exchange": exchange.id,
|
|
522
|
+
"data-hover": exchange.id === hovered ? "" : void 0,
|
|
523
|
+
"data-pending": exchange.id === pending ? "" : void 0,
|
|
524
|
+
"aria-busy": exchange.id === pending || void 0,
|
|
525
|
+
"aria-label": tickLabel(exchange.prompt),
|
|
526
|
+
"aria-current": exchange.id === active ? "location" : void 0,
|
|
527
|
+
tabIndex: exchange.id === tabStop ? 0 : -1,
|
|
528
|
+
onPointerEnter: (e) => point(exchange.id, e.currentTarget),
|
|
529
|
+
onFocus: (e) => point(exchange.id, e.currentTarget),
|
|
530
|
+
onClick: () => jump(exchange.id)
|
|
531
|
+
}, exchange.id))
|
|
532
|
+
})
|
|
533
|
+
}), /* @__PURE__ */ jsx(FloatingSurface, {
|
|
534
|
+
open: shown && carded !== void 0,
|
|
535
|
+
anchor: { element: card?.anchor ?? null },
|
|
536
|
+
side: "right",
|
|
537
|
+
align: "center",
|
|
538
|
+
offset: 10,
|
|
539
|
+
width: CARD_WIDTH_PX,
|
|
540
|
+
className: "zg-prompt-rail-card",
|
|
541
|
+
children: carded && /* @__PURE__ */ jsx(RailCard, { exchange: carded })
|
|
542
|
+
})] });
|
|
543
|
+
}
|
|
544
|
+
/** The run receipt's cells the card shows, as the receipt row's chips: the model that answered and how long it took. */
|
|
545
|
+
const CARD_CELLS = /* @__PURE__ */ new Set(["model", "duration"]);
|
|
546
|
+
/**
|
|
547
|
+
* The hover card's content: the prompt and the start of its answer, each clamped (a long message never grows the card,
|
|
548
|
+
* a long word or path wraps inside it), then the receipt's chips.
|
|
549
|
+
*/
|
|
550
|
+
function RailCard({ exchange }) {
|
|
551
|
+
const modelName = useModelName();
|
|
552
|
+
const cells = exchange.receipt ? formatRunReceiptCells(exchange.receipt, modelName).filter((c) => CARD_CELLS.has(c.kind)) : [];
|
|
553
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
554
|
+
className: "flex flex-col gap-1.5 px-3 py-2.5",
|
|
555
|
+
"aria-hidden": true,
|
|
556
|
+
children: [
|
|
557
|
+
/* @__PURE__ */ jsx("p", {
|
|
558
|
+
className: "m-0 text-zg-ui leading-zg-ui font-medium text-[var(--zg-text)] line-clamp-2 break-words",
|
|
559
|
+
children: exchange.prompt
|
|
560
|
+
}),
|
|
561
|
+
exchange.answer && /* @__PURE__ */ jsx("p", {
|
|
562
|
+
className: "m-0 text-zg-label leading-zg-label text-[var(--zg-text-muted)] line-clamp-3 break-words",
|
|
563
|
+
children: exchange.answer
|
|
564
|
+
}),
|
|
565
|
+
cells.length > 0 && /* @__PURE__ */ jsx("div", {
|
|
566
|
+
className: "zg-meta flex flex-wrap items-center gap-1 min-w-0 mt-0.5",
|
|
567
|
+
children: cells.map((cell) => /* @__PURE__ */ jsx("span", {
|
|
568
|
+
className: "zg-meta-chip shrink min-w-0 max-w-full overflow-hidden",
|
|
569
|
+
"data-cell": cell.kind,
|
|
570
|
+
children: /* @__PURE__ */ jsx(ReceiptValue, {
|
|
571
|
+
text: cell.text,
|
|
572
|
+
className: RUN_RECEIPT_TINT[cell.kind]
|
|
573
|
+
})
|
|
574
|
+
}, cell.kind))
|
|
575
|
+
})
|
|
576
|
+
]
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
export { RailTint, TranscriptRail, TranscriptRailProvider, useRailOutline, useRailPublish, useTranscriptRailStore };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* One transcript row: the switch from a pipeline `Row` to its component,
|
|
3
|
-
* and the
|
|
3
|
+
* and the slot a root row mounts through. `TranscriptRow` is memoized
|
|
4
4
|
* on the row's own inputs plus ONE shared `RowContext` per transcript, so a
|
|
5
5
|
* render (a stream tick, a page of history arriving) builds one element per
|
|
6
|
-
* row and bails out for every row that did not change.
|
|
6
|
+
* row and bails out for every row that did not change. A root row renders in
|
|
7
|
+
* its lazy wrapper (`TranscriptRowSlot`, `LazyRow`).
|
|
7
8
|
*/
|
|
8
9
|
import { Cluster, Row } from "../headless/transcript/rows.js";
|
|
9
10
|
import "../headless/transcript/index.js";
|
|
@@ -86,10 +87,6 @@ export interface SlotEntry {
|
|
|
86
87
|
}
|
|
87
88
|
/** Props for {@link TranscriptRowSlot}: the {@link TranscriptRowProps} of its row, plus its lazy wrapper's. */
|
|
88
89
|
export interface TranscriptRowSlotProps extends Omit<TranscriptRowProps, 'className' | 'style'> {
|
|
89
|
-
/** Mounts the row at once instead of waiting for it to approach (the transcript's tail). */
|
|
90
|
-
eager: boolean;
|
|
91
|
-
/** Height in pixels of the placeholder box before the row mounts. */
|
|
92
|
-
estimatePx: number;
|
|
93
90
|
/** Inline style for the row's wrapper, usually its content-visibility sizing. */
|
|
94
91
|
style: CSSProperties;
|
|
95
92
|
/** The select-turn stop the row belongs to; set only in select mode. */
|
|
@@ -102,4 +99,4 @@ export interface TranscriptRowSlotProps extends Omit<TranscriptRowProps, 'classN
|
|
|
102
99
|
/** Renders one transcript row by switching on its `kind`: prompts, replies, thinking, tool calls, notices, folds, and groups. */
|
|
103
100
|
export declare const TranscriptRow: import("react").MemoExoticComponent<({ row, showCaret, receipt, resumable, ctx, renderRows, status, className, style }: TranscriptRowProps) => import("react").JSX.Element | null>;
|
|
104
101
|
/** One root transcript row in its lazy wrapper, memoised on the row's own inputs. */
|
|
105
|
-
export declare const TranscriptRowSlot: import("react").MemoExoticComponent<({
|
|
102
|
+
export declare const TranscriptRowSlot: import("react").MemoExoticComponent<({ style, stop, sel, className, ...row }: TranscriptRowSlotProps) => import("react").JSX.Element>;
|
|
@@ -5,10 +5,11 @@ import { ExchangeFoldRow } from "./fold.js";
|
|
|
5
5
|
import { Dot, RowFrame, lineStateOf, useRowIcons } from "./frame.js";
|
|
6
6
|
import { LazyRow } from "./LazyRow.js";
|
|
7
7
|
import { MessageGroupRow } from "./messages.js";
|
|
8
|
-
import { COMMAND_DETAIL_LINE, CommandDetailRow, CommandNoteRow, ErrorRow, FailureRow, InfoRow, NoticeRow, SessionEventRow, SpawnEndRow, SpawnStartRow } from "./notices.js";
|
|
8
|
+
import { COMMAND_DETAIL_LINE, CommandDetailRow, CommandNoteRow, ErrorRow, FailureRow, InfoRow, NoticeRow, RepairedRow, SessionEventRow, SpawnEndRow, SpawnStartRow } from "./notices.js";
|
|
9
9
|
import { UserPromptRow } from "./prompt.js";
|
|
10
10
|
import { PromptOriginLabel } from "./PromptOriginLabel.js";
|
|
11
11
|
import { TextRow, ThinkingBatchRow, ThinkingRow } from "./prose.js";
|
|
12
|
+
import { rowEstimatePx } from "./row-estimate.js";
|
|
12
13
|
import { CompactSummaryRow, RunReceiptInline, RunSummaryRow } from "./run-rows.js";
|
|
13
14
|
import { ShellBlockProvider } from "./shell-block.js";
|
|
14
15
|
import { TaskBatchRow, TaskRow } from "./tasks.js";
|
|
@@ -157,7 +158,10 @@ const TranscriptRow = memo(({ row, showCaret, receipt, resumable, ctx, renderRow
|
|
|
157
158
|
notice: row.notice,
|
|
158
159
|
text: row.text
|
|
159
160
|
}) : /* @__PURE__ */ jsx(InfoRow, { text: row.text })),
|
|
160
|
-
row.kind === "error" && (row.
|
|
161
|
+
row.kind === "error" && (row.repaired ? /* @__PURE__ */ jsx(RepairedRow, {
|
|
162
|
+
text: row.text,
|
|
163
|
+
detail: row.detail
|
|
164
|
+
}) : row.failure ? /* @__PURE__ */ jsx(FailureRow, {
|
|
161
165
|
text: row.text,
|
|
162
166
|
detail: row.detail,
|
|
163
167
|
failure: row.failure,
|
|
@@ -218,11 +222,11 @@ const TranscriptRow = memo(({ row, showCaret, receipt, resumable, ctx, renderRow
|
|
|
218
222
|
});
|
|
219
223
|
TranscriptRow.displayName = "TranscriptRow";
|
|
220
224
|
/** One root transcript row in its lazy wrapper, memoised on the row's own inputs. */
|
|
221
|
-
const TranscriptRowSlot = memo(({
|
|
225
|
+
const TranscriptRowSlot = memo(({ style, stop, sel, className, ...row }) => {
|
|
222
226
|
return /* @__PURE__ */ jsx(LazyRow, {
|
|
223
227
|
className,
|
|
224
|
-
|
|
225
|
-
estimatePx,
|
|
228
|
+
itemKey: row.row.id,
|
|
229
|
+
estimatePx: rowEstimatePx(row.row),
|
|
226
230
|
style,
|
|
227
231
|
"data-stop": stop,
|
|
228
232
|
"data-sel": sel,
|