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.
Files changed (125) hide show
  1. package/README.en.md +50 -16
  2. package/README.md +40 -15
  3. package/THIRD-PARTY-NOTICES.md +188 -0
  4. package/lib/client.js +6512 -77887
  5. package/lib/index.js +1461 -1024
  6. package/lib/p2-router-fs.js +1 -1
  7. package/lib/types/client/CodeEditor.d.ts +25 -0
  8. package/lib/types/client/EditorPane.d.ts +16 -5
  9. package/lib/types/client/FloatingPlaceholder.d.ts +16 -5
  10. package/lib/types/client/RemoteEditorView.d.ts +13 -10
  11. package/lib/types/client/RemoteExplorer.d.ts +53 -0
  12. package/lib/types/client/RemoteRoot.d.ts +5 -5
  13. package/lib/types/client/TerminalSnippets.d.ts +36 -0
  14. package/lib/types/client/TerminalView.d.ts +1 -1
  15. package/lib/types/client/XTerm.d.ts +33 -0
  16. package/lib/types/client/api.d.ts +37 -2
  17. package/lib/types/client/changes/review-state.d.ts +19 -0
  18. package/lib/types/client/connection.d.ts +16 -0
  19. package/lib/types/client/editor-capability.d.ts +27 -0
  20. package/lib/types/client/i18n.d.ts +1 -1
  21. package/lib/types/client/request-gate.d.ts +110 -0
  22. package/lib/types/client/scm/DiffView.d.ts +45 -7
  23. package/lib/types/client/scm/actions.d.ts +31 -3
  24. package/lib/types/client/store.d.ts +112 -4
  25. package/lib/types/client/terminal-input.d.ts +23 -0
  26. package/lib/types/client/terminal-snippets.d.ts +86 -0
  27. package/lib/types/client/vsc/FindWidget.d.ts +6 -0
  28. package/lib/types/client/vsc/breadcrumb.d.ts +30 -0
  29. package/lib/types/client/vsc/change-marks.d.ts +16 -6
  30. package/lib/types/client/vsc/editor-caret.d.ts +32 -0
  31. package/lib/types/client/vsc/editor-keymap.d.ts +35 -1
  32. package/lib/types/client/vsc/editor-langs.d.ts +9 -0
  33. package/lib/types/client/vsc/editor-settings.d.ts +55 -0
  34. package/lib/types/client/vsc/image-preview.d.ts +36 -0
  35. package/lib/types/client/vsc/kit.d.ts +13 -0
  36. package/lib/types/client/vsc/save-shortcut.d.ts +21 -0
  37. package/lib/types/client/vsc/terminal-clipboard.d.ts +15 -0
  38. package/lib/types/client/vsc/terminal-line.d.ts +25 -0
  39. package/lib/types/client/vsc/terminal-links.d.ts +62 -0
  40. package/lib/types/client/vsc/terminal-theme.d.ts +48 -0
  41. package/lib/types/client/vsc/terminal-writer.d.ts +52 -0
  42. package/lib/types/forward.d.ts +12 -0
  43. package/lib/types/fs-ops.d.ts +42 -0
  44. package/lib/types/http.d.ts +2 -0
  45. package/lib/types/keygen.d.ts +9 -0
  46. package/lib/types/monitor.d.ts +8 -0
  47. package/lib/types/notices.d.ts +16 -1
  48. package/lib/types/p2/helper-rpc.d.ts +45 -0
  49. package/lib/types/pool.d.ts +25 -0
  50. package/lib/types/routes.d.ts +2 -0
  51. package/lib/types/store.d.ts +7 -0
  52. package/lib/types/terminal.d.ts +33 -1
  53. package/lib/types/view-settings.d.ts +5 -0
  54. package/lib/{worlds-B7gEDBzC.js → worlds-RG8K5eom.js} +113 -15
  55. package/package.json +2 -1
  56. package/src/client/CodeEditor.tsx +205 -10
  57. package/src/client/DirectoryFlow.tsx +16 -0
  58. package/src/client/DoctorPanel.tsx +70 -7
  59. package/src/client/EditorPane.tsx +545 -118
  60. package/src/client/FloatingPlaceholder.tsx +34 -5
  61. package/src/client/HostsView.tsx +12 -3
  62. package/src/client/RemoteDirectoryPicker.tsx +12 -0
  63. package/src/client/RemoteEditorView.tsx +14 -11
  64. package/src/client/RemoteExplorer.tsx +929 -40
  65. package/src/client/RemoteRoot.tsx +167 -147
  66. package/src/client/SearchView.tsx +8 -0
  67. package/src/client/TerminalSnippets.tsx +432 -0
  68. package/src/client/TerminalView.tsx +50 -1
  69. package/src/client/XTerm.tsx +228 -58
  70. package/src/client/api.ts +106 -13
  71. package/src/client/auto-open-remote.ts +11 -9
  72. package/src/client/changes/ChangesDock.tsx +188 -6
  73. package/src/client/changes/changes.css +10 -3
  74. package/src/client/changes/review-state.ts +34 -0
  75. package/src/client/connection.ts +29 -0
  76. package/src/client/downloads.ts +49 -4
  77. package/src/client/editor-capability.ts +42 -0
  78. package/src/client/i18n.ts +228 -12
  79. package/src/client/index.tsx +22 -6
  80. package/src/client/request-gate.ts +221 -0
  81. package/src/client/scm/CommitPane.tsx +20 -2
  82. package/src/client/scm/DiffView.tsx +343 -117
  83. package/src/client/scm/HistoryPanel.tsx +23 -2
  84. package/src/client/scm/RepoPicker.tsx +1 -1
  85. package/src/client/scm/ScmPanel.tsx +391 -87
  86. package/src/client/scm/actions.ts +95 -12
  87. package/src/client/store.tsx +537 -22
  88. package/src/client/terminal-input.ts +44 -0
  89. package/src/client/terminal-snippets.ts +216 -0
  90. package/src/client/ui.tsx +4 -0
  91. package/src/client/vsc/FindWidget.tsx +24 -9
  92. package/src/client/vsc/breadcrumb.tsx +339 -0
  93. package/src/client/vsc/change-marks.ts +93 -44
  94. package/src/client/vsc/editor-caret.ts +30 -0
  95. package/src/client/vsc/editor-keymap.ts +59 -1
  96. package/src/client/vsc/editor-langs.ts +20 -0
  97. package/src/client/vsc/editor-settings.ts +146 -0
  98. package/src/client/vsc/editor-theme.ts +4 -5
  99. package/src/client/vsc/file-icons.tsx +17 -3
  100. package/src/client/vsc/image-preview.tsx +110 -0
  101. package/src/client/vsc/kit.tsx +46 -10
  102. package/src/client/vsc/save-shortcut.ts +47 -1
  103. package/src/client/vsc/terminal-clipboard.ts +19 -0
  104. package/src/client/vsc/terminal-line.ts +101 -0
  105. package/src/client/vsc/terminal-links.ts +166 -0
  106. package/src/client/vsc/terminal-theme.ts +97 -0
  107. package/src/client/vsc/terminal-writer.ts +112 -0
  108. package/src/client/vsc/vsc.css +1078 -181
  109. package/src/forward.ts +47 -9
  110. package/src/fs-ops.ts +124 -4
  111. package/src/git-ops.ts +20 -3
  112. package/src/http.ts +35 -4
  113. package/src/keygen.ts +55 -4
  114. package/src/monitor.ts +13 -0
  115. package/src/notices.ts +23 -1
  116. package/src/p2/helper-rpc.ts +113 -7
  117. package/src/p2/worlds.ts +14 -1
  118. package/src/pool.ts +99 -27
  119. package/src/routes.ts +212 -43
  120. package/src/sftp.ts +51 -14
  121. package/src/store.ts +10 -0
  122. package/src/terminal.ts +225 -24
  123. package/src/view-settings.ts +50 -10
  124. package/lib/types/client/Dialog.d.ts +0 -14
  125. package/src/client/Dialog.tsx +0 -76
