dsh-remote-vs 0.25.0 → 0.27.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 +12 -15
- package/README.md +11 -12
- package/THIRD-PARTY-NOTICES.md +193 -0
- package/lib/client.js +7313 -79961
- package/lib/index.js +1529 -964
- package/lib/p2-router-fs.js +1 -1
- package/lib/types/client/CodeEditor.d.ts +22 -0
- package/lib/types/client/OutlinePanel.d.ts +22 -0
- package/lib/types/client/ProcessesSection.d.ts +19 -0
- package/lib/types/client/RemoteExplorer.d.ts +53 -0
- package/lib/types/client/api.d.ts +42 -3
- package/lib/types/client/blame-model.d.ts +77 -0
- package/lib/types/client/changes/review-state.d.ts +19 -0
- package/lib/types/client/connection.d.ts +16 -0
- package/lib/types/client/i18n.d.ts +1 -1
- package/lib/types/client/outline-model.d.ts +59 -0
- 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 +43 -4
- package/lib/types/client/store.d.ts +71 -0
- package/lib/types/client/vsc/FindWidget.d.ts +6 -0
- package/lib/types/client/vsc/blame.d.ts +19 -0
- package/lib/types/client/vsc/change-marks.d.ts +16 -6
- package/lib/types/client/vsc/editor-keymap.d.ts +35 -1
- package/lib/types/client/vsc/kit.d.ts +11 -2
- package/lib/types/client/vsc/preview-document.d.ts +46 -0
- package/lib/types/client/vsc/preview-model.d.ts +31 -0
- package/lib/types/client/vsc/preview-services.d.ts +24 -0
- package/lib/types/client/vsc/save-shortcut.d.ts +21 -0
- package/lib/types/client/vsc/terminal-theme.d.ts +28 -2
- package/lib/types/forward.d.ts +12 -0
- package/lib/types/fs-ops.d.ts +42 -0
- package/lib/types/git-ops.d.ts +18 -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/processes.d.ts +43 -0
- package/lib/types/protocol.d.ts +34 -0
- package/lib/types/routes.d.ts +2 -0
- package/lib/types/store.d.ts +7 -0
- package/lib/types/terminal.d.ts +8 -0
- package/lib/types/view-settings.d.ts +5 -0
- package/lib/{worlds-B7gEDBzC.js → worlds-RG8K5eom.js} +113 -15
- package/package.json +3 -1
- package/src/client/CodeEditor.tsx +194 -9
- package/src/client/DirectoryFlow.tsx +16 -0
- package/src/client/DoctorPanel.tsx +70 -7
- package/src/client/EditorPane.tsx +574 -42
- package/src/client/HostsView.tsx +12 -3
- package/src/client/MonitorView.tsx +16 -5
- package/src/client/OutlinePanel.tsx +287 -0
- package/src/client/ProcessesSection.tsx +292 -0
- package/src/client/RemoteDirectoryPicker.tsx +12 -0
- package/src/client/RemoteExplorer.tsx +929 -40
- package/src/client/RemoteRoot.tsx +147 -22
- package/src/client/SearchView.tsx +8 -0
- package/src/client/TerminalSnippets.tsx +83 -8
- package/src/client/api.ts +114 -13
- package/src/client/blame-model.ts +242 -0
- 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/i18n.ts +276 -8
- package/src/client/index.tsx +4 -0
- package/src/client/outline-model.ts +775 -0
- 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 +61 -3
- package/src/client/scm/RepoPicker.tsx +1 -1
- package/src/client/scm/ScmPanel.tsx +391 -87
- package/src/client/scm/actions.ts +150 -14
- package/src/client/store.tsx +426 -14
- package/src/client/ui.tsx +4 -0
- package/src/client/vsc/FindWidget.tsx +24 -9
- package/src/client/vsc/blame.ts +147 -0
- package/src/client/vsc/breadcrumb.tsx +91 -3
- package/src/client/vsc/change-marks.ts +93 -44
- package/src/client/vsc/editor-keymap.ts +59 -1
- package/src/client/vsc/file-icons.tsx +17 -3
- package/src/client/vsc/kit.tsx +29 -20
- package/src/client/vsc/preview-document.tsx +323 -0
- package/src/client/vsc/preview-model.ts +216 -0
- package/src/client/vsc/preview-services.ts +118 -0
- package/src/client/vsc/save-shortcut.ts +47 -1
- package/src/client/vsc/terminal-theme.ts +44 -18
- package/src/client/vsc/vsc.css +6509 -5458
- package/src/forward.ts +47 -9
- package/src/fs-ops.ts +124 -4
- package/src/git-ops.ts +54 -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/processes.ts +177 -0
- package/src/protocol.ts +37 -0
- package/src/routes.ts +330 -43
- package/src/sftp.ts +51 -14
- package/src/store.ts +10 -0
- package/src/terminal.ts +73 -26
- package/src/view-settings.ts +50 -10
- package/lib/types/client/Dialog.d.ts +0 -14
- package/src/client/Dialog.tsx +0 -76
package/src/client/store.tsx
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* Remote work stays lazy: a directory is listed once per expansion, a diff
|
|
13
13
|
* loads both revisions on demand, and git status is one NUL-separated call.
|
|
14
14
|
*/
|
|
15
|
-
import { useEffect, useSyncExternalStore } from 'react'
|
|
15
|
+
import { useCallback, useEffect, useRef, useSyncExternalStore } from 'react'
|
|
16
16
|
import type { Context } from '@deepseek-ai/cordis'
|
|
17
17
|
import type {
|
|
18
18
|
DiffModel,
|
|
@@ -51,8 +51,10 @@ import { captureLiveEditorPosition, captureLiveEditorText, isLiveEditorDirty, is
|
|
|
51
51
|
import { editorSeatCount } from './editor-capability.ts'
|
|
52
52
|
import { planWorkspaceFollow, selectionIsSessionBinding, type WorkspaceFollowDecision } from './remote-file-open-target.ts'
|
|
53
53
|
import { revealViewTab } from './reveal.ts'
|
|
54
|
-
import { connectionStateOf, isConnectionFailure } from './connection.ts'
|
|
55
|
-
import {
|
|
54
|
+
import { applyConnectionStatuses, connectionStateOf, isConnectionFailure, markConnectionProbeOk } from './connection.ts'
|
|
55
|
+
import { isRequestAbort } from './request-gate.ts'
|
|
56
|
+
import { confirmDialog, isImageFile, toast } from './vsc/kit.tsx'
|
|
57
|
+
import { hasTextSource, isBytePreview, previewKindOf } from './vsc/preview-model.ts'
|
|
56
58
|
import {
|
|
57
59
|
isWithinRoot,
|
|
58
60
|
normalizeRemotePath,
|
|
@@ -218,6 +220,8 @@ interface State {
|
|
|
218
220
|
revealRequest: RevealRequest | undefined
|
|
219
221
|
/** A pending "open a terminal in this folder" request (search-result menu). */
|
|
220
222
|
terminalRequest: TerminalRequest | undefined
|
|
223
|
+
/** A pending "select this commit in the history rail" request. */
|
|
224
|
+
commitFocus: CommitFocusRequest | undefined
|
|
221
225
|
/**
|
|
222
226
|
* Expanded untracked DIRECTORY rows (`-u normal` collapses a directory into
|
|
223
227
|
* one row, so the panel asks for its contents on demand — see
|
|
@@ -267,6 +271,13 @@ export interface TerminalRequest {
|
|
|
267
271
|
dir: string
|
|
268
272
|
}
|
|
269
273
|
|
|
274
|
+
/** One "show this commit in the history rail" request. */
|
|
275
|
+
export interface CommitFocusRequest {
|
|
276
|
+
/** Monotonic id so selecting the same commit twice still re-triggers. */
|
|
277
|
+
id: number
|
|
278
|
+
hash: string
|
|
279
|
+
}
|
|
280
|
+
|
|
270
281
|
const WS_KEY = 'dsh-remote-vs.files.ws'
|
|
271
282
|
const VIEW_KEY = 'dsh-remote-vs.view'
|
|
272
283
|
/** Per-workspace repository sub-directory, keyed by workspace id. */
|
|
@@ -525,6 +536,7 @@ const state: State = {
|
|
|
525
536
|
searchRequest: undefined,
|
|
526
537
|
revealRequest: undefined,
|
|
527
538
|
terminalRequest: undefined,
|
|
539
|
+
commitFocus: undefined,
|
|
528
540
|
untrackedDirs: new Map(),
|
|
529
541
|
}
|
|
530
542
|
|
|
@@ -576,6 +588,8 @@ export interface ExplorerValue {
|
|
|
576
588
|
revealRequest: RevealRequest | undefined
|
|
577
589
|
/** Pending "open a terminal here" request (consumed by the terminal panel). */
|
|
578
590
|
terminalRequest: TerminalRequest | undefined
|
|
591
|
+
/** Pending "select this commit in the history rail" request. */
|
|
592
|
+
commitFocus: CommitFocusRequest | undefined
|
|
579
593
|
setView: (view: RailView) => void
|
|
580
594
|
/** Switch to the search panel (optionally scoped to a folder) — the tree's
|
|
581
595
|
"find in folder" entry point. */
|
|
@@ -591,6 +605,8 @@ export interface ExplorerValue {
|
|
|
591
605
|
* search results' "open in terminal" entry.
|
|
592
606
|
*/
|
|
593
607
|
openTerminalAt: (dir: string) => void
|
|
608
|
+
/** Open the history rail with this commit selected (blame / file history). */
|
|
609
|
+
focusCommit: (hash: string) => void
|
|
594
610
|
/**
|
|
595
611
|
* The USER's pick — the workspace dropdowns and the wizard's "open files".
|
|
596
612
|
*
|
|
@@ -769,10 +785,12 @@ function build(): ExplorerValue {
|
|
|
769
785
|
searchRequest: state.searchRequest,
|
|
770
786
|
revealRequest: state.revealRequest,
|
|
771
787
|
terminalRequest: state.terminalRequest,
|
|
788
|
+
commitFocus: state.commitFocus,
|
|
772
789
|
setView,
|
|
773
790
|
requestSearch,
|
|
774
791
|
revealInExplorer,
|
|
775
792
|
openTerminalAt,
|
|
793
|
+
focusCommit,
|
|
776
794
|
selectWorkspace,
|
|
777
795
|
setRepoSubdir,
|
|
778
796
|
discoverRepos,
|
|
@@ -834,6 +852,128 @@ export function useExplorer(): ExplorerValue {
|
|
|
834
852
|
)
|
|
835
853
|
}
|
|
836
854
|
|
|
855
|
+
/**
|
|
856
|
+
* The store's subscription, extracted so `useExplorerSelector` passes React a
|
|
857
|
+
* STABLE function: a fresh arrow per render makes `useSyncExternalStore`
|
|
858
|
+
* unsubscribe/resubscribe on every paint.
|
|
859
|
+
*/
|
|
860
|
+
function subscribeStore(listener: () => void): () => void {
|
|
861
|
+
listeners.add(listener)
|
|
862
|
+
return () => {
|
|
863
|
+
listeners.delete(listener)
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
/**
|
|
868
|
+
* Shallow equality for selector results — one level deep, `Object.is` per field.
|
|
869
|
+
*
|
|
870
|
+
* Selectors naturally build a fresh `{ repoRoot, head, … }` object out of the
|
|
871
|
+
* snapshot, and a plain `Object.is` would then see a new reference on every
|
|
872
|
+
* publish and repaint the panel anyway (defeating the whole point). Passing this
|
|
873
|
+
* as `equal` compares the FIELDS, so "the snapshot was rebuilt but none of the
|
|
874
|
+
* fields I read changed" answers `true` and the previous value (and render) is
|
|
875
|
+
* kept. Arrays are compared as objects, i.e. by index.
|
|
876
|
+
*
|
|
877
|
+
* Shallow is deliberate: every selected field is either a primitive or a
|
|
878
|
+
* REFERENCE the store already owns (`status`, `buckets`, `tabs`, `untrackedDirs`
|
|
879
|
+
* …). Comparing those by reference is a real value check — the store only
|
|
880
|
+
* replaces them when they actually change.
|
|
881
|
+
*/
|
|
882
|
+
export function shallowEqual(a: unknown, b: unknown): boolean {
|
|
883
|
+
if (Object.is(a, b)) return true
|
|
884
|
+
if (typeof a !== 'object' || a === null || typeof b !== 'object' || b === null) return false
|
|
885
|
+
if (Array.isArray(a) !== Array.isArray(b)) return false
|
|
886
|
+
const left = a as Record<string, unknown>
|
|
887
|
+
const right = b as Record<string, unknown>
|
|
888
|
+
const keys = Object.keys(left)
|
|
889
|
+
if (keys.length !== Object.keys(right).length) return false
|
|
890
|
+
for (const key of keys) {
|
|
891
|
+
// `hasOwnProperty` first: `Object.is(undefined, undefined)` must still pass
|
|
892
|
+
// only for a field that EXISTS on both sides (a shorter object is a change).
|
|
893
|
+
if (!Object.prototype.hasOwnProperty.call(right, key)) return false
|
|
894
|
+
if (!Object.is(left[key], right[key])) return false
|
|
895
|
+
}
|
|
896
|
+
return true
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
/**
|
|
900
|
+
* Subscribe to ONE slice of the explorer store.
|
|
901
|
+
*
|
|
902
|
+
* Why this exists: `useExplorer()` hands out the whole `ExplorerValue`, and
|
|
903
|
+
* every `publish()` builds a NEW snapshot object — so every subscriber repaints
|
|
904
|
+
* on every mutation, including mutations its panel does not read (a save bumps
|
|
905
|
+
* the tab array, a git refresh replaces `status`, a rail switch changes `view`).
|
|
906
|
+
* With the panels kept MOUNTED, one publish therefore repainted every panel,
|
|
907
|
+
* and the SCM panel's change list (up to 4000 rows) was rebuilt for a change in
|
|
908
|
+
* an unrelated field.
|
|
909
|
+
*
|
|
910
|
+
* This hook re-renders its component ONLY when the selected value changes:
|
|
911
|
+
* - `publish()` still notifies every listener (that is how the store stays a
|
|
912
|
+
* single source of truth), but React asks this hook for a fresh value and
|
|
913
|
+
* `Object.is`-compares it with the last rendered one; equal means no render;
|
|
914
|
+
* - the selector runs at most once per (snapshot, selector) pair, and its
|
|
915
|
+
* result is kept in a per-hook cache, so an equal result keeps the PREVIOUS
|
|
916
|
+
* reference (downstream `useMemo`s keyed on it stay valid).
|
|
917
|
+
*
|
|
918
|
+
* Constraints, all from `useSyncExternalStore`:
|
|
919
|
+
* - the value returned for an UNCHANGED snapshot must be stable. This hook
|
|
920
|
+
* guarantees it (cache keyed on the snapshot identity), which is also why a
|
|
921
|
+
* selector may safely return a fresh object — with `shallowEqual` it is
|
|
922
|
+
* compared and the old reference is kept, and without `equal` it is cached
|
|
923
|
+
* and only recomputed when the snapshot itself changes;
|
|
924
|
+
* - `selector` must be PURE and should read only the snapshot. It may be an
|
|
925
|
+
* inline arrow (the hook tracks its identity, so a selector that closes over
|
|
926
|
+
* props is recomputed when it changes), but a module-level selector is
|
|
927
|
+
* cheaper: its identity is stable, so between publishes the cache answers
|
|
928
|
+
* without running it at all;
|
|
929
|
+
* - `selector` must not mutate the snapshot.
|
|
930
|
+
*
|
|
931
|
+
* @param selector - pure read of the fields this component needs.
|
|
932
|
+
* @param equal - comparison used to decide whether the new selection is the
|
|
933
|
+
* same value; defaults to `Object.is`. Pass `shallowEqual` for object slices.
|
|
934
|
+
*/
|
|
935
|
+
export function useExplorerSelector<T>(
|
|
936
|
+
selector: (snapshot: ExplorerValue) => T,
|
|
937
|
+
equal: (a: T, b: T) => boolean = Object.is,
|
|
938
|
+
): T {
|
|
939
|
+
/**
|
|
940
|
+
* Last (snapshot, selector) → value. A `useRef`, not module state: two
|
|
941
|
+
* components selecting different fields must not evict each other.
|
|
942
|
+
*/
|
|
943
|
+
const cache = useRef<{ source: ExplorerValue; selector: (snapshot: ExplorerValue) => T; value: T } | undefined>(undefined)
|
|
944
|
+
/**
|
|
945
|
+
* Latest selector/equal, kept in refs so `getSelection` can stay stable
|
|
946
|
+
* (one `useCallback([])`) while still calling the CURRENT functions. A
|
|
947
|
+
* selector that closes over props changes identity every render; comparing it
|
|
948
|
+
* with the cached one is what makes such a selector recompute (and see the new
|
|
949
|
+
* props) instead of returning the previous, now stale, value.
|
|
950
|
+
*/
|
|
951
|
+
const selectorRef = useRef(selector)
|
|
952
|
+
selectorRef.current = selector
|
|
953
|
+
const equalRef = useRef(equal)
|
|
954
|
+
equalRef.current = equal
|
|
955
|
+
const getSelection = useCallback((): T => {
|
|
956
|
+
const source = snapshot
|
|
957
|
+
const current = cache.current
|
|
958
|
+
if (current !== undefined && current.source === source && current.selector === selectorRef.current) {
|
|
959
|
+
// Same snapshot, same selector: the cached value is the answer. This is
|
|
960
|
+
// what `useSyncExternalStore` requires (a changing value here would loop),
|
|
961
|
+
// and what keeps two consecutive reads of one snapshot identical.
|
|
962
|
+
return current.value
|
|
963
|
+
}
|
|
964
|
+
const next = selectorRef.current(source)
|
|
965
|
+
if (current !== undefined && equalRef.current(current.value, next)) {
|
|
966
|
+
// The snapshot moved but this slice did not: keep the OLD reference so
|
|
967
|
+
// React sees no change (no render) and downstream memo keys stay stable.
|
|
968
|
+
cache.current = { source, selector: selectorRef.current, value: current.value }
|
|
969
|
+
return current.value
|
|
970
|
+
}
|
|
971
|
+
cache.current = { source, selector: selectorRef.current, value: next }
|
|
972
|
+
return next
|
|
973
|
+
}, [])
|
|
974
|
+
return useSyncExternalStore(subscribeStore, getSelection)
|
|
975
|
+
}
|
|
976
|
+
|
|
837
977
|
/** The repo-relative path of an absolute remote path ('' when outside). */
|
|
838
978
|
export function repoRelative(repoRoot: string | undefined, fullPath: string): string {
|
|
839
979
|
if (repoRoot === undefined) return ''
|
|
@@ -887,6 +1027,23 @@ const gitReads = new ReadQueue(refreshGitBusy)
|
|
|
887
1027
|
const latestGitRead = new Map<string, number>()
|
|
888
1028
|
let gitReadTicket = 0
|
|
889
1029
|
|
|
1030
|
+
/**
|
|
1031
|
+
* Cancellation handle for the git read in flight per binding.
|
|
1032
|
+
*
|
|
1033
|
+
* A workspace switch must take the OLD workspace's repository walk out of the
|
|
1034
|
+
* browser's connection pool. The browser gives one origin six connections and
|
|
1035
|
+
* the walk (probe + status + branch header) is the largest thing the plugin
|
|
1036
|
+
* sends; measured on the reported P710/Z700 trees, the walk took 8–9 s and a
|
|
1037
|
+
* purely in-memory `/status` route took 2.7–4.6 s during it — that is queueing,
|
|
1038
|
+
* not a slow host. Aborting the HTTP request frees the connection immediately;
|
|
1039
|
+
* the answer of an aborted read is dropped on purpose (a newer read of that
|
|
1040
|
+
* binding, or of the workspace now on screen, is the one that matters).
|
|
1041
|
+
*
|
|
1042
|
+
* One controller per binding, so a repo-picker move (same binding, another
|
|
1043
|
+
* directory) also retires the read it supersedes.
|
|
1044
|
+
*/
|
|
1045
|
+
const gitReadAborts = new Map<string, AbortController>()
|
|
1046
|
+
|
|
890
1047
|
/** True when `bindingId`'s read `ticket` may paint the on-screen slice. */
|
|
891
1048
|
function gitReadIsCurrent(bindingId: string, ticket: number): boolean {
|
|
892
1049
|
return latestGitRead.get(bindingId) === ticket && activeBinding().key === bindingId
|
|
@@ -1290,6 +1447,23 @@ export function openTerminalAt(dir: string): void {
|
|
|
1290
1447
|
setView('terminal')
|
|
1291
1448
|
}
|
|
1292
1449
|
|
|
1450
|
+
/** Monotonic ticket for "show this commit" requests from the editor. */
|
|
1451
|
+
let commitFocusSeq = 0
|
|
1452
|
+
|
|
1453
|
+
/**
|
|
1454
|
+
* Open the history rail and select one commit.
|
|
1455
|
+
*
|
|
1456
|
+
* Blame cells and the file-history menu only know a hash; the history panel owns
|
|
1457
|
+
* the list and the detail pane, so the selection travels as a request (the same
|
|
1458
|
+
* pattern as `revealInExplorer` / `openTerminalAt`).
|
|
1459
|
+
*/
|
|
1460
|
+
export function focusCommit(hash: string): void {
|
|
1461
|
+
if (hash === '' || /^0+$/.test(hash)) return
|
|
1462
|
+
commitFocusSeq += 1
|
|
1463
|
+
patch({ commitFocus: { id: commitFocusSeq, hash } })
|
|
1464
|
+
setView('history')
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1293
1467
|
/**
|
|
1294
1468
|
* Select the binding every view works against — the USER's choice.
|
|
1295
1469
|
*
|
|
@@ -1400,10 +1574,77 @@ function confirmDiscardOnWorkspaceSwitch(dirty: readonly EditorTab[]): Promise<b
|
|
|
1400
1574
|
})
|
|
1401
1575
|
}
|
|
1402
1576
|
|
|
1577
|
+
/**
|
|
1578
|
+
* The in-flight switch probe, so a newer switch cancels an older dial.
|
|
1579
|
+
*
|
|
1580
|
+
* A test dial is a real SSH connection attempt: against a host that is down it
|
|
1581
|
+
* runs for the connection timeout (tens of seconds), and it is a FOREGROUND
|
|
1582
|
+
* request (the tree is waiting on its answer), so it would hold the background
|
|
1583
|
+
* git channel shut behind it. Switching again makes that dial pointless, hence
|
|
1584
|
+
* the abort.
|
|
1585
|
+
*/
|
|
1586
|
+
let switchProbe: { alias: string; controller: AbortController } | undefined
|
|
1587
|
+
|
|
1588
|
+
/**
|
|
1589
|
+
* Re-prove one alias' link when the user selects a workspace on it.
|
|
1590
|
+
*
|
|
1591
|
+
* The connection chip polls (and an explicit retry is exactly this pair of
|
|
1592
|
+
* calls), but the tree gates on the same evidence: `loadDir`/`prefetchDir`
|
|
1593
|
+
* refuse an alias known down. A switch made inside the poll interval therefore
|
|
1594
|
+
* used to leave the tree empty until the next tick — the user had to retry by
|
|
1595
|
+
* hand. One dial here answers the question the switch just raised; a failed
|
|
1596
|
+
* probe changes nothing (the chip owns the failure, and the alias stays down).
|
|
1597
|
+
*/
|
|
1598
|
+
function probeConnectionOnSwitch(alias: string): void {
|
|
1599
|
+
if (alias === '') return
|
|
1600
|
+
switchProbe?.controller.abort()
|
|
1601
|
+
const controller = new AbortController()
|
|
1602
|
+
switchProbe = { alias, controller }
|
|
1603
|
+
void (async () => {
|
|
1604
|
+
try {
|
|
1605
|
+
// Background on purpose: a dead host's dial runs for the connection
|
|
1606
|
+
// timeout (45 s + guard). As a FOREGROUND request it would hold the
|
|
1607
|
+
// foreground counter up for that whole window and starve every background
|
|
1608
|
+
// git read; as a background one it only contends with the git channel,
|
|
1609
|
+
// while the tree keeps showing its cached/empty state.
|
|
1610
|
+
const answer = await api.testHost(alias, { background: true, signal: controller.signal })
|
|
1611
|
+
if (controller.signal.aborted || !answer.ok) return
|
|
1612
|
+
// The same two steps as the chip's retry: record the success (so a stale
|
|
1613
|
+
// poll cannot paint it red again) and refresh the pooled status.
|
|
1614
|
+
markConnectionProbeOk(alias)
|
|
1615
|
+
const statuses = await api.connectionStatus()
|
|
1616
|
+
if (controller.signal.aborted) return
|
|
1617
|
+
applyConnectionStatuses(statuses)
|
|
1618
|
+
} catch {
|
|
1619
|
+
// A failed probe is not news: the alias keeps the state the chip shows.
|
|
1620
|
+
} finally {
|
|
1621
|
+
if (switchProbe?.controller === controller) switchProbe = undefined
|
|
1622
|
+
}
|
|
1623
|
+
})()
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1403
1626
|
/** Move the selection; `byUser` decides whether it is remembered as a choice. */
|
|
1404
1627
|
function applyWorkspaceSelection(id: string, byUser: boolean): void {
|
|
1405
1628
|
if (state.workspaceId === id) return
|
|
1406
1629
|
if (byUser) noteManualPick()
|
|
1630
|
+
const target = state.workspaces.find(item => item.id === id)
|
|
1631
|
+
// A connection probe started for the workspace being left is a real SSH dial
|
|
1632
|
+
// (up to the connection timeout on a dead host) and it is a FOREGROUND
|
|
1633
|
+
// request: left running, it would keep the background git channel of the NEW
|
|
1634
|
+
// workspace shut. Cancel it whether or not the new alias needs its own probe.
|
|
1635
|
+
if (switchProbe !== undefined && switchProbe.alias !== target?.alias) {
|
|
1636
|
+
switchProbe.controller.abort()
|
|
1637
|
+
switchProbe = undefined
|
|
1638
|
+
}
|
|
1639
|
+
// The workspace being left may have a full `git status` walk in flight. It is
|
|
1640
|
+
// no longer what the screen shows, and its connections are exactly what the
|
|
1641
|
+
// new workspace's directory list needs — cancel it here (the read drops its
|
|
1642
|
+
// answer; the cache it may already have written stays).
|
|
1643
|
+
for (const [readId, controller] of [...gitReadAborts]) {
|
|
1644
|
+
if (readId === id) continue
|
|
1645
|
+
controller.abort()
|
|
1646
|
+
gitReadAborts.delete(readId)
|
|
1647
|
+
}
|
|
1407
1648
|
// Local stage results are repository-relative: another binding's paths must
|
|
1408
1649
|
// never be re-applied to this one. The expanded untracked directories are
|
|
1409
1650
|
// repository-relative too.
|
|
@@ -1430,6 +1671,9 @@ function applyWorkspaceSelection(id: string, byUser: boolean): void {
|
|
|
1430
1671
|
// flag must reflect that before anything is published again.
|
|
1431
1672
|
refreshGitBusy()
|
|
1432
1673
|
if (stale) void refreshGit('join')
|
|
1674
|
+
// Selected onto an alias whose last known state was `error`: ask once, so the
|
|
1675
|
+
// tree is not gated offline by evidence from before the switch.
|
|
1676
|
+
if (target !== undefined && connectionStateOf(target.alias) === 'error') probeConnectionOnSwitch(target.alias)
|
|
1433
1677
|
}
|
|
1434
1678
|
|
|
1435
1679
|
let searchSeq = 0
|
|
@@ -1479,6 +1723,9 @@ let manualPickSession: string | undefined
|
|
|
1479
1723
|
*/
|
|
1480
1724
|
function noteManualPick(): void {
|
|
1481
1725
|
if (followSessionId !== undefined) manualPickSession = followSessionId
|
|
1726
|
+
// An explicit choice settles the follow for good: no fast retry may move the
|
|
1727
|
+
// selection out from under it afterwards.
|
|
1728
|
+
clearFollowRetry()
|
|
1482
1729
|
}
|
|
1483
1730
|
|
|
1484
1731
|
/**
|
|
@@ -1506,11 +1753,118 @@ export function setFollowSession(sessionId: string | undefined): void {
|
|
|
1506
1753
|
// A new seat re-follows: the previous session's manual pick was about that
|
|
1507
1754
|
// session's workspace, not this one's.
|
|
1508
1755
|
manualPickSession = undefined
|
|
1756
|
+
// …and its pending retry was about the previous session too.
|
|
1757
|
+
clearFollowRetry()
|
|
1758
|
+
// A different seat gets its own fast-retry budget.
|
|
1759
|
+
followFastRetrySpent = undefined
|
|
1509
1760
|
}
|
|
1510
1761
|
|
|
1511
1762
|
/** One resolution in flight, so the same session is never probed twice at once. */
|
|
1512
1763
|
let followFlight: { sessionId: string; promise: Promise<string | undefined> } | undefined
|
|
1513
1764
|
|
|
1765
|
+
/**
|
|
1766
|
+
* Fast retries for a session whose workspace has not resolved yet.
|
|
1767
|
+
*
|
|
1768
|
+
* Opening a conversation right after a page load (or before the change panel's
|
|
1769
|
+
* first scan) used to leave the selector on the previous workspace until the
|
|
1770
|
+
* panel's slow fallback came around: the workspace visibly switched by itself a
|
|
1771
|
+
* quarter of a minute later, which reads as a slow/glitchy app. Three quick
|
|
1772
|
+
* attempts cover that window; the SLOW fallback stays in the panel, so this is a
|
|
1773
|
+
* latency fix, not a second poll. Only an UNRESOLVED follow retries: an answer
|
|
1774
|
+
* that landed, a manual pick and a session change all stop the chain.
|
|
1775
|
+
*
|
|
1776
|
+
* Module-level state for the same reason the follow itself is: it must outlive
|
|
1777
|
+
* any one surface's render, and there is exactly one follow per page.
|
|
1778
|
+
*/
|
|
1779
|
+
const FOLLOW_FAST_RETRY_MS = [300, 1_000, 3_000] as const
|
|
1780
|
+
|
|
1781
|
+
/** The pending fast-retry chain (one session at a time). */
|
|
1782
|
+
let followRetry: { sessionId: string; attempt: number; timer: ReturnType<typeof setTimeout> } | undefined
|
|
1783
|
+
|
|
1784
|
+
/**
|
|
1785
|
+
* Session whose fast-retry budget has been spent.
|
|
1786
|
+
*
|
|
1787
|
+
* The slow panel tick keeps calling the follow every 15 s; without this, each
|
|
1788
|
+
* unresolved answer would arm a NEW three-attempt chain and a session with no
|
|
1789
|
+
* resolvable workspace would cost four cwd probes per tick instead of one.
|
|
1790
|
+
* Cleared when the session changes (a new seat gets its own budget).
|
|
1791
|
+
*/
|
|
1792
|
+
let followFastRetrySpent: string | undefined
|
|
1793
|
+
|
|
1794
|
+
/** > 0 while a retry-driven `followSessionWorkspace` call is in flight. */
|
|
1795
|
+
let followRetryDrive = 0
|
|
1796
|
+
|
|
1797
|
+
/** Drop the pending retry (a resolution landed, the session changed, or the user picked). */
|
|
1798
|
+
function clearFollowRetry(): void {
|
|
1799
|
+
if (followRetry === undefined) return
|
|
1800
|
+
clearTimeout(followRetry.timer)
|
|
1801
|
+
followRetry = undefined
|
|
1802
|
+
}
|
|
1803
|
+
|
|
1804
|
+
/** Is the retry chain still about the session on screen, and still wanted? */
|
|
1805
|
+
function followRetryWanted(sessionId: string): boolean {
|
|
1806
|
+
return followSessionId === sessionId
|
|
1807
|
+
&& followedSession !== sessionId
|
|
1808
|
+
&& manualPickSession !== sessionId
|
|
1809
|
+
}
|
|
1810
|
+
|
|
1811
|
+
/**
|
|
1812
|
+
* Arm one attempt of the chain.
|
|
1813
|
+
*
|
|
1814
|
+
* The timer calls the follow again; a resolution that still has not landed
|
|
1815
|
+
* schedules the next attempt, and the chain stops after
|
|
1816
|
+
* {@link FOLLOW_FAST_RETRY_MS}'s last entry. "Still not landed" includes a cwd
|
|
1817
|
+
* probe that failed (resolved as "nothing resolved", not thrown); only a
|
|
1818
|
+
* rejection of the whole follow call — a bug, not a host answer — stops the
|
|
1819
|
+
* chain outright.
|
|
1820
|
+
*/
|
|
1821
|
+
function startFollowRetry(sessionId: string, attempt: number): void {
|
|
1822
|
+
clearFollowRetry()
|
|
1823
|
+
if (!followRetryWanted(sessionId)) return
|
|
1824
|
+
if (attempt >= FOLLOW_FAST_RETRY_MS.length) {
|
|
1825
|
+
followFastRetrySpent = sessionId
|
|
1826
|
+
return
|
|
1827
|
+
}
|
|
1828
|
+
const timer = setTimeout(() => {
|
|
1829
|
+
followRetry = undefined
|
|
1830
|
+
if (!followRetryWanted(sessionId)) return
|
|
1831
|
+
followRetryDrive += 1
|
|
1832
|
+
void followSessionWorkspace({}).then(
|
|
1833
|
+
(resolved) => {
|
|
1834
|
+
followRetryDrive -= 1
|
|
1835
|
+
if (resolved !== undefined || !followRetryWanted(sessionId)) {
|
|
1836
|
+
clearFollowRetry()
|
|
1837
|
+
return
|
|
1838
|
+
}
|
|
1839
|
+
startFollowRetry(sessionId, attempt + 1)
|
|
1840
|
+
},
|
|
1841
|
+
() => {
|
|
1842
|
+
followRetryDrive -= 1
|
|
1843
|
+
clearFollowRetry()
|
|
1844
|
+
},
|
|
1845
|
+
)
|
|
1846
|
+
}, FOLLOW_FAST_RETRY_MS[attempt] as number)
|
|
1847
|
+
// Never keep a Node gate (or a closing page) alive just for a retry.
|
|
1848
|
+
timer.unref?.()
|
|
1849
|
+
followRetry = { sessionId, attempt, timer }
|
|
1850
|
+
}
|
|
1851
|
+
|
|
1852
|
+
/**
|
|
1853
|
+
* Note that one resolution came back unresolved and arm the fast retry.
|
|
1854
|
+
*
|
|
1855
|
+
* A no-op while the chain already runs for this session (the chain owns its next
|
|
1856
|
+
* attempt — scheduling from here would restart the delays) and while a
|
|
1857
|
+
* retry-driven call is in flight. A chain belonging to ANOTHER session is stale
|
|
1858
|
+
* and is replaced.
|
|
1859
|
+
*/
|
|
1860
|
+
function noteFollowUnresolved(sessionId: string): void {
|
|
1861
|
+
// The fast budget is once per session: the slow tick must not refill it.
|
|
1862
|
+
if (followFastRetrySpent === sessionId) return
|
|
1863
|
+
if (followRetry !== undefined && followRetry.sessionId !== sessionId) clearFollowRetry()
|
|
1864
|
+
if (followRetryDrive > 0 || followRetry !== undefined) return
|
|
1865
|
+
startFollowRetry(sessionId, 0)
|
|
1866
|
+
}
|
|
1867
|
+
|
|
1514
1868
|
/**
|
|
1515
1869
|
* Point the workspace selector (and with it the tree, the editor's dropdown and
|
|
1516
1870
|
* the git panel) at the binding the registered session works in.
|
|
@@ -1569,8 +1923,14 @@ export function followSessionWorkspace(options: {
|
|
|
1569
1923
|
// re-deciding what was already decided. A manual pick made BEFORE anything
|
|
1570
1924
|
// resolved (see `manualPickSession`) is the same promise, kept even though
|
|
1571
1925
|
// there is no follow to remember.
|
|
1572
|
-
if (followedSession === sessionId)
|
|
1573
|
-
|
|
1926
|
+
if (followedSession === sessionId) {
|
|
1927
|
+
clearFollowRetry()
|
|
1928
|
+
return Promise.resolve(followedBindingId)
|
|
1929
|
+
}
|
|
1930
|
+
if (manualPickSession === sessionId) {
|
|
1931
|
+
clearFollowRetry()
|
|
1932
|
+
return Promise.resolve(undefined)
|
|
1933
|
+
}
|
|
1574
1934
|
const inFlight = followFlight
|
|
1575
1935
|
if (inFlight !== undefined && inFlight.sessionId === sessionId) return inFlight.promise
|
|
1576
1936
|
const promise = resolveSessionWorkspace(sessionId, options).finally(() => {
|
|
@@ -1611,6 +1971,9 @@ async function resolveSessionWorkspace(
|
|
|
1611
1971
|
cwd = answer.cwd
|
|
1612
1972
|
} catch {
|
|
1613
1973
|
// A failed probe resolves nothing: the selection stands, nothing is sent.
|
|
1974
|
+
// Still unresolved, so the fast retry gets its chance (the panel's slow
|
|
1975
|
+
// fallback would otherwise be the only way out).
|
|
1976
|
+
noteFollowUnresolved(sessionId)
|
|
1614
1977
|
return undefined
|
|
1615
1978
|
}
|
|
1616
1979
|
// The session may have changed while the host was answering; its evidence
|
|
@@ -1618,12 +1981,23 @@ async function resolveSessionWorkspace(
|
|
|
1618
1981
|
if (followSessionId !== sessionId) return undefined
|
|
1619
1982
|
if (cwd !== undefined && cwd !== '') decision = plan(cwd)
|
|
1620
1983
|
}
|
|
1621
|
-
if (decision.action === 'keep')
|
|
1984
|
+
if (decision.action === 'keep') {
|
|
1985
|
+
// Nothing resolved (the host knows no usable cwd for this session, or the
|
|
1986
|
+
// evidence names no binding): arm the fast retry instead of waiting for the
|
|
1987
|
+
// panel's slow one.
|
|
1988
|
+
noteFollowUnresolved(sessionId)
|
|
1989
|
+
return undefined
|
|
1990
|
+
}
|
|
1622
1991
|
// The user may have chosen a workspace WHILE this resolution was in flight:
|
|
1623
1992
|
// a choice beats a late answer.
|
|
1624
|
-
if (followSessionId !== sessionId || manualPickSession === sessionId)
|
|
1993
|
+
if (followSessionId !== sessionId || manualPickSession === sessionId) {
|
|
1994
|
+
clearFollowRetry()
|
|
1995
|
+
return undefined
|
|
1996
|
+
}
|
|
1625
1997
|
followedSession = decision.followedSession
|
|
1626
1998
|
followedBindingId = decision.bindingId
|
|
1999
|
+
// An answer landed: the chain has nothing left to do.
|
|
2000
|
+
clearFollowRetry()
|
|
1627
2001
|
if (state.workspaceId !== decision.bindingId) selectWorkspaceAuto(decision.bindingId)
|
|
1628
2002
|
return decision.bindingId
|
|
1629
2003
|
}
|
|
@@ -1767,6 +2141,9 @@ export async function refreshGit(mode: 'join' | 'fresh' = 'fresh'): Promise<void
|
|
|
1767
2141
|
try {
|
|
1768
2142
|
await gitReads.run(cacheKey, () => readGit(key, subdir, cacheKey), mode, settleMs)
|
|
1769
2143
|
} catch (error) {
|
|
2144
|
+
// A cancelled read (a workspace switch retired it) is not a failure: the
|
|
2145
|
+
// selection moved on and there is nothing to report for the old key.
|
|
2146
|
+
if (isRequestAbort(error)) return
|
|
1770
2147
|
// Only the settle deadline (or a throw before the read's own try) lands
|
|
1771
2148
|
// here: `readGit` handles read failures itself. The failure belongs to the
|
|
1772
2149
|
// key this read STARTED with — the repo picker may have moved the panel to
|
|
@@ -1789,6 +2166,14 @@ async function readGit(bindingId: string, subdir: string, cacheKey: string): Pro
|
|
|
1789
2166
|
// The binding can disappear from the table while this read waits in the queue.
|
|
1790
2167
|
const workspace = state.workspaces.find(item => item.id === bindingId)
|
|
1791
2168
|
if (workspace === undefined) return
|
|
2169
|
+
// A read of the SAME binding is starting: the one already running describes a
|
|
2170
|
+
// slice that is about to be replaced (another repository directory, or a
|
|
2171
|
+
// refresh that started later), so it must release its connection instead of
|
|
2172
|
+
// walking the tree to an answer nobody will use.
|
|
2173
|
+
gitReadAborts.get(bindingId)?.abort()
|
|
2174
|
+
const controller = new AbortController()
|
|
2175
|
+
gitReadAborts.set(bindingId, controller)
|
|
2176
|
+
const signal = controller.signal
|
|
1792
2177
|
const ticket = ++gitReadTicket
|
|
1793
2178
|
latestGitRead.set(bindingId, ticket)
|
|
1794
2179
|
// A local stage/unstage that happens while this read is in flight cannot be in
|
|
@@ -1802,7 +2187,7 @@ async function readGit(bindingId: string, subdir: string, cacheKey: string): Pro
|
|
|
1802
2187
|
// hint, which is the very blank state the cache exists to prevent.
|
|
1803
2188
|
// `withDeadline` covers the host that never answers at all; the probe itself
|
|
1804
2189
|
// reports transport failures.
|
|
1805
|
-
const probe = await withDeadline(probeRepoRoot(workspace.alias, workdir), gitDeadlineMs(), t('editor.readTimeout'))
|
|
2190
|
+
const probe = await withDeadline(probeRepoRoot(workspace.alias, workdir, signal), gitDeadlineMs(), t('editor.readTimeout'))
|
|
1806
2191
|
if (probe.kind === 'failed') throw new Error(probe.error)
|
|
1807
2192
|
if (probe.kind === 'none') {
|
|
1808
2193
|
const snapshot: GitSnapshot = {
|
|
@@ -1820,9 +2205,12 @@ async function readGit(bindingId: string, subdir: string, cacheKey: string): Pro
|
|
|
1820
2205
|
}
|
|
1821
2206
|
const root = probe.root
|
|
1822
2207
|
const [detail, head] = await Promise.all([
|
|
1823
|
-
withDeadline(loadStatusDetail(workspace.alias, root), gitDeadlineMs(), t('editor.readTimeout')),
|
|
1824
|
-
withDeadline(loadHead(workspace.alias, root), gitDeadlineMs(), t('editor.readTimeout')),
|
|
2208
|
+
withDeadline(loadStatusDetail(workspace.alias, root, signal), gitDeadlineMs(), t('editor.readTimeout')),
|
|
2209
|
+
withDeadline(loadHead(workspace.alias, root, signal), gitDeadlineMs(), t('editor.readTimeout')),
|
|
1825
2210
|
])
|
|
2211
|
+
// One half may have been aborted while the other answered; a half-finished
|
|
2212
|
+
// pair must never be cached (an aborted HEAD once landed as "detached").
|
|
2213
|
+
if (signal.aborted) return
|
|
1826
2214
|
// A directory INSIDE a repository settles on that repository's root, so the
|
|
1827
2215
|
// stored choice is what git actually uses (and what the picker shows). Only
|
|
1828
2216
|
// the binding's LATEST read may rewrite that persisted choice: a read
|
|
@@ -1866,6 +2254,11 @@ async function readGit(bindingId: string, subdir: string, cacheKey: string): Pro
|
|
|
1866
2254
|
if (settled !== subdir) writeGitSnapshot(gitCacheKey(bindingId, settled), snapshot)
|
|
1867
2255
|
paintGit(bindingId, ticket, snapshot)
|
|
1868
2256
|
} catch (error) {
|
|
2257
|
+
// An ABORTED read is not a failure. The switch (or the newer read that
|
|
2258
|
+
// superseded this one) cancelled it on purpose, so there is nothing to
|
|
2259
|
+
// report: `gitError` would blame the user's new workspace for a walk they
|
|
2260
|
+
// left, and the cached slice they already have stays the truth.
|
|
2261
|
+
if (signal.aborted || isRequestAbort(error)) return
|
|
1869
2262
|
if (!gitReadIsCurrent(bindingId, ticket)) return
|
|
1870
2263
|
// A failed read discards nothing that was already known: the panel keeps the
|
|
1871
2264
|
// last good (or cached) slice and prints the message above it, so a transient
|
|
@@ -1875,6 +2268,10 @@ async function readGit(bindingId: string, subdir: string, cacheKey: string): Pro
|
|
|
1875
2268
|
gitError: error instanceof Error ? error.message : String(error),
|
|
1876
2269
|
gitCached: state.repoRoot !== undefined,
|
|
1877
2270
|
})
|
|
2271
|
+
} finally {
|
|
2272
|
+
// Only the read that still owns the slot may clear it: a newer read has
|
|
2273
|
+
// already replaced the map entry and must stay abortable.
|
|
2274
|
+
if (gitReadAborts.get(bindingId) === controller) gitReadAborts.delete(bindingId)
|
|
1878
2275
|
}
|
|
1879
2276
|
}
|
|
1880
2277
|
|
|
@@ -2257,6 +2654,7 @@ export function openFile(fullPath: string, options: { line?: number } = {}): voi
|
|
|
2257
2654
|
const workspace = currentWorkspace()
|
|
2258
2655
|
if (workspace === undefined || fullPath === '') return
|
|
2259
2656
|
const id = `file:${workspace.alias}:${fullPath}`
|
|
2657
|
+
const previewKind = previewKindOf(fullPath)
|
|
2260
2658
|
// Re-opening a tab that is already up only re-addresses the reveal line, so
|
|
2261
2659
|
// a second search hit in the same file moves the cursor instead of reloading.
|
|
2262
2660
|
// The nonce also re-triggers a jump to the SAME line (value alone would not).
|
|
@@ -2284,10 +2682,10 @@ export function openFile(fullPath: string, options: { line?: number } = {}): voi
|
|
|
2284
2682
|
saving: false,
|
|
2285
2683
|
binary: false,
|
|
2286
2684
|
truncated: false,
|
|
2287
|
-
image:
|
|
2288
|
-
markdown:
|
|
2289
|
-
html:
|
|
2290
|
-
preview:
|
|
2685
|
+
image: previewKind === 'image',
|
|
2686
|
+
markdown: previewKind === 'markdown',
|
|
2687
|
+
html: previewKind === 'html',
|
|
2688
|
+
preview: hasTextSource(previewKind),
|
|
2291
2689
|
staged: false,
|
|
2292
2690
|
untracked: false,
|
|
2293
2691
|
...(options.line === undefined ? {} : { line: options.line, lineNonce: 1 }),
|
|
@@ -2295,6 +2693,13 @@ export function openFile(fullPath: string, options: { line?: number } = {}): voi
|
|
|
2295
2693
|
model: undefined,
|
|
2296
2694
|
view: 'split',
|
|
2297
2695
|
})
|
|
2696
|
+
// PDF/Office/media have no editable text: reading them through fs.read would
|
|
2697
|
+
// only fetch a capped base64 window and land on the binary notice. The
|
|
2698
|
+
// preview component reads their bytes from the download route instead.
|
|
2699
|
+
if (isBytePreview(previewKind)) {
|
|
2700
|
+
patchTab(id, { loading: false })
|
|
2701
|
+
return
|
|
2702
|
+
}
|
|
2298
2703
|
void (async () => {
|
|
2299
2704
|
try {
|
|
2300
2705
|
const read = await withDeadline(api.fileOp.read(workspace.alias, fullPath), fileReadDeadlineMs(), t('editor.readTimeout'))
|
|
@@ -2823,6 +3228,13 @@ export async function reloadTab(id: string): Promise<void> {
|
|
|
2823
3228
|
const tab = state.tabs.find(item => item.id === id)
|
|
2824
3229
|
if (workspace === undefined || tab === undefined) return
|
|
2825
3230
|
if (tab.kind === 'file') {
|
|
3231
|
+
// Byte previews have no text buffer: fs.read would fetch a capped base64
|
|
3232
|
+
// window and turn the tab into "binary", hiding the preview. A revision
|
|
3233
|
+
// bump is the whole reload for them.
|
|
3234
|
+
if (isBytePreview(previewKindOf(tab.fullPath))) {
|
|
3235
|
+
patchTab(id, { loading: false, error: undefined, reloadNonce: (tab.reloadNonce ?? 0) + 1 })
|
|
3236
|
+
return
|
|
3237
|
+
}
|
|
2826
3238
|
try {
|
|
2827
3239
|
const read = await withDeadline(api.fileOp.read(workspace.alias, tab.fullPath), fileReadDeadlineMs(), t('editor.readTimeout'))
|
|
2828
3240
|
patchTab(id, {
|
package/src/client/ui.tsx
CHANGED
|
@@ -107,6 +107,10 @@ export function Spinner(props: { size?: number }): ReactNode {
|
|
|
107
107
|
export function Notice(props: { kind: 'info' | 'error'; children: ReactNode }): ReactNode {
|
|
108
108
|
return (
|
|
109
109
|
<div
|
|
110
|
+
// A banner is how a remote failure reaches the user (a refused write, a
|
|
111
|
+
// dead link): announce it. An error asserts; informational copy is polite
|
|
112
|
+
// so it does not interrupt what the user is typing.
|
|
113
|
+
role={props.kind === 'error' ? 'alert' : 'status'}
|
|
110
114
|
style={{
|
|
111
115
|
margin: '8px 0',
|
|
112
116
|
padding: '6px 10px',
|