dsh-remote-vs 0.23.0 → 0.25.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.
Files changed (81) hide show
  1. package/README.en.md +49 -15
  2. package/README.md +40 -14
  3. package/lib/client.js +45978 -43338
  4. package/lib/index.js +388 -90
  5. package/lib/p2-router-fs.js +1 -1
  6. package/lib/types/client/CodeEditor.d.ts +17 -0
  7. package/lib/types/client/EditorPane.d.ts +16 -5
  8. package/lib/types/client/FloatingPlaceholder.d.ts +16 -5
  9. package/lib/types/client/RemoteEditorView.d.ts +13 -10
  10. package/lib/types/client/RemoteRoot.d.ts +5 -5
  11. package/lib/types/client/SettingsHosts.d.ts +3 -0
  12. package/lib/types/client/TerminalSnippets.d.ts +36 -0
  13. package/lib/types/client/TerminalView.d.ts +1 -1
  14. package/lib/types/client/XTerm.d.ts +33 -0
  15. package/lib/types/client/api.d.ts +4 -1
  16. package/lib/types/client/auto-open-remote.d.ts +41 -0
  17. package/lib/types/client/editor-capability.d.ts +27 -0
  18. package/lib/types/client/i18n.d.ts +1 -1
  19. package/lib/types/client/store.d.ts +59 -4
  20. package/lib/types/client/terminal-input.d.ts +23 -0
  21. package/lib/types/client/terminal-snippets.d.ts +86 -0
  22. package/lib/types/client/use-remote-chat-target.d.ts +2 -0
  23. package/lib/types/client/view-settings.d.ts +40 -0
  24. package/lib/types/client/vsc/breadcrumb.d.ts +30 -0
  25. package/lib/types/client/vsc/editor-caret.d.ts +32 -0
  26. package/lib/types/client/vsc/editor-langs.d.ts +9 -0
  27. package/lib/types/client/vsc/editor-settings.d.ts +55 -0
  28. package/lib/types/client/vsc/image-preview.d.ts +36 -0
  29. package/lib/types/client/vsc/kit.d.ts +2 -0
  30. package/lib/types/client/vsc/terminal-clipboard.d.ts +15 -0
  31. package/lib/types/client/vsc/terminal-line.d.ts +25 -0
  32. package/lib/types/client/vsc/terminal-links.d.ts +62 -0
  33. package/lib/types/client/vsc/terminal-theme.d.ts +22 -0
  34. package/lib/types/client/vsc/terminal-writer.d.ts +52 -0
  35. package/lib/types/paths.d.ts +9 -0
  36. package/lib/types/pool.d.ts +25 -0
  37. package/lib/types/protocol.d.ts +35 -0
  38. package/lib/types/routes.d.ts +7 -0
  39. package/lib/types/terminal.d.ts +25 -1
  40. package/lib/types/view-settings.d.ts +26 -0
  41. package/lib/{worlds-DXdP4SMn.js → worlds-B7gEDBzC.js} +13 -1
  42. package/package.json +36 -36
  43. package/src/client/CodeEditor.tsx +54 -2
  44. package/src/client/EditorPane.tsx +485 -107
  45. package/src/client/FloatingPlaceholder.tsx +34 -5
  46. package/src/client/RemoteEditorView.tsx +14 -11
  47. package/src/client/RemoteRoot.tsx +20 -125
  48. package/src/client/SettingsHosts.tsx +81 -3
  49. package/src/client/TerminalSnippets.tsx +357 -0
  50. package/src/client/TerminalView.tsx +50 -1
  51. package/src/client/XTerm.tsx +228 -58
  52. package/src/client/api.ts +7 -0
  53. package/src/client/auto-open-remote.ts +439 -0
  54. package/src/client/editor-capability.ts +42 -0
  55. package/src/client/i18n.ts +158 -6
  56. package/src/client/index.tsx +30 -6
  57. package/src/client/store.tsx +165 -13
  58. package/src/client/terminal-input.ts +44 -0
  59. package/src/client/terminal-snippets.ts +216 -0
  60. package/src/client/use-remote-chat-target.ts +1 -1
  61. package/src/client/view-settings.ts +99 -0
  62. package/src/client/vsc/breadcrumb.tsx +251 -0
  63. package/src/client/vsc/editor-caret.ts +30 -0
  64. package/src/client/vsc/editor-langs.ts +20 -0
  65. package/src/client/vsc/editor-settings.ts +146 -0
  66. package/src/client/vsc/editor-theme.ts +4 -5
  67. package/src/client/vsc/image-preview.tsx +110 -0
  68. package/src/client/vsc/kit.tsx +20 -1
  69. package/src/client/vsc/terminal-clipboard.ts +19 -0
  70. package/src/client/vsc/terminal-line.ts +101 -0
  71. package/src/client/vsc/terminal-links.ts +166 -0
  72. package/src/client/vsc/terminal-theme.ts +71 -0
  73. package/src/client/vsc/terminal-writer.ts +112 -0
  74. package/src/client/vsc/vsc.css +687 -48
  75. package/src/index.ts +6 -0
  76. package/src/paths.ts +13 -0
  77. package/src/pool.ts +99 -27
  78. package/src/protocol.ts +45 -0
  79. package/src/routes.ts +47 -0
  80. package/src/terminal.ts +160 -6
  81. package/src/view-settings.ts +133 -0