@@ -136,7 +136,7 @@ export function RepoPicker(props: {
136
136
 
137
137
  return (
138
138
  <div className="rvs-modal-mask" onMouseDown={(e) => { if (e.target === e.currentTarget) props.onClose() }}>
139
- <div className="rvs-modal-box rvs-repopick" role="dialog" aria-label={t('scm.pickTitle')}>
139
+ <div className="rvs-modal-box rvs-repopick" role="dialog" aria-modal="true" aria-label={t('scm.pickTitle')}>
140
140
  <div className="rvs-modal-title">
141
141
  {t('scm.pickTitle')}
142
142
  <IconButton title={t('common.close')} onClick={props.onClose}><IconClose size={13} /></IconButton>
@@ -8,15 +8,16 @@
8
8
  * and every successful write refreshes the shared status so the tree markers
9
9
  * and the change list never disagree.
10
10
  */
11
- import { Fragment, useCallback, useEffect, useMemo, useRef, useState, type MouseEvent as ReactMouseEvent, type ReactNode } from 'react'
11
+ import { Fragment, memo, useCallback, useEffect, useMemo, useRef, useState, type MouseEvent as ReactMouseEvent, type MutableRefObject, type ReactNode } from 'react'
12
12
  import type { GitBranch, GitRemote, GitStash, RemoteExecResult } from '../../protocol.ts'
13
- import { gitReadSettleMs, useExplorer } from '../store.tsx'
13
+ import { gitReadSettleMs, shallowEqual, useExplorerSelector, type ExplorerValue } from '../store.tsx'
14
14
  import { RemoteApiError, gitTimeoutMs } from '../api.ts'
15
15
  import {
16
16
  branchOp,
17
17
  commitAll,
18
18
  discardPaths,
19
19
  GitOpError,
20
+ initRepo,
20
21
  loadBranches,
21
22
  loadRemotes,
22
23
  loadStashes,
@@ -102,20 +103,237 @@ function messageOf(error: unknown): string {
102
103
  return error instanceof GitOpError || error instanceof Error ? error.message : String(error)
103
104
  }
104
105
 
106
+ /**
107
+ * How often the live exec panel repaints its log tail and running clock.
108
+ *
109
+ * The tail is accumulated in a REF by the SSE callback (`execLog`), so this
110
+ * cadence is the only thing that decides how often the panel paints: a
111
+ * per-chunk setState would repaint for every line git prints.
112
+ */
113
+ const EXEC_TICK_MS = 250
114
+
115
+ /**
116
+ * The same tick while the SIDEBAR is parked.
117
+ *
118
+ * The exec panel is portaled to `<body>` (a running push must stay reachable
119
+ * with its stop button even when another rail view is selected), so it is still
120
+ * on screen and must keep moving — it just does not need 4 Hz for a log the user
121
+ * is not looking at. Slowing down is what keeps that guarantee while parked.
122
+ */
123
+ const EXEC_TICK_PARKED_MS = 1000
124
+
125
+ /**
126
+ * The network verb's panel, ticking on ITS OWN state instead of the panel's.
127
+ *
128
+ * Why this is a component: the clock and the log tail are the only things that
129
+ * change while a fetch/push runs, but the timer used to live in `ScmPanel` and
130
+ * call `setExecPanel` — so every 250 ms the WHOLE source-control panel (up to
131
+ * 4000 change rows, plus the repository/stash/branch sections) re-rendered for
132
+ * a clock that belongs to one portaled box. Here the tick re-renders this small
133
+ * component only; the parent still hears about the run exactly twice (start and
134
+ * final status), which is the moment its own sections actually change.
135
+ */
136
+ function LiveExecPanel(props: {
137
+ state: ExecPanelState
138
+ /** Reads the log the stream callback has accumulated so far (no state per chunk). */
139
+ readLog: () => string
140
+ onCancel: () => void
141
+ onClose: () => void
142
+ /** `false` = the SCM panel is parked (the portal itself stays visible). */
143
+ visible: boolean
144
+ t: (key: string) => string
145
+ }): ReactNode {
146
+ const { state, readLog, visible, t } = props
147
+ const running = state.status === 'running'
148
+ const [output, setOutput] = useState(state.output)
149
+ /** Revision counter only: `Date.now()` below is what the clock paints. */
150
+ const [, bumpClock] = useState(0)
151
+ /** The finished state carries the final log; only a running one grows. */
152
+ const shown = running ? output : state.output
153
+ useEffect(() => {
154
+ if (!running) return
155
+ const timer = window.setInterval(() => {
156
+ const tail = readLog()
157
+ // Same string = same log: keep the previous value so the fold/render
158
+ // memo in `ExecPanel` is not invalidated by an identical copy.
159
+ setOutput(previous => (previous === tail ? previous : tail))
160
+ bumpClock(step => step + 1)
161
+ }, visible ? EXEC_TICK_MS : EXEC_TICK_PARKED_MS)
162
+ return () => window.clearInterval(timer)
163
+ }, [running, visible, readLog])
164
+ return (
165
+ <ExecPanel
166
+ state={{
167
+ ...state,
168
+ output: shown,
169
+ // A finished run keeps the duration it ended with; a running one counts.
170
+ elapsedMs: running ? Date.now() - state.startedAt : state.elapsedMs,
171
+ }}
172
+ onCancel={props.onCancel}
173
+ onClose={props.onClose}
174
+ t={t}
175
+ />
176
+ )
177
+ }
178
+
179
+ /**
180
+ * Handlers a change row needs, held in a REF (the same pattern as
181
+ * `ExplorerRowView` in the file tree).
182
+ *
183
+ * The panel rebuilds these closures on every render, and a render happens on
184
+ * every store publish; passing them as props would make the memo on the row
185
+ * pointless. The row reads them at CLICK time, so the current render's state is
186
+ * what a click acts on.
187
+ */
188
+ interface ChangeRowActions {
189
+ activate: (entry: ChangeEntry, isStaged: boolean) => void
190
+ openMenu: (event: ReactMouseEvent, entry: ChangeEntry) => void
191
+ stage: (entry: ChangeEntry, isStaged: boolean) => void
192
+ discard: (entry: ChangeEntry) => void
193
+ }
194
+
195
+ interface ChangeRowProps {
196
+ entry: ChangeEntry
197
+ isStaged: boolean
198
+ depth: number
199
+ /** An untracked-directory row whose files are already expanded below it. */
200
+ expanded: boolean
201
+ /** Any remote verb is running: every row's buttons are disabled together. */
202
+ busy: boolean
203
+ t: (key: string) => string
204
+ actions: MutableRefObject<ChangeRowActions>
205
+ }
206
+
207
+ /**
208
+ * One change row.
209
+ *
210
+ * Memoized on primitives, because the panel re-renders on every store publish
211
+ * (an editor save is 3-4 publishes) and rebuilding a 4000-row list means ~8
212
+ * elements per row every time. `entry` is a stable object from the store's
213
+ * status buckets, so an unchanged row now skips its own render entirely.
214
+ *
215
+ * `depth > 0` means it is a file inside an expanded untracked directory: same
216
+ * row, indented, and still fully actionable (staging such a file adds it to
217
+ * "staged changes" — see `store.applyLocalStage`). An UNTRACKED DIRECTORY row
218
+ * (`dir/`) is the one row whose click does not open a diff: it expands instead,
219
+ * because `-u normal` reported the directory alone and its files are otherwise
220
+ * invisible.
221
+ */
222
+ const ChangeRowView = memo(function ChangeRowView(props: ChangeRowProps): ReactNode {
223
+ const { entry, isStaged, depth, expanded, busy, t, actions } = props
224
+ const expandable = !isStaged && entry.path.endsWith('/')
225
+ const activate = (): void => { actions.current.activate(entry, isStaged) }
226
+ return (
227
+ <div
228
+ className="rvs-scm-item"
229
+ role="button"
230
+ tabIndex={0}
231
+ style={depth === 0 ? undefined : { paddingLeft: `${22 + depth * 12}px` }}
232
+ title={expandable ? `${entry.path}\n${t('scm.dirToggle')}` : `${entry.path}\n${t('scm.openHint')}`}
233
+ onClick={activate}
234
+ onContextMenu={(event) => actions.current.openMenu(event, entry)}
235
+ onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') activate() }}
236
+ >
237
+ {/* The chevron slot is reserved on EVERY row (11px), so a directory row
238
+ and its files stay in one column instead of shifting by an icon. */}
239
+ <span className={`rvs-chevron${expanded ? ' open' : ''}`} style={{ width: 11 }} aria-hidden="true">
240
+ {expandable ? <IconChevronRight size={11} /> : null}
241
+ </span>
242
+ <span className="rvs-node-icon">{expandable ? <IconFolder size={14} /> : <FileIcon path={entry.path} size={14} />}</span>
243
+ <span className="rvs-scm-path">{entry.path}</span>
244
+ {(entry.oldPath ?? '') !== '' && <span className="rvs-scm-dir">← {entry.oldPath}</span>}
245
+ <span className={`rvs-file-status rvs-letter-${gitStatusClass(entry.status)}`}>{gitLetter(entry.status)}</span>
246
+ <span className="rvs-scm-actions">
247
+ <IconButton
248
+ title={isStaged ? t('scm.unstage') : t('scm.stage')}
249
+ disabled={busy}
250
+ onClick={() => actions.current.stage(entry, isStaged)}
251
+ >
252
+ {isStaged ? <IconClose size={12} /> : <IconPlus size={13} />}
253
+ </IconButton>
254
+ {!isStaged && (
255
+ <IconButton
256
+ title={entry.status === '?' ? t('scm.deleteUntracked') : t('scm.discard')}
257
+ danger
258
+ disabled={busy}
259
+ onClick={() => actions.current.discard(entry)}
260
+ >
261
+ <IconTrash size={13} />
262
+ </IconButton>
263
+ )}
264
+ </span>
265
+ </div>
266
+ )
267
+ })
268
+
269
+ /**
270
+ * The store fields the panel reads — and ONLY those.
271
+ *
272
+ * The panel used to subscribe to the whole snapshot (`useExplorer()`), so every
273
+ * publish repainted it: a save in the editor (3-4 publishes), a git refresh, a
274
+ * rail switch. With the change list allowed to reach 4000 rows, that meant
275
+ * rebuilding the whole list for a change in a field this panel does not read.
276
+ * `useExplorerSelector` + `shallowEqual` re-render it only when one of the
277
+ * fields below actually changed.
278
+ *
279
+ * Module-level so the selector identity is stable: between publishes the hook's
280
+ * cache answers without running it. Actions are module-level functions in the
281
+ * store (`build()` copies the same references every time), and `t`/`lang` are
282
+ * constants, so they never invalidate the slice.
283
+ */
284
+ const selectScmStore = (snapshot: ExplorerValue) => ({
285
+ t: snapshot.t,
286
+ lang: snapshot.lang,
287
+ buckets: snapshot.buckets,
288
+ head: snapshot.head,
289
+ alias: snapshot.alias,
290
+ root: snapshot.root,
291
+ repoRoot: snapshot.repoRoot,
292
+ repoSubdir: snapshot.repoSubdir,
293
+ repoWorkdir: snapshot.repoWorkdir,
294
+ repoMissing: snapshot.repoMissing,
295
+ gitBusy: snapshot.gitBusy,
296
+ gitError: snapshot.gitError,
297
+ gitCached: snapshot.gitCached,
298
+ gitDeadlineMs: snapshot.gitDeadlineMs,
299
+ untrackedDirs: snapshot.untrackedDirs,
300
+ floatAvailable: snapshot.floatAvailable,
301
+ afterWrite: snapshot.afterWrite,
302
+ setRepoSubdir: snapshot.setRepoSubdir,
303
+ stageOptimistic: snapshot.stageOptimistic,
304
+ toggleUntrackedDir: snapshot.toggleUntrackedDir,
305
+ openFile: snapshot.openFile,
306
+ openDiff: snapshot.openDiff,
307
+ openDiffInFloatEditor: snapshot.openDiffInFloatEditor,
308
+ openInFloatEditor: snapshot.openInFloatEditor,
309
+ })
310
+
105
311
  export function ScmPanel(props: { onOpenHistory: () => void; visible: boolean }): ReactNode {
106
- const store = useExplorer()
312
+ const store = useExplorerSelector(selectScmStore, shallowEqual)
107
313
  const { t, lang, buckets, head, alias, repoRoot } = store
108
314
  const [folded, setFolded] = useState<Record<string, boolean>>({})
109
315
  /** Live log of the running network verb (undefined = panel closed). */
110
316
  const [execPanel, setExecPanel] = useState<ExecPanelState | undefined>(undefined)
111
317
  const execAbort = useRef<AbortController | undefined>(undefined)
112
318
  const execLog = useRef('')
113
- /** The live-log repaint interval (kept out of render state on purpose). */
114
- const execTimer = useRef<ReturnType<typeof setInterval> | undefined>(undefined)
115
- // Leaving the panel mid-push must not leave a 250 ms setState loop running.
116
- useEffect(() => () => {
117
- if (execTimer.current !== undefined) clearInterval(execTimer.current)
118
- }, [])
319
+ /**
320
+ * Stable reader for the live log tail, handed to `LiveExecPanel`.
321
+ *
322
+ * The stream appends into the ref (a setState per chunk would repaint the
323
+ * panel for every line git prints); the panel's own component polls this on
324
+ * its tick and owns the paint cadence.
325
+ */
326
+ const readExecLog = useCallback((): string => execLog.current, [])
327
+ /**
328
+ * Current change-row handlers, read at click time by the memoized rows (see
329
+ * `ChangeRowActions`). Assigned after the closures are defined.
330
+ */
331
+ const changeActions = useRef<ChangeRowActions>({
332
+ activate: () => {},
333
+ openMenu: () => {},
334
+ stage: () => {},
335
+ discard: () => {},
336
+ })
119
337
  const [message, setMessage] = useState<string>(() => {
120
338
  try {
121
339
  return localStorage.getItem(MSG_KEY) ?? ''
@@ -326,6 +544,28 @@ export function ScmPanel(props: { onOpenHistory: () => void; visible: boolean })
326
544
  }, 'status')
327
545
  }
328
546
 
547
+ /**
548
+ * `git init` in the directory git was pointed at.
549
+ *
550
+ * The "not a repository" state was a dead end: the command existed in the
551
+ * action layer but no surface offered it. `status` (not `all`) is enough here:
552
+ * the refresh re-probes the directory and the extras effect reloads the three
553
+ * side lists as soon as `repoRoot` appears (they are still empty right now).
554
+ */
555
+ const initRepository = async (): Promise<void> => {
556
+ if (alias === '' || store.repoWorkdir === '') return
557
+ const ok = await confirmDialog({
558
+ title: t('scm.initRepo'),
559
+ text: t('scm.initRepoText').replace('{path}', store.repoWorkdir),
560
+ okText: t('scm.initRepo'),
561
+ })
562
+ if (!ok) return
563
+ await guard('init', async () => {
564
+ await initRepo(alias, store.repoWorkdir)
565
+ toast(t('scm.initRepoDone'))
566
+ }, 'status')
567
+ }
568
+
329
569
  /**
330
570
  * Stage / unstage, the fast way: the row moves between sections at once and
331
571
  * ONE path-limited `git status` confirms it — no repository-wide status, no
@@ -525,9 +765,10 @@ export function ScmPanel(props: { onOpenHistory: () => void; visible: boolean })
525
765
  *
526
766
  * `streamNetworkVerb` speaks the SSE route; an older Host that has no such
527
767
  * route falls back to the unary verb and shows the complete result in the same
528
- * panel. The timer and the log are painted on their own 250 ms cadence — a
529
- * per-chunk setState would re-render the whole SCM panel for every line git
530
- * prints.
768
+ * panel. The log tail and the running clock are accumulated in `execLog` and
769
+ * painted by `LiveExecPanel`'s own tick — a per-chunk setState (or a timer
770
+ * owned by THIS panel) would re-render the whole SCM panel for every line git
771
+ * prints. Only the start and the final status pass through `execPanel`.
531
772
  */
532
773
  const runNetwork = async (
533
774
  kind: 'fetch' | 'pull' | 'push' | 'sync',
@@ -541,20 +782,6 @@ export function ScmPanel(props: { onOpenHistory: () => void; visible: boolean })
541
782
  execLog.current = ''
542
783
  setExecPanel({ title, output: '', status: 'running', startedAt, elapsedMs: 0 })
543
784
  setBusy(kind)
544
- let painted = ''
545
- const timer = setInterval(() => {
546
- if (execLog.current !== painted) {
547
- painted = execLog.current
548
- setExecPanel(prev => (prev === undefined || prev.status !== 'running'
549
- ? prev
550
- : { ...prev, output: painted, elapsedMs: Date.now() - startedAt }))
551
- return
552
- }
553
- setExecPanel(prev => (prev === undefined || prev.status !== 'running'
554
- ? prev
555
- : { ...prev, elapsedMs: Date.now() - startedAt }))
556
- }, 250)
557
- execTimer.current = timer
558
785
  /** True when the unary fallback answered (no exit code was observed then). */
559
786
  let fallbackUsed = false
560
787
  /** Cancel: no refresh storm while the user is just stopping a run. */
@@ -646,8 +873,6 @@ export function ScmPanel(props: { onOpenHistory: () => void; visible: boolean })
646
873
  }))
647
874
  toast(t('exec.unknownResult'), true)
648
875
  } finally {
649
- clearInterval(timer)
650
- execTimer.current = undefined
651
876
  execAbort.current = undefined
652
877
  setBusy(undefined)
653
878
  // A cancel already stopped the command; a full status+extras refresh would
@@ -671,6 +896,66 @@ export function ScmPanel(props: { onOpenHistory: () => void; visible: boolean })
671
896
  })
672
897
  }
