@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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { RefObject } from 'preact';
|
|
2
2
|
import { AlertTriangle, FileX, Loader2 } from 'lucide-preact';
|
|
3
|
+
import { ConflictStrip } from '@/client/components/workspace/editor/ConflictStrip';
|
|
3
4
|
import { EditorToolbar } from '@/client/components/workspace/editor/Toolbar';
|
|
4
5
|
import { FileDocument } from '@/client/components/workspace/editor/FileDocument';
|
|
5
6
|
import { PluginFileViewBody, type ResolvedPluginFileView } from '@/client/components/workspace/editor/plugin-file-view';
|
|
@@ -8,11 +9,11 @@ import { ViewerSurface, hasViewerSurface } from '@/client/components/workspace/e
|
|
|
8
9
|
import type { CodeSurfaceHandle } from '@/client/components/common/code-surface';
|
|
9
10
|
import type { UseFileEditorResult } from '@/client/hooks/editor/use-file-editor';
|
|
10
11
|
import type { EditorFindState } from '@/client/hooks/editor/use-editor-find';
|
|
11
|
-
import type { TextRange } from '@/shared/lib/code/editor/commands';
|
|
12
12
|
import type { EditorCommand } from '@/shared/lib/code/editor/keymap';
|
|
13
13
|
import { EDITOR_MAX_FONT_SIZE, EDITOR_MIN_FONT_SIZE } from '@/shared/lib/code/editor/typography';
|
|
14
14
|
import { RENDERED_VIEWERS, type ViewerKind } from '@/shared/lib/fs/document-kind';
|
|
15
15
|
import type { OpenedFile } from '@/shared/types/fs';
|
|
16
|
+
import type { EditorThemeState } from '@/client/hooks/editor/theme';
|
|
16
17
|
|
|
17
18
|
interface FilePaneProps {
|
|
18
19
|
activeFile: OpenedFile;
|
|
@@ -30,12 +31,21 @@ interface FilePaneProps {
|
|
|
30
31
|
setIsMaximized: (next: boolean) => void;
|
|
31
32
|
zoomLevel: number;
|
|
32
33
|
setZoomLevel: (update: (current: number) => number) => void;
|
|
33
|
-
occurrences: readonly TextRange[];
|
|
34
|
-
setOccurrences: (next: readonly TextRange[]) => void;
|
|
35
34
|
paletteOpen: boolean;
|
|
36
35
|
setPaletteOpen: (open: boolean) => void;
|
|
36
|
+
/** Bumped when the user asks for "go to line"; this pane owns the dialog. */
|
|
37
|
+
goToLineRequest: number;
|
|
38
|
+
/** Open the Save As dialog. */
|
|
39
|
+
onSaveAs: () => void;
|
|
40
|
+
/** The file picker is open. */
|
|
41
|
+
quickOpen: boolean;
|
|
42
|
+
onCloseQuickOpen: () => void;
|
|
43
|
+
onOpenPath?: (path: string) => void;
|
|
44
|
+
rootPath?: string | null;
|
|
45
|
+
repoPath?: string | null;
|
|
37
46
|
runCommand: (command: EditorCommand) => void;
|
|
38
47
|
editorFontFamily: string;
|
|
48
|
+
editorTheme: EditorThemeState;
|
|
39
49
|
togglePreview: () => void;
|
|
40
50
|
/** A search hit was jumped to in this file, so its matches are painted. */
|
|
41
51
|
revealActive: boolean;
|
|
@@ -72,12 +82,18 @@ export function FilePane({
|
|
|
72
82
|
setIsMaximized,
|
|
73
83
|
zoomLevel,
|
|
74
84
|
setZoomLevel,
|
|
75
|
-
occurrences,
|
|
76
|
-
setOccurrences,
|
|
77
85
|
paletteOpen,
|
|
78
86
|
setPaletteOpen,
|
|
87
|
+
goToLineRequest,
|
|
88
|
+
onSaveAs,
|
|
89
|
+
quickOpen,
|
|
90
|
+
onCloseQuickOpen,
|
|
91
|
+
onOpenPath,
|
|
92
|
+
rootPath = null,
|
|
93
|
+
repoPath = null,
|
|
79
94
|
runCommand,
|
|
80
95
|
editorFontFamily,
|
|
96
|
+
editorTheme,
|
|
81
97
|
togglePreview,
|
|
82
98
|
revealActive,
|
|
83
99
|
missing,
|
|
@@ -111,6 +127,11 @@ export function FilePane({
|
|
|
111
127
|
onZoomOut={() => setZoomLevel((z) => Math.max(EDITOR_MIN_FONT_SIZE, z - 1))}
|
|
112
128
|
onCopy={editor.copy}
|
|
113
129
|
onDownload={editor.download}
|
|
130
|
+
onRevert={editor.revertToDisk}
|
|
131
|
+
onSaveAs={onSaveAs}
|
|
132
|
+
// Only a buffer with edits has anything to throw away; a clean one would
|
|
133
|
+
// re-read the same bytes and blank the screen for a moment.
|
|
134
|
+
canRevert={editor.isDirty && !editor.loadError && !editor.unsupported}
|
|
114
135
|
onToggleMaximize={() => setIsMaximized(!isMaximized)}
|
|
115
136
|
/>
|
|
116
137
|
|
|
@@ -129,6 +150,19 @@ export function FilePane({
|
|
|
129
150
|
</div>
|
|
130
151
|
)}
|
|
131
152
|
|
|
153
|
+
{/* A save refused because the disk copy moved. Not a failure: the buffer is
|
|
154
|
+
intact, and the two answers are the only ones that exist. Above the
|
|
155
|
+
document rather than in a modal, because the user has to see what they
|
|
156
|
+
are choosing between. */}
|
|
157
|
+
{editor.conflict && (
|
|
158
|
+
<ConflictStrip
|
|
159
|
+
diskMtimeMs={editor.conflict.diskMtimeMs}
|
|
160
|
+
fileName={activeFile.name}
|
|
161
|
+
onReload={editor.resolveConflictByReload}
|
|
162
|
+
onKeepMine={editor.resolveConflictByKeepingMine}
|
|
163
|
+
/>
|
|
164
|
+
)}
|
|
165
|
+
|
|
132
166
|
{/* A launched file's handle dies with the page, so after a reload the tab
|
|
133
167
|
can read and edit but cannot write. Saying so is the whole point: the
|
|
134
168
|
Save button is disabled, and a user who is not told why would read it
|
|
@@ -212,12 +246,18 @@ export function FilePane({
|
|
|
212
246
|
surfaceRef={surfaceRef}
|
|
213
247
|
paletteOpen={paletteOpen}
|
|
214
248
|
onClosePalette={() => setPaletteOpen(false)}
|
|
249
|
+
goToLineRequest={goToLineRequest}
|
|
250
|
+
quickOpen={quickOpen}
|
|
251
|
+
onCloseQuickOpen={onCloseQuickOpen}
|
|
252
|
+
onOpenPath={onOpenPath}
|
|
253
|
+
rootPath={rootPath}
|
|
254
|
+
repoPath={repoPath}
|
|
215
255
|
onRunCommand={runCommand}
|
|
216
256
|
wordWrap={wordWrap}
|
|
217
257
|
zoomLevel={zoomLevel}
|
|
258
|
+
setZoomLevel={setZoomLevel}
|
|
218
259
|
editorFontFamily={editorFontFamily}
|
|
219
|
-
|
|
220
|
-
onOccurrencesChange={setOccurrences}
|
|
260
|
+
editorTheme={editorTheme}
|
|
221
261
|
isPreview={isPreview}
|
|
222
262
|
viewerKind={viewerKind}
|
|
223
263
|
revealActive={revealActive}
|
|
@@ -33,12 +33,14 @@ const calls: string[] = [];
|
|
|
33
33
|
|
|
34
34
|
/** A find state whose every action records itself, so a click is provable. */
|
|
35
35
|
function findState(overrides: Partial<EditorFindState> = {}): EditorFindState {
|
|
36
|
-
|
|
36
|
+
// `Object.assign` rather than a spread: a spread of `Partial<T>` widens every
|
|
37
|
+
// required property to `| undefined`, which the contract rightly refuses.
|
|
38
|
+
return Object.assign<EditorFindState, Partial<EditorFindState>>({
|
|
37
39
|
open: true,
|
|
38
40
|
replaceOpen: false,
|
|
39
41
|
query: '',
|
|
40
42
|
replacement: '',
|
|
41
|
-
options: { matchCase: false, wholeWord: false, isRegex: false },
|
|
43
|
+
options: { matchCase: false, wholeWord: false, isRegex: false, inSelection: false },
|
|
42
44
|
matches: [],
|
|
43
45
|
truncated: false,
|
|
44
46
|
invalid: false,
|
|
@@ -56,8 +58,10 @@ function findState(overrides: Partial<EditorFindState> = {}): EditorFindState {
|
|
|
56
58
|
step: (direction) => calls.push(`step:${direction}`),
|
|
57
59
|
replaceCurrent: () => calls.push('replaceCurrent'),
|
|
58
60
|
replaceAll: () => calls.push('replaceAll'),
|
|
59
|
-
|
|
60
|
-
|
|
61
|
+
selectionRange: null,
|
|
62
|
+
history: [],
|
|
63
|
+
useHistoryEntry: (value: string) => calls.push(`useHistoryEntry:${value}`),
|
|
64
|
+
}, overrides);
|
|
61
65
|
}
|
|
62
66
|
|
|
63
67
|
async function mount(find: EditorFindState) {
|
|
@@ -178,7 +182,7 @@ describe('FindWidget', () => {
|
|
|
178
182
|
});
|
|
179
183
|
|
|
180
184
|
test('each toggle reports its own state and its own shortcut', async () => {
|
|
181
|
-
await mount(findState({ options: { matchCase: true, wholeWord: false, isRegex: true } }));
|
|
185
|
+
await mount(findState({ options: { matchCase: true, wholeWord: false, isRegex: true, inSelection: false } }));
|
|
182
186
|
|
|
183
187
|
const matchCase = byLabelPrefix('Match case');
|
|
184
188
|
const wholeWord = byLabelPrefix('Match whole word');
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
ChevronDown,
|
|
13
13
|
ChevronUp,
|
|
14
14
|
Regex,
|
|
15
|
+
TextSelect,
|
|
15
16
|
Replace,
|
|
16
17
|
ReplaceAll,
|
|
17
18
|
WholeWord,
|
|
@@ -22,7 +23,7 @@ import { EDITOR_KEY_BINDINGS, type EditorCommand } from '@/shared/lib/code/edito
|
|
|
22
23
|
import { describeBinding } from '@/shared/lib/ui/key-binding';
|
|
23
24
|
import { isMacPlatform } from '@/shared/lib/util/platform';
|
|
24
25
|
import type { EditorFindState } from '@/client/hooks/editor/use-editor-find';
|
|
25
|
-
import type { FindOptions } from '@/shared/lib/code/editor/find';
|
|
26
|
+
import type { FindOptions } from '@/shared/lib/code/editor/find-scan';
|
|
26
27
|
|
|
27
28
|
const BUTTON_CLASS =
|
|
28
29
|
'flex items-center justify-center p-1 rounded transition-colors cursor-pointer disabled:cursor-default disabled:opacity-40';
|
|
@@ -112,7 +113,12 @@ export function FindWidget({ find }: FindWidgetProps) {
|
|
|
112
113
|
);
|
|
113
114
|
|
|
114
115
|
return (
|
|
115
|
-
|
|
116
|
+
// `w-[330px]` was wider than the panel's own default (320px), so the bar's
|
|
117
|
+
// leftmost control — Show replace — hung past the panel's edge and its click
|
|
118
|
+
// landed on whatever was beside it. A max width keeps the bar inside the
|
|
119
|
+
// panel it belongs to at any width, and `min-w-0` lets the fields shrink
|
|
120
|
+
// with it instead of pushing the buttons out.
|
|
121
|
+
<div className="absolute top-2 right-2 z-30 flex w-[330px] max-w-[calc(100%-1rem)] min-w-0 flex-col gap-1 bg-paper border border-ink/15 rounded-md shadow-lg p-1.5 text-xs text-ink font-sans">
|
|
116
122
|
<div className="flex items-center gap-1">
|
|
117
123
|
<button
|
|
118
124
|
type="button"
|
|
@@ -141,6 +147,15 @@ export function FindWidget({ find }: FindWidgetProps) {
|
|
|
141
147
|
{optionButton('matchCase', 'Match case', 'toggleCaseSensitive', <CaseSensitive size={13} />)}
|
|
142
148
|
{optionButton('wholeWord', 'Match whole word', 'toggleWholeWord', <WholeWord size={13} />)}
|
|
143
149
|
{optionButton('isRegex', 'Use regular expression', 'toggleRegex', <Regex size={13} />)}
|
|
150
|
+
{/* In selection: armed from the selection at the moment it is switched on, so
|
|
151
|
+
the toggle means "the text I had selected", not "whatever is selected now". */}
|
|
152
|
+
<ToggleButton
|
|
153
|
+
active={find.options.inSelection}
|
|
154
|
+
title={find.options.inSelection ? 'Searching the selection only' : 'Search the selection only'}
|
|
155
|
+
onToggle={() => find.toggleOption('inSelection')}
|
|
156
|
+
>
|
|
157
|
+
<TextSelect size={13} />
|
|
158
|
+
</ToggleButton>
|
|
144
159
|
|
|
145
160
|
<span
|
|
146
161
|
className={`font-mono text-[10px] whitespace-nowrap min-w-[52px] text-right ${find.invalid ? 'text-error' : 'text-ink/50'}`}
|
|
@@ -180,6 +195,25 @@ export function FindWidget({ find }: FindWidgetProps) {
|
|
|
180
195
|
</button>
|
|
181
196
|
</div>
|
|
182
197
|
|
|
198
|
+
{/* Recent queries. Absent until there is one, so the bar does not grow a row
|
|
199
|
+
nobody has used. */}
|
|
200
|
+
{find.history.length > 0 && (
|
|
201
|
+
<div className="flex items-center gap-1 overflow-x-auto no-scrollbar">
|
|
202
|
+
<span className="text-[9px] uppercase tracking-wide text-ink/40 flex-shrink-0">Recent</span>
|
|
203
|
+
{find.history.slice(0, 6).map((entry) => (
|
|
204
|
+
<button
|
|
205
|
+
key={entry}
|
|
206
|
+
type="button"
|
|
207
|
+
onClick={() => find.useHistoryEntry(entry)}
|
|
208
|
+
title={`Find ${entry}`}
|
|
209
|
+
className="px-1.5 py-0.5 rounded border border-ink/15 font-mono text-[10px] text-ink/70 hover:bg-ink/5 hover:text-ink transition-colors cursor-pointer whitespace-nowrap flex-shrink-0"
|
|
210
|
+
>
|
|
211
|
+
{entry}
|
|
212
|
+
</button>
|
|
213
|
+
))}
|
|
214
|
+
</div>
|
|
215
|
+
)}
|
|
216
|
+
|
|
183
217
|
{find.replaceOpen && (
|
|
184
218
|
<div className="flex items-center gap-1">
|
|
185
219
|
<span className="w-[22px]" aria-hidden="true" />
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Go to line (⌘G).
|
|
8
|
+
*
|
|
9
|
+
* A one-field dialog rather than a prompt, because the panel already has the modal
|
|
10
|
+
* shell and because the two things that make this feature usable are both UI: the
|
|
11
|
+
* field must be pre-selected (the user is typing a number, not editing text), and a
|
|
12
|
+
* number past the end must be CLAMPED rather than refused — "go to the end" is what
|
|
13
|
+
* a too-large number means.
|
|
14
|
+
*
|
|
15
|
+
* ## Why it goes through the surface handle
|
|
16
|
+
*
|
|
17
|
+
* `CodeSurfaceHandle` already has `select(offset, offset)` and `revealOffset`, which
|
|
18
|
+
* is exactly "put the caret on this line and scroll it into view". Importing
|
|
19
|
+
* CodeMirror here would be a second way into the same view, and the handle is the
|
|
20
|
+
* contract that kept the find bar, the outline jump and the search reveal working
|
|
21
|
+
* without knowing CM6 exists.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import { useEffect, useRef, useState } from 'preact/hooks';
|
|
25
|
+
import type { TargetedKeyboardEvent } from 'preact';
|
|
26
|
+
import { CornerDownLeft } from 'lucide-preact';
|
|
27
|
+
|
|
28
|
+
import { Modal } from '@/client/components/common/Modal';
|
|
29
|
+
|
|
30
|
+
interface GoToLineModalProps {
|
|
31
|
+
/** Total lines in the document, so a request can be clamped and named. */
|
|
32
|
+
lineCount: number;
|
|
33
|
+
onGo: (line: number) => void;
|
|
34
|
+
onClose: () => void;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The line a typed value resolves to.
|
|
39
|
+
*
|
|
40
|
+
* `null` for anything that is not a number, so the field can stay open with its
|
|
41
|
+
* value untouched instead of jumping to line 1 on a typo.
|
|
42
|
+
*/
|
|
43
|
+
export function resolveLineRequest(raw: string, lineCount: number): number | null {
|
|
44
|
+
const trimmed = raw.trim();
|
|
45
|
+
if (!/^\d+$/.test(trimmed)) return null;
|
|
46
|
+
const requested = Number(trimmed);
|
|
47
|
+
if (requested < 1) return null;
|
|
48
|
+
// Clamped, not refused: a number past the end means "the end", which is the only
|
|
49
|
+
// reading that does not waste the user's keystroke.
|
|
50
|
+
return Math.min(requested, Math.max(lineCount, 1));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function GoToLineModal({ lineCount, onGo, onClose }: GoToLineModalProps) {
|
|
54
|
+
const [value, setValue] = useState('');
|
|
55
|
+
const inputRef = useRef<HTMLInputElement | null>(null);
|
|
56
|
+
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
// Focus AND select: the field starts empty, and a re-open after a jump should
|
|
59
|
+
// replace the previous number rather than append to it.
|
|
60
|
+
inputRef.current?.focus();
|
|
61
|
+
inputRef.current?.select();
|
|
62
|
+
}, []);
|
|
63
|
+
|
|
64
|
+
const submit = () => {
|
|
65
|
+
const line = resolveLineRequest(value, lineCount);
|
|
66
|
+
if (line === null) return;
|
|
67
|
+
onGo(line);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const onKeyDown = (event: TargetedKeyboardEvent<HTMLInputElement>) => {
|
|
71
|
+
if (event.key === 'Enter') {
|
|
72
|
+
event.preventDefault();
|
|
73
|
+
submit();
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (event.key === 'Escape') {
|
|
77
|
+
event.preventDefault();
|
|
78
|
+
onClose();
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const resolved = resolveLineRequest(value, lineCount);
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<Modal
|
|
86
|
+
onClose={onClose}
|
|
87
|
+
maxWidthClass="max-w-xs"
|
|
88
|
+
header={<span className="text-sm font-semibold text-ink">Go to line</span>}
|
|
89
|
+
>
|
|
90
|
+
<div className="px-4 py-3 space-y-2">
|
|
91
|
+
<div className="flex items-center gap-2">
|
|
92
|
+
<input
|
|
93
|
+
ref={inputRef}
|
|
94
|
+
value={value}
|
|
95
|
+
onInput={(event) => setValue((event.target as HTMLInputElement).value)}
|
|
96
|
+
onKeyDown={onKeyDown}
|
|
97
|
+
inputMode="numeric"
|
|
98
|
+
placeholder="1"
|
|
99
|
+
aria-label="Line number"
|
|
100
|
+
className="flex-1 bg-paper border border-ink/20 rounded px-2 py-1 text-xs font-mono text-ink outline-none focus:border-ink/40"
|
|
101
|
+
/>
|
|
102
|
+
<span className="text-[10px] font-mono text-ink/40">/ {lineCount}</span>
|
|
103
|
+
<button
|
|
104
|
+
type="button"
|
|
105
|
+
onClick={submit}
|
|
106
|
+
disabled={resolved === null}
|
|
107
|
+
className="flex items-center gap-1 px-2 py-1 rounded bg-ink text-paper text-xs disabled:opacity-40 disabled:cursor-default cursor-pointer"
|
|
108
|
+
>
|
|
109
|
+
<CornerDownLeft size={12} />
|
|
110
|
+
Go
|
|
111
|
+
</button>
|
|
112
|
+
</div>
|
|
113
|
+
{/* The resolved line, so a clamped request says so before the jump. */}
|
|
114
|
+
{value && resolved !== null && String(resolved) !== value.trim() ? (
|
|
115
|
+
<div className="text-[10px] text-ink/50 font-mono">line {resolved} (the last line)</div>
|
|
116
|
+
) : null}
|
|
117
|
+
{value && resolved === null ? (
|
|
118
|
+
<div className="text-[10px] text-error font-mono">Enter a line number</div>
|
|
119
|
+
) : null}
|
|
120
|
+
</div>
|
|
121
|
+
</Modal>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The strips that stand between the toolbar and the document.
|
|
8
|
+
*
|
|
9
|
+
* Three of them, and each is a different fact about the same file:
|
|
10
|
+
*
|
|
11
|
+
* - **external change** — the disk moved while the buffer has edits, and nothing has
|
|
12
|
+
* been written yet;
|
|
13
|
+
* - **conflict** — a save was REFUSED because the disk moved, so the buffer is ahead
|
|
14
|
+
* and the server declined to overwrite;
|
|
15
|
+
* - **deleted** — the file is gone from disk, which the tab strip also says but in a
|
|
16
|
+
* small target in a crowded row.
|
|
17
|
+
*
|
|
18
|
+
* They sit above the document rather than in a modal because the user has to see the
|
|
19
|
+
* file they are choosing about, and they are one component rather than three call
|
|
20
|
+
* sites because two of them must never render together: a conflict is the LATER
|
|
21
|
+
* state of an external change, so showing both would ask the same question twice.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import { ExternalChangeStrip } from '@/client/components/workspace/editor/ExternalChangeStrip';
|
|
25
|
+
import { ConflictStrip } from '@/client/components/workspace/editor/ConflictStrip';
|
|
26
|
+
import type { DiskChange } from '@/client/hooks/editor/use-external-change';
|
|
27
|
+
import type { WriteConflict } from '@/client/hooks/editor/use-write-conflict';
|
|
28
|
+
import type { OpenedFile } from '@/shared/types/fs';
|
|
29
|
+
|
|
30
|
+
interface EditorNoticesProps {
|
|
31
|
+
activeFile: OpenedFile | undefined;
|
|
32
|
+
/** The disk moved under a dirty buffer, or null. */
|
|
33
|
+
externalChange: DiskChange | null;
|
|
34
|
+
/** A save was refused because the disk moved, or null. */
|
|
35
|
+
conflict: WriteConflict | null;
|
|
36
|
+
/** Take the disk copy and drop the buffer's edits. */
|
|
37
|
+
onReload: () => void;
|
|
38
|
+
/** Adopt the disk's mtime and keep editing. */
|
|
39
|
+
onKeepMine: () => void;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function EditorNotices({
|
|
43
|
+
activeFile,
|
|
44
|
+
externalChange,
|
|
45
|
+
conflict,
|
|
46
|
+
onReload,
|
|
47
|
+
onKeepMine,
|
|
48
|
+
}: EditorNoticesProps) {
|
|
49
|
+
if (!activeFile) return null;
|
|
50
|
+
|
|
51
|
+
// The conflict wins: it is the later state of the same story, and it is the one
|
|
52
|
+
// whose answer writes bytes. Offering both would be two controls for one choice.
|
|
53
|
+
if (conflict) {
|
|
54
|
+
return (
|
|
55
|
+
<ConflictStrip
|
|
56
|
+
diskMtimeMs={conflict.diskMtimeMs}
|
|
57
|
+
fileName={activeFile.name}
|
|
58
|
+
onReload={onReload}
|
|
59
|
+
onKeepMine={onKeepMine}
|
|
60
|
+
/>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (externalChange) {
|
|
65
|
+
return (
|
|
66
|
+
<ExternalChangeStrip fileName={activeFile.name} onReload={onReload} onKeepMine={onKeepMine} />
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* One pane of the editor column: the strip, the notices, the body, the Save As dialog and
|
|
8
|
+
* the two confirmations.
|
|
9
|
+
*
|
|
10
|
+
* Extracted so the SPLIT can render the same thing twice. A second hand-written pane would
|
|
11
|
+
* be a second list of what a pane contains, and the two would drift the moment one gained a
|
|
12
|
+
* notice — which is the class of bug the split must not introduce.
|
|
13
|
+
*
|
|
14
|
+
* It takes DATA (the file, the buffer, the conflict) and builds its own slots, so the panel
|
|
15
|
+
* only decides which pane it is drawing. That is also what keeps `index.tsx` under the
|
|
16
|
+
* repository's line ceiling as the column grew a split.
|
|
17
|
+
*
|
|
18
|
+
* ## A split pane draws no strip
|
|
19
|
+
*
|
|
20
|
+
* The tab order and the active tab belong to the LEFT pane, so a second strip would be a
|
|
21
|
+
* second owner of both.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import type { ComponentChildren } from 'preact';
|
|
25
|
+
|
|
26
|
+
import { EditorNotices } from '@/client/components/workspace/editor/Notices';
|
|
27
|
+
import { SaveAsModal } from '@/client/components/workspace/editor/SaveAsModal';
|
|
28
|
+
import { EditorDialogs } from '@/client/components/workspace/editor/Dialogs';
|
|
29
|
+
import type { DiskChange } from '@/client/hooks/editor/use-external-change';
|
|
30
|
+
import type { CloseGuard } from '@/client/hooks/editor/use-close-guard';
|
|
31
|
+
import type { UseFileEditorResult } from '@/client/hooks/editor/file-editor-types';
|
|
32
|
+
import type { WriteConflict } from '@/client/hooks/editor/use-write-conflict';
|
|
33
|
+
import type { OpenedFile } from '@/shared/types/fs';
|
|
34
|
+
|
|
35
|
+
interface EditorPaneProps {
|
|
36
|
+
className?: string;
|
|
37
|
+
isMaximized: boolean;
|
|
38
|
+
onKeyDownCapture: (event: never) => void;
|
|
39
|
+
asSplitPane: boolean;
|
|
40
|
+
/** The tab strip. Dropped in a split pane. */
|
|
41
|
+
tabs: ComponentChildren;
|
|
42
|
+
/** The active file and the buffer it is drawn from. */
|
|
43
|
+
activeFile: OpenedFile | undefined;
|
|
44
|
+
editor: UseFileEditorResult;
|
|
45
|
+
externalChange: DiskChange | null;
|
|
46
|
+
conflict: WriteConflict | null;
|
|
47
|
+
onReload: () => void;
|
|
48
|
+
onKeepMine: () => void;
|
|
49
|
+
/** The document area (toolbar + surface), already assembled. */
|
|
50
|
+
body: ComponentChildren;
|
|
51
|
+
/** Save As is open, and the callback that closes it after a write. */
|
|
52
|
+
saveAsOpen: boolean;
|
|
53
|
+
onSaveAsClose: () => void;
|
|
54
|
+
onSavedAs: (path: string) => void;
|
|
55
|
+
closeGuard: CloseGuard;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function EditorPane({
|
|
59
|
+
className = '',
|
|
60
|
+
isMaximized,
|
|
61
|
+
onKeyDownCapture,
|
|
62
|
+
asSplitPane,
|
|
63
|
+
tabs,
|
|
64
|
+
activeFile,
|
|
65
|
+
editor,
|
|
66
|
+
externalChange,
|
|
67
|
+
conflict,
|
|
68
|
+
onReload,
|
|
69
|
+
onKeepMine,
|
|
70
|
+
body,
|
|
71
|
+
saveAsOpen,
|
|
72
|
+
onSaveAsClose,
|
|
73
|
+
onSavedAs,
|
|
74
|
+
closeGuard,
|
|
75
|
+
}: EditorPaneProps) {
|
|
76
|
+
const containerClass = isMaximized
|
|
77
|
+
? 'fixed inset-0 z-50 flex flex-col bg-canvas'
|
|
78
|
+
: `flex flex-col h-full bg-canvas ${className}`;
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<div className={containerClass} onKeyDownCapture={onKeyDownCapture}>
|
|
82
|
+
{asSplitPane ? null : tabs}
|
|
83
|
+
|
|
84
|
+
<EditorNotices
|
|
85
|
+
activeFile={activeFile}
|
|
86
|
+
externalChange={externalChange}
|
|
87
|
+
conflict={conflict}
|
|
88
|
+
onReload={onReload}
|
|
89
|
+
onKeepMine={onKeepMine}
|
|
90
|
+
/>
|
|
91
|
+
|
|
92
|
+
{body}
|
|
93
|
+
|
|
94
|
+
{/* Save As needs the BUFFER, so it is built here from the editor state rather than
|
|
95
|
+
handed in as a slot. */}
|
|
96
|
+
{saveAsOpen && activeFile ? (
|
|
97
|
+
<SaveAsModal
|
|
98
|
+
fileName={activeFile.name}
|
|
99
|
+
filePath={activeFile.path}
|
|
100
|
+
content={editor.content}
|
|
101
|
+
eol={editor.eol}
|
|
102
|
+
root={activeFile.root}
|
|
103
|
+
repo={activeFile.repo}
|
|
104
|
+
onSaved={({ path }) => onSavedAs(path)}
|
|
105
|
+
onClose={onSaveAsClose}
|
|
106
|
+
/>
|
|
107
|
+
) : null}
|
|
108
|
+
|
|
109
|
+
<EditorDialogs
|
|
110
|
+
closeGuard={closeGuard}
|
|
111
|
+
activeFile={activeFile}
|
|
112
|
+
saveMissingConfirm={editor.saveMissingConfirm}
|
|
113
|
+
onCancelSaveMissing={editor.cancelSaveMissing}
|
|
114
|
+
onConfirmSaveMissing={editor.confirmSaveMissing}
|
|
115
|
+
/>
|
|
116
|
+
</div>
|
|
117
|
+
);
|
|
118
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The editor column taken over by a plugin.
|
|
8
|
+
*
|
|
9
|
+
* There is no tab strip in this mode and no file: the plugin owns the whole surface, the
|
|
10
|
+
* way a right-panel view does, and the layout's own toggle is what gives the column back.
|
|
11
|
+
* `PluginIdProvider` is what lets the plugin's own components resolve their registration.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import type { ComponentType } from 'preact/compat';
|
|
15
|
+
import { PluginIdProvider } from '@kabmo-labs/kabmo-ui';
|
|
16
|
+
|
|
17
|
+
interface PluginColumnProps {
|
|
18
|
+
pluginId: string;
|
|
19
|
+
Component: ComponentType<{ sessionId: string | null; workspacePath: string | null }>;
|
|
20
|
+
sessionId: string | null;
|
|
21
|
+
className?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function PluginColumn({ pluginId, Component, sessionId, className = '' }: PluginColumnProps) {
|
|
25
|
+
return (
|
|
26
|
+
<div className={`flex flex-col h-full bg-canvas ${className}`}>
|
|
27
|
+
<PluginIdProvider pluginId={pluginId}>
|
|
28
|
+
<Component sessionId={sessionId} workspacePath={null} />
|
|
29
|
+
</PluginIdProvider>
|
|
30
|
+
</div>
|
|
31
|
+
);
|
|
32
|
+
}
|