zidane-ui 9.2.3 → 9.4.0
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/live.d.ts +8 -0
- package/dist/adapters/live.js +19 -8
- package/dist/adapters/server-composer-host.js +22 -9
- package/dist/adapters/server-git-host.js +5 -2
- package/dist/adapters/server-host.js +158 -27
- package/dist/adapters/server-machines-host.js +7 -0
- package/dist/adapters/server-media.d.ts +9 -1
- package/dist/adapters/server-media.js +14 -1
- package/dist/adapters/server-session-host.js +49 -0
- package/dist/adapters/server-settings-sections.js +4 -1
- package/dist/adapters/sse-host.js +3 -0
- package/dist/adapters/sse-protocol.d.ts +10 -0
- package/dist/appearance/ZoomIndicator.js +5 -8
- package/dist/chat/HostTranscript.d.ts +0 -12
- package/dist/chat/HostTranscript.js +20 -1
- package/dist/chat/SessionStreamsProvider.d.ts +9 -1
- package/dist/chat/SessionStreamsProvider.js +11 -2
- package/dist/chat/Transcript.d.ts +21 -11
- package/dist/chat/Transcript.js +346 -161
- package/dist/chat/composer/ModelOptionsPicker.js +6 -2
- package/dist/chat/composer/ModelPicker.d.ts +1 -1
- package/dist/chat/composer/PlacePicker.d.ts +3 -1
- package/dist/chat/composer/PlacePicker.js +5 -1
- package/dist/chat/composer/use-draft-target.js +15 -3
- package/dist/chat/headless/block-runs.js +26 -1
- package/dist/chat/headless/chip-views.js +1 -1
- package/dist/chat/headless/draft-target.d.ts +28 -1
- package/dist/chat/headless/draft-target.js +22 -1
- package/dist/chat/headless/host.d.ts +43 -7
- package/dist/chat/headless/hosts.d.ts +4 -0
- package/dist/chat/headless/index.d.ts +27 -26
- package/dist/chat/headless/index.js +15 -14
- package/dist/chat/headless/labels.d.ts +17 -0
- package/dist/chat/headless/labels.js +17 -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 +64 -0
- package/dist/chat/headless/markdown-scan.js +119 -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/prompt-origin.d.ts +2 -0
- package/dist/chat/headless/prompt-origin.js +6 -2
- package/dist/chat/headless/session-list.d.ts +10 -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 +19 -2
- package/dist/chat/headless/sidebar/directory.js +19 -51
- package/dist/chat/headless/sidebar/environment.d.ts +15 -4
- package/dist/chat/headless/sidebar/environment.js +27 -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 +19 -2
- package/dist/chat/headless/sidebar/labels.js +8 -1
- 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 +4 -2
- package/dist/chat/headless/streams/actions.js +2 -1
- package/dist/chat/headless/streams/event-bytes.d.ts +17 -0
- package/dist/chat/headless/streams/event-bytes.js +46 -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 +45 -6
- package/dist/chat/headless/streams/store.js +85 -31
- package/dist/chat/headless/streams/transcript-map.d.ts +57 -0
- package/dist/chat/headless/streams/transcript-map.js +85 -0
- package/dist/chat/headless/streams/transcript.d.ts +4 -2
- package/dist/chat/headless/streams/transcript.js +19 -7
- package/dist/chat/headless/streams/types.d.ts +2 -1
- 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 +35 -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-attachments.d.ts +2 -0
- package/dist/chat/headless/transcript/fold-attachments.js +3 -2
- package/dist/chat/headless/transcript/fold.d.ts +2 -1
- package/dist/chat/headless/transcript/fold.js +16 -6
- 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 -2
- package/dist/chat/headless/transcript/index.js +2 -2
- package/dist/chat/headless/transcript/nesting.js +2 -1
- package/dist/chat/headless/transcript/rail.d.ts +50 -1
- package/dist/chat/headless/transcript/rail.js +165 -23
- package/dist/chat/headless/transcript/rows.d.ts +5 -1
- package/dist/chat/headless/transcript/run-failures.js +2 -1
- 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/index.d.ts +9 -8
- package/dist/chat/index.js +18 -17
- package/dist/chat/sidebar/ProjectIcon.js +1 -1
- package/dist/chat/sidebar/RowChips.js +2 -2
- package/dist/chat/sidebar/SessionSidebar.d.ts +6 -0
- package/dist/chat/sidebar/SessionSidebar.js +23 -16
- package/dist/chat/sidebar/SidebarFilterMenu.js +0 -1
- package/dist/chat/sidebar/SidebarFold.js +17 -16
- package/dist/chat/sidebar/SidebarFooter.d.ts +8 -5
- package/dist/chat/sidebar/SidebarFooter.js +6 -6
- package/dist/chat/sidebar/SidebarSessionRow.d.ts +7 -1
- package/dist/chat/sidebar/SidebarSessionRow.js +11 -8
- package/dist/chat/sidebar/session-menu.d.ts +4 -0
- package/dist/chat/sidebar/session-menu.js +14 -2
- package/dist/chat/sidebar/sidebar-live.js +28 -4
- package/dist/chat/sidebar/useInboxRows.js +6 -6
- package/dist/chat/sidebar/useInboxTriage.js +50 -47
- package/dist/chat/sidebar/useSessionSearch.js +19 -18
- package/dist/chat/testing/contract.d.ts +5 -3
- package/dist/chat/testing/contract.js +66 -1
- 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/FileChip.js +28 -0
- package/dist/chat/transcript/LazyRow.d.ts +40 -40
- package/dist/chat/transcript/LazyRow.js +100 -149
- package/dist/chat/transcript/MermaidDiagram.js +2 -1
- package/dist/chat/transcript/PromptEcho.js +3 -11
- package/dist/chat/transcript/SessionChip.d.ts +11 -0
- package/dist/chat/transcript/SessionChip.js +34 -0
- package/dist/chat/transcript/SubagentBlock.js +3 -2
- package/dist/chat/transcript/TranscriptRail.d.ts +25 -2
- package/dist/chat/transcript/TranscriptRail.js +175 -17
- package/dist/chat/transcript/TranscriptRow.d.ts +4 -7
- package/dist/chat/transcript/TranscriptRow.js +4 -3
- package/dist/chat/transcript/actions.d.ts +37 -1
- package/dist/chat/transcript/actions.js +27 -1
- package/dist/chat/transcript/chip-details.d.ts +11 -0
- package/dist/chat/transcript/chip-details.js +17 -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 +5 -3
- package/dist/chat/transcript/fold.js +13 -4
- package/dist/chat/transcript/index.d.ts +11 -10
- package/dist/chat/transcript/index.js +10 -9
- package/dist/chat/transcript/markdown-cache.d.ts +17 -2
- package/dist/chat/transcript/markdown-cache.js +48 -4
- package/dist/chat/transcript/markdown.js +110 -55
- package/dist/chat/transcript/media-gallery.d.ts +3 -2
- package/dist/chat/transcript/media-gallery.js +19 -19
- package/dist/chat/transcript/messages.js +5 -4
- package/dist/chat/transcript/notices.js +2 -1
- package/dist/chat/transcript/prompt.d.ts +1 -1
- package/dist/chat/transcript/prompt.js +6 -4
- package/dist/chat/transcript/prose.js +2 -1
- 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 +184 -0
- package/dist/chat/transcript/row-mount.js +532 -0
- package/dist/chat/transcript/row-parking.d.ts +152 -0
- package/dist/chat/transcript/row-parking.js +171 -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 +3 -2
- package/dist/chat/transcript/script-input.d.ts +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 -6
- 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 +25 -8
- package/dist/chat/transcript/use-transcript-rows.js +28 -46
- package/dist/chat/transcript/useHistoryBackfill.d.ts +42 -0
- package/dist/chat/transcript/useHistoryBackfill.js +170 -0
- package/dist/chat/transcript/useStickToBottom.js +2 -3
- package/dist/chat/transcript/useTranscriptFind.js +2 -4
- package/dist/chat/transcript/useTranscriptScroll.d.ts +7 -4
- package/dist/chat/transcript/useTranscriptScroll.js +12 -1
- package/dist/chat/transcript/useTranscriptSearch.d.ts +2 -2
- package/dist/chat/transcript/useTranscriptSearch.js +35 -19
- package/dist/chat/transcript/useTranscriptSelectionCopy.d.ts +5 -5
- package/dist/chat/transcript/useTranscriptSelectionCopy.js +28 -7
- package/dist/chat/transcript/view-scope.d.ts +26 -6
- package/dist/chat/transcript/view-scope.js +106 -20
- package/dist/code/editor/FileTree.d.ts +2 -0
- package/dist/code/editor/FileTree.js +1 -1
- package/dist/code/editor/FileView.js +16 -25
- package/dist/code/editor/find/useFind.js +17 -17
- package/dist/code/editor/useCodeDocument.js +22 -19
- package/dist/code/editor/useDetachCleanup.js +4 -3
- package/dist/code/use-highlighted-html.js +12 -13
- package/dist/components/IconButton.d.ts +3 -1
- package/dist/components/IconButton.js +7 -2
- package/dist/components/IconButtonTip.d.ts +3 -1
- package/dist/components/IconButtonTip.js +2 -1
- package/dist/components/RowActionsMenu.js +7 -14
- package/dist/components/Tooltip.d.ts +4 -1
- package/dist/components/Tooltip.js +8 -6
- package/dist/components/assign-ref.d.ts +8 -0
- package/dist/components/assign-ref.js +12 -0
- package/dist/components/floating/FloatingSurface.js +2 -2
- package/dist/components/floating/HoverCard.js +32 -14
- package/dist/components/floating/Popover.js +4 -7
- package/dist/components/floating/useAnchoredPosition.d.ts +5 -3
- package/dist/components/floating/useAnchoredPosition.js +7 -7
- package/dist/components/object-key.d.ts +7 -0
- package/dist/components/object-key.js +18 -0
- package/dist/components/palette/PaletteList.js +2 -7
- package/dist/components/tooltip-arming.d.ts +3 -0
- package/dist/components/tooltip-arming.js +8 -1
- package/dist/core.css +3 -3
- package/dist/dist/{index-E1Z0aPmi.d.ts → index-BheVJOLc.d.ts} +3 -1
- package/dist/dist/index.d.ts +2 -2
- package/dist/files/FilesTab.js +0 -1
- package/dist/files/TreeColumn.d.ts +2 -4
- package/dist/files/TreeColumn.js +0 -5
- package/dist/files/headless/host.d.ts +3 -7
- package/dist/files/headless/labels.d.ts +0 -1
- package/dist/files/headless/labels.js +0 -1
- package/dist/files/headless/workspace-diff.js +1 -1
- package/dist/files/useCodeReview.js +1 -3
- package/dist/files/useFilesDiagnostics.d.ts +1 -1
- package/dist/files/useFilesDiagnostics.js +4 -11
- package/dist/files/useOpenFiles.js +9 -12
- package/dist/files/useWorkspace.d.ts +5 -7
- package/dist/files/useWorkspace.js +4 -15
- package/dist/git/GitBar.js +5 -3
- package/dist/git/MoveSessionDialog.d.ts +18 -8
- package/dist/git/MoveSessionDialog.js +32 -53
- package/dist/git/MoveToDialog.d.ts +61 -0
- package/dist/git/MoveToDialog.js +240 -0
- package/dist/git/SandboxManager.js +9 -4
- package/dist/git/SyncChip.js +11 -4
- package/dist/git/TeleportSessionDialog.d.ts +69 -0
- package/dist/git/TeleportSessionDialog.js +440 -0
- package/dist/git/headless/host.d.ts +14 -0
- package/dist/git/headless/index.d.ts +2 -1
- package/dist/git/headless/index.js +2 -1
- package/dist/git/headless/labels.d.ts +44 -1
- package/dist/git/headless/labels.js +50 -0
- package/dist/git/headless/sandboxes.d.ts +1 -1
- package/dist/git/headless/sandboxes.js +4 -3
- package/dist/git/headless/teleport.d.ts +76 -0
- package/dist/git/headless/teleport.js +19 -0
- package/dist/git/index.d.ts +4 -2
- package/dist/git/index.js +4 -2
- package/dist/git/useEnvironmentChoices.d.ts +5 -2
- package/dist/git/useEnvironmentChoices.js +12 -4
- package/dist/hooks/useLatest.d.ts +8 -0
- package/dist/hooks/useLatest.js +17 -0
- package/dist/hooks/useMinuteTick.d.ts +6 -2
- package/dist/hooks/useMinuteTick.js +12 -6
- package/dist/hooks/useNearViewport.js +11 -8
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/keybindings/KeybindingsProvider.js +3 -4
- package/dist/keybindings/headless/catalog.d.ts +1 -1
- package/dist/keybindings/headless/catalog.js +18 -0
- package/dist/machines/AddServerForm.js +55 -3
- package/dist/machines/Banners.d.ts +2 -2
- package/dist/machines/Banners.js +3 -3
- package/dist/machines/DaemonMenu.js +1 -3
- package/dist/machines/HostsSection.js +5 -1
- package/dist/machines/OrganizationPanel.d.ts +25 -0
- package/dist/machines/OrganizationPanel.js +266 -0
- package/dist/machines/PersonalLayerPanel.d.ts +32 -0
- package/dist/machines/PersonalLayerPanel.js +360 -0
- package/dist/machines/headless/fixture-host.d.ts +10 -0
- package/dist/machines/headless/fixture-host.js +44 -0
- package/dist/machines/headless/host.d.ts +21 -1
- package/dist/machines/headless/index.d.ts +3 -1
- package/dist/machines/headless/index.js +3 -1
- package/dist/machines/headless/labels.d.ts +55 -0
- package/dist/machines/headless/labels.js +58 -1
- package/dist/machines/headless/layer.d.ts +64 -0
- package/dist/machines/headless/layer.js +56 -0
- package/dist/machines/headless/organization.d.ts +38 -0
- package/dist/machines/headless/organization.js +44 -0
- package/dist/machines/index.d.ts +3 -1
- package/dist/machines/index.js +3 -1
- package/dist/machines/testing/contract.d.ts +25 -1
- package/dist/machines/testing/contract.js +97 -1
- package/dist/motion/grow.js +12 -13
- package/dist/motion/swap.js +2 -5
- package/dist/motion/use-flip-list.d.ts +14 -0
- package/dist/motion/use-flip-list.js +17 -12
- package/dist/palette/headless/app-sources.js +37 -0
- package/dist/palette/headless/labels.js +3 -0
- package/dist/server/sse-handler.js +25 -2
- package/dist/session/DiffFileTree.js +1 -4
- package/dist/session/OpenSessionsDialog.d.ts +46 -0
- package/dist/session/OpenSessionsDialog.js +170 -0
- package/dist/session/PlanTracker.js +1 -2
- package/dist/session/ProjectHome.js +10 -9
- package/dist/session/RemindersPanel.js +10 -12
- package/dist/session/SecretsPanel.js +2 -1
- package/dist/session/SessionHeader.js +1 -0
- package/dist/session/SessionPeopleStack.d.ts +23 -0
- package/dist/session/SessionPeopleStack.js +65 -0
- package/dist/session/SessionPlaceMenu.js +5 -4
- package/dist/session/ShareSessionDialog.d.ts +32 -0
- package/dist/session/ShareSessionDialog.js +342 -0
- package/dist/session/TypingLine.d.ts +22 -0
- package/dist/session/TypingLine.js +31 -0
- package/dist/session/headless/host.d.ts +40 -1
- package/dist/session/headless/index.d.ts +4 -2
- package/dist/session/headless/index.js +3 -1
- package/dist/session/headless/labels.d.ts +49 -0
- package/dist/session/headless/labels.js +56 -0
- package/dist/session/headless/people.d.ts +29 -0
- package/dist/session/headless/people.js +53 -0
- package/dist/session/headless/place.d.ts +5 -0
- package/dist/session/headless/place.js +5 -1
- package/dist/session/headless/typing.d.ts +37 -0
- package/dist/session/headless/typing.js +60 -0
- package/dist/session/index.d.ts +5 -1
- package/dist/session/index.js +5 -1
- package/dist/settings/headless/fixture-performance.js +4 -2
- package/dist/settings/headless/performance.d.ts +4 -0
- package/dist/settings/headless/search.d.ts +1 -1
- package/dist/settings/headless/sections-host.d.ts +7 -2
- package/dist/settings/section.d.ts +15 -3
- package/dist/settings/section.js +15 -3
- package/dist/settings/sections/environments/EnvironmentsSection.js +30 -6
- package/dist/settings/sections/keybindings/labels.d.ts +3 -0
- package/dist/settings/sections/keybindings/labels.js +3 -0
- package/dist/settings/sections/keybindings/rows.js +12 -0
- package/dist/settings/sections/logs/LogsSection.js +5 -8
- 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/styles.css +65 -9
- package/dist/terminal/HostTerminalSurface.js +28 -30
- package/dist/terminal/TerminalPanel.js +4 -12
- package/dist/terminal/TerminalProvider.d.ts +10 -2
- package/dist/terminal/TerminalProvider.js +10 -2
- package/dist/terminal/headless/labels.d.ts +0 -1
- package/dist/terminal/headless/labels.js +1 -2
- package/dist/terminal/headless/store.js +5 -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/LayoutBudget.js +1 -7
- package/package.json +2 -2
- package/src/styles/chat.css +3 -1
- package/src/styles/palette.css +3 -3
- package/src/styles/transcript.css +50 -5
- /package/dist/dist/{index-De9AbmxS.d.ts → index-ttmMvjgM.d.ts} +0 -0
|
@@ -3,14 +3,16 @@ import { useStaysMounted } from "../../motion/collapse.js";
|
|
|
3
3
|
import { useChatLabels } from "../useChatLabels.js";
|
|
4
4
|
import { useModelName } from "./actions.js";
|
|
5
5
|
import { AnsiText } from "./AnsiText.js";
|
|
6
|
+
import { ClippedOutputControls, useClippedOutput } from "./clipped-output.js";
|
|
6
7
|
import { EditDiffBlock } from "./EditDiffBlock.js";
|
|
7
8
|
import { Caret, FailedMark } from "./frame.js";
|
|
8
9
|
import { ImageGenerationBlock, drawsImageGeneration } from "./ImageGenerationBlock.js";
|
|
9
10
|
import { useTranscriptRenderers } from "./renderers.js";
|
|
10
11
|
import { Rolling } from "./rolling.js";
|
|
12
|
+
import { useRowUiState } from "./row-ui-state.js";
|
|
11
13
|
import { scriptInputProps } from "./script-input.js";
|
|
12
14
|
import { ToolMedia, useToolMedia } from "./tool-media.js";
|
|
13
|
-
import { CODE_PANEL, LoadFullOutputButton, ReadFileBlock, ToolGlyph, ToolInput, ToolTiming,
|
|
15
|
+
import { CODE_PANEL, LoadFullOutputButton, ReadFileBlock, ToolGlyph, ToolInput, ToolTiming, useFullToolCall } from "./tool-parts.js";
|
|
14
16
|
import { Fragment, memo, useEffect, useMemo, useState } from "react";
|
|
15
17
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
16
18
|
import { computeLineDiff, isMcpJobDone, scriptProgressView } from "zidane/chat/pure";
|
|
@@ -27,7 +29,7 @@ function toolRowPropsEqual(prev, next) {
|
|
|
27
29
|
if (prev.mode !== next.mode || prev.showResult !== next.showResult || prev.showDiff !== next.showDiff || prev.lineState !== next.lineState || prev.className !== next.className || prev.style !== next.style) return false;
|
|
28
30
|
const a = prev.tool;
|
|
29
31
|
const b = next.tool;
|
|
30
|
-
return a.name === b.name && a.displayName === b.displayName && a.result === b.result && a.ok === b.ok && a.edit === b.edit && a.rawInput === b.rawInput && a.resultClipped === b.resultClipped && a.callId === b.callId && a.startedAt === b.startedAt && a.durationMs === b.durationMs && a.waitingFor === b.waitingFor && a.resuming === b.resuming && a.scriptProgress === b.scriptProgress && a.mcpJob === b.mcpJob && a.approval === b.approval && formattedEqual(a.formatted, b.formatted);
|
|
32
|
+
return a.name === b.name && a.displayName === b.displayName && a.result === b.result && a.ok === b.ok && a.edit === b.edit && a.rawInput === b.rawInput && a.resultClipped === b.resultClipped && a.inputClipped === b.inputClipped && a.callId === b.callId && a.turnId === b.turnId && a.startedAt === b.startedAt && a.durationMs === b.durationMs && a.waitingFor === b.waitingFor && a.resuming === b.resuming && a.scriptProgress === b.scriptProgress && a.mcpJob === b.mcpJob && a.approval === b.approval && formattedEqual(a.formatted, b.formatted);
|
|
31
33
|
}
|
|
32
34
|
function formattedEqual(a, b) {
|
|
33
35
|
if (a === b) return true;
|
|
@@ -89,10 +91,21 @@ const ToolRow = memo(({ tool, mode, showResult, showDiff, lineState, className,
|
|
|
89
91
|
const labels = useChatLabels();
|
|
90
92
|
const display = useDisplayPath();
|
|
91
93
|
const { SessionTitle, ToolBody, hasToolBody } = useTranscriptRenderers();
|
|
92
|
-
const [open, setOpen] =
|
|
94
|
+
const [open, setOpen] = useRowUiState(`tool:${tool.id}`, false);
|
|
93
95
|
/** Output revealed on demand while the "Tool outputs" setting is off. */
|
|
94
|
-
const [revealOutput, setRevealOutput] =
|
|
95
|
-
const
|
|
96
|
+
const [revealOutput, setRevealOutput] = useRowUiState(`tool-output:${tool.id}`, false);
|
|
97
|
+
const clippedOutput = useClippedOutput(tool);
|
|
98
|
+
const fullResult = clippedOutput.text;
|
|
99
|
+
const { full: fullCall, load: loadFullCall, available: canLoadCall, ready: callReady } = useFullToolCall(tool);
|
|
100
|
+
const input = fullCall !== "loading" && fullCall?.input ? fullCall.input : tool.rawInput;
|
|
101
|
+
const loadInputButton = tool.inputClipped && canLoadCall && (fullCall === null || fullCall === "loading") && /* @__PURE__ */ jsx(LoadFullOutputButton, {
|
|
102
|
+
loading: fullCall === "loading",
|
|
103
|
+
disabled: !callReady,
|
|
104
|
+
onClick: loadFullCall,
|
|
105
|
+
className: "mt-1.5",
|
|
106
|
+
label: labels.loadFullInput,
|
|
107
|
+
loadingLabel: labels.loadingFullInput
|
|
108
|
+
});
|
|
96
109
|
const bodyMounted = useStaysMounted(open);
|
|
97
110
|
const media = useToolMedia(tool, typeof fullResult === "string" ? fullResult : tool.result);
|
|
98
111
|
const hasDiff = showDiff && tool.edit;
|
|
@@ -119,10 +132,8 @@ const ToolRow = memo(({ tool, mode, showResult, showDiff, lineState, className,
|
|
|
119
132
|
const scriptInline = showInputPanel && tool.name === "codemode" && tool.scriptProgress !== void 0;
|
|
120
133
|
const hasExpandable = interaction || showInputPanel || hasOutput || mode === "full" && tool.rawInput || hasDiff;
|
|
121
134
|
const sweep = lineState === "running" && !tool.waitingFor;
|
|
122
|
-
const outputBody = showOutputPanel ? /* @__PURE__ */ jsxs(Fragment$1, { children: [bodyMounted &&
|
|
123
|
-
|
|
124
|
-
disabled: !fullReady,
|
|
125
|
-
onClick: loadFullResult,
|
|
135
|
+
const outputBody = showOutputPanel ? /* @__PURE__ */ jsxs(Fragment$1, { children: [bodyMounted && tool.resultClipped && /* @__PURE__ */ jsx(ClippedOutputControls, {
|
|
136
|
+
output: clippedOutput,
|
|
126
137
|
className: "mt-1.5"
|
|
127
138
|
}), !bodyMounted ? null : media ? /* @__PURE__ */ jsxs("div", {
|
|
128
139
|
className: "mt-1.5 flex flex-col gap-1.5",
|
|
@@ -230,7 +241,11 @@ const ToolRow = memo(({ tool, mode, showResult, showDiff, lineState, className,
|
|
|
230
241
|
"data-open": open,
|
|
231
242
|
children: /* @__PURE__ */ jsx("div", {
|
|
232
243
|
className: "zg-collapsible-inner",
|
|
233
|
-
children: bodyMounted && /* @__PURE__ */ jsx(EditDiffBlock, {
|
|
244
|
+
children: bodyMounted && /* @__PURE__ */ jsx(EditDiffBlock, {
|
|
245
|
+
edit: tool.edit,
|
|
246
|
+
...tool.callId ? { callId: tool.callId } : {},
|
|
247
|
+
...tool.turnId ? { turnId: tool.turnId } : {}
|
|
248
|
+
})
|
|
234
249
|
})
|
|
235
250
|
}),
|
|
236
251
|
interaction && ToolBody && /* @__PURE__ */ jsx("div", {
|
|
@@ -249,12 +264,16 @@ const ToolRow = memo(({ tool, mode, showResult, showDiff, lineState, className,
|
|
|
249
264
|
"data-open": open,
|
|
250
265
|
children: /* @__PURE__ */ jsx("div", {
|
|
251
266
|
className: "zg-collapsible-inner",
|
|
252
|
-
children: bodyMounted && /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
267
|
+
children: bodyMounted && /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
268
|
+
showOutputPanel && !scriptInline && /* @__PURE__ */ jsx(PanelCaption, { children: labels.inputCaption }),
|
|
269
|
+
/* @__PURE__ */ jsx(ToolInput, {
|
|
270
|
+
name: tool.name,
|
|
271
|
+
input,
|
|
272
|
+
...scriptInputProps(tool),
|
|
273
|
+
...scriptInline && outputBody ? { output: outputBody } : {}
|
|
274
|
+
}),
|
|
275
|
+
loadInputButton
|
|
276
|
+
] })
|
|
258
277
|
})
|
|
259
278
|
}),
|
|
260
279
|
hasOutput && !showOutputPanel && /* @__PURE__ */ jsx("div", {
|
|
@@ -283,11 +302,11 @@ const ToolRow = memo(({ tool, mode, showResult, showDiff, lineState, className,
|
|
|
283
302
|
"data-open": open,
|
|
284
303
|
children: /* @__PURE__ */ jsx("div", {
|
|
285
304
|
className: "zg-collapsible-inner",
|
|
286
|
-
children: bodyMounted && /* @__PURE__ */ jsx(ToolInput, {
|
|
305
|
+
children: bodyMounted && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(ToolInput, {
|
|
287
306
|
name: tool.name,
|
|
288
|
-
input: tool.rawInput,
|
|
307
|
+
input: input ?? tool.rawInput,
|
|
289
308
|
...scriptInputProps(tool)
|
|
290
|
-
})
|
|
309
|
+
}), loadInputButton] })
|
|
291
310
|
})
|
|
292
311
|
})
|
|
293
312
|
]
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { ChatEvent } from "../headless/host.js";
|
|
2
1
|
import { Cluster, Row } from "../headless/transcript/rows.js";
|
|
3
2
|
import { SelectStops } from "../headless/transcript/select-stops.js";
|
|
3
|
+
import { ChatEvent } from "../headless/host.js";
|
|
4
4
|
import "../headless/transcript/index.js";
|
|
5
|
-
import {
|
|
5
|
+
import { TranscriptRowsSlice } from "../headless/transcript/incremental.js";
|
|
6
|
+
import { RunReceipt, TranscriptEvents } from "zidane/chat/pure";
|
|
6
7
|
/** The display options that shape the rows. */
|
|
7
8
|
export interface TranscriptRowsInput {
|
|
8
9
|
/** Show cache notices (cache expired / break, dropped reasoning). */
|
|
@@ -30,15 +31,30 @@ export interface TranscriptRows {
|
|
|
30
31
|
clusters: readonly Cluster[];
|
|
31
32
|
/** The reply still streaming: the only row with a caret. */
|
|
32
33
|
lastStreamingRow: Row | null | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* `visibleRows` and `clusters` split at the open exchange: `settled` keeps
|
|
36
|
+
* its arrays (and every row and cluster in them) while only the open
|
|
37
|
+
* exchange streams. A renderer can read these instead of the joined arrays.
|
|
38
|
+
*/
|
|
39
|
+
parts?: {
|
|
40
|
+
settled: TranscriptRowsSlice;
|
|
41
|
+
open: TranscriptRowsSlice;
|
|
42
|
+
};
|
|
33
43
|
}
|
|
44
|
+
/** A transcript's events: an array, or the transcript store a session stream store holds (`TranscriptEvents`). */
|
|
45
|
+
export type TranscriptSource = readonly ChatEvent[] | TranscriptEvents<ChatEvent>;
|
|
46
|
+
/** Rows, or what holds them (read only when needed: `useTranscriptRows`' result joins its parts on first read). */
|
|
47
|
+
type RowsSource = readonly Row[] | {
|
|
48
|
+
readonly visibleRows: readonly Row[];
|
|
49
|
+
};
|
|
34
50
|
/**
|
|
35
|
-
* Runs the headless pipeline over a transcript's events,
|
|
51
|
+
* Runs the headless pipeline over a transcript's events, incrementally (only the open exchange re-derives per tick), and returns the rows to paint.
|
|
36
52
|
*
|
|
37
|
-
* @param events - The session's events, oldest first.
|
|
53
|
+
* @param events - The session's events, oldest first, or its transcript store (then nothing walks the settled exchanges per tick).
|
|
38
54
|
* @param streaming - A run is in flight, so the last reply may still be streaming.
|
|
39
55
|
* @param input - The display options that shape the rows.
|
|
40
56
|
*/
|
|
41
|
-
export declare function useTranscriptRows(events:
|
|
57
|
+
export declare function useTranscriptRows(events: TranscriptSource, streaming: boolean, { showCacheNotices, codemodeShowCalls, showEditDiffs, groupToolCalls, showRunReceipt, compact }: TranscriptRowsInput): TranscriptRows;
|
|
42
58
|
/**
|
|
43
59
|
* Select-turn stops (`computeSelectStops`): which turns the cursor walks
|
|
44
60
|
* and which rows light up. Derived per transcript change while the mode is
|
|
@@ -47,10 +63,11 @@ export declare function useTranscriptRows(events: readonly ChatEvent[], streamin
|
|
|
47
63
|
* before the mode is on, and on every arrow), cached per input so a burst
|
|
48
64
|
* of arrows computes once.
|
|
49
65
|
*
|
|
50
|
-
* @param visibleRows - The rows painted,
|
|
51
|
-
* @param events - The session's events, oldest first.
|
|
66
|
+
* @param visibleRows - The rows painted, or {@link useTranscriptRows}' result (its rows are read only while the mode is on or asked).
|
|
67
|
+
* @param events - The session's events, oldest first, or its transcript store (read as one array only while the mode is on or asked).
|
|
52
68
|
* @param showThinking - Reasoning rows are shown, so they can be stops.
|
|
53
69
|
* @param selecting - Select-turn mode is on.
|
|
54
70
|
* @param registerStops - Hands the app the stops source; returns its unregister function.
|
|
55
71
|
*/
|
|
56
|
-
export declare function useSelectStops(visibleRows:
|
|
72
|
+
export declare function useSelectStops(visibleRows: RowsSource, events: TranscriptSource, showThinking: boolean, selecting: boolean, registerStops: ((source: () => SelectStops) => () => void) | undefined): SelectStops | null;
|
|
73
|
+
export {};
|
|
@@ -1,58 +1,40 @@
|
|
|
1
|
-
import { batchTaskRuns, batchThinkingRuns, batchToolRuns, clusterByOwner } from "../headless/transcript/batch.js";
|
|
2
|
-
import { collapseEvents } from "../headless/transcript/collapse.js";
|
|
3
1
|
import { computeSelectStops } from "../headless/transcript/select-stops.js";
|
|
4
|
-
import {
|
|
5
|
-
import { markRunFailures } from "../headless/transcript/run-failures.js";
|
|
6
|
-
import { nestToolCalls, nestedCallVisible } from "../headless/transcript/nesting.js";
|
|
2
|
+
import { createTranscriptRowsDeriver } from "../headless/transcript/incremental.js";
|
|
7
3
|
import { isHiddenRow } from "./TranscriptRow.js";
|
|
8
|
-
import { useEffect, useLayoutEffect, useMemo, useRef } from "react";
|
|
9
|
-
import {
|
|
4
|
+
import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
5
|
+
import { transcriptArray, turnSelectionOwnership } from "zidane/chat/pure";
|
|
10
6
|
// src/chat/transcript/use-transcript-rows.ts
|
|
11
|
-
|
|
7
|
+
function asStream(events) {
|
|
8
|
+
return Array.isArray(events) ? events : transcriptArray(events);
|
|
9
|
+
}
|
|
10
|
+
const rowsOf = (rows) => Array.isArray(rows) ? rows : rows.visibleRows;
|
|
12
11
|
/**
|
|
13
|
-
* Runs the headless pipeline over a transcript's events,
|
|
12
|
+
* Runs the headless pipeline over a transcript's events, incrementally (only the open exchange re-derives per tick), and returns the rows to paint.
|
|
14
13
|
*
|
|
15
|
-
* @param events - The session's events, oldest first.
|
|
14
|
+
* @param events - The session's events, oldest first, or its transcript store (then nothing walks the settled exchanges per tick).
|
|
16
15
|
* @param streaming - A run is in flight, so the last reply may still be streaming.
|
|
17
16
|
* @param input - The display options that shape the rows.
|
|
18
17
|
*/
|
|
19
18
|
function useTranscriptRows(events, streaming, { showCacheNotices, codemodeShowCalls, showEditDiffs, groupToolCalls, showRunReceipt, compact }) {
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
const [deriver] = useState(createTranscriptRowsDeriver);
|
|
20
|
+
return useMemo(() => deriver.derive(events, streaming, {
|
|
21
|
+
showCacheNotices,
|
|
22
|
+
codemodeShowCalls,
|
|
23
|
+
showEditDiffs,
|
|
24
|
+
groupToolCalls,
|
|
25
|
+
showRunReceipt,
|
|
26
|
+
compact
|
|
27
|
+
}), [
|
|
28
|
+
deriver,
|
|
24
29
|
events,
|
|
30
|
+
streaming,
|
|
25
31
|
showCacheNotices,
|
|
26
|
-
codemodeShowCalls
|
|
27
|
-
]);
|
|
28
|
-
const rows = useMemo(() => nestToolCalls(collapseEvents(shownEvents, showEditDiffs, streaming)), [
|
|
29
|
-
shownEvents,
|
|
32
|
+
codemodeShowCalls,
|
|
30
33
|
showEditDiffs,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const failed = useMemo(() => markRunFailures(batched), [batched]);
|
|
35
|
-
const { visibleRows: dockedRows, receiptByRowId } = useMemo(() => dockRunReceipts(failed, showRunReceipt), [failed, showRunReceipt]);
|
|
36
|
-
const visibleRows = useMemo(() => compact ? foldExchanges(dockedRows, streaming) : dockedRows, [
|
|
37
|
-
dockedRows,
|
|
38
|
-
compact,
|
|
39
|
-
streaming
|
|
34
|
+
groupToolCalls,
|
|
35
|
+
showRunReceipt,
|
|
36
|
+
compact
|
|
40
37
|
]);
|
|
41
|
-
return {
|
|
42
|
-
visibleRows,
|
|
43
|
-
receiptByRowId,
|
|
44
|
-
resumableId: useMemo(() => {
|
|
45
|
-
if (streaming) return null;
|
|
46
|
-
for (let i = visibleRows.length - 1; i >= 0; i--) {
|
|
47
|
-
const row = visibleRows[i];
|
|
48
|
-
if (row.kind === "separator" || row.kind === "run-summary") continue;
|
|
49
|
-
return row.kind === "error" && row.failure ? row.id : null;
|
|
50
|
-
}
|
|
51
|
-
return null;
|
|
52
|
-
}, [visibleRows, streaming]),
|
|
53
|
-
clusters: useMemo(() => clusterByOwner(visibleRows), [visibleRows]),
|
|
54
|
-
lastStreamingRow: findLastStreamingRow(visibleRows)
|
|
55
|
-
};
|
|
56
38
|
}
|
|
57
39
|
/**
|
|
58
40
|
* Select-turn stops (`computeSelectStops`): which turns the cursor walks
|
|
@@ -62,14 +44,14 @@ function useTranscriptRows(events, streaming, { showCacheNotices, codemodeShowCa
|
|
|
62
44
|
* before the mode is on, and on every arrow), cached per input so a burst
|
|
63
45
|
* of arrows computes once.
|
|
64
46
|
*
|
|
65
|
-
* @param visibleRows - The rows painted,
|
|
66
|
-
* @param events - The session's events, oldest first.
|
|
47
|
+
* @param visibleRows - The rows painted, or {@link useTranscriptRows}' result (its rows are read only while the mode is on or asked).
|
|
48
|
+
* @param events - The session's events, oldest first, or its transcript store (read as one array only while the mode is on or asked).
|
|
67
49
|
* @param showThinking - Reasoning rows are shown, so they can be stops.
|
|
68
50
|
* @param selecting - Select-turn mode is on.
|
|
69
51
|
* @param registerStops - Hands the app the stops source; returns its unregister function.
|
|
70
52
|
*/
|
|
71
53
|
function useSelectStops(visibleRows, events, showThinking, selecting, registerStops) {
|
|
72
|
-
const stops = useMemo(() => selecting ? computeSelectStops(visibleRows, turnSelectionOwnership(asStream(events)), (row) => isHiddenRow(row, showThinking)) : null, [
|
|
54
|
+
const stops = useMemo(() => selecting ? computeSelectStops(rowsOf(visibleRows), turnSelectionOwnership(asStream(events)), (row) => isHiddenRow(row, showThinking)) : null, [
|
|
73
55
|
selecting,
|
|
74
56
|
visibleRows,
|
|
75
57
|
events,
|
|
@@ -94,7 +76,7 @@ function useSelectStops(visibleRows, events, showThinking, selecting, registerSt
|
|
|
94
76
|
const { rows, events: evts, showThinking: show } = stopsInput.current;
|
|
95
77
|
const hit = stopsCache.current;
|
|
96
78
|
if (hit && hit.rows === rows && hit.events === evts && hit.show === show) return hit.stops;
|
|
97
|
-
const fresh = computeSelectStops(rows, turnSelectionOwnership(asStream(evts)), (row) => isHiddenRow(row, show));
|
|
79
|
+
const fresh = computeSelectStops(rowsOf(rows), turnSelectionOwnership(asStream(evts)), (row) => isHiddenRow(row, show));
|
|
98
80
|
stopsCache.current = {
|
|
99
81
|
rows,
|
|
100
82
|
events: evts,
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/** The reader counts as idle after this long without scrolling. */
|
|
2
|
+
export declare const BACKFILL_QUIET_MS = 1000;
|
|
3
|
+
/** Rows of one session (`eventBytes`) past which pages load only on demand: prewarm's budget. */
|
|
4
|
+
export declare const BACKFILL_MAX_BYTES: number;
|
|
5
|
+
/** Runs one offered load at a time, once the reader has held still. */
|
|
6
|
+
export interface HistoryBackfill {
|
|
7
|
+
/** The load to run once the reader is idle (it runs once); `null`: nothing to load now. */
|
|
8
|
+
offer: (load: (() => void) | null) => void;
|
|
9
|
+
/** Waits a quiet period from now (a conversation opened). */
|
|
10
|
+
restart: () => void;
|
|
11
|
+
dispose: () => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Creates the scheduler of {@link useHistoryBackfill}.
|
|
15
|
+
*
|
|
16
|
+
* @param target - Where the reader's input is heard (the document).
|
|
17
|
+
* @param quietMs - How long the reader holds still before a load runs.
|
|
18
|
+
*/
|
|
19
|
+
export declare function createHistoryBackfill(target: EventTarget, quietMs?: number): HistoryBackfill;
|
|
20
|
+
/** What {@link useHistoryBackfill} reads of the conversation shown. */
|
|
21
|
+
export interface HistoryBackfillInputs {
|
|
22
|
+
/** Its events are hydrated. */
|
|
23
|
+
ready: boolean;
|
|
24
|
+
/** Older pages exist (and can be loaded). */
|
|
25
|
+
hasMore: boolean;
|
|
26
|
+
/** A page is loading. */
|
|
27
|
+
loading: boolean;
|
|
28
|
+
/** How much is loaded: changes when a page lands (the window's first position, or its length). */
|
|
29
|
+
loaded: number;
|
|
30
|
+
/** Loads the next older page. */
|
|
31
|
+
load: () => void;
|
|
32
|
+
/** About how many bytes its rows hold (`eventBytes`). Absent: nothing loads in the background. */
|
|
33
|
+
bytes: (() => number) | undefined;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Loads the conversation's older pages in the background while the reader is idle (see the module comment).
|
|
37
|
+
*
|
|
38
|
+
* @param sessionId - The conversation shown.
|
|
39
|
+
* @param inputs - The {@link HistoryBackfillInputs}.
|
|
40
|
+
* @param maxBytes - The byte budget. Default {@link BACKFILL_MAX_BYTES}.
|
|
41
|
+
*/
|
|
42
|
+
export declare function useHistoryBackfill(sessionId: string | null, inputs: HistoryBackfillInputs, maxBytes?: number): void;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
// src/chat/transcript/useHistoryBackfill.ts
|
|
3
|
+
/**
|
|
4
|
+
* Background scrollback: once a conversation has opened and the reader holds
|
|
5
|
+
* still, its older pages load one at a time in idle time, until the history
|
|
6
|
+
* is complete or its rows reach a byte budget. The scrollbar then measures
|
|
7
|
+
* the whole conversation, and its top is there without a wait.
|
|
8
|
+
*
|
|
9
|
+
* Loading waits while the reader scrolls: a wheel, a touch, a press, a scroll
|
|
10
|
+
* key, and the scroll events that carry a gesture on (momentum, a scrollbar
|
|
11
|
+
* drag) restart a quiet period of {@link BACKFILL_QUIET_MS}. A scroll event
|
|
12
|
+
* alone never starts one: the view's own corrections (a page held in place, a
|
|
13
|
+
* live run followed at the bottom) are not the reader. A page lands as
|
|
14
|
+
* unmounted placeholders (`row-mount.ts`), and the view keeps its place
|
|
15
|
+
* (`useStickToBottom`, or the browser's scroll anchoring). Past the budget,
|
|
16
|
+
* scroll-to-load and Load earlier reach the rest.
|
|
17
|
+
*/
|
|
18
|
+
/** The reader counts as idle after this long without scrolling. */
|
|
19
|
+
const BACKFILL_QUIET_MS = 1e3;
|
|
20
|
+
/** Rows of one session (`eventBytes`) past which pages load only on demand: prewarm's budget. */
|
|
21
|
+
const BACKFILL_MAX_BYTES = 25165824;
|
|
22
|
+
/** Keys that scroll the view. */
|
|
23
|
+
const SCROLL_KEYS = /* @__PURE__ */ new Set([
|
|
24
|
+
"ArrowUp",
|
|
25
|
+
"ArrowDown",
|
|
26
|
+
"PageUp",
|
|
27
|
+
"PageDown",
|
|
28
|
+
"Home",
|
|
29
|
+
"End",
|
|
30
|
+
" "
|
|
31
|
+
]);
|
|
32
|
+
const INPUTS = [
|
|
33
|
+
"wheel",
|
|
34
|
+
"touchstart",
|
|
35
|
+
"touchmove",
|
|
36
|
+
"touchend",
|
|
37
|
+
"pointerdown"
|
|
38
|
+
];
|
|
39
|
+
function requestIdle(run) {
|
|
40
|
+
if (typeof requestIdleCallback === "function") {
|
|
41
|
+
const id = requestIdleCallback(run);
|
|
42
|
+
return () => cancelIdleCallback(id);
|
|
43
|
+
}
|
|
44
|
+
const id = setTimeout(run, 0);
|
|
45
|
+
return () => clearTimeout(id);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Creates the scheduler of {@link useHistoryBackfill}.
|
|
49
|
+
*
|
|
50
|
+
* @param target - Where the reader's input is heard (the document).
|
|
51
|
+
* @param quietMs - How long the reader holds still before a load runs.
|
|
52
|
+
*/
|
|
53
|
+
function createHistoryBackfill(target, quietMs = BACKFILL_QUIET_MS) {
|
|
54
|
+
let quiet = false;
|
|
55
|
+
let timer;
|
|
56
|
+
let cancelIdle;
|
|
57
|
+
let pending = null;
|
|
58
|
+
const kick = () => {
|
|
59
|
+
if (!quiet || !pending || cancelIdle) return;
|
|
60
|
+
cancelIdle = requestIdle(() => {
|
|
61
|
+
cancelIdle = void 0;
|
|
62
|
+
const load = pending;
|
|
63
|
+
pending = null;
|
|
64
|
+
load?.();
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
const restart = () => {
|
|
68
|
+
quiet = false;
|
|
69
|
+
cancelIdle?.();
|
|
70
|
+
cancelIdle = void 0;
|
|
71
|
+
clearTimeout(timer);
|
|
72
|
+
timer = setTimeout(() => {
|
|
73
|
+
timer = void 0;
|
|
74
|
+
quiet = true;
|
|
75
|
+
kick();
|
|
76
|
+
}, quietMs);
|
|
77
|
+
};
|
|
78
|
+
const onKey = (e) => {
|
|
79
|
+
if (SCROLL_KEYS.has(e.key)) restart();
|
|
80
|
+
};
|
|
81
|
+
const onScroll = (e) => {
|
|
82
|
+
const el = e.target;
|
|
83
|
+
if (quiet || !(el instanceof Element) || el.scrollHeight - el.scrollTop - el.clientHeight <= 2) return;
|
|
84
|
+
restart();
|
|
85
|
+
};
|
|
86
|
+
for (const type of INPUTS) target.addEventListener(type, restart, {
|
|
87
|
+
capture: true,
|
|
88
|
+
passive: true
|
|
89
|
+
});
|
|
90
|
+
target.addEventListener("keydown", onKey, { capture: true });
|
|
91
|
+
target.addEventListener("scroll", onScroll, {
|
|
92
|
+
capture: true,
|
|
93
|
+
passive: true
|
|
94
|
+
});
|
|
95
|
+
restart();
|
|
96
|
+
return {
|
|
97
|
+
offer(load) {
|
|
98
|
+
pending = load;
|
|
99
|
+
if (!load) {
|
|
100
|
+
cancelIdle?.();
|
|
101
|
+
cancelIdle = void 0;
|
|
102
|
+
}
|
|
103
|
+
kick();
|
|
104
|
+
},
|
|
105
|
+
restart,
|
|
106
|
+
dispose() {
|
|
107
|
+
for (const type of INPUTS) target.removeEventListener(type, restart, { capture: true });
|
|
108
|
+
target.removeEventListener("keydown", onKey, { capture: true });
|
|
109
|
+
target.removeEventListener("scroll", onScroll, { capture: true });
|
|
110
|
+
clearTimeout(timer);
|
|
111
|
+
cancelIdle?.();
|
|
112
|
+
cancelIdle = void 0;
|
|
113
|
+
pending = null;
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Loads the conversation's older pages in the background while the reader is idle (see the module comment).
|
|
119
|
+
*
|
|
120
|
+
* @param sessionId - The conversation shown.
|
|
121
|
+
* @param inputs - The {@link HistoryBackfillInputs}.
|
|
122
|
+
* @param maxBytes - The byte budget. Default {@link BACKFILL_MAX_BYTES}.
|
|
123
|
+
*/
|
|
124
|
+
function useHistoryBackfill(sessionId, inputs, maxBytes = BACKFILL_MAX_BYTES) {
|
|
125
|
+
const { ready, hasMore, loading, loaded, load, bytes } = inputs;
|
|
126
|
+
const backfill = useRef(null);
|
|
127
|
+
const latest = useRef({
|
|
128
|
+
load,
|
|
129
|
+
bytes
|
|
130
|
+
});
|
|
131
|
+
useEffect(() => {
|
|
132
|
+
latest.current = {
|
|
133
|
+
load,
|
|
134
|
+
bytes
|
|
135
|
+
};
|
|
136
|
+
});
|
|
137
|
+
useEffect(() => {
|
|
138
|
+
const created = createHistoryBackfill(document);
|
|
139
|
+
backfill.current = created;
|
|
140
|
+
return () => {
|
|
141
|
+
created.dispose();
|
|
142
|
+
backfill.current = null;
|
|
143
|
+
};
|
|
144
|
+
}, []);
|
|
145
|
+
useEffect(() => {
|
|
146
|
+
if (sessionId && ready) backfill.current?.restart();
|
|
147
|
+
}, [sessionId, ready]);
|
|
148
|
+
const measured = bytes !== void 0;
|
|
149
|
+
useEffect(() => {
|
|
150
|
+
const b = backfill.current;
|
|
151
|
+
if (!b) return;
|
|
152
|
+
if (!sessionId || !ready || !hasMore || loading || !measured) {
|
|
153
|
+
b.offer(null);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
b.offer(() => {
|
|
157
|
+
const { load, bytes } = latest.current;
|
|
158
|
+
if (bytes && bytes() < maxBytes) load();
|
|
159
|
+
});
|
|
160
|
+
}, [
|
|
161
|
+
sessionId,
|
|
162
|
+
ready,
|
|
163
|
+
hasMore,
|
|
164
|
+
loading,
|
|
165
|
+
loaded,
|
|
166
|
+
measured,
|
|
167
|
+
maxBytes
|
|
168
|
+
]);
|
|
169
|
+
}
|
|
170
|
+
export { BACKFILL_MAX_BYTES, BACKFILL_QUIET_MS, createHistoryBackfill, useHistoryBackfill };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { currentMotionTransition } from "../../motion/springs.js";
|
|
2
2
|
import { dataRowSelector } from "../headless/transcript/rail.js";
|
|
3
|
-
import {
|
|
3
|
+
import { revealRow } from "./row-mount.js";
|
|
4
4
|
import { mayShrink } from "./scroll-clamp.js";
|
|
5
5
|
import { viewAbove } from "./view-anchor.js";
|
|
6
6
|
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
@@ -360,8 +360,7 @@ function useStickToBottom(scrollRef, { paused = false, rowSelector = ".zg-cv-row
|
|
|
360
360
|
};
|
|
361
361
|
restoreRows.current = (rows) => {
|
|
362
362
|
const find = (id) => el.querySelector(dataRowSelector(id));
|
|
363
|
-
|
|
364
|
-
if (outer) mountRowNow(outer);
|
|
363
|
+
if (rows.length > 0) revealRow(el, rows[rows.length - 1].id);
|
|
365
364
|
for (const [i, place] of rows.entries()) {
|
|
366
365
|
const target = find(place.id);
|
|
367
366
|
if (!target) continue;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useTranscriptFindKey } from "./useTranscriptFindKey.js";
|
|
2
|
-
import { useCallback,
|
|
2
|
+
import { useCallback, useMemo, useState } from "react";
|
|
3
3
|
// src/chat/transcript/useTranscriptFind.ts
|
|
4
4
|
/**
|
|
5
5
|
* The find in the conversation's state: which session it is open on and the
|
|
@@ -25,9 +25,7 @@ function useTranscriptFind({ sessionId, blocked }) {
|
|
|
25
25
|
onFind,
|
|
26
26
|
...blocked ? { blocked } : {}
|
|
27
27
|
});
|
|
28
|
-
|
|
29
|
-
if (target && target.sessionId !== sessionId) setTarget(null);
|
|
30
|
-
}, [sessionId, target]);
|
|
28
|
+
if (target && target.sessionId !== sessionId) setTarget(null);
|
|
31
29
|
const close = useCallback(() => setTarget(null), []);
|
|
32
30
|
const findIn = useCallback((next) => setTarget(next), []);
|
|
33
31
|
const open = target !== null && target.sessionId === sessionId;
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
* The conversation's transcript scroll: stick-to-bottom (paused while
|
|
3
3
|
* select-turn mode drives the cursor), where a conversation opens (back where
|
|
4
4
|
* it was left, or at the bottom), the scrolled-from-top signal for the
|
|
5
|
-
* footer's fade,
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* footer's fade, lazy scrollback, and the rest of the history loading in the
|
|
6
|
+
* background while the reader is idle (`useHistoryBackfill`). The container
|
|
7
|
+
* hands it the session's page state, loader and row size, whether
|
|
8
|
+
* select-turn drives the view, and the Keep scroll position setting.
|
|
8
9
|
*/
|
|
9
10
|
import { SessionPageState } from "../headless/streams/types.js";
|
|
10
11
|
/** What {@link useTranscriptScroll} reads from its container. */
|
|
@@ -19,6 +20,8 @@ export interface TranscriptScrollInputs<K extends string = string> {
|
|
|
19
20
|
selecting: boolean;
|
|
20
21
|
/** Reopen a conversation where it was left (Keep scroll position). */
|
|
21
22
|
keepPosition: boolean;
|
|
23
|
+
/** About how many bytes the session's rows hold (the stream store's `eventBytes`): what background loading budgets by. Absent: older pages load only on demand. */
|
|
24
|
+
eventBytes?: (sessionId: K) => number;
|
|
22
25
|
}
|
|
23
26
|
/**
|
|
24
27
|
* The transcript's scroll: stick-to-bottom, where a conversation opens, the from-top signal and lazy scrollback (see the module comment).
|
|
@@ -27,7 +30,7 @@ export interface TranscriptScrollInputs<K extends string = string> {
|
|
|
27
30
|
* @param hydrated - Its events have loaded.
|
|
28
31
|
* @param inputs - The {@link TranscriptScrollInputs}.
|
|
29
32
|
*/
|
|
30
|
-
export declare function useTranscriptScroll<K extends string>(sessionId: K | null, hydrated: boolean, { page, loadEarlier, selecting, keepPosition }: TranscriptScrollInputs<K>): {
|
|
33
|
+
export declare function useTranscriptScroll<K extends string>(sessionId: K | null, hydrated: boolean, { page, loadEarlier, selecting, keepPosition, eventBytes }: TranscriptScrollInputs<K>): {
|
|
31
34
|
scrollRef: import("react").RefObject<HTMLElement | null>;
|
|
32
35
|
pinned: boolean;
|
|
33
36
|
scrolledFromTop: boolean;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useFillViewportScrollback } from "./EarlierHistory.js";
|
|
2
2
|
import { createRecentMap } from "./recent-map.js";
|
|
3
|
+
import { useHistoryBackfill } from "./useHistoryBackfill.js";
|
|
3
4
|
import { useStickToBottom } from "./useStickToBottom.js";
|
|
4
5
|
import { useWheelHoverPause } from "./useWheelHoverPause.js";
|
|
5
6
|
import { useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
@@ -21,7 +22,7 @@ const positions = createRecentMap(500);
|
|
|
21
22
|
* @param hydrated - Its events have loaded.
|
|
22
23
|
* @param inputs - The {@link TranscriptScrollInputs}.
|
|
23
24
|
*/
|
|
24
|
-
function useTranscriptScroll(sessionId, hydrated, { page, loadEarlier, selecting, keepPosition }) {
|
|
25
|
+
function useTranscriptScroll(sessionId, hydrated, { page, loadEarlier, selecting, keepPosition, eventBytes }) {
|
|
25
26
|
const scrollRef = useRef(null);
|
|
26
27
|
const { pinned, snapToBottom, glideToBottom, readPosition, restorePosition } = useStickToBottom(scrollRef, { paused: selecting });
|
|
27
28
|
useWheelHoverPause(scrollRef);
|
|
@@ -121,6 +122,16 @@ function useTranscriptScroll(sessionId, hydrated, { page, loadEarlier, selecting
|
|
|
121
122
|
loadEarlier,
|
|
122
123
|
slackPx: LOAD_EARLIER_PX
|
|
123
124
|
});
|
|
125
|
+
useHistoryBackfill(sessionId, {
|
|
126
|
+
ready: hydrated,
|
|
127
|
+
hasMore: page.hasMore,
|
|
128
|
+
loading: page.loadingEarlier,
|
|
129
|
+
loaded: page.firstSeq,
|
|
130
|
+
load: () => {
|
|
131
|
+
if (sessionId) loadEarlier(sessionId);
|
|
132
|
+
},
|
|
133
|
+
bytes: sessionId && eventBytes ? () => eventBytes(sessionId) : void 0
|
|
134
|
+
});
|
|
124
135
|
return {
|
|
125
136
|
scrollRef,
|
|
126
137
|
pinned,
|
|
@@ -44,12 +44,12 @@ export interface TranscriptSearchOptions {
|
|
|
44
44
|
* the user away from the match they're reading. Only a needle CHANGE
|
|
45
45
|
* scrolls.
|
|
46
46
|
*
|
|
47
|
-
* @param
|
|
47
|
+
* @param containerRef - The transcript's scroll container.
|
|
48
48
|
* @param query - The query as typed.
|
|
49
49
|
* @param revision - Changes identity when the transcript re-renders.
|
|
50
50
|
* @param options - The {@link TranscriptSearchOptions}.
|
|
51
51
|
*/
|
|
52
|
-
export declare function useTranscriptSearch(
|
|
52
|
+
export declare function useTranscriptSearch(containerRef: React.RefObject<HTMLElement | null>, query: string, revision: unknown, { terms, revealFirstMatch }?: TranscriptSearchOptions): TranscriptSearchState;
|
|
53
53
|
/**
|
|
54
54
|
* The `::highlight()` color rules, resolved once per mount.
|
|
55
55
|
* `::highlight()` pseudos can't reliably resolve CSS custom properties
|