673
898
 
899
+ /**
900
+ * Rename one LOCAL branch (`git branch -m`).
901
+ *
902
+ * Remote-tracking rows (`refs/remotes/...`) are excluded: their name is the
903
+ * remote side's, and `git branch -m` does not rename them. The prompt is
904
+ * prefilled with the current name, and the write refreshes the extras because
905
+ * the branch list (and HEAD's own name when it is the current branch) changed.
906
+ */
907
+ const renameBranch = async (branch: GitBranch): Promise<void> => {
908
+ if (repoRoot === undefined) return
909
+ const answer = await promptDialog({
910
+ title: t('scm.renameBranch'),
911
+ text: t('scm.renameBranchText').replace('{branch}', branch.name),
912
+ initial: branch.name,
913
+ okText: t('scm.renameBranch'),
914
+ })
915
+ if (answer === undefined) return
916
+ const next = answer.trim()
917
+ // Empty and unchanged are the two answers that cannot be a rename; say so
918
+ // instead of running a command git would refuse (or that would be a no-op).
919
+ if (next === '' || next === branch.name) {
920
+ toast(t('scm.renameBranchInvalid'), true)
921
+ return
922
+ }
923
+ await guard('branch', async () => {
924
+ await branchOp(alias, repoRoot, { kind: 'rename', from: branch.name, to: next })
925
+ toast(t('scm.renameBranchDone'))
926
+ })
927
+ }
928
+
929
+ /**
930
+ * Point an existing remote at another URL.
931
+ *
932
+ * Only the `fetch` row gets the entry: `git remote set-url` without `--push`
933
+ * rewrites the fetch URL, and a `push` row's URL is a separate (usually equal)
934
+ * one — editing it would silently need a flag this action does not expose.
935
+ * The prompt is prefilled with the current URL so a typo can be fixed in place.
936
+ */
937
+ const setRemoteUrl = async (remote: GitRemote): Promise<void> => {
938
+ if (repoRoot === undefined) return
939
+ const answer = await promptDialog({
940
+ title: t('scm.setRemoteUrl'),
941
+ text: t('scm.setRemoteUrlText').replace('{name}', remote.name),
942
+ initial: remote.url,
943
+ okText: t('scm.setRemoteUrl'),
944
+ })
945
+ if (answer === undefined) return
946
+ const url = answer.trim()
947
+ if (url === '') {
948
+ toast(t('scm.remoteUrlEmpty'), true)
949
+ return
950
+ }
951
+ // The same URL is not a change: skip the remote git write (and its refresh).
952
+ if (url === remote.url) return
953
+ await guard('remote', async () => {
954
+ await remoteOp(alias, repoRoot, { kind: 'setUrl', name: remote.name, url })
955
+ toast(t('scm.setRemoteUrlDone'))
956
+ })
957
+ }
958
+
674
959
  const changes = buckets.changes