@@ -0,0 +1,357 @@
1
+ /**
2
+ * The "常用指令" panel above the terminal: a personal library of NAME + COMMAND
3
+ * pairs that paste into the active terminal's command line WITHOUT pressing
4
+ * Enter (misclick safety: the user still reviews and runs it).
5
+ *
6
+ * Why it is a popover rather than a dock: the terminal needs the whole column
7
+ * for output; the list is opened deliberately, used once, and dismissed. The
8
+ * panel is portaled with fixed coordinates so the terminal's own scroller and
9
+ * the sidebar's `overflow: hidden` cannot clip it.
10
+ *
11
+ * Snapshot + subscribe come from `terminal-snippets.ts` (one list shared with the
12
+ * Ctrl+B quick-add shortcut, which `XTerm` reports as a counter prop).
13
+ */
14
+ import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore, type ReactNode } from 'react'
15
+ import { createPortal } from 'react-dom'
16
+ import {
17
+ addSnippet,
18
+ moveSnippet,
19
+ removeSnippet,
20
+ snippetsSnapshot,
21
+ subscribeSnippets,
22
+ updateSnippet,
23
+ updateSnippets,
24
+ type TerminalSnippet,
25
+ } from './terminal-snippets.ts'
26
+ import { confirmDialog } from './vsc/kit.tsx'
27
+
28
+ /** Props of the panel (plus the button that opens it). */
29
+ export interface TerminalSnippetsProps {
30
+ /** Translator. */
31
+ t: (key: string) => string
32
+ /** Insert one command into the active terminal; false when none is mounted. */
33
+ onInsert: (command: string) => boolean
34
+ /** Bumped by the Ctrl+B shortcut; each change opens the ADD dialog. */
35
+ addRequest: number
36
+ /**
37
+ * Draft the Ctrl+B form starts with (the terminal selection, else the line
38
+ * reconstructed from keystrokes). Empty for the panel's own "+" button.
39
+ */
40
+ addContent: string
41
+ }
42
+
43
+ /** Where the popover is anchored (viewport coordinates of the button). */
44
+ interface Anchor {
45
+ left: number
46
+ top: number
47
+ width: number
48
+ }
49
+
50
+ /** What the form dialog is doing. */
51
+ type FormState = { mode: 'add'; content: string } | { mode: 'edit'; snippet: TerminalSnippet }
52
+
53
+ /** One row, identified for drag & drop. */
54
+ interface DragState {
55
+ from: number
56
+ }
57
+
58
+ /**
59
+ * The panel.
60
+ *
61
+ * Kept in one component on purpose: the button, the popover, the form and their
62
+ * shared focus/dismissal rules are one interaction, and splitting them would
63
+ * need a context for four pieces of state.
64
+ */
65
+ export function TerminalSnippets(props: TerminalSnippetsProps): ReactNode {
66
+ const t = props.t
67
+ const items = useSyncExternalStore(subscribeSnippets, snippetsSnapshot, snippetsSnapshot)
68
+ const [anchor, setAnchor] = useState<Anchor | undefined>(undefined)
69
+ const [form, setForm] = useState<FormState | undefined>(undefined)
70
+ const [drag, setDrag] = useState<DragState | undefined>(undefined)
71
+ const [dropIndex, setDropIndex] = useState<number | undefined>(undefined)
72
+ const buttonRef = useRef<HTMLButtonElement>(null)
73
+ const panelRef = useRef<HTMLDivElement>(null)
74
+ /** Latest `addRequest` already handled (the prop is a counter, not an event). */
75
+ const handledAdd = useRef(props.addRequest)
76
+
77
+ /** Open the panel under the button. */
78
+ const openPanel = useCallback((): void => {
79
+ const rect = buttonRef.current?.getBoundingClientRect()
80
+ if (rect === undefined || rect === null) return
81
+ setAnchor({ left: Math.max(4, rect.left), top: rect.bottom + 4, width: 300 })
82
+ }, [])
83
+
84
+ const closePanel = useCallback((): void => {
85
+ setAnchor(undefined)
86
+ setDrag(undefined)
87
+ setDropIndex(undefined)
88
+ }, [])
89
+
90
+ // Ctrl+B from the terminal: open the ADD form (and the panel behind it) with
91
+ // the draft the terminal handed over — selection first, else the typed line.
92
+ useEffect(() => {
93
+ if (props.addRequest === handledAdd.current) return
94
+ handledAdd.current = props.addRequest
95
+ openPanel()
96
+ setForm({ mode: 'add', content: props.addContent })
97
+ }, [props.addRequest, props.addContent, openPanel])
98
+
99
+ // Close on outside click / Esc / window resize (a fixed popover would be left
100
+ // pointing at nothing). Capture phase so xterm's own mousedown cannot refocus
101
+ // the terminal first, which would make the panel look unclosable.
102
+ useEffect(() => {
103
+ if (anchor === undefined) return
104
+ const onMouseDown = (event: MouseEvent): void => {
105
+ const target = event.target
106
+ if (!(target instanceof Node)) return
107
+ if (panelRef.current?.contains(target) === true) return
108
+ if (buttonRef.current?.contains(target) === true) return
109
+ closePanel()
110
+ }
111
+ const onKeyDown = (event: KeyboardEvent): void => {
112
+ if (event.isComposing) return
113
+ if (event.key === 'Escape' && form === undefined) closePanel()
114
+ }
115
+ const onResize = (): void => closePanel()
116
+ document.addEventListener('mousedown', onMouseDown, true)
117
+ document.addEventListener('keydown', onKeyDown, true)
118
+ window.addEventListener('resize', onResize)
119
+ return () => {
120
+ document.removeEventListener('mousedown', onMouseDown, true)
121
+ document.removeEventListener('keydown', onKeyDown, true)
122
+ window.removeEventListener('resize', onResize)
123
+ }
124
+ }, [anchor, form, closePanel])
125
+
126
+ /** Paste one command and get out of the way. */
127
+ const insert = (snippet: TerminalSnippet): void => {
128
+ if (!props.onInsert(snippet.command)) {
129
+ // No mounted terminal for the active tab: the caller says so; the panel
130
+ // stays open so the click can be retried.
131
+ window.setTimeout(() => { setForm(undefined) }, 0)
132
+ return
133
+ }
134
+ closePanel()
135
+ }
136
+
137
+ const requestDelete = (snippet: TerminalSnippet): void => {
138
+ void confirmDialog({
139
+ title: t('term.snippetDeleteTitle'),
140
+ text: snippet.name,
141
+ danger: true,
142
+ okText: t('term.snippetDelete'),
143
+ }).then((ok) => {
144
+ if (ok) updateSnippets(list => removeSnippet(list, snippet.id))
145
+ })
146
+ }
147
+
148
+ /** Move one row by keyboard (Alt+Arrow) — the accessible twin of dragging. */
149
+ const moveBy = (index: number, direction: -1 | 1): void => {
150
+ updateSnippets(list => moveSnippet(list, index, index + direction))
151
+ }
152
+
153
+ const panel = anchor === undefined
154
+ ? undefined
155
+ : createPortal(
156
+ <div
157
+ ref={panelRef}
158
+ className="rvs-portal rvs-snips-panel"
159
+ role="dialog"
160
+ aria-label={t('term.snippets')}
161
+ style={{ left: `${anchor.left}px`, top: `${anchor.top}px`, width: `${anchor.width}px` }}
162
+ >
163
+ <div className="rvs-snips-head">
164
+ <span className="rvs-snips-title">⚡ {t('term.snippets')}</span>
165
+ <span className="rvs-snips-spacer" />
166
+ <button
167
+ type="button"
168
+ className="rvs-snips-add"
169
+ title={t('term.snippetAdd')}
170
+ aria-label={t('term.snippetAdd')}
171
+ onClick={() => setForm({ mode: 'add', content: '' })}
172
+ >+</button>
173
+ </div>
174
+ <div className="rvs-snips-list">
175
+ {items.length === 0 && (
176
+ <div className="rvs-snips-empty">{t('term.snippetEmpty')}</div>
177
+ )}
178
+ {items.map((snippet, index) => (
179
+ <div
180
+ key={snippet.id}
181
+ className={`rvs-snips-row${dropIndex === index && drag !== undefined ? ' drop' : ''}`}
182
+ draggable
183
+ onDragStart={(event) => {
184
+ setDrag({ from: index })
185
+ event.dataTransfer.effectAllowed = 'move'
186
+ event.dataTransfer.setData('text/plain', String(index))
187
+ }}
188
+ onDragOver={(event) => {
189
+ if (drag === undefined) return
190
+ event.preventDefault()
191
+ event.dataTransfer.dropEffect = 'move'
192
+ setDropIndex(index)
193
+ }}
194
+ onDrop={(event) => {
195
+ event.preventDefault()
196
+ const from = Number(event.dataTransfer.getData('text/plain'))
197
+ setDrag(undefined)
198
+ setDropIndex(undefined)
199
+ if (Number.isFinite(from)) updateSnippets(list => moveSnippet(list, from, index))
200
+ }}
201
+ onDragEnd={() => { setDrag(undefined); setDropIndex(undefined) }}
202
+ >
203
+ <span
204
+ className="rvs-snips-grip"
205
+ title={t('term.snippetDragHint')}
206
+ role="button"
207
+ aria-label={t('term.snippetDragHint')}
208
+ tabIndex={0}
209
+ onKeyDown={(event) => {
210
+ if (event.altKey && event.key === 'ArrowUp') { event.preventDefault(); moveBy(index, -1) }
211
+ if (event.altKey && event.key === 'ArrowDown') { event.preventDefault(); moveBy(index, 1) }
212
+ }}
213
+ >⠿</span>
214
+ <button
215
+ type="button"
216
+ className="rvs-snips-insert"
217
+ title={`${t('term.snippetInsertHint')}\n${snippet.command}`}
218
+ onClick={() => insert(snippet)}
219
+ >
220
+ <span className="rvs-snips-name">{snippet.name}</span>
221
+ <span className="rvs-snips-arrow" aria-hidden="true">--&gt;</span>
222
+ <span className="rvs-snips-text">{snippet.command}</span>
223
+ </button>
224
+ <button
225
+ type="button"
226
+ className="rvs-snips-icon"
227
+ title={t('term.snippetEdit')}
228
+ aria-label={t('term.snippetEdit')}
229
+ onClick={() => setForm({ mode: 'edit', snippet })}
230
+ >✎</button>
231
+ <button
232
+ type="button"
233
+ className="rvs-snips-icon danger"
234
+ title={t('term.snippetDelete')}
235
+ aria-label={t('term.snippetDelete')}
236
+ onClick={() => requestDelete(snippet)}
237
+ >×</button>
238
+ </div>
239
+ ))}
240
+ </div>
241
+ <div className="rvs-snips-foot">{t('term.snippetFootHint')}</div>
242
+ </div>,
243
+ document.body,
244
+ )
245
+
246
+ return (
247
+ <>
248
+ <button
249
+ ref={buttonRef}
250
+ type="button"
251
+ className="rvs-hbtn rvs-snips-btn"
252
+ title={t('term.snippets')}
253
+ aria-label={t('term.snippets')}
254
+ onClick={() => { if (anchor === undefined) openPanel(); else closePanel() }}
255
+ >
256
+ <span aria-hidden="true">⚡</span> {t('term.snippets')}
257
+ </button>
258
+ {panel}
259
+ {form !== undefined && (
260
+ <SnippetForm
261
+ t={t}
262
+ mode={form.mode}
263
+ {...(form.mode === 'edit' ? { snippet: form.snippet } : { initialCommand: form.content })}
264
+ onCancel={() => setForm(undefined)}
265
+ onSubmit={(input) => {
266
+ if (form.mode === 'add') {
267
+ updateSnippets(list => addSnippet(list, input))
268
+ } else {
269
+ updateSnippets(list => updateSnippet(list, form.snippet.id, input))
270
+ }
271
+ setForm(undefined)
272
+ closePanel()
273
+ }}
274
+ />
275
+ )}
276
+ </>
277
+ )
278
+ }
279
+
280
+ /** The add / edit form (name + command), portaled like the shared dialogs. */
281
+ function SnippetForm(props: {
282
+ t: (key: string) => string
283
+ mode: 'add' | 'edit'
284
+ snippet?: TerminalSnippet
285
+ /** Draft for a NEW snippet (Ctrl+B hands over the selection / typed line). */
286
+ initialCommand?: string
287
+ onCancel: () => void
288
+ onSubmit: (input: { name: string; command: string }) => void
289
+ }): ReactNode {
290
+ const t = props.t
291
+ const [name, setName] = useState(props.snippet?.name ?? '')
292
+ const [command, setCommand] = useState(props.snippet?.command ?? props.initialCommand ?? '')
293
+ const [error, setError] = useState<string | undefined>(undefined)
294
+ const nameRef = useRef<HTMLInputElement>(null)
295
+ const openerRef = useRef<HTMLElement | null>(document.activeElement as HTMLElement | null)
296
+
297
+ useEffect(() => {
298
+ nameRef.current?.focus()
299
+ nameRef.current?.select()
300
+ return () => {
301
+ const opener = openerRef.current
302
+ if (opener !== null && document.body.contains(opener)) opener.focus()
303
+ }
304
+ }, [])
305
+
306
+ useEffect(() => {
307
+ const onKey = (event: KeyboardEvent): void => {
308
+ if (event.isComposing) return
309
+ if (event.key === 'Escape') {
310
+ event.preventDefault()
311
+ props.onCancel()
312
+ }
313
+ }
314
+ document.addEventListener('keydown', onKey, true)
315
+ return () => document.removeEventListener('keydown', onKey, true)
316
+ }, [props])
317
+
318
+ const submit = (): void => {
319
+ if (name.trim() === '') { setError(t('term.snippetNameRequired')); return }
320
+ if (command.trim() === '') { setError(t('term.snippetCommandRequired')); return }
321
+ props.onSubmit({ name, command })
322
+ }
323
+
324
+ return createPortal(
325
+ <div className="rvs-portal rvs-modal-mask" onMouseDown={(event) => { if (event.target === event.currentTarget) props.onCancel() }}>
326
+ <div className="rvs-modal-box" role="dialog" aria-modal="true" aria-label={props.mode === 'add' ? t('term.snippetAdd') : t('term.snippetEdit')}>
327
+ <div className="rvs-modal-title">{props.mode === 'add' ? t('term.snippetAdd') : t('term.snippetEdit')}</div>
328
+ <label className="rvs-snips-field">
329
+ <span>{t('term.snippetName')}</span>
330
+ <input
331
+ ref={nameRef}
332
+ value={name}
333
+ placeholder={t('term.snippetNamePlaceholder')}
334
+ onChange={(event) => { setName(event.target.value); setError(undefined) }}
335
+ onKeyDown={(event) => { if (event.key === 'Enter' && !event.nativeEvent.isComposing) { event.preventDefault(); submit() } }}
336
+ />
337
+ </label>
338
+ <label className="rvs-snips-field">
339
+ <span>{t('term.snippetCommand')}</span>
340
+ <textarea
341
+ className="rvs-snips-command"
342
+ value={command}
343
+ placeholder={t('term.snippetCommandPlaceholder')}
344
+ rows={4}
345
+ onChange={(event) => { setCommand(event.target.value); setError(undefined) }}
346
+ />
347
+ </label>
348
+ {error !== undefined && <div className="rvs-snips-error" role="alert">{error}</div>}
349
+ <div className="rvs-modal-row">
350
+ <button type="button" className="rvs-modal-btn" onClick={props.onCancel}>{t('common.cancel')}</button>
351
+ <button type="button" className="rvs-modal-btn primary" onClick={submit}>{t('common.save')}</button>
352
+ </div>
353
+ </div>
354
+ </div>,
355
+ document.body,
356
+ )
357
+ }
@@ -11,8 +11,10 @@ import { useCallback, useEffect, useRef, useState, useSyncExternalStore, type Re
11
11
  import type { RemoteHostSummary } from '../protocol.ts'
12
12
  import { RemoteApiError, api } from './api.ts'
13
13
  import { XTerm } from './XTerm.tsx'
14
+ import { TerminalSnippets } from './TerminalSnippets.tsx'
15
+ import { pasteIntoTerminal } from './terminal-input.ts'
14
16
  import { cdCommand } from './shell.ts'
15
- import type { TerminalRequest } from './store.tsx'
17
+ import { jumpToTerminalPath, type TerminalRequest } from './store.tsx'
16
18
  import { optionStyle } from './ui.tsx'
17
19
  import {
18
20
  IconButton,
@@ -20,6 +22,7 @@ import {
20
22
  IconPlus,
21
23
  IconTerminal,
22
24
  confirmDialog,
25
+ toast,
23
26
  } from './vsc/kit.tsx'
24
27
 
25
28
  const ALIAS_KEY = 'dsh-remote-vs.term.alias'
@@ -221,6 +224,15 @@ export function TerminalView(props: {
221
224
  connected: true,
222
225
  })))
