@kabmo-labs/kabmo 0.8.0 → 0.10.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/README.md +52 -0
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +336 -336
- package/dist/client/static/js/index-18xe7655.css +1 -0
- package/dist/client/static/js/{index-qwpvd9fv.js → index-nxpe7835.js} +933 -898
- package/package.json +11 -1
- package/src/client/components/common/code-surface/bracket-guide.test.ts +249 -0
- package/src/client/components/common/code-surface/bracket-guide.ts +131 -0
- package/src/client/components/common/code-surface/documents.test.ts +122 -0
- package/src/client/components/common/code-surface/documents.ts +286 -0
- package/src/client/components/common/code-surface/extensions.test.ts +115 -0
- package/src/client/components/common/code-surface/extensions.ts +295 -0
- package/src/client/components/common/code-surface/fold-stack.test.ts +218 -0
- package/src/client/components/common/code-surface/fold.test.ts +148 -0
- package/src/client/components/common/code-surface/fold.ts +118 -0
- package/src/client/components/common/code-surface/handle.ts +102 -0
- package/src/client/components/common/code-surface/indent-guide.ts +104 -0
- package/src/client/components/common/code-surface/indent.test.ts +239 -0
- package/src/client/components/common/code-surface/indent.ts +124 -0
- package/src/client/components/common/code-surface/index.tsx +283 -314
- package/src/client/components/common/code-surface/keymap.test.ts +133 -0
- package/src/client/components/common/code-surface/keymap.ts +256 -0
- package/src/client/components/common/code-surface/line-commands.test.ts +90 -0
- package/src/client/components/common/code-surface/line-commands.ts +103 -0
- package/src/client/components/common/code-surface/marks.ts +74 -0
- package/src/client/components/common/code-surface/props.ts +87 -0
- package/src/client/components/common/code-surface/shiki.ts +234 -0
- package/src/client/components/common/code-surface/stream-language.test.ts +118 -0
- package/src/client/components/common/code-surface/stream-language.ts +123 -0
- package/src/client/components/common/code-surface/sync.test.ts +185 -0
- package/src/client/components/common/code-surface/sync.ts +58 -0
- package/src/client/components/common/code-surface/theme.test.ts +237 -0
- package/src/client/components/common/code-surface/theme.ts +224 -0
- package/src/client/components/common/code-surface/typing.test.ts +97 -0
- package/src/client/components/common/code-surface/typing.ts +111 -0
- package/src/client/components/common/editor-view-buttons/index.test.tsx +148 -0
- package/src/client/components/common/editor-view-buttons/index.tsx +109 -0
- package/src/client/components/common/shell-update-button/Modal.tsx +163 -0
- package/src/client/components/common/shell-update-button/index.test.tsx +251 -0
- package/src/client/components/common/shell-update-button/index.tsx +125 -0
- package/src/client/components/common/toolbar-row/index.test.tsx +215 -0
- package/src/client/components/common/toolbar-row/index.tsx +260 -0
- package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +58 -78
- package/src/client/components/layout/desktop-layout/index.tsx +65 -67
- package/src/client/components/layout/desktop-layout/resizer/index.tsx +6 -3
- package/src/client/components/layout/session-sidebar/Footer.tsx +8 -15
- package/src/client/components/mobile/LayoutWrapper.tsx +1 -0
- package/src/client/components/mobile/mobile-right-sidebar/FullDiff.tsx +3 -0
- package/src/client/components/mobile/mobile-right-sidebar/FullEditor.tsx +98 -71
- package/src/client/components/mobile/mobile-right-sidebar/Header.tsx +20 -1
- package/src/client/components/mobile/mobile-right-sidebar/OutlineButton.test.tsx +137 -0
- package/src/client/components/mobile/mobile-right-sidebar/OutlineButton.tsx +14 -3
- package/src/client/components/mobile/mobile-right-sidebar/editor-props.ts +25 -0
- package/src/client/components/mobile/mobile-session-sidebar/Footer.tsx +9 -21
- package/src/client/components/settings/Modal.tsx +8 -0
- package/src/client/components/settings/categories/AppearanceSettings.tsx +9 -0
- package/src/client/components/settings/categories/appearance-settings/EditorIndentSection.tsx +87 -0
- package/src/client/components/settings/categories/appearance-settings/EditorThemeSection.test.tsx +167 -0
- package/src/client/components/settings/categories/appearance-settings/EditorThemeSection.tsx +184 -0
- package/src/client/components/settings/categories/appearance-settings/EditorTypingSection.tsx +99 -0
- package/src/client/components/settings/categories/project-settings/WorktreeSettings.tsx +8 -2
- package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +16 -8
- package/src/client/components/workspace/chat-timeline/SystemNotice.tsx +9 -4
- package/src/client/components/workspace/chat-timeline/TaskResultContent.tsx +9 -7
- package/src/client/components/workspace/chat-timeline/chat-input/expansion.ts +9 -4
- package/src/client/components/workspace/chat-timeline/chat-input/index.tsx +15 -11
- package/src/client/components/workspace/chat-timeline/chat-input/stretch-send.test.tsx +165 -0
- package/src/client/components/workspace/chat-timeline/target-picker/WorkspacePicker.test.tsx +132 -0
- package/src/client/components/workspace/chat-timeline/target-picker/WorkspacePicker.tsx +120 -0
- package/src/client/components/workspace/chat-timeline/target-picker/WorktreePicker.test.tsx +319 -0
- package/src/client/components/workspace/chat-timeline/target-picker/WorktreePicker.tsx +285 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/index.test.ts +2 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/hashline-patch/index.tsx +34 -29
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/AstEdit.tsx +11 -9
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.tsx +10 -7
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Edit.tsx +25 -8
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Eval.tsx +8 -11
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/FileMatches.test.ts +114 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/FileMatches.tsx +111 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.tsx +7 -7
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/SearchTool.tsx +9 -59
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ArtifactBody.tsx +2 -7
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/DiffView.test.ts +43 -30
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/DiffView.tsx +49 -32
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ExcerptCode.tsx +8 -8
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/HighlightedCode.tsx +35 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/JsonCodeBlock.tsx +4 -4
- package/src/client/components/workspace/diff-panel/MergeDiffView.tsx +179 -0
- package/src/client/components/workspace/diff-panel/ThemedMergeDiffView.tsx +24 -0
- package/src/client/components/workspace/diff-panel/Toolbar.tsx +224 -186
- package/src/client/components/workspace/diff-panel/ToolbarSegments.tsx +98 -0
- package/src/client/components/workspace/diff-panel/index.tsx +76 -145
- package/src/client/components/workspace/diff-panel/merge.ts +315 -0
- package/src/client/components/workspace/editor/Body.tsx +28 -7
- package/src/client/components/workspace/editor/CommandPalette.tsx +6 -6
- package/src/client/components/workspace/editor/ConflictStrip.tsx +77 -0
- package/src/client/components/workspace/editor/Dialogs.tsx +53 -0
- package/src/client/components/workspace/editor/EmptyEditor.tsx +23 -0
- package/src/client/components/workspace/editor/ExternalChangeStrip.tsx +61 -0
- package/src/client/components/workspace/editor/FileDocument.tsx +146 -63
- package/src/client/components/workspace/editor/FilePane.tsx +47 -7
- package/src/client/components/workspace/editor/FindWidget.test.ts +9 -5
- package/src/client/components/workspace/editor/FindWidget.tsx +36 -2
- package/src/client/components/workspace/editor/GoToLineModal.tsx +123 -0
- package/src/client/components/workspace/editor/Notices.tsx +71 -0
- package/src/client/components/workspace/editor/Pane.tsx +118 -0
- package/src/client/components/workspace/editor/PluginColumn.tsx +32 -0
- package/src/client/components/workspace/editor/QuickOpenModal.tsx +146 -0
- package/src/client/components/workspace/editor/SaveAsModal.tsx +175 -0
- package/src/client/components/workspace/editor/SplitColumn.tsx +98 -0
- package/src/client/components/workspace/editor/SplitPane.tsx +57 -0
- package/src/client/components/workspace/editor/StatusBar.tsx +106 -0
- package/src/client/components/workspace/editor/TabContextMenu.tsx +75 -0
- package/src/client/components/workspace/editor/Tabs.tsx +195 -18
- package/src/client/components/workspace/editor/Toolbar.tsx +110 -140
- package/src/client/components/workspace/editor/index.tsx +201 -193
- package/src/client/components/workspace/editor/props.ts +64 -0
- package/src/client/components/workspace/editor/toolbar-clusters.tsx +300 -0
- package/src/client/components/workspace/file-explorer/Modals.tsx +14 -1
- package/src/client/components/workspace/file-explorer/OutlineSection.test.tsx +18 -0
- package/src/client/components/workspace/file-explorer/OutlineSection.tsx +10 -3
- package/src/client/components/workspace/file-explorer/TreeItem.tsx +2 -1
- package/src/client/components/workspace/file-explorer/clipboard.test.ts +3 -1
- package/src/client/components/workspace/file-explorer/index.test.ts +61 -0
- package/src/client/components/workspace/file-explorer/index.tsx +10 -48
- package/src/client/components/workspace/file-explorer/local-edit.test.ts +8 -3
- package/src/client/components/workspace/search-panel/Body.tsx +7 -2
- package/src/client/components/workspace/worktree-modal/index.test.tsx +118 -0
- package/src/client/hooks/chat/composer/file-drop.ts +22 -37
- package/src/client/hooks/chat/composer/pipeline.test.ts +76 -0
- package/src/client/hooks/chat/composer/pipeline.ts +12 -1
- package/src/client/hooks/chat/omp/reconnect.test.ts +338 -0
- package/src/client/hooks/chat/omp/reconnect.ts +187 -0
- package/src/client/hooks/chat/omp/run-liveness.test.ts +71 -0
- package/src/client/hooks/chat/omp/run-liveness.ts +65 -0
- package/src/client/hooks/chat/omp/session-list.activity.test.ts +114 -0
- package/src/client/hooks/chat/omp/session-list.test-util.ts +164 -0
- package/src/client/hooks/chat/omp/session-list.test.ts +30 -150
- package/src/client/hooks/chat/omp/session-list.tsx +69 -9
- package/src/client/hooks/chat/timeline/generating.ts +19 -2
- package/src/client/hooks/chat/timeline/index.ts +19 -24
- package/src/client/hooks/chat/timeline/lost-run.test.ts +329 -0
- package/src/client/hooks/chat/timeline/lost-run.ts +177 -0
- package/src/client/hooks/chat/timeline/session-load.test-util.ts +205 -0
- package/src/client/hooks/chat/timeline/session-load.test.ts +61 -162
- package/src/client/hooks/chat/timeline/session-load.ts +69 -37
- package/src/client/hooks/chat/timeline/session-switch.test.ts +65 -0
- package/src/client/hooks/chat/timeline/session-switch.ts +63 -0
- package/src/client/hooks/code/deferred-highlight.test.ts +182 -0
- package/src/client/hooks/code/deferred-highlight.ts +129 -0
- package/src/client/hooks/editor/caret-position.test.ts +58 -0
- package/src/client/hooks/editor/caret-position.ts +48 -0
- package/src/client/hooks/editor/file-editor-types.ts +200 -0
- package/src/client/hooks/editor/find-history.test.ts +132 -0
- package/src/client/hooks/editor/find-history.ts +46 -0
- package/src/client/hooks/editor/find-selection-range.test.ts +100 -0
- package/src/client/hooks/editor/find-selection-range.ts +49 -0
- package/src/client/hooks/editor/find-state.ts +14 -1
- package/src/client/hooks/editor/font.test.ts +0 -93
- package/src/client/hooks/editor/indent-settings.test.ts +104 -0
- package/src/client/hooks/editor/indent-settings.ts +88 -0
- package/src/client/hooks/editor/quick-open.test.ts +141 -0
- package/src/client/hooks/editor/quick-open.ts +127 -0
- package/src/client/hooks/editor/save-as.test.ts +156 -0
- package/src/client/hooks/editor/save-as.ts +122 -0
- package/src/client/hooks/editor/save-file.test.ts +179 -0
- package/src/client/hooks/editor/save-file.ts +73 -28
- package/src/client/hooks/editor/theme.test.ts +206 -0
- package/src/client/hooks/editor/theme.ts +82 -0
- package/src/client/hooks/editor/typing-settings.test.ts +73 -0
- package/src/client/hooks/editor/typing-settings.ts +65 -0
- package/src/client/hooks/editor/use-close-guard.ts +98 -0
- package/src/client/hooks/editor/use-editor-drop-overlay.test.ts +159 -0
- package/src/client/hooks/editor/use-editor-drop.shell.test.ts +224 -0
- package/src/client/hooks/editor/use-editor-drop.test.ts +101 -0
- package/src/client/hooks/editor/use-editor-drop.ts +120 -77
- package/src/client/hooks/editor/use-editor-find.test.ts +2 -2
- package/src/client/hooks/editor/use-editor-find.ts +45 -10
- package/src/client/hooks/editor/use-editor-panel-keys.ts +152 -0
- package/src/client/hooks/editor/use-editor-tab-state.ts +71 -0
- package/src/client/hooks/editor/use-external-change-notice.ts +71 -0
- package/src/client/hooks/editor/use-external-change.test.ts +88 -0
- package/src/client/hooks/editor/use-external-change.ts +146 -0
- package/src/client/hooks/editor/use-file-editor.ts +83 -116
- package/src/client/hooks/editor/use-file-read.ts +16 -8
- package/src/client/hooks/editor/use-file-writes.ts +28 -3
- package/src/client/hooks/editor/use-mobile-editor-find.ts +69 -0
- package/src/client/hooks/editor/use-mobile-reveal.ts +53 -0
- package/src/client/hooks/editor/use-outline-view.test.ts +182 -0
- package/src/client/hooks/editor/use-outline-view.ts +94 -7
- package/src/client/hooks/editor/use-scroll-restore.test.ts +55 -2
- package/src/client/hooks/editor/use-scroll-restore.ts +124 -4
- package/src/client/hooks/editor/use-search-reveal-jump.ts +57 -0
- package/src/client/hooks/editor/use-search-reveal.ts +1 -1
- package/src/client/hooks/editor/use-split-editor.test.tsx +169 -0
- package/src/client/hooks/editor/use-split-editor.ts +91 -0
- package/src/client/hooks/editor/use-unload-guard.tsx +117 -0
- package/src/client/hooks/editor/use-write-conflict.test.ts +164 -0
- package/src/client/hooks/editor/use-write-conflict.ts +152 -0
- package/src/client/hooks/editor/wheel-zoom.test.ts +141 -0
- package/src/client/hooks/editor/wheel-zoom.ts +96 -0
- package/src/client/hooks/ui/drag-presence.test.ts +193 -0
- package/src/client/hooks/ui/drag-presence.ts +108 -0
- package/src/client/hooks/ui/settings-modal.test.ts +115 -0
- package/src/client/hooks/ui/settings-modal.ts +56 -0
- package/src/client/hooks/ui/updates/shell-download.test.ts +2 -0
- package/src/client/hooks/ui/updates/shell-download.ts +55 -14
- package/src/client/hooks/ui/updates/shell-offer.test.ts +26 -0
- package/src/client/hooks/ui/updates/shell-update.test.ts +140 -0
- package/src/client/hooks/ui/updates/shell-update.ts +119 -0
- package/src/client/hooks/workspace/diff-file.ts +29 -10
- package/src/client/hooks/workspace/diff-git-actions.ts +147 -0
- package/src/client/hooks/workspace/editor-view.ts +61 -0
- package/src/client/hooks/workspace/file-listing.ts +36 -24
- package/src/client/hooks/workspace/file-tabs.test.ts +152 -5
- package/src/client/hooks/workspace/file-tabs.ts +70 -11
- package/src/client/hooks/workspace/file-tree-edits.ts +103 -0
- package/src/client/hooks/workspace/navbar-session-actions.ts +72 -0
- package/src/client/hooks/workspace/worktree/index.ts +20 -5
- package/src/client/lib/desktop/bridge.ts +45 -0
- package/src/client/lib/desktop/dropped-paths.ts +83 -0
- package/src/client/lib/editor/tab-menu.test.ts +127 -0
- package/src/client/lib/editor/tab-menu.ts +127 -0
- package/src/client/lib/editor-dirty-tabs.test.ts +102 -0
- package/src/client/lib/editor-dirty-tabs.ts +103 -0
- package/src/client/lib/native/resume.test.ts +66 -0
- package/src/client/lib/native/resume.ts +42 -0
- package/src/client/lib/search-reveal.ts +1 -1
- package/src/client/main.tsx +13 -1
- package/src/client/tailwind.css +75 -8
- package/src/server/lib/auth/guard.test.ts +28 -0
- package/src/server/lib/auth/guard.ts +10 -0
- package/src/server/lib/bundler/css.test.ts +31 -0
- package/src/server/lib/fs/listing.test.ts +81 -16
- package/src/server/lib/fs/listing.ts +72 -5
- package/src/server/lib/fs/worktree/create.ts +2 -3
- package/src/server/lib/fs/worktree/list.ts +13 -0
- package/src/server/lib/fs/worktree/remove.ts +3 -3
- package/src/server/lib/fs/write-conflict.test.ts +68 -0
- package/src/server/lib/fs/write-conflict.ts +84 -0
- package/src/server/lib/lifecycle/claim-port.test.ts +156 -0
- package/src/server/lib/lifecycle/port-guard.test.ts +20 -164
- package/src/server/lib/lifecycle/port-guard.ts +39 -7
- package/src/server/lib/lifecycle/probe-health.test.ts +166 -0
- package/src/server/lib/lifecycle/probe.test.ts +77 -164
- package/src/server/lib/lifecycle/probe.ts +121 -13
- package/src/server/lib/omp/rpc/frame-fold-signals.test.ts +112 -0
- package/src/server/lib/omp/rpc/frame-fold.ts +10 -5
- package/src/server/lib/omp/session/sidebar-activity.server.test.ts +162 -0
- package/src/server/lib/omp/session/sidebar-activity.server.ts +70 -0
- package/src/server/lib/omp/session/telemetry/compute.ts +13 -1
- package/src/server/lib/omp/session/telemetry.test.ts +33 -0
- package/src/server/lib/realtime/signals.server.ts +10 -0
- package/src/server/lib/realtime/topics/catalog.server.ts +4 -1
- package/src/server/lib/realtime/topics.server.ts +16 -0
- package/src/server/lib/updates/shell-assets.ts +94 -3
- package/src/server/lib/updates/shell-cache.ts +105 -0
- package/src/server/lib/updates/shell-pages.test.ts +33 -2
- package/src/server/lib/updates/shell-pages.ts +17 -5
- package/src/server/lib/updates/shell-release-desktop.test.ts +166 -0
- package/src/server/lib/updates/shell-release.test.ts +10 -27
- package/src/server/lib/updates/shell-release.ts +107 -111
- package/src/server/routes/fs/action-save-as.test.ts +82 -0
- package/src/server/routes/fs/action.test.ts +82 -0
- package/src/server/routes/fs/action.ts +54 -1
- package/src/server/routes/fs/exists.ts +11 -1
- package/src/server/routes/fs/git-merge.test.ts +11 -1
- package/src/server/routes/fs/read.test.ts +24 -7
- package/src/server/routes/fs/read.ts +6 -1
- package/src/server/routes/fs/scope.test.ts +15 -10
- package/src/server/routes/fs/scope.ts +3 -14
- package/src/server/routes/updates/android.ts +6 -1
- package/src/server/routes/updates/desktop.ts +29 -7
- package/src/server/routes/updates/ios.ts +5 -1
- package/src/server/routes/worktrees/list.ts +11 -1
- package/src/server/routes/worktrees/routes.test.ts +17 -0
- package/src/shared/lib/chat/timeline/omp-callbacks.test.ts +36 -0
- package/src/shared/lib/chat/timeline/omp-callbacks.ts +18 -0
- package/src/shared/lib/chat/timeline/run-signals.test.ts +2 -0
- package/src/shared/lib/code/editor/comment-syntax.test.ts +37 -0
- package/src/shared/lib/code/editor/comment-syntax.ts +55 -0
- package/src/shared/lib/code/editor/find-replace.test.ts +134 -0
- package/src/shared/lib/code/editor/{find.ts → find-replace.ts} +23 -107
- package/src/shared/lib/code/editor/{find.test.ts → find-scan.test.ts} +20 -74
- package/src/shared/lib/code/editor/find-scan.ts +198 -0
- package/src/shared/lib/code/editor/find-selection.test.ts +56 -0
- package/src/shared/lib/code/editor/indent-guide-rule.test.ts +65 -0
- package/src/shared/lib/code/editor/indent-guide-rule.ts +47 -0
- package/src/shared/lib/code/editor/indent-rules.test.ts +219 -0
- package/src/shared/lib/code/editor/indent-rules.ts +198 -0
- package/src/shared/lib/code/editor/keymap.test.ts +23 -0
- package/src/shared/lib/code/editor/keymap.ts +43 -6
- package/src/shared/lib/code/editor/lines.test.ts +7 -55
- package/src/shared/lib/code/editor/lines.ts +8 -48
- package/src/shared/lib/code/editor/marks.test.ts +4 -5
- package/src/shared/lib/code/editor/marks.ts +13 -25
- package/src/shared/lib/code/editor/palette.test.ts +25 -2
- package/src/shared/lib/code/editor/palette.ts +10 -0
- package/src/shared/lib/code/editor/stream-modes.ts +225 -0
- package/src/shared/lib/code/editor/theme-loader.ts +97 -0
- package/src/shared/lib/code/editor/themes.generated.ts +156 -0
- package/src/shared/lib/code/editor/themes.test.ts +165 -0
- package/src/shared/lib/code/editor/themes.ts +165 -0
- package/src/shared/lib/code/highlight-memo.test.ts +103 -0
- package/src/shared/lib/code/highlight-memo.ts +149 -0
- package/src/shared/lib/code/highlighter-warmup.ts +112 -0
- package/src/shared/lib/code/highlighter.ts +3 -1
- package/src/shared/lib/code/idle.ts +37 -0
- package/src/shared/lib/code/outline/rows.test.ts +96 -0
- package/src/shared/lib/code/outline/rows.ts +94 -0
- package/src/shared/lib/code/syntax-highlight.test.ts +2 -80
- package/src/shared/lib/code/syntax-highlight.ts +2 -3
- package/src/shared/lib/fs/file-kind-classify.test.ts +25 -11
- package/src/shared/lib/fs/file-kind.ts +47 -13
- package/src/shared/lib/fs/file-tree.test.ts +41 -0
- package/src/shared/lib/fs/file-tree.ts +126 -34
- package/src/shared/lib/fs/file-url.test.ts +52 -0
- package/src/shared/lib/fs/file-url.ts +37 -0
- package/src/shared/lib/fs/folder-chain.test.ts +87 -0
- package/src/shared/lib/fs/folder-chain.ts +91 -0
- package/src/shared/lib/fs/fs-helpers.test.ts +4 -50
- package/src/shared/lib/fs/patch-sides.test.ts +114 -0
- package/src/shared/lib/fs/patch-sides.ts +139 -0
- package/src/shared/lib/realtime/connection.test.ts +5 -1
- package/src/shared/lib/realtime/connection.ts +25 -119
- package/src/shared/lib/realtime/frozen-recovery.test.ts +93 -0
- package/src/shared/lib/realtime/protocol.ts +16 -0
- package/src/shared/lib/realtime/resume.ts +223 -0
- package/src/shared/lib/realtime/state.ts +22 -0
- package/src/shared/lib/realtime/watchdog-wiring.test.ts +224 -0
- package/src/shared/lib/realtime/watchdog.test.ts +99 -0
- package/src/shared/lib/realtime/watchdog.ts +72 -0
- package/src/shared/lib/ui/toolbar-overflow.test.ts +83 -0
- package/src/shared/lib/ui/toolbar-overflow.ts +86 -0
- package/src/shared/lib/updates/shell-arch.ts +54 -0
- package/src/shared/lib/updates/shell-ua.ts +4 -4
- package/src/shared/lib/workspace/editor-view-mode.test.ts +70 -0
- package/src/shared/lib/workspace/editor-view-mode.ts +48 -0
- package/src/shared/lib/workspace/panel-widths.test.ts +30 -0
- package/src/shared/lib/workspace/panel-widths.ts +25 -5
- package/src/shared/lib/workspace/session-state/cache.ts +159 -0
- package/src/shared/lib/workspace/session-state/harness.test-util.ts +55 -0
- package/src/shared/lib/workspace/session-state/merge.ts +100 -0
- package/src/shared/lib/workspace/session-state/store-load.test.ts +206 -0
- package/src/shared/lib/workspace/session-state/store.test.ts +17 -139
- package/src/shared/lib/workspace/session-state/store.ts +92 -130
- package/src/shared/lib/workspace/split-editor.test.ts +104 -0
- package/src/shared/lib/workspace/split-editor.ts +129 -0
- package/src/shared/lib/workspace/workspace-panel-widths.ts +124 -0
- package/src/shared/types/realtime.ts +29 -0
- package/src/shared/types/settings/state.ts +10 -0
- package/src/test-support/file-explorer-disk.test-util.ts +30 -3
- package/src/test-support/loopback.ts +183 -0
- package/src/test-support/pristine-globals.ts +7 -0
- package/dist/client/static/js/index-gtbpewr7.css +0 -1
- package/src/client/components/common/code-editor/handler.test.ts +0 -274
- package/src/client/components/common/code-editor/handler.ts +0 -175
- package/src/client/components/common/code-editor/index.tsx +0 -314
- package/src/client/components/common/code-surface/measure.ts +0 -148
- package/src/client/components/workspace/chat-timeline/target-picker/index.test.tsx +0 -227
- package/src/client/components/workspace/chat-timeline/target-picker/index.tsx +0 -260
- package/src/client/components/workspace/diff-panel/SplitView.tsx +0 -209
- package/src/client/components/workspace/diff-panel/UnifiedView.tsx +0 -150
- package/src/client/hooks/editor/scroll-container.test.ts +0 -102
- package/src/client/hooks/editor/scroll-container.ts +0 -26
- package/src/client/hooks/editor/use-code-window.ts +0 -100
- package/src/client/hooks/editor/use-editor-history.test.ts +0 -216
- package/src/client/hooks/editor/use-editor-history.ts +0 -134
- package/src/client/hooks/editor/use-occurrences.test.ts +0 -236
- package/src/client/hooks/editor/use-occurrences.ts +0 -98
- package/src/shared/lib/code/editor/commands.test.ts +0 -155
- package/src/shared/lib/code/editor/commands.ts +0 -260
- package/src/shared/lib/code/editor/edits.test.ts +0 -100
- package/src/shared/lib/code/editor/edits.ts +0 -122
- package/src/shared/lib/code/editor/history.test.ts +0 -118
- package/src/shared/lib/code/editor/history.ts +0 -101
- package/src/shared/lib/code/editor/layers.test.ts +0 -77
- package/src/shared/lib/code/editor/layers.ts +0 -67
- package/src/shared/lib/code/editor/line-edits.test.ts +0 -131
- package/src/shared/lib/code/editor/line-edits.ts +0 -159
- package/src/shared/lib/code/editor/occurrences.test.ts +0 -117
- package/src/shared/lib/code/editor/occurrences.ts +0 -111
- package/src/shared/lib/code/editor/reset-css.test.ts +0 -35
- package/src/shared/lib/code/editor/reset-css.ts +0 -32
- package/src/shared/lib/code/editor/text-commands.test.ts +0 -178
- package/src/shared/lib/code/editor/text-commands.ts +0 -154
- package/src/shared/lib/code/lazy-window.test.ts +0 -161
- package/src/shared/lib/code/lazy-window.ts +0 -156
- package/src/shared/lib/code/windowed-highlight.ts +0 -114
- package/src/shared/lib/fs/diff-parser.test.ts +0 -116
- package/src/shared/lib/fs/diff-parser.ts +0 -213
|
@@ -3,12 +3,12 @@ import { FilePane } from '@/client/components/workspace/editor/FilePane';
|
|
|
3
3
|
import type { EditorFindState } from '@/client/hooks/editor/use-editor-find';
|
|
4
4
|
import type { UseFileEditorResult } from '@/client/hooks/editor/use-file-editor';
|
|
5
5
|
import type { ResolvedPluginFileView } from '@/client/components/workspace/editor/plugin-file-view';
|
|
6
|
-
import type { TextRange } from '@/shared/lib/code/editor/commands';
|
|
7
6
|
import type { EditorCommand } from '@/shared/lib/code/editor/keymap';
|
|
8
7
|
import type { CodeSurfaceHandle } from '@/client/components/common/code-surface';
|
|
9
8
|
import type { RefObject } from 'preact';
|
|
10
9
|
import type { ViewerKind } from '@/shared/lib/fs/document-kind';
|
|
11
10
|
import type { OpenedFile } from '@/shared/types/fs';
|
|
11
|
+
import type { EditorThemeState } from '@/client/hooks/editor/theme';
|
|
12
12
|
|
|
13
13
|
interface EditorBodyProps {
|
|
14
14
|
activeFile: OpenedFile | undefined;
|
|
@@ -25,12 +25,21 @@ interface EditorBodyProps {
|
|
|
25
25
|
setIsMaximized: (next: boolean) => void;
|
|
26
26
|
zoomLevel: number;
|
|
27
27
|
setZoomLevel: (update: (current: number) => number) => void;
|
|
28
|
-
occurrences: readonly TextRange[];
|
|
29
|
-
setOccurrences: (next: readonly TextRange[]) => void;
|
|
30
28
|
paletteOpen: boolean;
|
|
31
29
|
setPaletteOpen: (open: boolean) => void;
|
|
30
|
+
/** Bumped when the user asks for "go to line"; the document owns the dialog. */
|
|
31
|
+
goToLineRequest: number;
|
|
32
|
+
/** Open the Save As dialog. */
|
|
33
|
+
onSaveAs: () => void;
|
|
34
|
+
/** The file picker is open. */
|
|
35
|
+
quickOpen: boolean;
|
|
36
|
+
onCloseQuickOpen: () => void;
|
|
37
|
+
onOpenPath?: (path: string) => void;
|
|
38
|
+
rootPath?: string | null;
|
|
39
|
+
repoPath?: string | null;
|
|
32
40
|
runCommand: (command: EditorCommand) => void;
|
|
33
41
|
editorFontFamily: string;
|
|
42
|
+
editorTheme: EditorThemeState;
|
|
34
43
|
togglePreview: () => void;
|
|
35
44
|
revealActive: boolean;
|
|
36
45
|
missing: boolean;
|
|
@@ -60,12 +69,18 @@ export function EditorBody({
|
|
|
60
69
|
setIsMaximized,
|
|
61
70
|
zoomLevel,
|
|
62
71
|
setZoomLevel,
|
|
63
|
-
occurrences,
|
|
64
|
-
setOccurrences,
|
|
65
72
|
paletteOpen,
|
|
66
73
|
setPaletteOpen,
|
|
74
|
+
goToLineRequest,
|
|
75
|
+
onSaveAs,
|
|
76
|
+
quickOpen,
|
|
77
|
+
onCloseQuickOpen,
|
|
78
|
+
onOpenPath,
|
|
79
|
+
rootPath = null,
|
|
80
|
+
repoPath = null,
|
|
67
81
|
runCommand,
|
|
68
82
|
editorFontFamily,
|
|
83
|
+
editorTheme,
|
|
69
84
|
togglePreview,
|
|
70
85
|
revealActive,
|
|
71
86
|
missing,
|
|
@@ -113,12 +128,18 @@ export function EditorBody({
|
|
|
113
128
|
setIsMaximized={setIsMaximized}
|
|
114
129
|
zoomLevel={zoomLevel}
|
|
115
130
|
setZoomLevel={setZoomLevel}
|
|
116
|
-
occurrences={occurrences}
|
|
117
|
-
setOccurrences={setOccurrences}
|
|
118
131
|
paletteOpen={paletteOpen}
|
|
119
132
|
setPaletteOpen={setPaletteOpen}
|
|
133
|
+
goToLineRequest={goToLineRequest}
|
|
134
|
+
onSaveAs={onSaveAs}
|
|
135
|
+
quickOpen={quickOpen}
|
|
136
|
+
onCloseQuickOpen={onCloseQuickOpen}
|
|
137
|
+
onOpenPath={onOpenPath}
|
|
138
|
+
rootPath={rootPath}
|
|
139
|
+
repoPath={repoPath}
|
|
120
140
|
runCommand={runCommand}
|
|
121
141
|
editorFontFamily={editorFontFamily}
|
|
142
|
+
editorTheme={editorTheme}
|
|
122
143
|
togglePreview={togglePreview}
|
|
123
144
|
revealActive={revealActive}
|
|
124
145
|
missing={missing}
|
|
@@ -7,15 +7,15 @@
|
|
|
7
7
|
* The editor's command palette (⌘⇧P).
|
|
8
8
|
*
|
|
9
9
|
* Every editor command this app implements is listed here with the chord that
|
|
10
|
-
* reaches it, both derived from the same keymap table the
|
|
11
|
-
*
|
|
10
|
+
* reaches it, both derived from the same keymap table the editor binds against.
|
|
11
|
+
* The palette is therefore a VIEW of the keymap rather than a second
|
|
12
12
|
* list to keep in sync — a command cannot be listed here and unbound there, and
|
|
13
13
|
* a chord cannot be shown that does not work.
|
|
14
14
|
*
|
|
15
|
-
* Commands this editor deliberately does not have (
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
15
|
+
* Commands this editor deliberately does not have (go-to-definition, the `⌘K`
|
|
16
|
+
* prefix chords) are absent rather than listed and inert: a palette entry that
|
|
17
|
+
* does nothing is worse than no entry, because the user concludes the editor is
|
|
18
|
+
* broken rather than that the feature is missing.
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
import { useEffect, useMemo, useRef, useState } from 'preact/hooks';
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The write-conflict strip: "this file changed on disk".
|
|
8
|
+
*
|
|
9
|
+
* A save refused with `409` is not a failure — the buffer is intact and the disk
|
|
10
|
+
* holds someone else's bytes — so the panel cannot report it as one. It offers the
|
|
11
|
+
* two answers that actually exist:
|
|
12
|
+
*
|
|
13
|
+
* - **Reload** takes the disk copy and discards the buffer's edits.
|
|
14
|
+
* - **Keep mine** writes the buffer over it, adopting the disk mtime as the new
|
|
15
|
+
* base so the same refusal cannot come straight back.
|
|
16
|
+
*
|
|
17
|
+
* The strip sits above the document rather than in a modal: the user has to see
|
|
18
|
+
* what they are choosing between, and a modal over the editor hides it. It is
|
|
19
|
+
* also the reason the toolbar's save status stays `idle` on a conflict — two
|
|
20
|
+
* indicators for one event would disagree about whether the file was written.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import { AlertTriangle } from 'lucide-preact';
|
|
24
|
+
|
|
25
|
+
interface ConflictStripProps {
|
|
26
|
+
/** The mtime the disk holds now, or null when the refusal named none. */
|
|
27
|
+
diskMtimeMs: number | null;
|
|
28
|
+
fileName: string;
|
|
29
|
+
onReload: () => void;
|
|
30
|
+
onKeepMine: () => void;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** `14:32:07` — the disk copy's own clock, so the two sides are comparable. */
|
|
34
|
+
function formatTime(mtimeMs: number | null): string | null {
|
|
35
|
+
if (mtimeMs === null) return null;
|
|
36
|
+
const date = new Date(mtimeMs);
|
|
37
|
+
if (Number.isNaN(date.getTime())) return null;
|
|
38
|
+
return date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', second: '2-digit' });
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function ConflictStrip({ diskMtimeMs, fileName, onReload, onKeepMine }: ConflictStripProps) {
|
|
42
|
+
const at = formatTime(diskMtimeMs);
|
|
43
|
+
return (
|
|
44
|
+
<div
|
|
45
|
+
className="flex items-start gap-2 px-3 py-2 border-b border-warning/30 bg-warning/10 text-[11px] text-ink flex-shrink-0"
|
|
46
|
+
role="alert"
|
|
47
|
+
data-conflict-strip=""
|
|
48
|
+
>
|
|
49
|
+
<AlertTriangle size={13} className="text-warning flex-shrink-0 mt-0.5" />
|
|
50
|
+
<div className="min-w-0 flex-1">
|
|
51
|
+
<div className="font-medium">
|
|
52
|
+
<span className="font-mono">{fileName}</span> changed on disk
|
|
53
|
+
{at ? <span className="text-ink/60"> at {at}</span> : null}.
|
|
54
|
+
</div>
|
|
55
|
+
<div className="text-ink/60 mt-0.5">Your save was refused so nothing was overwritten.</div>
|
|
56
|
+
</div>
|
|
57
|
+
<div className="flex items-center gap-1 flex-shrink-0">
|
|
58
|
+
<button
|
|
59
|
+
type="button"
|
|
60
|
+
onClick={onReload}
|
|
61
|
+
className="px-2 py-1 rounded border border-ink/20 hover:bg-ink/5 transition-colors cursor-pointer"
|
|
62
|
+
title="Discard my changes and take the file from disk"
|
|
63
|
+
>
|
|
64
|
+
Reload
|
|
65
|
+
</button>
|
|
66
|
+
<button
|
|
67
|
+
type="button"
|
|
68
|
+
onClick={onKeepMine}
|
|
69
|
+
className="px-2 py-1 rounded border border-warning/50 text-warning hover:bg-warning/10 transition-colors cursor-pointer"
|
|
70
|
+
title="Write my buffer over the file on disk"
|
|
71
|
+
>
|
|
72
|
+
Keep mine
|
|
73
|
+
</button>
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The two questions the editor panel can ask, in one place.
|
|
8
|
+
*
|
|
9
|
+
* Both are MODALS and both outlive a tab switch, which is why neither is owned by the
|
|
10
|
+
* component that raises it: the close confirmation is raised by the tab strip, and the
|
|
11
|
+
* deleted-file confirmation by the write path — and a tab switch must not dismiss a
|
|
12
|
+
* question the user has not answered.
|
|
13
|
+
*
|
|
14
|
+
* They are also mutually exclusive in practice (a save on a deleted file and a close on a
|
|
15
|
+
* dirty one cannot both be waiting), so drawing them together would stack two backdrops.
|
|
16
|
+
* The close confirmation wins, because it is the one that ends with a tab gone.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { CloseDirtyTabModal } from '@/client/hooks/editor/use-unload-guard';
|
|
20
|
+
import { SaveDeletedFileModal } from '@/client/components/workspace/editor/SaveDeletedFileModal';
|
|
21
|
+
import type { CloseGuard } from '@/client/hooks/editor/use-close-guard';
|
|
22
|
+
import type { OpenedFile } from '@/shared/types/fs';
|
|
23
|
+
|
|
24
|
+
interface EditorDialogsProps {
|
|
25
|
+
closeGuard: CloseGuard;
|
|
26
|
+
activeFile: OpenedFile | undefined;
|
|
27
|
+
saveMissingConfirm: boolean;
|
|
28
|
+
onCancelSaveMissing: () => void;
|
|
29
|
+
onConfirmSaveMissing: () => void;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function EditorDialogs({
|
|
33
|
+
closeGuard,
|
|
34
|
+
activeFile,
|
|
35
|
+
saveMissingConfirm,
|
|
36
|
+
onCancelSaveMissing,
|
|
37
|
+
onConfirmSaveMissing,
|
|
38
|
+
}: EditorDialogsProps) {
|
|
39
|
+
if (closeGuard.pending) {
|
|
40
|
+
return <CloseDirtyTabModal fileName={closeGuard.pending.name} onAnswer={closeGuard.answer} />;
|
|
41
|
+
}
|
|
42
|
+
if (saveMissingConfirm && activeFile) {
|
|
43
|
+
return (
|
|
44
|
+
<SaveDeletedFileModal
|
|
45
|
+
fileName={activeFile.name}
|
|
46
|
+
filePath={activeFile.path}
|
|
47
|
+
onClose={onCancelSaveMissing}
|
|
48
|
+
onConfirm={onConfirmSaveMissing}
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The editor column with nothing open.
|
|
8
|
+
*
|
|
9
|
+
* Its own component for the per-file ceiling, and because the sentence is a promise the
|
|
10
|
+
* panel has to keep: the column is open (the user toggled it) and there is no file in it,
|
|
11
|
+
* so the only thing to say is how to put one there.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { FileIcon } from '@/client/components/common/file-icon';
|
|
15
|
+
|
|
16
|
+
export function EmptyEditor({ className = '' }: { className?: string }) {
|
|
17
|
+
return (
|
|
18
|
+
<div className={`flex flex-col h-full bg-canvas items-center justify-center text-ink/40 ${className}`}>
|
|
19
|
+
<FileIcon name="placeholder.txt" size={48} className="mb-4 opacity-20" />
|
|
20
|
+
<p className="font-mono text-sm">Select a file to open</p>
|
|
21
|
+
</div>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The external-change strip: "this file changed on disk while you were editing".
|
|
8
|
+
*
|
|
9
|
+
* Distinct from `ConflictStrip` on purpose, and the difference is what the user can
|
|
10
|
+
* do. A CONFLICT is a save the server refused — the buffer is still ahead and the
|
|
11
|
+
* choice is which side wins. This is the earlier warning: the disk moved and the
|
|
12
|
+
* buffer has NOT been written, so the choice is "take theirs now" or "keep editing
|
|
13
|
+
* mine". Both offer Reload/Keep, and neither is a modal: the user has to see the
|
|
14
|
+
* file they are choosing about.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { RefreshCw } from 'lucide-preact';
|
|
18
|
+
|
|
19
|
+
interface ExternalChangeStripProps {
|
|
20
|
+
fileName: string;
|
|
21
|
+
onReload: () => void;
|
|
22
|
+
onKeepMine: () => void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function ExternalChangeStrip({ fileName, onReload, onKeepMine }: ExternalChangeStripProps) {
|
|
26
|
+
return (
|
|
27
|
+
<div
|
|
28
|
+
className="flex items-start gap-2 px-3 py-2 border-b border-info/30 bg-info/10 text-[11px] text-ink flex-shrink-0"
|
|
29
|
+
role="status"
|
|
30
|
+
data-external-change-strip=""
|
|
31
|
+
>
|
|
32
|
+
<RefreshCw size={13} className="text-info flex-shrink-0 mt-0.5" />
|
|
33
|
+
<div className="min-w-0 flex-1">
|
|
34
|
+
<div className="font-medium">
|
|
35
|
+
<span className="font-mono">{fileName}</span> changed on disk.
|
|
36
|
+
</div>
|
|
37
|
+
<div className="text-ink/60 mt-0.5">
|
|
38
|
+
Reload takes the disk copy and discards your edits. Keep mine writes yours over it.
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
<div className="flex items-center gap-1 flex-shrink-0">
|
|
42
|
+
<button
|
|
43
|
+
type="button"
|
|
44
|
+
onClick={onReload}
|
|
45
|
+
className="px-2 py-1 rounded border border-ink/20 hover:bg-ink/5 transition-colors cursor-pointer"
|
|
46
|
+
title="Take the file from disk"
|
|
47
|
+
>
|
|
48
|
+
Reload
|
|
49
|
+
</button>
|
|
50
|
+
<button
|
|
51
|
+
type="button"
|
|
52
|
+
onClick={onKeepMine}
|
|
53
|
+
className="px-2 py-1 rounded border border-info/50 text-info hover:bg-info/10 transition-colors cursor-pointer"
|
|
54
|
+
title="Keep my buffer; the next save writes it"
|
|
55
|
+
>
|
|
56
|
+
Keep mine
|
|
57
|
+
</button>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
@@ -1,15 +1,24 @@
|
|
|
1
|
+
import { useEffect, useState } from 'preact/hooks';
|
|
1
2
|
import type { RefObject } from 'preact';
|
|
2
3
|
import { MarkdownRenderer } from '@/client/components/common/MarkdownRenderer';
|
|
3
4
|
import { CodeSurface, type CodeSurfaceHandle } from '@/client/components/common/code-surface';
|
|
4
5
|
import { FindWidget } from '@/client/components/workspace/editor/FindWidget';
|
|
5
6
|
import { CommandPalette } from '@/client/components/workspace/editor/CommandPalette';
|
|
6
7
|
import { useScrollRestore } from '@/client/hooks/editor/use-scroll-restore';
|
|
8
|
+
import { indentUnitFor, useEditorIndent } from '@/client/hooks/editor/indent-settings';
|
|
9
|
+
import { useEditorTyping } from '@/client/hooks/editor/typing-settings';
|
|
10
|
+
import { EditorStatusBar } from '@/client/components/workspace/editor/StatusBar';
|
|
11
|
+
import { useWheelZoom } from '@/client/hooks/editor/wheel-zoom';
|
|
12
|
+
import { GoToLineModal } from '@/client/components/workspace/editor/GoToLineModal';
|
|
13
|
+
import { QuickOpenModal } from '@/client/components/workspace/editor/QuickOpenModal';
|
|
14
|
+
import type { CaretPosition } from '@/client/hooks/editor/caret-position';
|
|
15
|
+
import { lineStartOffset } from '@/shared/lib/code/editor/lines';
|
|
7
16
|
import type { UseFileEditorResult } from '@/client/hooks/editor/use-file-editor';
|
|
8
17
|
import type { EditorFindState } from '@/client/hooks/editor/use-editor-find';
|
|
9
18
|
import { EDITOR_LINE_HEIGHT } from '@/shared/lib/code/editor/typography';
|
|
10
19
|
import type { ViewerKind } from '@/shared/lib/fs/document-kind';
|
|
11
|
-
import type { TextRange } from '@/shared/lib/code/editor/commands';
|
|
12
20
|
import type { EditorCommand } from '@/shared/lib/code/editor/keymap';
|
|
21
|
+
import type { EditorThemeState } from '@/client/hooks/editor/theme';
|
|
13
22
|
|
|
14
23
|
interface FileDocumentProps {
|
|
15
24
|
activeFile: { id: number | string; name: string; path: string; root?: string; repo?: string };
|
|
@@ -18,12 +27,21 @@ interface FileDocumentProps {
|
|
|
18
27
|
surfaceRef: RefObject<CodeSurfaceHandle>;
|
|
19
28
|
paletteOpen: boolean;
|
|
20
29
|
onClosePalette: () => void;
|
|
30
|
+
/** Bumped when the user asks for "go to line"; a counter, so one bump is one open. */
|
|
31
|
+
goToLineRequest: number;
|
|
32
|
+
/** The file picker is open. */
|
|
33
|
+
quickOpen: boolean;
|
|
34
|
+
onCloseQuickOpen: () => void;
|
|
35
|
+
onOpenPath?: (path: string) => void;
|
|
36
|
+
rootPath?: string | null;
|
|
37
|
+
repoPath?: string | null;
|
|
21
38
|
onRunCommand: (command: EditorCommand) => void;
|
|
22
39
|
wordWrap: boolean;
|
|
23
40
|
zoomLevel: number;
|
|
41
|
+
/** The setter, so ⌘/Ctrl + wheel can zoom without a second source of truth. */
|
|
42
|
+
setZoomLevel: (update: (current: number) => number) => void;
|
|
24
43
|
editorFontFamily: string;
|
|
25
|
-
|
|
26
|
-
onOccurrencesChange: (next: readonly TextRange[]) => void;
|
|
44
|
+
editorTheme: EditorThemeState;
|
|
27
45
|
/** The surface this file's kind is drawn by (see `document-kind`). */
|
|
28
46
|
viewerKind: ViewerKind;
|
|
29
47
|
/** The rendered view is on for the active file — render it, not the source. */
|
|
@@ -53,12 +71,18 @@ export function FileDocument({
|
|
|
53
71
|
surfaceRef,
|
|
54
72
|
paletteOpen,
|
|
55
73
|
onClosePalette,
|
|
74
|
+
goToLineRequest,
|
|
75
|
+
quickOpen,
|
|
76
|
+
onCloseQuickOpen,
|
|
77
|
+
onOpenPath,
|
|
78
|
+
rootPath = null,
|
|
79
|
+
repoPath = null,
|
|
56
80
|
onRunCommand,
|
|
57
81
|
wordWrap,
|
|
58
82
|
zoomLevel,
|
|
83
|
+
setZoomLevel,
|
|
59
84
|
editorFontFamily,
|
|
60
|
-
|
|
61
|
-
onOccurrencesChange,
|
|
85
|
+
editorTheme,
|
|
62
86
|
viewerKind,
|
|
63
87
|
isPreview,
|
|
64
88
|
revealActive,
|
|
@@ -67,6 +91,27 @@ export function FileDocument({
|
|
|
67
91
|
// SVG picture are drawn by the viewer dispatch instead (they replace the code
|
|
68
92
|
// surface rather than living inside its scroller).
|
|
69
93
|
const isMd = viewerKind === 'markdown';
|
|
94
|
+
// One indentation level, from the settings blob. Read here rather than passed
|
|
95
|
+
// down: the setting is a live event, and a prop captured at boot would not reach
|
|
96
|
+
// an editor that is already open.
|
|
97
|
+
const editorIndent = useEditorIndent();
|
|
98
|
+
const editorTyping = useEditorTyping();
|
|
99
|
+
const [caret, setCaret] = useState<CaretPosition | null>(null);
|
|
100
|
+
const [goToLineOpen, setGoToLineOpen] = useState(false);
|
|
101
|
+
// The request is a COUNTER: the dialog closes itself, and a boolean would need a
|
|
102
|
+
// matching "closed" write from this component to the panel that owns the chord.
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
if (goToLineRequest > 0) setGoToLineOpen(true);
|
|
105
|
+
}, [goToLineRequest]);
|
|
106
|
+
/**
|
|
107
|
+
* The code surface's scroller, which belongs to CodeMirror and appears only
|
|
108
|
+
* once its view mounts. Reported through `onScroller` because a `ref` cannot
|
|
109
|
+
* reach a node the component does not render.
|
|
110
|
+
*/
|
|
111
|
+
const [codeScroller, setCodeScroller] = useState<HTMLElement | null>(null);
|
|
112
|
+
// ⌘/Ctrl + wheel, and a trackpad pinch, clamped to the toolbar's own bounds. Armed on
|
|
113
|
+
// the render the scroller arrives in: it exists only once the view mounts.
|
|
114
|
+
useWheelZoom(codeScroller, setZoomLevel);
|
|
70
115
|
// The document owns its scroller, so it remembers where the reader left it.
|
|
71
116
|
// One offset per SURFACE: the rendered markdown and its source are different
|
|
72
117
|
// documents in the same container and share neither a line nor a height.
|
|
@@ -74,26 +119,57 @@ export function FileDocument({
|
|
|
74
119
|
tabKey: String(activeFile.id),
|
|
75
120
|
surface: isMd && isPreview ? 'rendered' : 'code',
|
|
76
121
|
ready: editor.loaded,
|
|
122
|
+
// `undefined` on the markdown branch, which owns its own scroller and uses
|
|
123
|
+
// the binding's `ref` instead.
|
|
124
|
+
element: isMd && isPreview ? undefined : codeScroller,
|
|
77
125
|
});
|
|
78
126
|
|
|
79
127
|
return (
|
|
80
128
|
<div className="relative flex-1 min-h-0 flex flex-col">
|
|
81
129
|
{find.open ? <FindWidget find={find} /> : null}
|
|
82
130
|
{paletteOpen ? <CommandPalette onRun={onRunCommand} onClose={onClosePalette} /> : null}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
131
|
+
{quickOpen && onOpenPath ? (
|
|
132
|
+
<QuickOpenModal
|
|
133
|
+
root={rootPath}
|
|
134
|
+
repo={repoPath}
|
|
135
|
+
onOpen={(path) => {
|
|
136
|
+
onCloseQuickOpen();
|
|
137
|
+
// Through `handleOpenFile`, so the tab gets the id scheme every other
|
|
138
|
+
// opener shares rather than one computed here.
|
|
139
|
+
onOpenPath(path);
|
|
140
|
+
}}
|
|
141
|
+
onClose={onCloseQuickOpen}
|
|
142
|
+
/>
|
|
143
|
+
) : null}
|
|
144
|
+
{goToLineOpen ? (
|
|
145
|
+
<GoToLineModal
|
|
146
|
+
lineCount={editor.content ? editor.content.split('\n').length : 1}
|
|
147
|
+
onGo={(line) => {
|
|
148
|
+
setGoToLineOpen(false);
|
|
149
|
+
// The handle already owns "put the caret here and show it", which is why
|
|
150
|
+
// this needs no CodeMirror import: the find bar, the outline jump and the
|
|
151
|
+
// search reveal all go through the same two calls.
|
|
152
|
+
const offset = lineStartOffset(editor.content, line - 1);
|
|
153
|
+
surfaceRef.current?.select(offset, offset, true);
|
|
154
|
+
surfaceRef.current?.revealOffset(offset);
|
|
155
|
+
}}
|
|
156
|
+
onClose={() => setGoToLineOpen(false)}
|
|
157
|
+
/>
|
|
158
|
+
) : null}
|
|
159
|
+
{isMd && isPreview ? (
|
|
160
|
+
<div
|
|
161
|
+
ref={scroll.ref}
|
|
162
|
+
onScroll={scroll.onScroll}
|
|
163
|
+
// No accessible name exists for a scroll container, so the E2E layer
|
|
164
|
+
// addresses it by testid (see `tests/e2e/fixtures/selectors.ts`).
|
|
165
|
+
data-testid="editor-scroller"
|
|
166
|
+
className="flex-1 overflow-auto bg-paper flex"
|
|
167
|
+
>
|
|
168
|
+
{/* No `prose` wrapper: markdown is styled by `.prose-content` alone
|
|
169
|
+
(the same system the chat timeline uses). The typography plugin
|
|
170
|
+
fought it — `.prose img` added 2em vertical margins that ballooned
|
|
171
|
+
a badge row into its own line box, and `--tw-prose-*` colors
|
|
172
|
+
ignored the theme. */}
|
|
97
173
|
<div className="p-6 max-w-4xl mx-auto font-sans flex-1" style={{ fontSize: `${zoomLevel}px` }}>
|
|
98
174
|
<MarkdownRenderer
|
|
99
175
|
content={editor.content}
|
|
@@ -101,50 +177,57 @@ export function FileDocument({
|
|
|
101
177
|
scope={{ path: activeFile.path, root: activeFile.root, repo: activeFile.repo }}
|
|
102
178
|
/>
|
|
103
179
|
</div>
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
180
|
+
</div>
|
|
181
|
+
) : (
|
|
182
|
+
// The code surface owns its own scroller (CodeMirror's), so it is NOT
|
|
183
|
+
// wrapped in one: an outer `overflow-auto` would take the document's
|
|
184
|
+
// height and the editor's viewport would be the whole file.
|
|
185
|
+
<CodeSurface
|
|
186
|
+
ref={surfaceRef}
|
|
187
|
+
value={editor.content}
|
|
188
|
+
onValueChange={editor.onChange}
|
|
189
|
+
language={editor.language}
|
|
190
|
+
wordWrap={wordWrap}
|
|
191
|
+
documentKey={String(activeFile.id)}
|
|
192
|
+
marks={find.open || revealActive ? find.matches : undefined}
|
|
193
|
+
currentMark={find.currentIndex}
|
|
194
|
+
onCommand={onRunCommand}
|
|
195
|
+
onScroller={setCodeScroller}
|
|
196
|
+
onCaret={setCaret}
|
|
197
|
+
scrollTestId="editor-scroller"
|
|
198
|
+
// The editor theme paints its own surface, so the app's `bg-paper`
|
|
199
|
+
// must not sit under it: an explicit theme's background is opaque and
|
|
200
|
+
// would be a rectangle inside the panel's own colour.
|
|
201
|
+
className="flex-1 min-h-0 text-ink select-text"
|
|
202
|
+
themeVars={editorTheme.vars}
|
|
203
|
+
themes={editorTheme.themes}
|
|
204
|
+
indentUnitText={indentUnitFor(editorIndent)}
|
|
205
|
+
typing={editorTyping}
|
|
206
|
+
padding={16}
|
|
207
|
+
style={{
|
|
208
|
+
fontFamily: editorFontFamily,
|
|
209
|
+
fontSize: `${zoomLevel}px`,
|
|
210
|
+
lineHeight: EDITOR_LINE_HEIGHT,
|
|
211
|
+
}}
|
|
212
|
+
/>
|
|
213
|
+
)}
|
|
214
|
+
|
|
215
|
+
{/* Where the caret is, how the file is indented, and how it ends. The phone's
|
|
216
|
+
strip has printed the first of those since the editor was rebuilt; the
|
|
217
|
+
desktop pane had nothing, so the line number had to be counted. */}
|
|
218
|
+
{!isMd || !isPreview ? (
|
|
219
|
+
<EditorStatusBar
|
|
220
|
+
caret={caret}
|
|
221
|
+
eol={editor.eol}
|
|
222
|
+
onSetEol={editor.setEol}
|
|
223
|
+
indentWidth={editorIndent.width}
|
|
224
|
+
insertSpaces={editorIndent.insertSpaces}
|
|
225
|
+
language={editor.language}
|
|
226
|
+
byteViewer={editor.isBinaryViewer}
|
|
227
|
+
viewerKind={viewerKind}
|
|
228
|
+
lineCount={editor.content ? editor.content.split('\n').length : 0}
|
|
229
|
+
/>
|
|
230
|
+
) : null}
|
|
148
231
|
</div>
|
|
149
232
|
);
|
|
150
233
|
}
|