675
960
  const staged = buckets.staged
676
961
  const conflicts = buckets.conflicts
@@ -708,68 +993,48 @@ export function ScmPanel(props: { onOpenHistory: () => void; visible: boolean })
708
993
  }
709
994
 
710
995
  /**
711
- * One row. `depth > 0` means it is a file inside an expanded untracked
712
- * directory: same row, indented, and still fully actionable (staging such a
713
- * file adds it to "staged changes" — see `store.applyLocalStage`).
996
+ * What a row's click does, as one callback the memoized rows can call.
714
997
  *
715
- * An UNTRACKED DIRECTORY row (`dir/`) is the one row whose click does not
716
- * open a diff: it expands instead, because `-u normal` reported the directory
717
- * alone and its files are otherwise invisible.
998
+ * A directory row toggles its files (an untracked directory has no single
999
+ * diff to open); everything else opens its file/diff. Kept in the parent
1000
+ * because it is the same behaviour for every row and must not re-render one.
718
1001
  */
719
- const changeRow = (entry: ChangeEntry, isStaged: boolean, depth = 0): ReactNode => {
720
- const expandable = !isStaged && entry.path.endsWith('/')
721
- const expanded = expandable && store.untrackedDirs.has(entry.path)
722
- const activate = (): void => {
723
- if (!expandable) {
724
- openChange(entry)
725
- return
726
- }
1002
+ const activateRow = (entry: ChangeEntry, isStaged: boolean): void => {
1003
+ if (!isStaged && entry.path.endsWith('/')) {
727
1004
  void store.toggleUntrackedDir(entry.path).catch((error: unknown) => { toast(messageOf(error), true) })
1005
+ return
728
1006
  }
729
- return (
730
- <div
731
- key={`${isStaged ? 's' : 'u'}:${entry.path}`}
732
- className="rvs-scm-item"
733
- role="button"
734
- tabIndex={0}
735
- style={depth === 0 ? undefined : { paddingLeft: `${22 + depth * 12}px` }}
736
- title={expandable ? `${entry.path}\n${t('scm.dirToggle')}` : `${entry.path}\n${t('scm.openHint')}`}
737
- onClick={activate}
738
- onContextMenu={(event) => openRowMenu(event, entry)}
739
- onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') activate() }}
740
- >
741
- {/* The chevron slot is reserved on EVERY row (11px), so a directory row
742
- and its files stay in one column instead of shifting by an icon. */}
743
- <span className={`rvs-chevron${expanded ? ' open' : ''}`} style={{ width: 11 }} aria-hidden="true">
744
- {expandable ? <IconChevronRight size={11} /> : null}
745
- </span>
746
- <span className="rvs-node-icon">{expandable ? <IconFolder size={14} /> : <FileIcon path={entry.path} size={14} />}</span>
747
- <span className="rvs-scm-path">{entry.path}</span>
748
- {(entry.oldPath ?? '') !== '' && <span className="rvs-scm-dir">← {entry.oldPath}</span>}
749
- <span className={`rvs-file-status rvs-letter-${gitStatusClass(entry.status)}`}>{gitLetter(entry.status)}</span>
750
- <span className="rvs-scm-actions">
751
- <IconButton
752
- title={isStaged ? t('scm.unstage') : t('scm.stage')}
753
- disabled={busy !== undefined}
754
- onClick={() => { void stageOne(entry, isStaged) }}
755
- >
756
- {isStaged ? <IconClose size={12} /> : <IconPlus size={13} />}
757
- </IconButton>
758
- {!isStaged && (
759
- <IconButton
760
- title={entry.status === '?' ? t('scm.deleteUntracked') : t('scm.discard')}
761
- danger
762
- disabled={busy !== undefined}
763
- onClick={() => { void discardOne(entry) }}
764
- >
765
- <IconTrash size={13} />
766
- </IconButton>
767
- )}
768
- </span>
769
- </div>
770
- )
1007
+ openChange(entry)
1008
+ }
1009
+
1010
+ // The world a memoized row sees. Reassigned on every render ON PURPOSE: the
1011
+ // closures carry this render's `busy`/repository/selection, and a row only
1012
+ // holds the ref (not the closures), so refreshing it is free.
1013
+ changeActions.current = {
1014
+ activate: activateRow,
1015
+ openMenu: openRowMenu,
1016
+ stage: stageOne,
1017
+ discard: (entry) => { void discardOne(entry) },
771
1018
  }
772
1019
 
1020
+ /**
1021
+ * One row element. The component behind it is memoized (`ChangeRowView`), so
1022
+ * this wrapper only decides its props — a publish that changes nothing about
1023
+ * a row no longer rebuilds that row's ~8 elements.
1024
+ */
1025
+ const changeRow = (entry: ChangeEntry, isStaged: boolean, depth = 0, expanded = false): ReactNode => (
1026
+ <ChangeRowView
1027
+ key={`${isStaged ? 's' : 'u'}:${entry.path}`}
1028
+ entry={entry}
1029
+ isStaged={isStaged}
1030
+ depth={depth}
1031
+ expanded={expanded}
1032
+ busy={busy !== undefined}
1033
+ t={t}
1034
+ actions={changeActions}
1035
+ />
1036
+ )
1037
+
773
1038
  /**
774
1039
  * Rows plus the contents of any expanded untracked directory, in place.
775
1040
  *
@@ -780,7 +1045,12 @@ export function ScmPanel(props: { onOpenHistory: () => void; visible: boolean })
780
1045
  const changeRows = (entries: readonly ChangeEntry[], depth = 0): ReactNode =>
781
1046
  entries.map(entry => (
782
1047
  <Fragment key={`${depth}:${entry.path}`}>
783
- {changeRow(entry, false, depth)}
1048
+ {changeRow(
1049
+ entry,
1050
+ false,
1051
+ depth,
1052
+ entry.path.endsWith('/') && store.untrackedDirs.has(entry.path),
1053
+ )}
784
1054
  {depth < 8
785
1055
  ? changeRows(store.untrackedDirs.get(entry.path) ?? [], depth + 1)
786
1056
  : null}
@@ -790,8 +1060,13 @@ export function ScmPanel(props: { onOpenHistory: () => void; visible: boolean })
790
1060
  return (
791
1061
  <div className="rvs-pane grow">
792
1062
  {execPanel !== undefined && (
793
- <ExecPanel
1063
+ <LiveExecPanel
1064
+ // A new run starts a fresh clock/log; without the key the previous
1065
+ // run's tail would be on screen until the first tick.
1066
+ key={execPanel.startedAt}
794
1067
  state={execPanel}
1068
+ readLog={readExecLog}
1069
+ visible={props.visible}
795
1070
  onCancel={cancelNetwork}
796
1071
  onClose={() => { setExecPanel(undefined) }}
797
1072
  t={t}
@@ -876,8 +1151,18 @@ export function ScmPanel(props: { onOpenHistory: () => void; visible: boolean })
876
1151
  ? t('git.hint')
877
1152
  : `${t('common.loading')} ${store.gitBusy ? `— ${t('scm.loadingSlow')} (≤${Math.round(store.gitDeadlineMs / 1000)}s)` : ''}`}
878
1153
  {store.repoMissing && (
879
- <div className="rvs-repo-bar-fix">
1154
+ <div className="rvs-repo-bar-fix" style={{ gap: 6 }}>
880
1155
  <button type="button" className="rvs-chip" onClick={() => setPicker(true)}>{t('scm.browse')}</button>
1156
+ {/* The not-a-repository state offers the one verb that turns it
1157
+ into a repository: `git init` right here. */}
1158
+ <button
1159
+ type="button"
1160
+ className="rvs-chip primary"
1161
+ disabled={busy !== undefined || store.gitBusy}
1162
+ onClick={() => { void initRepository() }}
1163
+ >
1164
+ {t('scm.initRepo')}
1165
+ </button>
881
1166
  </div>
882
1167
  )}
