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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useHydrated } from "../../hooks/useHydrated.js";
|
|
2
|
-
import { holdForceMountRows,
|
|
2
|
+
import { holdForceMountRows, useForcedRows } from "./LazyRow.js";
|
|
3
|
+
import { mountAround } from "./row-mount.js";
|
|
3
4
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
4
5
|
import { jsx } from "react/jsx-runtime";
|
|
5
6
|
// src/chat/transcript/useTranscriptSearch.tsx
|
|
@@ -14,9 +15,10 @@ import { jsx } from "react/jsx-runtime";
|
|
|
14
15
|
* re-deriving text from stream events — the DOM is the source of truth
|
|
15
16
|
* for "what the user can see" (markdown rendering, tool-row formatting,
|
|
16
17
|
* masking all live there). `content-visibility: auto` rows keep their
|
|
17
|
-
* text in the DOM even when paint is skipped, and
|
|
18
|
-
*
|
|
19
|
-
* walk still finds
|
|
18
|
+
* text in the DOM even when paint is skipped, and while a needle is
|
|
19
|
+
* active the transcript mounts the rows whose data holds it wherever they
|
|
20
|
+
* are (`holdForceMountRows`), so the walk still finds matches in rows
|
|
21
|
+
* that never mounted or parked. Highlighting uses the CSS Custom Highlight API
|
|
20
22
|
* (`CSS.highlights`) so we never mutate the transcript's DOM — wrapping
|
|
21
23
|
* matches in `<mark>` would fight React's reconciler on the next
|
|
22
24
|
* streaming tick.
|
|
@@ -121,10 +123,16 @@ function releaseHighlights(owner) {
|
|
|
121
123
|
/**
|
|
122
124
|
* Jump to a match's row. `block: 'center'` keeps context visible above
|
|
123
125
|
* and below; on a `content-visibility: auto` row this forces render,
|
|
124
|
-
* which is exactly what we want before the user reads the match.
|
|
126
|
+
* which is exactly what we want before the user reads the match. The rows
|
|
127
|
+
* around it that have not mounted mount first (`mountAround`), at their
|
|
128
|
+
* real heights: mounting after the jump, they would push the match out of
|
|
129
|
+
* view. Their render lands with the next commit, so the jump waits for it.
|
|
125
130
|
*/
|
|
126
|
-
function scrollToRange(range) {
|
|
127
|
-
range.startContainer.parentElement
|
|
131
|
+
function scrollToRange(range, root) {
|
|
132
|
+
const target = range.startContainer.parentElement;
|
|
133
|
+
if (!target) return;
|
|
134
|
+
if (root && mountAround(root, target, root.clientHeight)) queueMicrotask(() => target.isConnected && target.scrollIntoView({ block: "center" }));
|
|
135
|
+
else target.scrollIntoView({ block: "center" });
|
|
128
136
|
}
|
|
129
137
|
/**
|
|
130
138
|
* `revision` is any value whose identity changes when the transcript
|
|
@@ -133,12 +141,12 @@ function scrollToRange(range) {
|
|
|
133
141
|
* the user away from the match they're reading. Only a needle CHANGE
|
|
134
142
|
* scrolls.
|
|
135
143
|
*
|
|
136
|
-
* @param
|
|
144
|
+
* @param containerRef - The transcript's scroll container.
|
|
137
145
|
* @param query - The query as typed.
|
|
138
146
|
* @param revision - Changes identity when the transcript re-renders.
|
|
139
147
|
* @param options - The {@link TranscriptSearchOptions}.
|
|
140
148
|
*/
|
|
141
|
-
function useTranscriptSearch(
|
|
149
|
+
function useTranscriptSearch(containerRef, query, revision, { terms, revealFirstMatch = false } = {}) {
|
|
142
150
|
const [needle, setNeedle] = useState(NO_NEEDLE);
|
|
143
151
|
const [matches, setMatches] = useState({
|
|
144
152
|
count: 0,
|
|
@@ -174,9 +182,10 @@ function useTranscriptSearch(container, query, revision, { terms, revealFirstMat
|
|
|
174
182
|
* sees the freshly-rendered rows.
|
|
175
183
|
*/
|
|
176
184
|
const prevNeedleRef = useRef("");
|
|
177
|
-
const
|
|
185
|
+
const forced = useForcedRows();
|
|
178
186
|
const searching = needle.key !== "";
|
|
179
|
-
useEffect(() => searching ? holdForceMountRows() : void 0, [searching]);
|
|
187
|
+
useEffect(() => searching ? holdForceMountRows(needle.needles) : void 0, [searching, needle]);
|
|
188
|
+
const rowsMounted = forced.all || needle.needles.every((n) => forced.needles.includes(n));
|
|
180
189
|
/** A rescan the transcript changing asked for, waiting out a burst of stream updates. */
|
|
181
190
|
const rescanTimer = useRef(null);
|
|
182
191
|
useEffect(() => () => {
|
|
@@ -184,16 +193,16 @@ function useTranscriptSearch(container, query, revision, { terms, revealFirstMat
|
|
|
184
193
|
}, []);
|
|
185
194
|
useEffect(() => {
|
|
186
195
|
const owner = ownerRef.current;
|
|
187
|
-
const root =
|
|
196
|
+
const root = containerRef.current;
|
|
188
197
|
if (searching && !rowsMounted) return;
|
|
189
198
|
const needleChanged = prevNeedleRef.current !== needle.key;
|
|
190
199
|
if (needleChanged && prevNeedleRef.current !== "") revealArmed.current = false;
|
|
191
|
-
prevNeedleRef.current = needle.key;
|
|
192
200
|
if (rescanTimer.current) {
|
|
193
201
|
clearTimeout(rescanTimer.current);
|
|
194
202
|
rescanTimer.current = null;
|
|
195
203
|
}
|
|
196
204
|
if (!root || !searching) {
|
|
205
|
+
prevNeedleRef.current = needle.key;
|
|
197
206
|
if (rangesRef.current.length === 0 && !needleChanged) return;
|
|
198
207
|
rangesRef.current = [];
|
|
199
208
|
setMatches((prev) => prev.count === 0 && !prev.capped ? prev : {
|
|
@@ -206,6 +215,7 @@ function useTranscriptSearch(container, query, revision, { terms, revealFirstMat
|
|
|
206
215
|
}
|
|
207
216
|
const scan = () => {
|
|
208
217
|
rescanTimer.current = null;
|
|
218
|
+
prevNeedleRef.current = needle.key;
|
|
209
219
|
const ranges = collectMatches(root, needle.needles);
|
|
210
220
|
const jump = needleChanged || revealArmed.current;
|
|
211
221
|
const nextIndex = needleChanged ? 0 : Math.min(activeIndexRef.current, Math.max(0, ranges.length - 1));
|
|
@@ -218,16 +228,22 @@ function useTranscriptSearch(container, query, revision, { terms, revealFirstMat
|
|
|
218
228
|
setHighlights(owner, ranges, nextIndex);
|
|
219
229
|
if (jump && ranges.length > 0) {
|
|
220
230
|
revealArmed.current = false;
|
|
221
|
-
scrollToRange(ranges[nextIndex]);
|
|
231
|
+
scrollToRange(ranges[nextIndex], root);
|
|
222
232
|
}
|
|
223
233
|
};
|
|
224
|
-
if (needleChanged)
|
|
225
|
-
|
|
234
|
+
if (needleChanged) {
|
|
235
|
+
let live = true;
|
|
236
|
+
queueMicrotask(() => live && scan());
|
|
237
|
+
return () => {
|
|
238
|
+
live = false;
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
rescanTimer.current = setTimeout(scan, RESCAN_MS);
|
|
226
242
|
}, [
|
|
227
243
|
needle,
|
|
228
244
|
searching,
|
|
229
245
|
revision,
|
|
230
|
-
|
|
246
|
+
containerRef,
|
|
231
247
|
rowsMounted
|
|
232
248
|
]);
|
|
233
249
|
/** Highlights are registered document-wide — drop ours on unmount. */
|
|
@@ -241,8 +257,8 @@ function useTranscriptSearch(container, query, revision, { terms, revealFirstMat
|
|
|
241
257
|
const next = (activeIndexRef.current + direction + ranges.length) % ranges.length;
|
|
242
258
|
setActiveIndex(next);
|
|
243
259
|
setHighlights(ownerRef.current, ranges, next);
|
|
244
|
-
scrollToRange(ranges[next]);
|
|
245
|
-
}, []);
|
|
260
|
+
scrollToRange(ranges[next], containerRef.current);
|
|
261
|
+
}, [containerRef]);
|
|
246
262
|
return {
|
|
247
263
|
count: matches.count,
|
|
248
264
|
capped: matches.capped,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Drag-select transcript copy — mirrors the TUI's OSC-52 hook. On
|
|
3
|
-
* mouseup inside the timeline, if the live
|
|
4
|
-
* transcript and is non-empty, write its
|
|
5
|
-
* clipboard. Debounced via `lastCopiedRef` so
|
|
6
|
-
* selection doesn't spam the clipboard.
|
|
2
|
+
* Drag-select transcript copy — mirrors the TUI's OSC-52 hook. On a
|
|
3
|
+
* mouseup that ends a drag begun inside the timeline, if the live
|
|
4
|
+
* selection intersects the transcript and is non-empty, write its
|
|
5
|
+
* plain-text contents to the clipboard. Debounced via `lastCopiedRef` so
|
|
6
|
+
* dragging across the same selection doesn't spam the clipboard.
|
|
7
7
|
*
|
|
8
8
|
* Web equivalent of the TUI's OSC-52 path. We don't subscribe to
|
|
9
9
|
* `selectionchange` directly because that event fires per-character
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { useEffect, useRef } from "react";
|
|
2
2
|
// src/chat/transcript/useTranscriptSelectionCopy.ts
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
|
|
4
|
+
* How far the pointer moves between press and release before it counts as a
|
|
5
|
+
* drag. Below it, a release is a click, even when the browser widens a double
|
|
6
|
+
* or triple click to a word or a line: clicking a row twice to open it must
|
|
7
|
+
* not copy its first word.
|
|
8
|
+
*/
|
|
9
|
+
const DRAG_SLOP_PX = 4;
|
|
10
|
+
/**
|
|
11
|
+
* Drag-select transcript copy — mirrors the TUI's OSC-52 hook. On a
|
|
12
|
+
* mouseup that ends a drag begun inside the timeline, if the live
|
|
13
|
+
* selection intersects the transcript and is non-empty, write its
|
|
14
|
+
* plain-text contents to the clipboard. Debounced via `lastCopiedRef` so
|
|
15
|
+
* dragging across the same selection doesn't spam the clipboard.
|
|
9
16
|
*
|
|
10
17
|
* Web equivalent of the TUI's OSC-52 path. We don't subscribe to
|
|
11
18
|
* `selectionchange` directly because that event fires per-character
|
|
@@ -18,7 +25,17 @@ function useTranscriptSelectionCopy(containerRef) {
|
|
|
18
25
|
useEffect(() => {
|
|
19
26
|
const root = containerRef.current;
|
|
20
27
|
if (!root) return;
|
|
21
|
-
|
|
28
|
+
let press = null;
|
|
29
|
+
const onMouseDown = (event) => {
|
|
30
|
+
press = {
|
|
31
|
+
x: event.clientX,
|
|
32
|
+
y: event.clientY
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
const onMouseUp = (event) => {
|
|
36
|
+
const from = press;
|
|
37
|
+
press = null;
|
|
38
|
+
if (!from || Math.hypot(event.clientX - from.x, event.clientY - from.y) < DRAG_SLOP_PX) return;
|
|
22
39
|
window.setTimeout(() => {
|
|
23
40
|
const selection = window.getSelection();
|
|
24
41
|
if (!selection || selection.isCollapsed) return;
|
|
@@ -31,8 +48,12 @@ function useTranscriptSelectionCopy(containerRef) {
|
|
|
31
48
|
navigator.clipboard.writeText(text).catch(() => {});
|
|
32
49
|
}, 0);
|
|
33
50
|
};
|
|
51
|
+
root.addEventListener("mousedown", onMouseDown);
|
|
34
52
|
root.addEventListener("mouseup", onMouseUp);
|
|
35
|
-
return () =>
|
|
53
|
+
return () => {
|
|
54
|
+
root.removeEventListener("mousedown", onMouseDown);
|
|
55
|
+
root.removeEventListener("mouseup", onMouseUp);
|
|
56
|
+
};
|
|
36
57
|
}, [containerRef]);
|
|
37
58
|
}
|
|
38
59
|
export { useTranscriptSelectionCopy };
|
|
@@ -10,7 +10,7 @@ import { ViewAnswer, ViewAnswers } from "../../views/headless/answers.js";
|
|
|
10
10
|
import { ReplyViewPlace, TextlessExchange } from "../../views/headless/placement.js";
|
|
11
11
|
import { ChatEvent } from "../headless/host.js";
|
|
12
12
|
import { ReactNode } from "react";
|
|
13
|
-
import { ViewsOrchestrationMode } from "zidane/chat/pure";
|
|
13
|
+
import { TranscriptEvents, ViewsOrchestrationMode } from "zidane/chat/pure";
|
|
14
14
|
/** Props of the views chunk's fence: see `ui/src/views/TranscriptViews.tsx`. */
|
|
15
15
|
export interface ViewFencePartProps {
|
|
16
16
|
/** The fence body. */
|
|
@@ -143,8 +143,13 @@ export declare function viewFenceStarts(text: string): readonly number[];
|
|
|
143
143
|
* The fences of each chunk of a reply.
|
|
144
144
|
*
|
|
145
145
|
* @param chunks - The reply's chunks.
|
|
146
|
+
* @param previous - The last call's chunks and result: a chunk still the same string is not read again (a streaming
|
|
147
|
+
* reply's closed chunks keep theirs), and keeps its value while its base does.
|
|
146
148
|
*/
|
|
147
|
-
export declare function chunkFencesFor(chunks: readonly string[]
|
|
149
|
+
export declare function chunkFencesFor(chunks: readonly string[], previous?: {
|
|
150
|
+
chunks: readonly string[];
|
|
151
|
+
fences: readonly ChunkFences[];
|
|
152
|
+
} | null): ChunkFences[];
|
|
148
153
|
/**
|
|
149
154
|
* Provides one chunk's fences. The value stays while its base and starts do: a streamed chunk
|
|
150
155
|
* that grows with no new fence changes nothing below it.
|
|
@@ -163,21 +168,36 @@ export declare function ChunkFencesScope({ base, starts, children }: ChunkFences
|
|
|
163
168
|
export declare function fenceIndexIn(chunk: ChunkFences, offset: number): number;
|
|
164
169
|
/** Where each reply row's views go, read per row: a row draws again only when its own place changes. */
|
|
165
170
|
export declare class ReplyViewPlaces {
|
|
166
|
-
|
|
171
|
+
/** The places of the settled exchanges (or of a whole array). */
|
|
172
|
+
private base;
|
|
173
|
+
/** The places the open exchange sets, over `base`. */
|
|
174
|
+
private top;
|
|
175
|
+
private source;
|
|
167
176
|
private events;
|
|
177
|
+
/** The folds of a transcript store's settled exchanges, per chunk list. */
|
|
178
|
+
private settled;
|
|
168
179
|
private textless;
|
|
180
|
+
private textlessKey;
|
|
169
181
|
private readonly changed;
|
|
170
182
|
private readonly listeners;
|
|
171
183
|
/**
|
|
172
184
|
* Reads the events: the places (`viewPlacements`) and the exchanges with no reply text
|
|
173
185
|
* (`textlessExchanges`). A stream tick changes neither, so it reads nothing. Rows rendering
|
|
174
|
-
* after it read the places; {@link flush} tells the others.
|
|
186
|
+
* after it read the places; {@link flush} tells the others. A transcript store's settled
|
|
187
|
+
* exchanges are read once: a tick reads its open exchange.
|
|
175
188
|
*
|
|
176
|
-
* @param events - The session's events, oldest first.
|
|
189
|
+
* @param events - The session's events, oldest first, or its transcript store.
|
|
177
190
|
*/
|
|
178
|
-
update(events: readonly ChatEvent[]): void;
|
|
191
|
+
update(events: readonly ChatEvent[] | TranscriptEvents<ChatEvent>): void;
|
|
192
|
+
private updateTranscript;
|
|
179
193
|
/** The exchanges with no reply text, as of the last {@link update}. */
|
|
180
194
|
get textlessExchanges(): readonly TextlessExchange[];
|
|
195
|
+
/** The places as one map (the array path's `previous`). */
|
|
196
|
+
private flat;
|
|
197
|
+
/**
|
|
198
|
+
* Sets the places, noting the rows whose place changed: every row when `whole`, else those the
|
|
199
|
+
* open exchange set before or sets now (the base is the same).
|
|
200
|
+
*/
|
|
181
201
|
private replace;
|
|
182
202
|
/** Tells the rows whose place changed since the last flush. */
|
|
183
203
|
flush(): void;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { lazyPart } from "../../components/lazy-part.js";
|
|
2
|
-
import { onlyLastTextChanged, textlessExchanges, unplacedCodemodeViews, viewPlacements } from "../../views/headless/placement.js";
|
|
2
|
+
import { closePlacementExchange, foldPlacements, foldTextless, onlyLastTextChanged, placementFold, sameViewPlace, textlessExchanges, textlessFold, unplacedCodemodeViews, viewPlacements } from "../../views/headless/placement.js";
|
|
3
3
|
import { useViewsHost, useViewsMeta } from "../../views/ViewsProvider.js";
|
|
4
4
|
import { Suspense, createContext, useCallback, useContext, useEffect, useMemo, useState, useSyncExternalStore } from "react";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
import { findViewFences, mayHoldViewFence } from "zidane/chat/pure";
|
|
6
|
+
import { findViewFences, mayHoldViewFence, noteTranscriptPass } from "zidane/chat/pure";
|
|
7
7
|
// src/chat/transcript/view-scope.tsx
|
|
8
8
|
/** Loads the views chunk. Counted by the tests that prove it never loads with views off. */
|
|
9
9
|
const loadViews = () => import("../../views/TranscriptViews.js");
|
|
@@ -144,13 +144,16 @@ function viewFenceStarts(text) {
|
|
|
144
144
|
* The fences of each chunk of a reply.
|
|
145
145
|
*
|
|
146
146
|
* @param chunks - The reply's chunks.
|
|
147
|
+
* @param previous - The last call's chunks and result: a chunk still the same string is not read again (a streaming
|
|
148
|
+
* reply's closed chunks keep theirs), and keeps its value while its base does.
|
|
147
149
|
*/
|
|
148
|
-
function chunkFencesFor(chunks) {
|
|
150
|
+
function chunkFencesFor(chunks, previous) {
|
|
149
151
|
let base = 0;
|
|
150
|
-
return chunks.map((text) => {
|
|
151
|
-
const
|
|
152
|
+
return chunks.map((text, i) => {
|
|
153
|
+
const kept = previous && previous.chunks[i] === text ? previous.fences[i] : void 0;
|
|
154
|
+
const value = kept && kept.base === base ? kept : {
|
|
152
155
|
base,
|
|
153
|
-
starts: viewFenceStarts(text)
|
|
156
|
+
starts: kept ? kept.starts : viewFenceStarts(text)
|
|
154
157
|
};
|
|
155
158
|
base += value.starts.length;
|
|
156
159
|
return value;
|
|
@@ -182,37 +185,120 @@ function ChunkFencesScope({ base, starts, children }) {
|
|
|
182
185
|
function fenceIndexIn(chunk, offset) {
|
|
183
186
|
return Math.max(0, chunk.starts.filter((start) => start <= offset).length - 1);
|
|
184
187
|
}
|
|
188
|
+
const NO_PLACES = /* @__PURE__ */ new Map();
|
|
185
189
|
/** Where each reply row's views go, read per row: a row draws again only when its own place changes. */
|
|
186
190
|
var ReplyViewPlaces = class {
|
|
187
|
-
|
|
191
|
+
/** The places of the settled exchanges (or of a whole array). */
|
|
192
|
+
base = NO_PLACES;
|
|
193
|
+
/** The places the open exchange sets, over `base`. */
|
|
194
|
+
top = NO_PLACES;
|
|
195
|
+
source = null;
|
|
188
196
|
events = [];
|
|
197
|
+
/** The folds of a transcript store's settled exchanges, per chunk list. */
|
|
198
|
+
settled = null;
|
|
189
199
|
textless = [];
|
|
200
|
+
textlessKey = null;
|
|
190
201
|
changed = /* @__PURE__ */ new Set();
|
|
191
202
|
listeners = /* @__PURE__ */ new Map();
|
|
192
203
|
/**
|
|
193
204
|
* Reads the events: the places (`viewPlacements`) and the exchanges with no reply text
|
|
194
205
|
* (`textlessExchanges`). A stream tick changes neither, so it reads nothing. Rows rendering
|
|
195
|
-
* after it read the places; {@link flush} tells the others.
|
|
206
|
+
* after it read the places; {@link flush} tells the others. A transcript store's settled
|
|
207
|
+
* exchanges are read once: a tick reads its open exchange.
|
|
196
208
|
*
|
|
197
|
-
* @param events - The session's events, oldest first.
|
|
209
|
+
* @param events - The session's events, oldest first, or its transcript store.
|
|
198
210
|
*/
|
|
199
211
|
update(events) {
|
|
200
|
-
if (events === this.
|
|
201
|
-
if (
|
|
202
|
-
|
|
203
|
-
this.
|
|
212
|
+
if (events === this.source) return;
|
|
213
|
+
if (Array.isArray(events)) {
|
|
214
|
+
const list = events;
|
|
215
|
+
if (!onlyLastTextChanged(this.events, list)) {
|
|
216
|
+
this.replace(viewPlacements(list, this.flat()), NO_PLACES, true);
|
|
217
|
+
this.textless = textlessExchanges(list);
|
|
218
|
+
}
|
|
219
|
+
this.events = list;
|
|
220
|
+
this.settled = null;
|
|
221
|
+
this.textlessKey = null;
|
|
222
|
+
} else {
|
|
223
|
+
this.updateTranscript(events);
|
|
224
|
+
this.events = [];
|
|
225
|
+
}
|
|
226
|
+
this.source = events;
|
|
227
|
+
}
|
|
228
|
+
updateTranscript(transcript) {
|
|
229
|
+
let settled = this.settled;
|
|
230
|
+
const whole = !settled || settled.chunks !== transcript.chunks;
|
|
231
|
+
if (!settled || whole) {
|
|
232
|
+
noteTranscriptPass("views:settle", transcript.prefixLength);
|
|
233
|
+
const places = placementFold();
|
|
234
|
+
const textless = textlessFold();
|
|
235
|
+
for (const chunk of transcript.chunks) {
|
|
236
|
+
foldPlacements(places, chunk);
|
|
237
|
+
foldTextless(textless, chunk);
|
|
238
|
+
}
|
|
239
|
+
const map = places.places;
|
|
240
|
+
for (const [rowId, place] of map) {
|
|
241
|
+
const before = this.get(rowId);
|
|
242
|
+
if (before && sameViewPlace(before, place)) map.set(rowId, before);
|
|
243
|
+
}
|
|
244
|
+
settled = {
|
|
245
|
+
chunks: transcript.chunks,
|
|
246
|
+
places,
|
|
247
|
+
textless
|
|
248
|
+
};
|
|
249
|
+
this.settled = settled;
|
|
250
|
+
}
|
|
251
|
+
noteTranscriptPass("views:open", transcript.tail.length);
|
|
252
|
+
const fold = placementFold(settled.places);
|
|
253
|
+
foldPlacements(fold, transcript.tail);
|
|
254
|
+
closePlacementExchange(fold);
|
|
255
|
+
const top = fold.places.top;
|
|
256
|
+
for (const [rowId, place] of top) {
|
|
257
|
+
const before = this.get(rowId);
|
|
258
|
+
if (before && sameViewPlace(before, place)) top.set(rowId, before);
|
|
259
|
+
}
|
|
260
|
+
this.replace(settled.places.places, top, whole);
|
|
261
|
+
const tf = textlessFold(settled.textless);
|
|
262
|
+
foldTextless(tf, transcript.tail);
|
|
263
|
+
const open = !tf.replied && tf.turns.length > 0 ? tf.turns : null;
|
|
264
|
+
const key = this.textlessKey;
|
|
265
|
+
if (!(key !== null && key.closed === tf.out && (key.open === open || key.open !== null && open !== null && key.open.length === open.length && key.open.every((t, i) => t === open[i])))) {
|
|
266
|
+
this.textless = open ? [...tf.out, {
|
|
267
|
+
turns: open,
|
|
268
|
+
closed: false
|
|
269
|
+
}] : tf.out;
|
|
270
|
+
this.textlessKey = {
|
|
271
|
+
closed: tf.out,
|
|
272
|
+
open
|
|
273
|
+
};
|
|
204
274
|
}
|
|
205
|
-
this.events = events;
|
|
206
275
|
}
|
|
207
276
|
/** The exchanges with no reply text, as of the last {@link update}. */
|
|
208
277
|
get textlessExchanges() {
|
|
209
278
|
return this.textless;
|
|
210
279
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
this.
|
|
280
|
+
/** The places as one map (the array path's `previous`). */
|
|
281
|
+
flat() {
|
|
282
|
+
if (this.top.size === 0) return this.base;
|
|
283
|
+
const all = new Map(this.base);
|
|
284
|
+
for (const [rowId, place] of this.top) all.set(rowId, place);
|
|
285
|
+
return all;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Sets the places, noting the rows whose place changed: every row when `whole`, else those the
|
|
289
|
+
* open exchange set before or sets now (the base is the same).
|
|
290
|
+
*/
|
|
291
|
+
replace(base, top, whole) {
|
|
292
|
+
const read = (rowId) => top.has(rowId) ? top.get(rowId) : base.get(rowId);
|
|
293
|
+
const keys = whole ? [
|
|
294
|
+
this.base.keys(),
|
|
295
|
+
this.top.keys(),
|
|
296
|
+
base.keys(),
|
|
297
|
+
top.keys()
|
|
298
|
+
] : [this.top.keys(), top.keys()];
|
|
299
|
+
for (const list of keys) for (const rowId of list) if (this.get(rowId) !== read(rowId)) this.changed.add(rowId);
|
|
300
|
+
this.base = base;
|
|
301
|
+
this.top = top;
|
|
216
302
|
}
|
|
217
303
|
/** Tells the rows whose place changed since the last flush. */
|
|
218
304
|
flush() {
|
|
@@ -221,7 +307,7 @@ var ReplyViewPlaces = class {
|
|
|
221
307
|
for (const rowId of changed) for (const listener of [...this.listeners.get(rowId) ?? []]) listener();
|
|
222
308
|
}
|
|
223
309
|
get(rowId) {
|
|
224
|
-
return this.
|
|
310
|
+
return this.top.has(rowId) ? this.top.get(rowId) : this.base.get(rowId);
|
|
225
311
|
}
|
|
226
312
|
subscribe(rowId, onChange) {
|
|
227
313
|
let set = this.listeners.get(rowId);
|
|
@@ -28,6 +28,8 @@ export interface TreeEntry {
|
|
|
28
28
|
kind: 'file' | 'dir';
|
|
29
29
|
/** Dimmed (gitignored). */
|
|
30
30
|
ignored?: boolean;
|
|
31
|
+
/** A folder whose contents are listed when it opens (`onExpandFolder`). */
|
|
32
|
+
deferred?: boolean;
|
|
31
33
|
}
|
|
32
34
|
/** A path's git status, painted on its row. */
|
|
33
35
|
export interface TreeGitStatus {
|
|
@@ -77,7 +77,7 @@ function FileTree({ controlRef, entries, gitStatus, selectedPath, onSelect, onOp
|
|
|
77
77
|
} }
|
|
78
78
|
} : {}
|
|
79
79
|
});
|
|
80
|
-
const lazyDirs = useMemo(() => entries.filter((e) => e.ignored && e.kind === "dir" && e.path.endsWith("/")).map((e) => e.path), [entries]);
|
|
80
|
+
const lazyDirs = useMemo(() => entries.filter((e) => (e.ignored || e.deferred) && e.kind === "dir" && e.path.endsWith("/")).map((e) => e.path), [entries]);
|
|
81
81
|
const lazyRef = useRef({
|
|
82
82
|
dirs: lazyDirs,
|
|
83
83
|
onExpandFolder
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useLatest } from "../../hooks/useLatest.js";
|
|
1
2
|
import { useEditorEnvironment } from "./environment.js";
|
|
2
3
|
import { DIFFS_HOST_STYLE, DIFFS_UNSAFE_CSS, PREFERRED_HIGHLIGHTER, VIRTUALIZER_CONFIG } from "./pierre-theme.js";
|
|
3
4
|
import { revealOnHighlight } from "./reveal.js";
|
|
@@ -21,7 +22,7 @@ function FileViewInner({ name, contents, wrap = false, hideHeader = false, selec
|
|
|
21
22
|
const { shikiTheme: theme, appearance } = useEditorEnvironment();
|
|
22
23
|
const selectable = onSelectionEnd !== void 0;
|
|
23
24
|
const host = useDetachCleanup();
|
|
24
|
-
const latest =
|
|
25
|
+
const latest = useLatest({
|
|
25
26
|
onSelectionEnd,
|
|
26
27
|
onGutterAction,
|
|
27
28
|
onTokenEnter,
|
|
@@ -32,48 +33,38 @@ function FileViewInner({ name, contents, wrap = false, hideHeader = false, selec
|
|
|
32
33
|
edit,
|
|
33
34
|
wrap
|
|
34
35
|
});
|
|
35
|
-
latest.current = {
|
|
36
|
-
onSelectionEnd,
|
|
37
|
-
onGutterAction,
|
|
38
|
-
onTokenEnter,
|
|
39
|
-
onTokenLeave,
|
|
40
|
-
onTokenClick,
|
|
41
|
-
onHighlighted,
|
|
42
|
-
renderAnnotation,
|
|
43
|
-
edit,
|
|
44
|
-
wrap
|
|
45
|
-
};
|
|
46
36
|
const highlightedOnce = useRef(false);
|
|
47
37
|
const words = useMemo(() => wordHover({
|
|
48
|
-
enter: (t, e) => latest.
|
|
49
|
-
leave: () => latest.
|
|
50
|
-
}), []);
|
|
38
|
+
enter: (t, e) => latest().onTokenEnter?.(t, e),
|
|
39
|
+
leave: () => latest().onTokenLeave?.()
|
|
40
|
+
}), [latest]);
|
|
51
41
|
const stable = useMemo(() => ({
|
|
52
|
-
onLineSelectionEnd: (r) => latest.
|
|
53
|
-
onGutterUtilityClick: (r) => latest.
|
|
42
|
+
onLineSelectionEnd: (r) => latest().onSelectionEnd?.(r),
|
|
43
|
+
onGutterUtilityClick: (r) => latest().onGutterAction?.(r),
|
|
54
44
|
onTokenEnter: (t, e) => words.enter(t, e),
|
|
55
45
|
onTokenLeave: () => words.leave(),
|
|
56
46
|
onTokenClick: (t, e) => {
|
|
57
47
|
const token = words.token(t, e.clientX, e.clientY);
|
|
58
|
-
if (token) latest.
|
|
48
|
+
if (token) latest().onTokenClick?.(token, e);
|
|
59
49
|
},
|
|
60
|
-
renderAnnotation: (a) => latest.
|
|
61
|
-
onEditChange: (e) => latest.
|
|
50
|
+
renderAnnotation: (a) => latest().renderAnnotation?.(a) ?? null,
|
|
51
|
+
onEditChange: (e) => latest().edit?.onChange(e.file.contents, e.changes.map((c) => ({
|
|
62
52
|
range: c.range,
|
|
63
53
|
text: c.text
|
|
64
54
|
}))),
|
|
65
|
-
onEditComplete: (e) => latest.
|
|
55
|
+
onEditComplete: (e) => latest().edit?.onComplete?.(e) ?? "reject",
|
|
66
56
|
onPostRender: (node, instance, phase) => {
|
|
67
57
|
const highlighted = phase !== "unmount" && isHighlighted(instance, node);
|
|
68
58
|
revealOnHighlight(node, highlighted, phase, phase !== "unmount" && colorsFile(instance));
|
|
69
|
-
|
|
70
|
-
|
|
59
|
+
const current = latest();
|
|
60
|
+
scrollReachOnRender(node, !current.wrap, phase);
|
|
61
|
+
if (phase === "unmount" || highlightedOnce.current || !current.onHighlighted) return;
|
|
71
62
|
if (highlighted) {
|
|
72
63
|
highlightedOnce.current = true;
|
|
73
|
-
|
|
64
|
+
current.onHighlighted();
|
|
74
65
|
}
|
|
75
66
|
}
|
|
76
|
-
}), [words]);
|
|
67
|
+
}), [words, latest]);
|
|
77
68
|
const hasTokenHandlers = onTokenEnter !== void 0;
|
|
78
69
|
const hasTokenClick = onTokenClick !== void 0;
|
|
79
70
|
const hasGutter = onGutterAction !== void 0;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useLatest } from "../../../hooks/useLatest.js";
|
|
1
2
|
import { clearFind, paintFind, rowOf } from "./find-highlight.js";
|
|
2
3
|
import { findAll } from "./find-model.js";
|
|
3
4
|
import { settleScroll } from "./settle-scroll.js";
|
|
@@ -23,23 +24,16 @@ function useFind({ parts, version, surfaces, scroller, fallback, smooth }) {
|
|
|
23
24
|
const [needle, setNeedle] = useState("");
|
|
24
25
|
const [opts, setOpts] = useState({ caseSensitive: false });
|
|
25
26
|
const [index, setIndex] = useState(0);
|
|
26
|
-
const latest =
|
|
27
|
-
parts,
|
|
27
|
+
const latest = useLatest({
|
|
28
28
|
surfaces,
|
|
29
29
|
scroller,
|
|
30
30
|
fallback
|
|
31
31
|
});
|
|
32
|
-
latest.current = {
|
|
33
|
-
parts,
|
|
34
|
-
surfaces,
|
|
35
|
-
scroller,
|
|
36
|
-
fallback
|
|
37
|
-
};
|
|
38
32
|
useEffect(() => {
|
|
39
33
|
const t = window.setTimeout(setNeedle, QUERY_DEBOUNCE_MS, query);
|
|
40
34
|
return () => window.clearTimeout(t);
|
|
41
35
|
}, [query]);
|
|
42
|
-
const { matches, capped } = useMemo(() => open && needle ? findAll(
|
|
36
|
+
const { matches, capped } = useMemo(() => open && needle ? findAll(parts(), needle, opts) : {
|
|
43
37
|
matches: [],
|
|
44
38
|
capped: false
|
|
45
39
|
}, [
|
|
@@ -69,13 +63,14 @@ function useFind({ parts, version, surfaces, scroller, fallback, smooth }) {
|
|
|
69
63
|
cancelAnimationFrame(frame.current);
|
|
70
64
|
frame.current = requestAnimationFrame(() => {
|
|
71
65
|
if (!open || !needle) return clearFind(me.current);
|
|
72
|
-
paintFind(me.current, latest.
|
|
66
|
+
paintFind(me.current, latest().surfaces(), needle, opts, current);
|
|
73
67
|
});
|
|
74
68
|
}, [
|
|
75
69
|
open,
|
|
76
70
|
needle,
|
|
77
71
|
opts,
|
|
78
|
-
current
|
|
72
|
+
current,
|
|
73
|
+
latest
|
|
79
74
|
]);
|
|
80
75
|
useEffect(() => {
|
|
81
76
|
paint();
|
|
@@ -83,14 +78,14 @@ function useFind({ parts, version, surfaces, scroller, fallback, smooth }) {
|
|
|
83
78
|
useEffect(() => () => clearFind(me.current), []);
|
|
84
79
|
useEffect(() => {
|
|
85
80
|
if (!open) return;
|
|
86
|
-
const root = latest.
|
|
81
|
+
const root = latest().scroller();
|
|
87
82
|
const watched = /* @__PURE__ */ new WeakSet();
|
|
88
83
|
const observer = new MutationObserver(() => {
|
|
89
84
|
watch();
|
|
90
85
|
paint();
|
|
91
86
|
});
|
|
92
87
|
function watch() {
|
|
93
|
-
for (const s of latest.
|
|
88
|
+
for (const s of latest().surfaces()) {
|
|
94
89
|
if (watched.has(s.root)) continue;
|
|
95
90
|
watched.add(s.root);
|
|
96
91
|
observer.observe(s.root, {
|
|
@@ -110,7 +105,11 @@ function useFind({ parts, version, surfaces, scroller, fallback, smooth }) {
|
|
|
110
105
|
observer.disconnect();
|
|
111
106
|
root?.removeEventListener("scroll", onScroll);
|
|
112
107
|
};
|
|
113
|
-
}, [
|
|
108
|
+
}, [
|
|
109
|
+
open,
|
|
110
|
+
paint,
|
|
111
|
+
latest
|
|
112
|
+
]);
|
|
114
113
|
const stop = useRef(null);
|
|
115
114
|
const currentRef = useRef(current);
|
|
116
115
|
useLayoutEffect(() => {
|
|
@@ -119,10 +118,10 @@ function useFind({ parts, version, surfaces, scroller, fallback, smooth }) {
|
|
|
119
118
|
const currentKey = current ? `${current.part}\0${current.side}\0${current.line}\0${current.start}` : "";
|
|
120
119
|
useEffect(() => {
|
|
121
120
|
stop.current?.();
|
|
122
|
-
const root = latest.
|
|
121
|
+
const root = latest().scroller();
|
|
123
122
|
const target = currentRef.current;
|
|
124
123
|
if (!open || !target || !root) return;
|
|
125
|
-
stop.current = settleScroll(root, () => rowOf(latest.
|
|
124
|
+
stop.current = settleScroll(root, () => rowOf(latest().surfaces(), target) ?? latest().fallback(target, root), {
|
|
126
125
|
offset: (r) => r.clientHeight * LAND_AT,
|
|
127
126
|
smooth
|
|
128
127
|
});
|
|
@@ -131,7 +130,8 @@ function useFind({ parts, version, surfaces, scroller, fallback, smooth }) {
|
|
|
131
130
|
open,
|
|
132
131
|
currentKey,
|
|
133
132
|
jumps,
|
|
134
|
-
smooth
|
|
133
|
+
smooth,
|
|
134
|
+
latest
|
|
135
135
|
]);
|
|
136
136
|
const step = useCallback((direction) => {
|
|
137
137
|
if (matches.length === 0) return;
|