dsh-remote-vs 0.24.0 → 0.26.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.en.md +50 -16
- package/README.md +40 -15
- package/THIRD-PARTY-NOTICES.md +188 -0
- package/lib/client.js +6512 -77887
- package/lib/index.js +1461 -1024
- package/lib/p2-router-fs.js +1 -1
- package/lib/types/client/CodeEditor.d.ts +25 -0
- package/lib/types/client/EditorPane.d.ts +16 -5
- package/lib/types/client/FloatingPlaceholder.d.ts +16 -5
- package/lib/types/client/RemoteEditorView.d.ts +13 -10
- package/lib/types/client/RemoteExplorer.d.ts +53 -0
- package/lib/types/client/RemoteRoot.d.ts +5 -5
- package/lib/types/client/TerminalSnippets.d.ts +36 -0
- package/lib/types/client/TerminalView.d.ts +1 -1
- package/lib/types/client/XTerm.d.ts +33 -0
- package/lib/types/client/api.d.ts +37 -2
- package/lib/types/client/changes/review-state.d.ts +19 -0
- package/lib/types/client/connection.d.ts +16 -0
- package/lib/types/client/editor-capability.d.ts +27 -0
- package/lib/types/client/i18n.d.ts +1 -1
- package/lib/types/client/request-gate.d.ts +110 -0
- package/lib/types/client/scm/DiffView.d.ts +45 -7
- package/lib/types/client/scm/actions.d.ts +31 -3
- package/lib/types/client/store.d.ts +112 -4
- package/lib/types/client/terminal-input.d.ts +23 -0
- package/lib/types/client/terminal-snippets.d.ts +86 -0
- package/lib/types/client/vsc/FindWidget.d.ts +6 -0
- package/lib/types/client/vsc/breadcrumb.d.ts +30 -0
- package/lib/types/client/vsc/change-marks.d.ts +16 -6
- package/lib/types/client/vsc/editor-caret.d.ts +32 -0
- package/lib/types/client/vsc/editor-keymap.d.ts +35 -1
- package/lib/types/client/vsc/editor-langs.d.ts +9 -0
- package/lib/types/client/vsc/editor-settings.d.ts +55 -0
- package/lib/types/client/vsc/image-preview.d.ts +36 -0
- package/lib/types/client/vsc/kit.d.ts +13 -0
- package/lib/types/client/vsc/save-shortcut.d.ts +21 -0
- package/lib/types/client/vsc/terminal-clipboard.d.ts +15 -0
- package/lib/types/client/vsc/terminal-line.d.ts +25 -0
- package/lib/types/client/vsc/terminal-links.d.ts +62 -0
- package/lib/types/client/vsc/terminal-theme.d.ts +48 -0
- package/lib/types/client/vsc/terminal-writer.d.ts +52 -0
- package/lib/types/forward.d.ts +12 -0
- package/lib/types/fs-ops.d.ts +42 -0
- package/lib/types/http.d.ts +2 -0
- package/lib/types/keygen.d.ts +9 -0
- package/lib/types/monitor.d.ts +8 -0
- package/lib/types/notices.d.ts +16 -1
- package/lib/types/p2/helper-rpc.d.ts +45 -0
- package/lib/types/pool.d.ts +25 -0
- package/lib/types/routes.d.ts +2 -0
- package/lib/types/store.d.ts +7 -0
- package/lib/types/terminal.d.ts +33 -1
- package/lib/types/view-settings.d.ts +5 -0
- package/lib/{worlds-B7gEDBzC.js → worlds-RG8K5eom.js} +113 -15
- package/package.json +2 -1
- package/src/client/CodeEditor.tsx +205 -10
- package/src/client/DirectoryFlow.tsx +16 -0
- package/src/client/DoctorPanel.tsx +70 -7
- package/src/client/EditorPane.tsx +545 -118
- package/src/client/FloatingPlaceholder.tsx +34 -5
- package/src/client/HostsView.tsx +12 -3
- package/src/client/RemoteDirectoryPicker.tsx +12 -0
- package/src/client/RemoteEditorView.tsx +14 -11
- package/src/client/RemoteExplorer.tsx +929 -40
- package/src/client/RemoteRoot.tsx +167 -147
- package/src/client/SearchView.tsx +8 -0
- package/src/client/TerminalSnippets.tsx +432 -0
- package/src/client/TerminalView.tsx +50 -1
- package/src/client/XTerm.tsx +228 -58
- package/src/client/api.ts +106 -13
- package/src/client/auto-open-remote.ts +11 -9
- package/src/client/changes/ChangesDock.tsx +188 -6
- package/src/client/changes/changes.css +10 -3
- package/src/client/changes/review-state.ts +34 -0
- package/src/client/connection.ts +29 -0
- package/src/client/downloads.ts +49 -4
- package/src/client/editor-capability.ts +42 -0
- package/src/client/i18n.ts +228 -12
- package/src/client/index.tsx +22 -6
- package/src/client/request-gate.ts +221 -0
- package/src/client/scm/CommitPane.tsx +20 -2
- package/src/client/scm/DiffView.tsx +343 -117
- package/src/client/scm/HistoryPanel.tsx +23 -2
- package/src/client/scm/RepoPicker.tsx +1 -1
- package/src/client/scm/ScmPanel.tsx +391 -87
- package/src/client/scm/actions.ts +95 -12
- package/src/client/store.tsx +537 -22
- package/src/client/terminal-input.ts +44 -0
- package/src/client/terminal-snippets.ts +216 -0
- package/src/client/ui.tsx +4 -0
- package/src/client/vsc/FindWidget.tsx +24 -9
- package/src/client/vsc/breadcrumb.tsx +339 -0
- package/src/client/vsc/change-marks.ts +93 -44
- package/src/client/vsc/editor-caret.ts +30 -0
- package/src/client/vsc/editor-keymap.ts +59 -1
- package/src/client/vsc/editor-langs.ts +20 -0
- package/src/client/vsc/editor-settings.ts +146 -0
- package/src/client/vsc/editor-theme.ts +4 -5
- package/src/client/vsc/file-icons.tsx +17 -3
- package/src/client/vsc/image-preview.tsx +110 -0
- package/src/client/vsc/kit.tsx +46 -10
- package/src/client/vsc/save-shortcut.ts +47 -1
- package/src/client/vsc/terminal-clipboard.ts +19 -0
- package/src/client/vsc/terminal-line.ts +101 -0
- package/src/client/vsc/terminal-links.ts +166 -0
- package/src/client/vsc/terminal-theme.ts +97 -0
- package/src/client/vsc/terminal-writer.ts +112 -0
- package/src/client/vsc/vsc.css +1078 -181
- package/src/forward.ts +47 -9
- package/src/fs-ops.ts +124 -4
- package/src/git-ops.ts +20 -3
- package/src/http.ts +35 -4
- package/src/keygen.ts +55 -4
- package/src/monitor.ts +13 -0
- package/src/notices.ts +23 -1
- package/src/p2/helper-rpc.ts +113 -7
- package/src/p2/worlds.ts +14 -1
- package/src/pool.ts +99 -27
- package/src/routes.ts +212 -43
- package/src/sftp.ts +51 -14
- package/src/store.ts +10 -0
- package/src/terminal.ts +225 -24
- package/src/view-settings.ts +50 -10
- package/lib/types/client/Dialog.d.ts +0 -14
- package/src/client/Dialog.tsx +0 -76
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
* Sidebar surface (better-sidebar tab, or the native right-Sidebar fallback):
|
|
3
3
|
* a VS Code-style activity rail plus one column that shows the active view.
|
|
4
4
|
*
|
|
5
|
-
* The editor
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
* The DOCKED editor is the default seat (`editorSurface === 'sidebar'`) and it
|
|
6
|
+
* is a FULL-COLUMN rail page — one view at a time, like the local sidebar
|
|
7
|
+
* plugin: opening a file switches the column to the editor, and closing its last
|
|
8
|
+
* file switches back to the directory. The conversation-view tab next to 轨迹 is
|
|
9
|
+
* the OPTIONAL full-width seat the editor's own button switches to.
|
|
10
10
|
*/
|
|
11
11
|
import type { Context } from '@deepseek-ai/cordis'
|
|
12
|
-
import { useCallback, useEffect, useRef, useState, type ReactNode } from 'react'
|
|
12
|
+
import { memo, useCallback, useEffect, useRef, useState, type ReactNode } from 'react'
|
|
13
13
|
import { api } from './api.ts'
|
|
14
14
|
import { ConnectionStatusChip } from './ConnectionStatus.tsx'
|
|
15
15
|
import { applyConnectionStatuses, isConnectionRecovery, setActiveConnectionAlias, useConnectionStatus, type ConnectionTrace } from './connection.ts'
|
|
16
|
-
import { EditorPane } from './EditorPane.tsx'
|
|
17
|
-
import { FloatingEditorPlaceholder } from './FloatingPlaceholder.tsx'
|
|
16
|
+
import { EditorPane as EditorPaneView } from './EditorPane.tsx'
|
|
17
|
+
import { FloatingEditorPlaceholder as FloatingEditorPlaceholderView } from './FloatingPlaceholder.tsx'
|
|
18
18
|
import { DownloadDock } from './DownloadDock.tsx'
|
|
19
19
|
import { PortsView, IconPlug } from './PortsView.tsx'
|
|
20
20
|
import { MonitorView, IconMonitor } from './MonitorView.tsx'
|
|
@@ -25,9 +25,20 @@ import { HistoryPanel } from './scm/HistoryPanel.tsx'
|
|
|
25
25
|
import { ScmPanel } from './scm/ScmPanel.tsx'
|
|
26
26
|
import { TerminalView } from './TerminalView.tsx'
|
|
27
27
|
import { WorkspacesView } from './WorkspacesView.tsx'
|
|
28
|
-
import {
|
|
28
|
+
import {
|
|
29
|
+
followSessionWorkspace,
|
|
30
|
+
refreshAfterReconnect,
|
|
31
|
+
selectWorkspace,
|
|
32
|
+
setFollowSession,
|
|
33
|
+
setView,
|
|
34
|
+
shallowEqual,
|
|
35
|
+
useBootstrap,
|
|
36
|
+
useExplorerSelector,
|
|
37
|
+
type ExplorerValue,
|
|
38
|
+
} from './store.tsx'
|
|
29
39
|
import { useRemoteChatTarget } from './use-remote-chat-target.ts'
|
|
30
40
|
import { DialogHost } from './vsc/kit.tsx'
|
|
41
|
+
import { FOREIGN_TARGET, isModalLayerOpen } from './vsc/save-shortcut.ts'
|
|
31
42
|
import {
|
|
32
43
|
IconBranch,
|
|
33
44
|
IconCode,
|
|
@@ -41,7 +52,6 @@ import {
|
|
|
41
52
|
|
|
42
53
|
type RailView = 'explorer' | 'search' | 'scm' | 'history' | 'editor' | 'terminal' | 'ports' | 'monitor' | 'workspaces'
|
|
43
54
|
|
|
44
|
-
const SPLIT_KEY = 'dsh-remote-vs.split'
|
|
45
55
|
const HIDDEN_KEY = 'dsh-remote-vs.showHidden'
|
|
46
56
|
|
|
47
57
|
/**
|
|
@@ -79,6 +89,81 @@ export function planRecoveryReload(
|
|
|
79
89
|
}
|
|
80
90
|
}
|
|
81
91
|
|
|
92
|
+
/**
|
|
93
|
+
* What the SHELL itself renders — and nothing else.
|
|
94
|
+
*
|
|
95
|
+
* The shell used to subscribe to the whole snapshot (`useExplorer()`), so every
|
|
96
|
+
* publish repainted it: a save (3-4 publishes), a git status refresh, a tab
|
|
97
|
+
* dirty flag. Each of those renders re-created the element for every KEPT-ALIVE
|
|
98
|
+
* panel (the wrapper is always mounted, see `panelFor`) and — because a function
|
|
99
|
+
* component re-renders whenever its parent does — rebuilt all ten panels,
|
|
100
|
+
* including the 4000-row SCM change list.
|
|
101
|
+
*
|
|
102
|
+
* This slice is exactly what the root chrome paints (rail badges and title,
|
|
103
|
+
* workspace picker, branch pill, busy spinner, banner) plus what its effects
|
|
104
|
+
* need (tabs for the recovery timer, workspaces/aliasPaths for the session
|
|
105
|
+
* follow, terminalRequest for the terminal page). `useExplorerSelector` +
|
|
106
|
+
* `shallowEqual` repaint the shell only when one of these changes; the panels
|
|
107
|
+
* are memoized below, so even when the shell DOES render they are skipped
|
|
108
|
+
* unless their own props changed.
|
|
109
|
+
*
|
|
110
|
+
* Module-level so its identity is stable: between publishes the hook's cache
|
|
111
|
+
* answers without running the selector.
|
|
112
|
+
*/
|
|
113
|
+
const selectShellStore = (snapshot: ExplorerValue) => ({
|
|
114
|
+
t: snapshot.t,
|
|
115
|
+
ready: snapshot.ready,
|
|
116
|
+
view: snapshot.view,
|
|
117
|
+
hosts: snapshot.hosts,
|
|
118
|
+
workspaces: snapshot.workspaces,
|
|
119
|
+
routing: snapshot.routing,
|
|
120
|
+
workspace: snapshot.workspace,
|
|
121
|
+
aliasPaths: snapshot.aliasPaths,
|
|
122
|
+
error: snapshot.error,
|
|
123
|
+
repoRoot: snapshot.repoRoot,
|
|
124
|
+
head: snapshot.head,
|
|
125
|
+
gitBusy: snapshot.gitBusy,
|
|
126
|
+
editorSurface: snapshot.editorSurface,
|
|
127
|
+
floatOpen: snapshot.floatOpen,
|
|
128
|
+
terminalRequest: snapshot.terminalRequest,
|
|
129
|
+
tabs: snapshot.tabs,
|
|
130
|
+
activeTab: snapshot.activeTab,
|
|
131
|
+
buckets: snapshot.buckets,
|
|
132
|
+
selectWorkspace: snapshot.selectWorkspace,
|
|
133
|
+
refreshAll: snapshot.refreshAll,
|
|
134
|
+
reloadTab: snapshot.reloadTab,
|
|
135
|
+
info: snapshot.info,
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* The kept-alive panels, memoized.
|
|
140
|
+
*
|
|
141
|
+
* `React.memo` compares PROPS shallowly: none of these panels is re-rendered
|
|
142
|
+
* just because their parent was — only when their own props changed. That is
|
|
143
|
+
* what makes the selector migration pay off, and it also covers local shell
|
|
144
|
+
* state (the Ctrl+P modal, `showHidden`, the IntersectionObserver's `live` bit)
|
|
145
|
+
* that used to drag every panel into a render.
|
|
146
|
+
*
|
|
147
|
+
* The props must therefore be STABLE while nothing changes for the panel:
|
|
148
|
+
* - `go`/`openHistory`/`openWorkspaceFiles`/`toggleHidden` below are
|
|
149
|
+
* `useCallback`s over module-level store actions, so they keep one identity;
|
|
150
|
+
* - the other props are strings, booleans or store references, compared with
|
|
151
|
+
* `Object.is` (and the store hands out the same reference until that value
|
|
152
|
+
* changes — see `selectShellStore`).
|
|
153
|
+
*
|
|
154
|
+
* `EditorPane` and `FloatingEditorPlaceholder` keep their original JSX names
|
|
155
|
+
* (a gate pins those call sites), so they are wrapped under their own name.
|
|
156
|
+
*/
|
|
157
|
+
const MemoSearchView = memo(SearchView)
|
|
158
|
+
const MemoScmPanel = memo(ScmPanel)
|
|
159
|
+
const MemoHistoryPanel = memo(HistoryPanel)
|
|
160
|
+
const MemoTerminalView = memo(TerminalView)
|
|
161
|
+
const MemoPortsView = memo(PortsView)
|
|
162
|
+
const MemoMonitorView = memo(MonitorView)
|
|
163
|
+
const MemoWorkspacesView = memo(WorkspacesView)
|
|
164
|
+
const EditorPane = memo(EditorPaneView)
|
|
165
|
+
const FloatingEditorPlaceholder = memo(FloatingEditorPlaceholderView)
|
|
166
|
+
|
|
82
167
|
export function RemoteRoot(props: { ctx: Context; visible?: boolean }): ReactNode {
|
|
83
168
|
useBootstrap(props.ctx)
|
|
84
169
|
return (
|
|
@@ -90,7 +175,7 @@ export function RemoteRoot(props: { ctx: Context; visible?: boolean }): ReactNod
|
|
|
90
175
|
}
|
|
91
176
|
|
|
92
177
|
function Shell(props: { ctx: Context; visible: boolean }): ReactNode {
|
|
93
|
-
const store =
|
|
178
|
+
const store = useExplorerSelector(selectShellStore, shallowEqual)
|
|
94
179
|
const t = store.t
|
|
95
180
|
// The active panel lives in the shared store so other surfaces (the tree's
|
|
96
181
|
// "Find in Folder…", the SCM panel's history shortcut) can switch it.
|
|
@@ -105,18 +190,6 @@ function Shell(props: { ctx: Context; visible: boolean }): ReactNode {
|
|
|
105
190
|
return false
|
|
106
191
|
}
|
|
107
192
|
})
|
|
108
|
-
const [split, setSplit] = useState<number>(() => {
|
|
109
|
-
try {
|
|
110
|
-
const saved = Number(localStorage.getItem(SPLIT_KEY))
|
|
111
|
-
return Number.isFinite(saved) && saved > 0.15 && saved < 0.9 ? saved : 0.45
|
|
112
|
-
} catch {
|
|
113
|
-
return 0.45
|
|
114
|
-
}
|
|
115
|
-
})
|
|
116
|
-
const splitRef = useRef(split)
|
|
117
|
-
const [dragging, setDragging] = useState(false)
|
|
118
|
-
const dragRef = useRef<{ startY: number; startRatio: number } | undefined>(undefined)
|
|
119
|
-
const columnRef = useRef<HTMLDivElement>(null)
|
|
120
193
|
|
|
121
194
|
/**
|
|
122
195
|
* Visibility is measured, not promised.
|
|
@@ -184,16 +257,35 @@ function Shell(props: { ctx: Context; visible: boolean }): ReactNode {
|
|
|
184
257
|
if (!(event.ctrlKey || event.metaKey)) return
|
|
185
258
|
if (event.altKey || event.shiftKey) return
|
|
186
259
|
if (event.key !== 'p' && event.key !== 'P') return
|
|
260
|
+
// Claimed even when the handler steps aside below: the browser's print
|
|
261
|
+
// dialog must never appear behind a layer that owns the keyboard.
|
|
187
262
|
event.preventDefault()
|
|
188
263
|
// Auto-repeat would flash the modal on a held key.
|
|
189
264
|
if (event.repeat) return
|
|
190
|
-
|
|
191
|
-
|
|
265
|
+
// While OUR modal is up, Ctrl+P is its documented "press again to leave",
|
|
266
|
+
// so the guards below (which belong to OPENING it) must not run.
|
|
267
|
+
if (!quickOpen) {
|
|
268
|
+
// A dialog or menu on screen owns the keyboard: opening QuickOpen over a
|
|
269
|
+
// host approval / the Settings dialog would steal the focus from the
|
|
270
|
+
// layer the user is answering (audit I-2).
|
|
271
|
+
if (isModalLayerOpen()) return
|
|
272
|
+
const focused = document.activeElement
|
|
273
|
+
if (focused instanceof HTMLElement && focused.closest('.xterm') !== null) return
|
|
274
|
+
// Every other text field keeps Ctrl+P too — the host's chat composer, a
|
|
275
|
+
// dialog input — i.e. the same FOREIGN_TARGET the save shortcut yields
|
|
276
|
+
// to, so both global shortcuts draw one line (audit I-11). Our own
|
|
277
|
+
// CodeMirror surface is the exception: editing is the state quick open is
|
|
278
|
+
// FOR, and CodeMirror marks its content `contenteditable`, which the
|
|
279
|
+
// shared list would otherwise turn into "Ctrl+P does nothing here".
|
|
280
|
+
if (focused instanceof HTMLElement
|
|
281
|
+
&& focused.closest(FOREIGN_TARGET) !== null
|
|
282
|
+
&& focused.closest('.cm-content') === null) return
|
|
283
|
+
}
|
|
192
284
|
setQuickOpen(open => !open)
|
|
193
285
|
}
|
|
194
286
|
window.addEventListener('keydown', onQuickOpenKey)
|
|
195
287
|
return () => window.removeEventListener('keydown', onQuickOpenKey)
|
|
196
|
-
}, [live, storeReady])
|
|
288
|
+
}, [live, storeReady, quickOpen])
|
|
197
289
|
|
|
198
290
|
/**
|
|
199
291
|
* Leaving the panel closes the modal.
|
|
@@ -206,9 +298,28 @@ function Shell(props: { ctx: Context; visible: boolean }): ReactNode {
|
|
|
206
298
|
if (!live) setQuickOpen(false)
|
|
207
299
|
}, [live])
|
|
208
300
|
|
|
301
|
+
/**
|
|
302
|
+
* Stable identities for the panel props below: a `useCallback` over a
|
|
303
|
+
* MODULE-level store action (`setView`/`selectWorkspace`), not over the slice
|
|
304
|
+
* object — the slice changes whenever any chrome field does, which would make
|
|
305
|
+
* every prop refresh and defeat `React.memo` on the panels.
|
|
306
|
+
*/
|
|
209
307
|
const go = useCallback((next: RailView): void => {
|
|
210
|
-
|
|
211
|
-
}, [
|
|
308
|
+
setView(next)
|
|
309
|
+
}, [])
|
|
310
|
+
/** The SCM panel's "history →" shortcut (stable, see above). */
|
|
311
|
+
const openHistory = useCallback((): void => {
|
|
312
|
+
setView('history')
|
|
313
|
+
}, [])
|
|
314
|
+
/** The workspace wizard's "open files" (stable, see above). */
|
|
315
|
+
const openWorkspaceFiles = useCallback((value: string): void => {
|
|
316
|
+
selectWorkspace(value)
|
|
317
|
+
setView('explorer')
|
|
318
|
+
}, [])
|
|
319
|
+
/** Arrow for `RemoteExplorer`'s "show hidden" toggle (stable, see above). */
|
|
320
|
+
const toggleHidden = useCallback((): void => {
|
|
321
|
+
setShowHidden(v => !v)
|
|
322
|
+
}, [])
|
|
212
323
|
|
|
213
324
|
/**
|
|
214
325
|
* Connection status: point the client view at the workspace's host and poll
|
|
@@ -254,8 +365,9 @@ function Shell(props: { ctx: Context; visible: boolean }): ReactNode {
|
|
|
254
365
|
* user's edits away) and the user is told so. Read-only DIFF tabs have no
|
|
255
366
|
* unsaved edits, so they are reloaded like clean file tabs.
|
|
256
367
|
*
|
|
257
|
-
* Deps are intentionally just the state:
|
|
258
|
-
*
|
|
368
|
+
* Deps are intentionally just the connection state: the store slice changes
|
|
369
|
+
* whenever any chrome field does, and re-running this on those changes would
|
|
370
|
+
* re-fire the refresh loop.
|
|
259
371
|
*/
|
|
260
372
|
const lastConnection = useRef<ConnectionTrace | undefined>(undefined)
|
|
261
373
|
// Live mirrors for the settle timer below (it fires long after the effect ran).
|
|
@@ -339,27 +451,6 @@ function Shell(props: { ctx: Context; visible: boolean }): ReactNode {
|
|
|
339
451
|
})
|
|
340
452
|
}, [target.sessionId, target.sessionWorkspacePath, store.ready, store.workspaces, store.aliasPaths])
|
|
341
453
|
|
|
342
|
-
/**
|
|
343
|
-
* The mount surface owns the editor, so a persisted `view === 'editor'` is
|
|
344
|
-
* only reachable where the sidebar still holds the editor.
|
|
345
|
-
*
|
|
346
|
-
* `view` is restored from localStorage (where 'editor' is an allowed value)
|
|
347
|
-
* and `editorSurface` starts as 'sidebar' before index.tsx flips it once the
|
|
348
|
-
* conversation-view slot registers. A profile that last used the fallback
|
|
349
|
-
* layout therefore came back with `view === 'editor'` while the rail button
|
|
350
|
-
* that owns it was gone AND the centre tab mounted a second EditorPane on
|
|
351
|
-
* the same store tab — two live buffers with independent undo state, the one
|
|
352
|
-
* state this file declares must never happen.
|
|
353
|
-
*
|
|
354
|
-
* Only the CENTRE pixel surface triggers this redirect. While the editor
|
|
355
|
-
* floats the sidebar keeps whatever view it had: the editor panel renders a
|
|
356
|
-
* "docked elsewhere" placeholder (see panelFor), and on docking the user
|
|
357
|
-
* lands back where they were.
|
|
358
|
-
*/
|
|
359
|
-
useEffect(() => {
|
|
360
|
-
if (store.editorSurface === 'center' && view === 'editor') go('explorer')
|
|
361
|
-
}, [store.editorSurface, view, go])
|
|
362
|
-
|
|
363
454
|
useEffect(() => {
|
|
364
455
|
try {
|
|
365
456
|
localStorage.setItem(HIDDEN_KEY, showHidden ? '1' : '0')
|
|
@@ -368,42 +459,6 @@ function Shell(props: { ctx: Context; visible: boolean }): ReactNode {
|
|
|
368
459
|
}
|
|
369
460
|
}, [showHidden])
|
|
370
461
|
|
|
371
|
-
const onDividerDown = (e: React.PointerEvent<HTMLDivElement>): void => {
|
|
372
|
-
if (e.button !== 0) return
|
|
373
|
-
e.preventDefault()
|
|
374
|
-
try {
|
|
375
|
-
e.currentTarget.setPointerCapture(e.pointerId)
|
|
376
|
-
} catch {
|
|
377
|
-
// Older engine: the buttons gate below covers it.
|
|
378
|
-
}
|
|
379
|
-
dragRef.current = { startY: e.clientY, startRatio: splitRef.current }
|
|
380
|
-
setDragging(true)
|
|
381
|
-
}
|
|
382
|
-
const onDividerMove = (e: React.PointerEvent<HTMLDivElement>): void => {
|
|
383
|
-
const drag = dragRef.current
|
|
384
|
-
if (drag === undefined) return
|
|
385
|
-
if ((e.buttons & 1) === 0) {
|
|
386
|
-
dragRef.current = undefined
|
|
387
|
-
setDragging(false)
|
|
388
|
-
return
|
|
389
|
-
}
|
|
390
|
-
const total = columnRef.current?.clientHeight ?? 0
|
|
391
|
-
if (total < 200) return
|
|
392
|
-
const next = Math.min(0.88, Math.max(0.12, drag.startRatio + (e.clientY - drag.startY) / total))
|
|
393
|
-
splitRef.current = next
|
|
394
|
-
setSplit(next)
|
|
395
|
-
}
|
|
396
|
-
const onDividerEnd = (): void => {
|
|
397
|
-
if (dragRef.current === undefined) return
|
|
398
|
-
dragRef.current = undefined
|
|
399
|
-
setDragging(false)
|
|
400
|
-
try {
|
|
401
|
-
localStorage.setItem(SPLIT_KEY, String(splitRef.current))
|
|
402
|
-
} catch {
|
|
403
|
-
// Ignore.
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
|
|
407
462
|
if (!store.ready) {
|
|
408
463
|
return (
|
|
409
464
|
<div className="rvs-root">
|
|
@@ -413,8 +468,6 @@ function Shell(props: { ctx: Context; visible: boolean }): ReactNode {
|
|
|
413
468
|
}
|
|
414
469
|
|
|
415
470
|
const editorInSidebar = store.editorSurface === 'sidebar'
|
|
416
|
-
const browsing = view === 'explorer' || view === 'search' || view === 'scm' || view === 'history'
|
|
417
|
-
const showEditorWithView = editorInSidebar && browsing && store.tabs.length > 0
|
|
418
471
|
|
|
419
472
|
/**
|
|
420
473
|
* One panel body. Every visited panel stays MOUNTED (hidden by CSS), which
|
|
@@ -424,74 +477,68 @@ function Shell(props: { ctx: Context; visible: boolean }): ReactNode {
|
|
|
424
477
|
*/
|
|
425
478
|
const panelFor = (id: RailView): ReactNode => {
|
|
426
479
|
switch (id) {
|
|
427
|
-
case 'search': return <
|
|
428
|
-
case 'scm': return <
|
|
429
|
-
case 'history': return <
|
|
480
|
+
case 'search': return <MemoSearchView />
|
|
481
|
+
case 'scm': return <MemoScmPanel onOpenHistory={openHistory} visible={panelLive('scm')} />
|
|
482
|
+
case 'history': return <MemoHistoryPanel />
|
|
430
483
|
case 'terminal':
|
|
431
484
|
// The terminal draws its own header + tab strip, so it takes the whole
|
|
432
485
|
// slot (no extra padding wrapper).
|
|
433
|
-
return <
|
|
486
|
+
return <MemoTerminalView t={t} hosts={store.hosts} visible={panelLive('terminal')} request={store.terminalRequest} />
|
|
434
487
|
case 'ports':
|
|
435
488
|
// Same shape as the terminal: its own header (host picker + refresh) and
|
|
436
489
|
// its own scroller, so no viewpad wrapper either.
|
|
437
|
-
return <
|
|
490
|
+
return <MemoPortsView t={t} hosts={store.hosts} visible={panelLive('ports')} />
|
|
438
491
|
case 'monitor':
|
|
439
492
|
// Live host metrics: own header (scope picker + refresh/pause) and its
|
|
440
493
|
// own scroller. Cross-host by design, so it reads `store.hosts` rather
|
|
441
494
|
// than the current binding.
|
|
442
|
-
return <
|
|
495
|
+
return <MemoMonitorView t={t} hosts={store.hosts} visible={panelLive('monitor')} />
|
|
443
496
|
case 'workspaces':
|
|
444
497
|
return (
|
|
445
498
|
<div className="rvs-viewpad" style={{ height: '100%' }}>
|
|
446
|
-
<
|
|
499
|
+
<MemoWorkspacesView
|
|
447
500
|
t={t}
|
|
448
501
|
hosts={store.hosts}
|
|
449
502
|
workspaces={store.workspaces}
|
|
450
503
|
routing={store.routing}
|
|
451
504
|
onChanged={store.refreshAll}
|
|
452
|
-
onOpenFiles={
|
|
505
|
+
onOpenFiles={openWorkspaceFiles}
|
|
453
506
|
/>
|
|
454
507
|
</div>
|
|
455
508
|
)
|
|
456
509
|
case 'editor':
|
|
457
|
-
// The
|
|
458
|
-
//
|
|
459
|
-
//
|
|
510
|
+
// The docked editor is the DEFAULT seat: opening a file switches this
|
|
511
|
+
// column to this page, so the editor owns the whole sidebar instead of
|
|
512
|
+
// sharing it with the tree. It must not render while the centre surface
|
|
460
513
|
// or the floating window owns the editor: all of them read the same
|
|
461
514
|
// store, so two live editors for one tab fight over the scroll position
|
|
462
515
|
// and the hidden one — sitting at scrollTop 0 — wins, which is exactly
|
|
463
516
|
// why a tab switch kept snapping back to the top of the file.
|
|
464
517
|
if (editorInSidebar) return <EditorPane visible={panelLive('editor')} />
|
|
465
|
-
//
|
|
466
|
-
//
|
|
467
|
-
return store.floatOpen ?
|
|
518
|
+
// The editor lives elsewhere: the panel stays reachable (so docking
|
|
519
|
+
// returns here) but says where it went and how to bring it back.
|
|
520
|
+
return <FloatingEditorPlaceholder mode={store.floatOpen ? 'float' : 'center'} />
|
|
468
521
|
default:
|
|
469
522
|
return (
|
|
470
523
|
<RemoteExplorer
|
|
471
524
|
showHidden={showHidden}
|
|
472
|
-
onToggleHidden={
|
|
525
|
+
onToggleHidden={toggleHidden}
|
|
473
526
|
visible={panelLive('explorer')}
|
|
474
527
|
/>
|
|
475
528
|
)
|
|
476
529
|
}
|
|
477
530
|
}
|
|
478
531
|
|
|
479
|
-
// Without a conversation-view slot the editor has no center tab, so it keeps
|
|
480
|
-
// its rail entry (and the split) — the older layout, still fully reachable.
|
|
481
|
-
const editorInStack = editorInSidebar && !showEditorWithView
|
|
482
|
-
|
|
483
532
|
const panel = (
|
|
484
533
|
<div className="rvs-pane grow">
|
|
485
534
|
{[...mounted].map(id => (
|
|
486
535
|
<div
|
|
487
536
|
key={id}
|
|
488
537
|
className="rvs-viewslot"
|
|
489
|
-
//
|
|
490
|
-
//
|
|
491
|
-
//
|
|
492
|
-
|
|
493
|
-
// that is also what keeps two live buffers from fighting.
|
|
494
|
-
style={{ display: view === id && !(showEditorWithView && id === 'editor') ? 'flex' : 'none' }}
|
|
538
|
+
// Kept MOUNTED and only hidden: removing a panel from this list
|
|
539
|
+
// unmounted it, so switching rail pages rebuilt the editor and
|
|
540
|
+
// dropped its local undo/scroll state (and re-listed the tree).
|
|
541
|
+
style={{ display: view === id ? 'flex' : 'none' }}
|
|
495
542
|
>
|
|
496
543
|
{panelFor(id)}
|
|
497
544
|
</div>
|
|
@@ -523,14 +570,15 @@ function Shell(props: { ctx: Context; visible: boolean }): ReactNode {
|
|
|
523
570
|
{railButton('scm', t('tab.git'), <IconBranch size={17} />, store.buckets.total)}
|
|
524
571
|
{railButton('history', t('tab.history'), <IconHistory size={17} />)}
|
|
525
572
|
<div className="rvs-rail-sep" />
|
|
526
|
-
{
|
|
527
|
-
|
|
573
|
+
{/* Always present, like the local sidebar: with no file open it is the
|
|
574
|
+
empty state, and a click from anywhere lands on the editor again. */}
|
|
575
|
+
{railButton('editor', store.activeTab?.rel.split('/').pop() ?? t('tab.editor'), <IconDiff size={17} />, store.tabs.length)}
|
|
528
576
|
{railButton('terminal', t('tab.terminal'), <IconTerminal size={17} />)}
|
|
529
577
|
{railButton('ports', t('tab.ports'), <IconPlug size={17} />)}
|
|
530
578
|
{railButton('monitor', t('tab.monitor'), <IconMonitor size={17} />)}
|
|
531
579
|
{railButton('workspaces', t('tab.workspaces'), <IconServer size={17} />, store.workspaces.length)}
|
|
532
580
|
</div>
|
|
533
|
-
<div className="rvs-column"
|
|
581
|
+
<div className="rvs-column">
|
|
534
582
|
<div className="rvs-globalbar">
|
|
535
583
|
<select
|
|
536
584
|
className="rvs-select"
|
|
@@ -552,38 +600,10 @@ function Shell(props: { ctx: Context; visible: boolean }): ReactNode {
|
|
|
552
600
|
)}
|
|
553
601
|
{store.gitBusy && <MiniSpinner />}
|
|
554
602
|
</div>
|
|
555
|
-
{store.error !== undefined && <div className="rvs-banner error">{store.error}</div>}
|
|
556
|
-
|
|
557
|
-
It used to swap a Fragment for a `div` here, and React reconciles
|
|
558
|
-
by type — so every flip deleted and remounted the whole subtree,
|
|
559
|
-
which is the kept-alive panel stack (`panel` below). Consequences
|
|
560
|
-
were exactly what the keep-alive design exists to prevent: the
|
|
561
|
-
explorer re-listed over SFTP and lost its expansion, and every
|
|
562
|
-
xterm was torn down and rebuilt, closing its WebSocket and
|
|
563
|
-
orphaning a tab whose session id had not arrived yet. Same element,
|
|
564
|
-
different props, always. */}
|
|
565
|
-
<div
|
|
566
|
-
className="rvs-pane"
|
|
567
|
-
style={showEditorWithView ? { height: `${Math.round(split * 1000) / 10}%`, flex: 'none', minHeight: 0 } : { flex: 1, minHeight: 0 }}
|
|
568
|
-
>
|
|
603
|
+
{store.error !== undefined && <div className="rvs-banner error" role="status">{store.error}</div>}
|
|
604
|
+
<div className="rvs-pane" style={{ flex: 1, minHeight: 0 }}>
|
|
569
605
|
{panel}
|
|
570
606
|
</div>
|
|
571
|
-
{showEditorWithView && (
|
|
572
|
-
<>
|
|
573
|
-
<div
|
|
574
|
-
className="rvs-vsplit-handle"
|
|
575
|
-
data-dragging={dragging ? 'true' : 'false'}
|
|
576
|
-
onPointerDown={onDividerDown}
|
|
577
|
-
onPointerMove={onDividerMove}
|
|
578
|
-
onPointerUp={onDividerEnd}
|
|
579
|
-
onPointerCancel={onDividerEnd}
|
|
580
|
-
title={t('editor.resizeHint')}
|
|
581
|
-
/>
|
|
582
|
-
<div className="rvs-pane grow">
|
|
583
|
-
<EditorPane visible={live} />
|
|
584
|
-
</div>
|
|
585
|
-
</>
|
|
586
|
-
)}
|
|
587
607
|
</div>
|
|
588
608
|
</div>
|
|
589
609
|
)
|
|
@@ -507,6 +507,14 @@ export function SearchView(): ReactNode {
|
|
|
507
507
|
spellCheck={false}
|
|
508
508
|
onChange={(e) => setQuery(e.target.value)}
|
|
509
509
|
onKeyDown={(e) => {
|
|
510
|
+
// An IME candidate window uses Enter to pick a character and Escape
|
|
511
|
+
// to drop it. Searching then would submit a half-composed query,
|
|
512
|
+
// and clearing the field would wipe the composing text; skipping
|
|
513
|
+
// preventDefault keeps the candidate commit alive. `isComposing` is
|
|
514
|
+
// the platform-agnostic signal; `keyCode === 229` is the fallback
|
|
515
|
+
// for engines that dispatch compositionend before this keydown
|
|
516
|
+
// (Chrome), so that one Enter cannot run twice.
|
|
517
|
+
if (e.nativeEvent.isComposing === true || e.keyCode === 229) return
|
|
510
518
|
if (e.key === 'Enter') {
|
|
511
519
|
e.preventDefault()
|
|
512
520
|
void run(query, mode, effectiveScope, options)
|