883
1168
  </div>
@@ -1111,6 +1396,18 @@ export function ScmPanel(props: { onOpenHistory: () => void; visible: boolean })
1111
1396
  {branch.remote === true && <span className="rvs-scm-dir"> · remote</span>}
1112
1397
  </span>
1113
1398
  <span className="rvs-scm-actions" style={{ display: 'flex' }}>
1399
+ {/* Local branches only: a remote-tracking ref
1400
+ (`refs/remotes/...`) carries the remote side's
1401
+ name and `git branch -m` does not rename it. */}
1402
+ {branch.remote !== true && (
1403
+ <IconButton
1404
+ title={t('scm.renameBranch')}
1405
+ disabled={busy !== undefined}
1406
+ onClick={() => { void renameBranch(branch) }}
1407
+ >
1408
+ ✎
1409
+ </IconButton>
1410
+ )}
1114
1411
  {!branch.head && (
1115
1412
  <IconButton
1116
1413
  title={t('scm.checkout')}
@@ -1193,6 +1490,13 @@ export function ScmPanel(props: { onOpenHistory: () => void; visible: boolean })
1193
1490
  <span className="rvs-scm-path" title={remote.url}>{remote.name} <span className="rvs-scm-dir">{remote.kind}</span></span>
1194
1491
  {remote.kind === 'fetch' && (
1195
1492
  <span className="rvs-scm-actions" style={{ display: 'flex' }}>
1493
+ <IconButton
1494
+ title={t('scm.setRemoteUrl')}
1495
+ disabled={busy !== undefined}
1496
+ onClick={() => { void setRemoteUrl(remote) }}
1497
+ >
1498
+ ✎
1499
+ </IconButton>
1196
1500
  <IconButton
1197
1501
  title={t('scm.removeRemote')}
1198
1502
  danger