223
226
  const [activeId, setActiveId] = useState<string | undefined>(() => tabs[0]?.id)
227
+ /**
228
+ * The "quick add snippet" request from Ctrl+B: a counter (so the same draft
229
+ * repeated still opens the form) plus the draft to pre-fill.
230
+ *
231
+ * A value rather than a callback prop: the shortcut lives in `XTerm` while the
232
+ * form lives in the header, and this is the one value both sides can share
233
+ * without lifting xterm state into React.
234
+ */
235
+ const [snippetAdd, setSnippetAdd] = useState<{ id: number; content: string } | undefined>(undefined)
224
236
 
225
237
  const effectiveAlias = (alias !== '' && props.hosts.some(host => host.alias === alias))
226
238
  ? alias
@@ -370,6 +382,18 @@ export function TerminalView(props: {
370
382
 
371
383
  const active = tabs.find(tab => tab.id === activeId) ?? tabs[0]
372
384
 
385
+ /**
386
+ * Remote home of a tab's host, for `~/path` tokens printed in its terminal.
387
+ *
388
+ * The SSH user is the only honest source (the PTY protocol carries no home):
389
+ * root lives in `/root`, everyone else in `/home/<user>`.
390
+ */
391
+ const homeFor = (hostAlias: string): string | undefined => {
392
+ const host = props.hosts.find(item => item.alias === hostAlias)
393
+ if (host === undefined) return undefined
394
+ return host.user === 'root' ? '/root' : `/home/${host.user}`
395
+ }
396
+
373
397
  const labelFor = (tab: TermTab): string => {
374
398
  const siblings = tabs.filter(item => item.alias === tab.alias)
375
399
  const index = siblings.findIndex(item => item.id === tab.id) + 1
@@ -392,6 +416,18 @@ export function TerminalView(props: {
392
416
  <div className="rvs-pane grow">
393
417
  <div className="rvs-header">
394
418
  <span className="rvs-title">{t('tab.terminal')}</span>
419
+ {/* The "常用指令" library: a personal list of name+command pairs that
420
+ paste into the active terminal without pressing Enter. */}
421
+ <TerminalSnippets
422
+ t={t}
423
+ addRequest={snippetAdd?.id ?? 0}
424
+ addContent={snippetAdd?.content ?? ''}
425
+ onInsert={(command) => {
426
+ if (pasteIntoTerminal(active?.id, command)) return true
427
+ toast(t('term.snippetNoTerminal'), true)
428
+ return false
429
+ }}
430
+ />
395
431
  <select
396
432
  className="rvs-select"
397
433
  value={effectiveAlias}
@@ -481,6 +517,19 @@ export function TerminalView(props: {
481
517
  })}
482
518
  visible={props.visible && tab.id === active?.id}
483
519
  t={t}
520
+ tabId={tab.id}
521
+ onQuickAddSnippet={(draft) => {
522
+ // Ctrl+B: pre-fill the form with what the user selected, else
523
+ // with the line reconstructed from this session's keystrokes.
524
+ const content = (draft.selection ?? draft.line ?? '').trim()
525
+ setSnippetAdd(previous => ({ id: (previous?.id ?? 0) + 1, content }))
526
+ }}
527
+ {...(homeFor(tab.alias) === undefined ? {} : { home: homeFor(tab.alias) })}
528
+ onPathClick={(token, context) => {
529
+ // Ctrl+Click in the terminal: validated against the host, then
530
+ // revealed in the tree (see `jumpToTerminalPath`).
531
+ void jumpToTerminalPath(tab.alias, token, context)
532
+ }}
484
533
  {...(tab.initialCommand === undefined ? {} : { initialInput: tab.initialCommand })}
485
534
  onReady={(id) => patchTab(tab.id, { session: id, connected: true, note: undefined })}
486
535
  onExit={(code, message) => {