@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
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Quick open (⌘P): a file picker over `/api/fs/list`.
|
|
8
|
+
*
|
|
9
|
+
* The index is fetched once per scope and cached for the session: the route walks
|
|
10
|
+
* the tree, so re-reading it on every keystroke would be a walk per character. A
|
|
11
|
+
* `workspace-dirty` signal invalidates it, because a file created by the agent (or
|
|
12
|
+
* by the New File dialog) is exactly the file a picker should be able to find.
|
|
13
|
+
*
|
|
14
|
+
* ## The dialog is the same shell as Go-to-line, deliberately
|
|
15
|
+
*
|
|
16
|
+
* Two one-field modals that look different read as two different features; the
|
|
17
|
+
* keyboard contract (type, arrows, Enter, Escape) is the only thing the user has to
|
|
18
|
+
* learn, so both use it.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { useEffect, useMemo, useRef, useState } from 'preact/hooks';
|
|
22
|
+
import type { TargetedKeyboardEvent } from 'preact';
|
|
23
|
+
import { FileIcon } from '@/client/components/common/file-icon';
|
|
24
|
+
import { Modal } from '@/client/components/common/Modal';
|
|
25
|
+
import { fetchQuickOpenIndex, rankQuickOpen, type QuickOpenEntry } from '@/client/hooks/editor/quick-open';
|
|
26
|
+
|
|
27
|
+
interface QuickOpenModalProps {
|
|
28
|
+
root?: string | null;
|
|
29
|
+
repo?: string | null;
|
|
30
|
+
onOpen: (path: string) => void;
|
|
31
|
+
onClose: () => void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Index cache, keyed by scope. `bun --hot` keeps it, which is the point. */
|
|
35
|
+
const indexCache = new Map<string, QuickOpenEntry[]>();
|
|
36
|
+
|
|
37
|
+
/** Drop the cached index — a `workspace-dirty` signal means a file may be new. */
|
|
38
|
+
export function invalidateQuickOpenIndex(): void {
|
|
39
|
+
indexCache.clear();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function QuickOpenModal({ root, repo, onOpen, onClose }: QuickOpenModalProps) {
|
|
43
|
+
const scope = `${root ?? ''}\u0000${repo ?? '.'}`;
|
|
44
|
+
const [query, setQuery] = useState('');
|
|
45
|
+
const [index, setIndex] = useState<QuickOpenEntry[]>(() => indexCache.get(scope) ?? []);
|
|
46
|
+
const [activeIndex, setActiveIndex] = useState(0);
|
|
47
|
+
const inputRef = useRef<HTMLInputElement | null>(null);
|
|
48
|
+
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
inputRef.current?.focus();
|
|
51
|
+
}, []);
|
|
52
|
+
|
|
53
|
+
// One fetch per scope, cached for the session. The dialog stays usable while it
|
|
54
|
+
// lands: a query against an empty index shows "no files" for a beat, which is the
|
|
55
|
+
// honest state rather than a spinner over a list that is about to appear.
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (indexCache.has(scope)) return;
|
|
58
|
+
let cancelled = false;
|
|
59
|
+
void fetchQuickOpenIndex(root, repo).then((entries) => {
|
|
60
|
+
if (cancelled) return;
|
|
61
|
+
indexCache.set(scope, entries);
|
|
62
|
+
setIndex(entries);
|
|
63
|
+
});
|
|
64
|
+
return () => {
|
|
65
|
+
cancelled = true;
|
|
66
|
+
};
|
|
67
|
+
}, [scope, root, repo]);
|
|
68
|
+
|
|
69
|
+
const matches = useMemo(() => rankQuickOpen(index, query), [index, query]);
|
|
70
|
+
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
setActiveIndex((previous) => Math.min(previous, Math.max(matches.length - 1, 0)));
|
|
73
|
+
}, [matches.length]);
|
|
74
|
+
|
|
75
|
+
const commit = (entry: QuickOpenEntry | undefined) => {
|
|
76
|
+
if (!entry) return;
|
|
77
|
+
onOpen(entry.path);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const onKeyDown = (event: TargetedKeyboardEvent<HTMLInputElement>) => {
|
|
81
|
+
if (event.key === 'Escape') {
|
|
82
|
+
event.preventDefault();
|
|
83
|
+
onClose();
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (event.key === 'Enter') {
|
|
87
|
+
event.preventDefault();
|
|
88
|
+
commit(matches[activeIndex]);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (event.key === 'ArrowDown') {
|
|
92
|
+
event.preventDefault();
|
|
93
|
+
setActiveIndex((previous) => (matches.length === 0 ? 0 : (previous + 1) % matches.length));
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (event.key === 'ArrowUp') {
|
|
97
|
+
event.preventDefault();
|
|
98
|
+
setActiveIndex((previous) => (matches.length === 0 ? 0 : (previous - 1 + matches.length) % matches.length));
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
return (
|
|
103
|
+
<Modal
|
|
104
|
+
onClose={onClose}
|
|
105
|
+
maxWidthClass="max-w-lg"
|
|
106
|
+
header={<span className="text-sm font-semibold text-ink">Open file</span>}
|
|
107
|
+
>
|
|
108
|
+
<div className="px-4 py-3 space-y-2">
|
|
109
|
+
<input
|
|
110
|
+
ref={inputRef}
|
|
111
|
+
value={query}
|
|
112
|
+
onInput={(event) => setQuery((event.target as HTMLInputElement).value)}
|
|
113
|
+
onKeyDown={onKeyDown}
|
|
114
|
+
placeholder="Search by file name"
|
|
115
|
+
aria-label="File name"
|
|
116
|
+
className="w-full bg-paper border border-ink/20 rounded px-2 py-1.5 text-xs font-mono text-ink outline-none focus:border-ink/40"
|
|
117
|
+
/>
|
|
118
|
+
<div className="max-h-[45vh] overflow-y-auto scrollbar-overlay-container rounded border border-ink/10 divide-y divide-ink/5">
|
|
119
|
+
{matches.length === 0 ? (
|
|
120
|
+
<div className="px-3 py-2 text-[11px] text-ink/40 font-mono">
|
|
121
|
+
{index.length === 0 ? 'Reading the file index…' : 'No file matches'}
|
|
122
|
+
</div>
|
|
123
|
+
) : (
|
|
124
|
+
matches.map((entry, position) => (
|
|
125
|
+
<button
|
|
126
|
+
key={entry.path}
|
|
127
|
+
type="button"
|
|
128
|
+
onClick={() => commit(entry)}
|
|
129
|
+
onMouseEnter={() => setActiveIndex(position)}
|
|
130
|
+
className={`w-full flex items-center gap-2 px-3 py-1.5 text-left transition-colors cursor-pointer ${
|
|
131
|
+
position === activeIndex ? 'bg-ink/10' : 'hover:bg-ink/5'
|
|
132
|
+
}`}
|
|
133
|
+
>
|
|
134
|
+
<FileIcon name={entry.name} size={13} className="flex-shrink-0 opacity-70" />
|
|
135
|
+
<span className="text-xs font-mono text-ink truncate">{entry.name}</span>
|
|
136
|
+
{entry.directory ? (
|
|
137
|
+
<span className="text-[10px] font-mono text-ink/40 truncate ml-auto">{entry.directory}</span>
|
|
138
|
+
) : null}
|
|
139
|
+
</button>
|
|
140
|
+
))
|
|
141
|
+
)}
|
|
142
|
+
</div>
|
|
143
|
+
</div>
|
|
144
|
+
</Modal>
|
|
145
|
+
);
|
|
146
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The Save As dialog.
|
|
8
|
+
*
|
|
9
|
+
* Two fields, because a destination is two facts: which DIRECTORY, and what NAME. The
|
|
10
|
+
* directory is workspace-relative — the editor only ever deals in paths relative to the
|
|
11
|
+
* scope it was opened in, and an absolute path would be a value the server has to refuse
|
|
12
|
+
* (`resolveWithinRoot` is the boundary). The name starts as `<file> copy.<ext>` rather than
|
|
13
|
+
* `copy` alone: a destination that lost its extension would be saved as a file the surface
|
|
14
|
+
* no longer recognises, so the language would change under the user.
|
|
15
|
+
*
|
|
16
|
+
* ## A refusal keeps the dialog open, with the name still in it
|
|
17
|
+
*
|
|
18
|
+
* An existing destination is the common refusal and it is not a failure — the user picked a
|
|
19
|
+
* name that is taken. Closing the dialog on a `409` would read as success and leave them
|
|
20
|
+
* wondering where the file went, so the refusal is shown inline and the field stays.
|
|
21
|
+
*
|
|
22
|
+
* ## What Save As does NOT do
|
|
23
|
+
*
|
|
24
|
+
* The original file is untouched and the ORIGINAL tab stays open. The new file gets its own
|
|
25
|
+
* tab, which is what makes the operation reversible by closing one tab — and what makes it
|
|
26
|
+
* different from a rename (which is the Files panel's job).
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
import { useEffect, useRef, useState } from 'preact/hooks';
|
|
30
|
+
import type { TargetedKeyboardEvent } from 'preact';
|
|
31
|
+
import { CornerDownLeft, Loader2 } from 'lucide-preact';
|
|
32
|
+
|
|
33
|
+
import { Modal } from '@/client/components/common/Modal';
|
|
34
|
+
import {
|
|
35
|
+
isSingleSegmentName,
|
|
36
|
+
saveAsSuggestedName,
|
|
37
|
+
saveFileAs,
|
|
38
|
+
type SaveAsOutcome,
|
|
39
|
+
} from '@/client/hooks/editor/save-as';
|
|
40
|
+
|
|
41
|
+
interface SaveAsModalProps {
|
|
42
|
+
/** The open file: its name seeds the field, its path seeds the directory. */
|
|
43
|
+
fileName: string;
|
|
44
|
+
/** Workspace-relative path of the source, so the directory starts where it lives. */
|
|
45
|
+
filePath: string;
|
|
46
|
+
/** The buffer, LF-only. */
|
|
47
|
+
content: string;
|
|
48
|
+
eol: 'lf' | 'crlf';
|
|
49
|
+
root?: string;
|
|
50
|
+
repo?: string;
|
|
51
|
+
onSaved: (outcome: { path: string }) => void;
|
|
52
|
+
onClose: () => void;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** The directory part of a workspace-relative path, or `''` at the root. */
|
|
56
|
+
export function directoryOf(path: string): string {
|
|
57
|
+
const cut = path.lastIndexOf('/');
|
|
58
|
+
return cut === -1 ? '' : path.slice(0, cut);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function SaveAsModal({
|
|
62
|
+
fileName,
|
|
63
|
+
filePath,
|
|
64
|
+
content,
|
|
65
|
+
eol,
|
|
66
|
+
root,
|
|
67
|
+
repo,
|
|
68
|
+
onSaved,
|
|
69
|
+
onClose,
|
|
70
|
+
}: SaveAsModalProps) {
|
|
71
|
+
const [directory, setDirectory] = useState(() => directoryOf(filePath));
|
|
72
|
+
const [name, setName] = useState(() => saveAsSuggestedName(fileName));
|
|
73
|
+
const [busy, setBusy] = useState(false);
|
|
74
|
+
const [refusal, setRefusal] = useState<string | null>(null);
|
|
75
|
+
const nameRef = useRef<HTMLInputElement | null>(null);
|
|
76
|
+
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
nameRef.current?.focus();
|
|
79
|
+
// Select the stem so typing replaces it — the suggested name is a starting point,
|
|
80
|
+
// and a user who types immediately means to replace it, not append to it.
|
|
81
|
+
nameRef.current?.select();
|
|
82
|
+
}, []);
|
|
83
|
+
|
|
84
|
+
const valid = isSingleSegmentName(name);
|
|
85
|
+
|
|
86
|
+
const submit = async () => {
|
|
87
|
+
if (!valid || busy) return;
|
|
88
|
+
setBusy(true);
|
|
89
|
+
setRefusal(null);
|
|
90
|
+
const outcome: SaveAsOutcome = await saveFileAs({ parent: directory, name, content, eol, root, repo });
|
|
91
|
+
setBusy(false);
|
|
92
|
+
if (outcome.status === 'written') {
|
|
93
|
+
onSaved({ path: outcome.path });
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
// Both refusals keep the dialog open with the field intact: the user picked a name
|
|
97
|
+
// that cannot be used, and closing would read as success.
|
|
98
|
+
setRefusal(outcome.reason);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const onKeyDown = (event: TargetedKeyboardEvent<HTMLInputElement>) => {
|
|
102
|
+
if (event.key === 'Enter') {
|
|
103
|
+
event.preventDefault();
|
|
104
|
+
void submit();
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (event.key === 'Escape') {
|
|
108
|
+
event.preventDefault();
|
|
109
|
+
onClose();
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
<Modal
|
|
115
|
+
onClose={onClose}
|
|
116
|
+
maxWidthClass="max-w-md"
|
|
117
|
+
header={<span className="text-sm font-semibold text-ink">Save as</span>}
|
|
118
|
+
footer={
|
|
119
|
+
<div className="flex items-center justify-end gap-2 px-4 py-3 border-t border-ink/10">
|
|
120
|
+
<button
|
|
121
|
+
type="button"
|
|
122
|
+
onClick={onClose}
|
|
123
|
+
className="px-3 py-1.5 rounded border border-ink/20 text-ink/80 hover:bg-ink/5 transition-colors cursor-pointer"
|
|
124
|
+
>
|
|
125
|
+
Cancel
|
|
126
|
+
</button>
|
|
127
|
+
<button
|
|
128
|
+
type="button"
|
|
129
|
+
onClick={() => void submit()}
|
|
130
|
+
disabled={!valid || busy}
|
|
131
|
+
className="flex items-center gap-1.5 px-3 py-1.5 rounded bg-ink text-paper disabled:opacity-40 disabled:cursor-default cursor-pointer"
|
|
132
|
+
>
|
|
133
|
+
{busy ? <Loader2 size={12} className="animate-spin" /> : <CornerDownLeft size={12} />}
|
|
134
|
+
Save
|
|
135
|
+
</button>
|
|
136
|
+
</div>
|
|
137
|
+
}
|
|
138
|
+
>
|
|
139
|
+
<div className="px-4 py-3 space-y-2 text-xs">
|
|
140
|
+
<label className="block">
|
|
141
|
+
<span className="block text-[10px] uppercase tracking-wide text-ink/50 mb-1">Folder</span>
|
|
142
|
+
<input
|
|
143
|
+
value={directory}
|
|
144
|
+
onInput={(event) => setDirectory((event.target as HTMLInputElement).value)}
|
|
145
|
+
onKeyDown={onKeyDown}
|
|
146
|
+
placeholder="(workspace root)"
|
|
147
|
+
aria-label="Destination folder"
|
|
148
|
+
className="w-full bg-paper border border-ink/20 rounded px-2 py-1 font-mono text-ink outline-none focus:border-ink/40"
|
|
149
|
+
/>
|
|
150
|
+
</label>
|
|
151
|
+
<label className="block">
|
|
152
|
+
<span className="block text-[10px] uppercase tracking-wide text-ink/50 mb-1">Name</span>
|
|
153
|
+
<input
|
|
154
|
+
ref={nameRef}
|
|
155
|
+
value={name}
|
|
156
|
+
onInput={(event) => setName((event.target as HTMLInputElement).value)}
|
|
157
|
+
onKeyDown={onKeyDown}
|
|
158
|
+
aria-label="File name"
|
|
159
|
+
aria-invalid={!valid}
|
|
160
|
+
className={`w-full bg-paper border rounded px-2 py-1 font-mono text-ink outline-none ${
|
|
161
|
+
valid ? 'border-ink/20 focus:border-ink/40' : 'border-error text-error'
|
|
162
|
+
}`}
|
|
163
|
+
/>
|
|
164
|
+
</label>
|
|
165
|
+
{!valid ? (
|
|
166
|
+
<div className="text-[10px] text-error font-mono">Enter a file name without a path separator</div>
|
|
167
|
+
) : null}
|
|
168
|
+
{refusal ? <div className="text-[10px] text-error font-mono">{refusal}</div> : null}
|
|
169
|
+
<div className="text-[10px] text-ink/40">
|
|
170
|
+
The original file stays where it is, and its tab stays open.
|
|
171
|
+
</div>
|
|
172
|
+
</div>
|
|
173
|
+
</Modal>
|
|
174
|
+
);
|
|
175
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Two panes and the divider between them.
|
|
8
|
+
*
|
|
9
|
+
* The split divides the width the editor panel ALREADY has — its fraction, its floor and
|
|
10
|
+
* its diff variant are untouched — so nothing about the group's coupled-pair width model
|
|
11
|
+
* changes. Splitting a column is a different decision from how wide the column is, and
|
|
12
|
+
* keeping them apart is what made this feature cheap.
|
|
13
|
+
*
|
|
14
|
+
* ## The divider uses pointer capture
|
|
15
|
+
*
|
|
16
|
+
* A 3px handle is easy to leave mid-drag, and a listener on the handle alone would stop
|
|
17
|
+
* receiving `pointermove` the moment the pointer crossed into a pane. Capture keeps the
|
|
18
|
+
* events coming for the whole gesture, so a fast drag resizes instead of stalling.
|
|
19
|
+
*
|
|
20
|
+
* ## The position is a FRACTION
|
|
21
|
+
*
|
|
22
|
+
* A pixel width is only right on the display it was dragged on. The parent persists the
|
|
23
|
+
* fraction and clamps it (`clampSplitFraction`), so neither pane can be squeezed out of
|
|
24
|
+
* existence by a drag or by a hand-edited blob.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
import { useRef } from 'preact/hooks';
|
|
28
|
+
import type { ComponentChildren } from 'preact';
|
|
29
|
+
|
|
30
|
+
import { SplitPane } from '@/client/components/workspace/editor/SplitPane';
|
|
31
|
+
import { clampSplitFraction } from '@/shared/lib/workspace/split-editor';
|
|
32
|
+
|
|
33
|
+
interface SplitColumnProps {
|
|
34
|
+
/** The divider's position, 0–1. */
|
|
35
|
+
fraction: number;
|
|
36
|
+
onFraction: (fraction: number) => void;
|
|
37
|
+
rightPaneName: string;
|
|
38
|
+
onClosePane: () => void;
|
|
39
|
+
rightPane: ComponentChildren;
|
|
40
|
+
/** The left pane — the panel body, strip included. */
|
|
41
|
+
children: ComponentChildren;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function SplitColumn({
|
|
45
|
+
fraction,
|
|
46
|
+
onFraction,
|
|
47
|
+
rightPaneName,
|
|
48
|
+
onClosePane,
|
|
49
|
+
rightPane,
|
|
50
|
+
children,
|
|
51
|
+
}: SplitColumnProps) {
|
|
52
|
+
const columnRef = useRef<HTMLDivElement | null>(null);
|
|
53
|
+
|
|
54
|
+
const startDrag = (event: PointerEvent) => {
|
|
55
|
+
const handle = event.currentTarget as HTMLElement | null;
|
|
56
|
+
const column = columnRef.current;
|
|
57
|
+
if (!handle || !column) return;
|
|
58
|
+
handle.setPointerCapture(event.pointerId);
|
|
59
|
+
|
|
60
|
+
const move = (moveEvent: PointerEvent) => {
|
|
61
|
+
const rect = column.getBoundingClientRect();
|
|
62
|
+
// A zero-width column (a collapsed panel mid-transition) has no meaningful
|
|
63
|
+
// fraction to compute, and dividing by it would write NaN into the session blob.
|
|
64
|
+
if (rect.width === 0) return;
|
|
65
|
+
onFraction(clampSplitFraction((moveEvent.clientX - rect.left) / rect.width));
|
|
66
|
+
};
|
|
67
|
+
const up = () => {
|
|
68
|
+
handle.releasePointerCapture(event.pointerId);
|
|
69
|
+
handle.removeEventListener('pointermove', move);
|
|
70
|
+
handle.removeEventListener('pointerup', up);
|
|
71
|
+
};
|
|
72
|
+
handle.addEventListener('pointermove', move);
|
|
73
|
+
handle.addEventListener('pointerup', up);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<div ref={columnRef} className="flex w-full h-full" data-split-column="">
|
|
78
|
+
<div
|
|
79
|
+
className="flex flex-col min-w-0 h-full"
|
|
80
|
+
style={{ width: `${Math.round(clampSplitFraction(fraction) * 100)}%` }}
|
|
81
|
+
>
|
|
82
|
+
{children}
|
|
83
|
+
</div>
|
|
84
|
+
<div
|
|
85
|
+
className="w-[3px] flex-shrink-0 cursor-col-resize bg-ink/10 hover:bg-ink/40 transition-colors"
|
|
86
|
+
role="separator"
|
|
87
|
+
aria-orientation="vertical"
|
|
88
|
+
aria-label="Resize split panes"
|
|
89
|
+
onPointerDown={startDrag}
|
|
90
|
+
/>
|
|
91
|
+
<div className="flex-1 min-w-0 h-full">
|
|
92
|
+
<SplitPane fileName={rightPaneName} onClose={onClosePane}>
|
|
93
|
+
{rightPane}
|
|
94
|
+
</SplitPane>
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The right pane of a split editor column.
|
|
8
|
+
*
|
|
9
|
+
* It is a SECOND `Editor`, not a second document list: the pane takes the tab it should
|
|
10
|
+
* show and renders the same panel with that tab forced active. Everything about it — the
|
|
11
|
+
* toolbar, the find bar, the surface, the save path — is the panel the left pane already
|
|
12
|
+
* uses, so a split cannot have a feature the unsplit editor lacks.
|
|
13
|
+
*
|
|
14
|
+
* ## Why a forced `activeFileId` rather than a second tab list
|
|
15
|
+
*
|
|
16
|
+
* The strip stays in the LEFT pane and stays the single owner of the tab order and of
|
|
17
|
+
* `activeFileId`. The right pane is given its own id to render and is told to keep it: a
|
|
18
|
+
* click on its tab strip would move the left pane's active tab, which is the behaviour the
|
|
19
|
+
* user is not asking for when they split.
|
|
20
|
+
*
|
|
21
|
+
* ## Closing the pane closes the VIEW, not the tab
|
|
22
|
+
*
|
|
23
|
+
* The tab stays in the strip, which is what makes the split a layout decision rather than a
|
|
24
|
+
* document one.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
import type { ComponentChildren } from 'preact';
|
|
28
|
+
import { X } from 'lucide-preact';
|
|
29
|
+
|
|
30
|
+
interface SplitPaneProps {
|
|
31
|
+
/** The tab's name, for the header that identifies which document this is. */
|
|
32
|
+
fileName: string;
|
|
33
|
+
onClose: () => void;
|
|
34
|
+
children: ComponentChildren;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function SplitPane({ fileName, onClose, children }: SplitPaneProps) {
|
|
38
|
+
return (
|
|
39
|
+
<div className="flex flex-col h-full min-w-0" data-split-pane="">
|
|
40
|
+
<div className="flex items-center justify-between gap-2 px-3 py-1 border-b border-ink/10 bg-canvas flex-shrink-0">
|
|
41
|
+
<span className="text-[11px] font-mono text-ink/60 truncate" title={fileName}>
|
|
42
|
+
{fileName}
|
|
43
|
+
</span>
|
|
44
|
+
<button
|
|
45
|
+
type="button"
|
|
46
|
+
onClick={onClose}
|
|
47
|
+
className="p-0.5 rounded hover:bg-ink/10 text-ink/50 hover:text-ink transition-colors cursor-pointer flex-shrink-0"
|
|
48
|
+
title="Close this pane (the tab stays open)"
|
|
49
|
+
aria-label="Close split pane"
|
|
50
|
+
>
|
|
51
|
+
<X size={12} />
|
|
52
|
+
</button>
|
|
53
|
+
</div>
|
|
54
|
+
<div className="flex-1 min-h-0">{children}</div>
|
|
55
|
+
</div>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The desktop editor's status bar: where the caret is, how the file is indented, and
|
|
8
|
+
* how it ends.
|
|
9
|
+
*
|
|
10
|
+
* The phone has had a status strip since the editor was rebuilt (`lines · chars ·
|
|
11
|
+
* language`); the desktop pane had nothing, so the only way to know the caret's line
|
|
12
|
+
* was to count. This is the missing half, and it is also where the two settings that
|
|
13
|
+
* change the BYTES of a save are reported — the indent unit and the line ending —
|
|
14
|
+
* because a user who cannot see them cannot tell whether a 4-space repository is
|
|
15
|
+
* being indented correctly.
|
|
16
|
+
*
|
|
17
|
+
* ## It does not hide
|
|
18
|
+
*
|
|
19
|
+
* The panel has a 320px floor (`MIN_EDITOR_PANEL_WIDTH`), so there is always room for
|
|
20
|
+
* one 24px row — and a readout that disappears at some widths is a readout the user
|
|
21
|
+
* cannot rely on. A container query was tried and removed: the strip's own root has no
|
|
22
|
+
* `@container` ancestor, so `@[240px]:flex` never matched and the row was `hidden` at
|
|
23
|
+
* every width, which a test caught rather than a reader.
|
|
24
|
+
*
|
|
25
|
+
* ## The right half is the SAVE state, not a second copy of the toolbar's
|
|
26
|
+
*
|
|
27
|
+
* The toolbar already shows saving/saved/error through its icon. Repeating it here
|
|
28
|
+
* would be two indicators for one fact, so the right half carries only what the
|
|
29
|
+
* toolbar cannot: the file's own line ending, and the language the surface resolved.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
import { VIEWER_LABELS, type ViewerKind } from '@/shared/lib/fs/document-kind';
|
|
33
|
+
import type { CaretPosition } from '@/client/hooks/editor/caret-position';
|
|
34
|
+
import type { LineEnding } from '@/shared/lib/code/line-endings';
|
|
35
|
+
|
|
36
|
+
interface EditorStatusBarProps {
|
|
37
|
+
/** `null` before the surface reports a state, and for a byte viewer. */
|
|
38
|
+
caret: CaretPosition | null;
|
|
39
|
+
/** The file's own ending, which the next save restores. */
|
|
40
|
+
eol: LineEnding;
|
|
41
|
+
/** Change the ending the next save writes. */
|
|
42
|
+
onSetEol: (eol: LineEnding) => void;
|
|
43
|
+
/** One indentation level, already resolved from the setting. */
|
|
44
|
+
indentWidth: number;
|
|
45
|
+
insertSpaces: boolean;
|
|
46
|
+
/** The Shiki language id the surface resolved. */
|
|
47
|
+
language: string;
|
|
48
|
+
/** A byte-drawing viewer prints its KIND instead of a caret. */
|
|
49
|
+
byteViewer: boolean;
|
|
50
|
+
viewerKind: ViewerKind;
|
|
51
|
+
lineCount: number;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** `Spaces: 2` / `Tabs`, which is what the indent actually inserts. */
|
|
55
|
+
function indentLabel(width: number, insertSpaces: boolean): string {
|
|
56
|
+
return insertSpaces ? `Spaces: ${width}` : 'Tabs';
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function EditorStatusBar({
|
|
60
|
+
caret,
|
|
61
|
+
eol,
|
|
62
|
+
onSetEol,
|
|
63
|
+
indentWidth,
|
|
64
|
+
insertSpaces,
|
|
65
|
+
language,
|
|
66
|
+
byteViewer,
|
|
67
|
+
viewerKind,
|
|
68
|
+
lineCount,
|
|
69
|
+
}: EditorStatusBarProps) {
|
|
70
|
+
return (
|
|
71
|
+
<footer
|
|
72
|
+
className="flex bg-canvas border-t border-ink/10 px-3 items-center justify-between text-[10px] text-ink/50 flex-shrink-0 font-mono h-6"
|
|
73
|
+
data-editor-status-bar=""
|
|
74
|
+
>
|
|
75
|
+
<div className="flex items-center gap-3 min-w-0">
|
|
76
|
+
{byteViewer ? (
|
|
77
|
+
<span className="uppercase">{VIEWER_LABELS[viewerKind]}</span>
|
|
78
|
+
) : (
|
|
79
|
+
<>
|
|
80
|
+
{/* `Ln 12, Col 34` is the shape every editor uses, and it is also what a
|
|
81
|
+
stack trace gives the user to look for. */}
|
|
82
|
+
<span className="tabular-nums">
|
|
83
|
+
{caret ? `Ln ${caret.line}, Col ${caret.column}` : 'Ln —, Col —'}
|
|
84
|
+
</span>
|
|
85
|
+
<span>{indentLabel(indentWidth, insertSpaces)}</span>
|
|
86
|
+
{/* A control, not a label: the ending is a choice the write path already
|
|
87
|
+
carries, and a file that arrived as CRLF had no way to become LF. */}
|
|
88
|
+
<button
|
|
89
|
+
type="button"
|
|
90
|
+
onClick={() => onSetEol(eol === 'lf' ? 'crlf' : 'lf')}
|
|
91
|
+
className="uppercase hover:text-ink transition-colors cursor-pointer"
|
|
92
|
+
title={`Line endings: ${eol.toUpperCase()} — click to switch`}
|
|
93
|
+
aria-label={`Line endings ${eol.toUpperCase()}, switch`}
|
|
94
|
+
>
|
|
95
|
+
{eol}
|
|
96
|
+
</button>
|
|
97
|
+
<span>{lineCount} lines</span>
|
|
98
|
+
</>
|
|
99
|
+
)}
|
|
100
|
+
</div>
|
|
101
|
+
<div className="flex items-center gap-3 min-w-0">
|
|
102
|
+
<span className="uppercase text-ink/40">{language}</span>
|
|
103
|
+
</div>
|
|
104
|
+
</footer>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The tab strip's context menu, drawn from `tab-menu.ts`'s rows.
|
|
8
|
+
*
|
|
9
|
+
* A portal to `document.body`, like every other menu here: the tab strip is a
|
|
10
|
+
* horizontal scroller inside a resizable panel, and a `position: fixed` menu nested in
|
|
11
|
+
* one is clipped the moment the panel is narrower than the menu.
|
|
12
|
+
*
|
|
13
|
+
* The geometry is measured, not guessed — a hand-written height puts the last rows off
|
|
14
|
+
* screen the moment a row is added, which is the failure the Files panel's own menu
|
|
15
|
+
* documents.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { useLayoutEffect, useRef, useState } from 'preact/hooks';
|
|
19
|
+
import { createPortal } from 'preact/compat';
|
|
20
|
+
|
|
21
|
+
import type { TabMenuAction, TabMenuRow } from '@/client/lib/editor/tab-menu';
|
|
22
|
+
|
|
23
|
+
interface TabContextMenuProps {
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
26
|
+
rows: TabMenuRow[];
|
|
27
|
+
onAction: (action: TabMenuAction) => void;
|
|
28
|
+
onClose: () => void;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function TabContextMenu({ x, y, rows, onAction, onClose }: TabContextMenuProps) {
|
|
32
|
+
const menuRef = useRef<HTMLDivElement | null>(null);
|
|
33
|
+
const [position, setPosition] = useState({ left: x, top: y });
|
|
34
|
+
|
|
35
|
+
// Clamp against the viewport's edges once the menu has a real height. A menu opened
|
|
36
|
+
// near the bottom would otherwise draw its last rows past the window.
|
|
37
|
+
useLayoutEffect(() => {
|
|
38
|
+
const menu = menuRef.current;
|
|
39
|
+
if (!menu) return;
|
|
40
|
+
const { width, height } = menu.getBoundingClientRect();
|
|
41
|
+
setPosition({
|
|
42
|
+
left: Math.min(x, Math.max(0, window.innerWidth - width - 8)),
|
|
43
|
+
top: Math.min(y, Math.max(0, window.innerHeight - height - 8)),
|
|
44
|
+
});
|
|
45
|
+
}, [x, y, rows.length]);
|
|
46
|
+
|
|
47
|
+
return createPortal(
|
|
48
|
+
<div className="fixed inset-0 z-[70]" onClick={onClose} onContextMenu={(event) => { event.preventDefault(); onClose(); }}>
|
|
49
|
+
<div
|
|
50
|
+
ref={menuRef}
|
|
51
|
+
role="menu"
|
|
52
|
+
aria-label="Tab actions"
|
|
53
|
+
className="absolute w-52 bg-paper border border-ink/15 rounded-md shadow-xl py-1 text-xs text-ink"
|
|
54
|
+
style={{ left: `${position.left}px`, top: `${position.top}px` }}
|
|
55
|
+
onClick={(event) => event.stopPropagation()}
|
|
56
|
+
>
|
|
57
|
+
{rows.map((row) => (
|
|
58
|
+
<button
|
|
59
|
+
key={row.action}
|
|
60
|
+
type="button"
|
|
61
|
+
role="menuitem"
|
|
62
|
+
onClick={() => {
|
|
63
|
+
onAction(row.action);
|
|
64
|
+
onClose();
|
|
65
|
+
}}
|
|
66
|
+
className="w-full text-left px-3 py-1.5 hover:bg-ink/5 transition-colors cursor-pointer"
|
|
67
|
+
>
|
|
68
|
+
{row.label}
|
|
69
|
+
</button>
|
|
70
|
+
))}
|
|
71
|
+
</div>
|
|
72
|
+
</div>,
|
|
73
|
+
document.body,
|
|
74
|
+
);
|
|
75
|
+
}
|