dsh-remote-vs 0.27.0 → 0.28.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 (48) hide show
  1. package/README.en.md +110 -19
  2. package/README.md +82 -19
  3. package/lib/client.js +6789 -6607
  4. package/lib/index.js +546 -16
  5. package/lib/types/changes/recorder.d.ts +119 -2
  6. package/lib/types/client/CodeEditor.d.ts +15 -0
  7. package/lib/types/client/api.d.ts +17 -1
  8. package/lib/types/client/changes/apply-failure.d.ts +41 -0
  9. package/lib/types/client/changes/block-confirm.d.ts +97 -0
  10. package/lib/types/client/changes/diff-outcome.d.ts +56 -0
  11. package/lib/types/client/changes/freshness.d.ts +51 -0
  12. package/lib/types/client/changes/model.d.ts +19 -1
  13. package/lib/types/client/changes/session-diff.d.ts +100 -0
  14. package/lib/types/client/changes/staleness.d.ts +98 -0
  15. package/lib/types/client/changes/turn-reverted.d.ts +82 -0
  16. package/lib/types/client/changes/turn-view.d.ts +131 -0
  17. package/lib/types/client/changes/undo-affordance.d.ts +44 -10
  18. package/lib/types/client/changes/undo-target.d.ts +12 -0
  19. package/lib/types/client/i18n.d.ts +1 -1
  20. package/lib/types/client/store.d.ts +91 -1
  21. package/lib/types/client/vsc/change-marks.d.ts +21 -0
  22. package/lib/types/protocol.d.ts +99 -1
  23. package/package.json +1 -1
  24. package/src/changes/recorder.ts +851 -8
  25. package/src/client/CodeEditor.tsx +43 -3
  26. package/src/client/EditorPane.tsx +64 -7
  27. package/src/client/api.ts +30 -3
  28. package/src/client/changes/ChangesDock.tsx +539 -54
  29. package/src/client/changes/apply-failure.ts +73 -0
  30. package/src/client/changes/block-confirm.ts +180 -0
  31. package/src/client/changes/changes.css +45 -0
  32. package/src/client/changes/diff-outcome.ts +97 -0
  33. package/src/client/changes/freshness.ts +68 -0
  34. package/src/client/changes/model.ts +56 -1
  35. package/src/client/changes/session-diff.ts +187 -0
  36. package/src/client/changes/staleness.ts +148 -0
  37. package/src/client/changes/turn-reverted.ts +254 -0
  38. package/src/client/changes/turn-view.ts +195 -0
  39. package/src/client/changes/undo-affordance.ts +295 -63
  40. package/src/client/changes/undo-target.ts +12 -0
  41. package/src/client/i18n.ts +102 -4
  42. package/src/client/scm/DiffView.tsx +32 -13
  43. package/src/client/store.tsx +392 -16
  44. package/src/client/vsc/change-marks.ts +21 -0
  45. package/src/client/vsc/preview-document.tsx +4 -1
  46. package/src/client/vsc/vsc.css +6642 -6509
  47. package/src/protocol.ts +101 -1
  48. package/src/routes.ts +20 -9
package/README.en.md CHANGED
@@ -6,9 +6,8 @@
6
6
 
7
7
  SSH host management inside the DSH Host process + helper push pipeline + a **VS Code-style remote
8
8
  workbench** (explorer / search / source control / commit graph with its commit-details pane / multi-tab editor / floating editor /
9
- side-by-side diff / multiple terminals / port forwarding). Hosts live in DSH Settings ("Remote hosts"); with `dsh-better-sidebar` installed
10
- there is an extra standalone "Remote Workspace" tab, otherwise it falls back to a native right-Sidebar "Remote Workspace"
11
- page (same content, self-opened from the guide, per-session instances). **The sidebar's editor is the DEFAULT
9
+ side-by-side diff / multiple terminals / port forwarding). Hosts live in DSH Settings ("Remote hosts");native right-Sidebar "Remote Workspace"
10
+ page. **The sidebar's editor is the DEFAULT
12
11
  seat**: opening a file switches the whole column to it (one view at a time, no tree/editor split) and closing
13
12
  the last file returns to the directory. The conversation view slot is registered too, but as the OPTIONAL
14
13
  full-width seat — the editor's own expand/dock button moves the same buffer between the two. Since P2, native
@@ -40,8 +39,7 @@ dsh plugin --profile web add dsh-remote-vs
40
39
 
41
40
  **Requires DSH `0.2.2-rc.5` or newer and below `0.3.0`** (`engines.dsh` enforces the range;
42
41
  **adapted to and typechecked against `0.2.2-rc.5`**). On Host `0.2.2-rc.4` use plugin `0.23.0`; `0.2.2-rc.2` / `0.2.2-rc.3` use plugin `0.22.0`; on `0.2.2-alpha.3` / `0.2.2-rc.1` use `0.20.1`; the
43
- `0.2.2-alpha.2` generation needs `0.17.0` and the `0.2.1-rc.2` generation needs `0.9.3`. `--profile web` selects which profile to install into —
44
- this is a Web plugin, so it has to go into the profile your Web GUI runs from (`web` is
42
+ `0.2.2-alpha.2` generation needs `0.17.0`. `--profile web` selects which profile to install, so it has to go into the profile your Web GUI runs from (`web` is
45
43
  the common name; use your own profile's name). Desktop uses the reserved `desktop`
46
44
  profile instead — see [Desktop](#desktop-dsh-desktop) below.
47
45
 
@@ -52,14 +50,6 @@ profile instead — see [Desktop](#desktop-dsh-desktop) below.
52
50
  > one ~47 MB upload on that first contact. The old helper directory is kept, so rolling back
53
51
  > is just pushing the old version again.
54
52
 
55
- **That one command is all it takes — no build scripts have to be approved.** The package
56
- has no `prepare`/`postinstall` and no package in the dependency tree carries an install
57
- script (`ssh2` is **bundled into the artifact**, not depended on); the repository route
58
- also ships the built `lib/`. The old "allow the printed build scripts in that profile's
59
- `pnpm-workspace.yaml` and re-run" step was pnpm 12's hard policy gate for dependencies
60
- with lifecycle scripts (`ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED` / `ERR_PNPM_IGNORED_BUILDS`);
61
- it cannot be waived from the dependency side, only removed from the tree. Then restart
62
- `dsh web` and open Settings → Remote hosts to configure.
63
53
 
64
54
  ### Desktop (DSH Desktop)
65
55
 
@@ -104,11 +94,11 @@ extra configuration is needed.
104
94
  | Search | Two modes: **file names** (remote `find`) and **contents** (remote `grep`). Content mode has a scope folder, `Aa` (case) / `ab_` (whole word) / `.*` (regex), results grouped per file with match highlights, and clicking a hit jumps to that line; **content mode can be aborted** (changing or clearing the query kills the running remote `grep`; an older Host without the streaming route degrades to a one-shot, non-cancellable query), success with stderr warnings is reported above the results, and a **directory** hit in name mode is revealed in the tree instead of being opened as a file |
105
95
  | Connection status and offline read-only | The top bar and the editor info bar show the current workspace's SSH link state (**connection OK / connection issue / ready, connects on demand**): a drop is no longer silent — open editor tabs keep their cached content and turn **read-only** (saves are blocked with an explanation), the tree keeps showing cached directories while background refreshes stay quiet, and uncached directories say they are offline. When the link recovers, directories, git status, **unmodified file tabs and read-only diff tabs** refresh automatically (tabs with unsaved edits are left alone and the user is told). An errored link is retried at most three times, 30 s apart, then the chip is a manual retry control. While the link is down, "Undo this change" and the diff's hunk actions are blocked too; **a single operation's deadline is NOT treated as a broken link** — the chip stays ok and only that operation fails, with the real reason; when the link is down and the workspace has no cache, the SCM panel says it cannot read instead of sitting on "loading". **No cross-reload persistent cache** (remote source never lands on disk) — a deliberate privacy trade-off |
106
96
  | Source control | **Repository-folder picker** (for workspaces whose git repository lives in a sub-folder: browse the remote tree, one-click jump to any repository discovered inside the workspace, type a relative or absolute path, and see which repository each folder resolves to); changes / staged / untracked / ignored buckets; **untracked directory rows expand on click**; per-file AND **per-hunk** stage / unstage / discard (behind a confirm) / commit; branches, remotes and stash panes; sync (fetch/pull/push), with **push refspec support** (Gerrit style `HEAD:refs/for/<branch>`; empty = plain `git push`, a non-empty value is remembered); fetch/pull/push/sync get a **live output panel** (server-sent events showing git/remote output, a running clock, **cancel** that kills the remote process group, and the full log for copying afterwards; an older Host without the streaming route falls back to the one-shot result); a non-repository workspace can **initialize a repository**, a branch can be **renamed**, and a remote URL can be **edited** (each behind a confirm/validation) |
107
- | Session change review | The **collapsible** panel above the composer: what THIS SESSION changed (one row per file, file-type icon, `+a −b` on the right); clicking a file opens it in the remote editor with **line shading plus character-level inline diff**, `n/N ↑↓` jumps between change points, and hovering a changed line offers **Undo this change** (remote `git apply -R`). See "Session change review" below; the header can **show only unreviewed files** and **jump to the next unreviewed one** (wraps, never marks a file reviewed) |
97
+ | Session change review | The **collapsible** panel above the composer: what THIS SESSION changed, with a one-click switch to **this turn** (the most recent completed turn; the default stays the session total) — one row per file, file-type icon, `+a −b` on the right; clicking a file opens it in the remote editor with **line shading plus character-level inline diff**, `n/N ↑↓` jumps between change points; hovering a changed line puts a `⋯` menu at the row end with **Undo this change** (remote `git apply -R`, failures classified) and **Keep this change** (per block, local only, independent of the file-level ✓); a row's right-click opens a **read-only side-by-side diff** of the ledger baseline, and open tabs are marked "positions stale" when the panel's poll sees their row move. See "Session change review" below; the header can **show only unreviewed files** and **jump to the next unreviewed one** (wraps, never marks a file reviewed) |
108
98
  | Side-by-side diff | Panes stay **exactly equal** + per-hunk buttons in the middle gutter + a **top horizontal scrollbar** (a very long line can no longer break the symmetry) + pinned line numbers, **rendering only the rows inside the viewport** (a 3000-line file goes from 9000 row containers to ~174, with exactly the same scroll range as a full render); switch between "before / after", and the after side is editable and savable (the save writes the working-tree file back; a diff above 8MiB is read-only, so a truncated prefix can never be written over the real file) |
109
99
  | Commit graph | SVG branch/merge graph; selecting a commit opens the **resizable / expandable commit-details pane** below it with three views: **Commit details** (subject, author, time, full hash + copy, parents, refs, message body, checkout), **Contents** (changed files grouped by directory, collapsible and path-filterable; click for the diff, right-click or the row button to open in the editor), **Diff** (only the first ~1500 rows start expanded, later files start folded; both line numbers, `+/−` counts, line wrapping, previous/next-file navigation, and copy of one file's patch or the whole patch). Merge commits are shown against their **first parent** (git lists no files for a merge otherwise) |
110
100
  | AI review | A single-file diff OR a **whole commit** can be handed to the conversation with one click — the request is **appended to the composer draft only** (nothing is sent automatically, and you can edit it first): a diff up to 32 KiB is inlined verbatim; a larger one (or one silently truncated at the 2 MB cap) becomes a summary request — file/commit facts + hunk headers + "fetch it yourself with `git show`" (a 2 MB diff is hundreds of thousands of tokens, so inlining it is pointless); an untracked or binary file is passed by path and the model reads it. Entries: the side-by-side diff toolbar and the commit pane's Diff toolbar; the button is disabled with the reason when the current session is not bound to this remote workspace, or the host exposes no conversation input channel |
111
- | Multi-tab editor | Open/save/reload, dirty marks, several files at once; **saves are atomic** (side file + rename, writing through symlinks and keeping the mode bits); **a save is checked against the remote baseline** — when the file was written by someone else (an agent through the transparent route, a terminal, another editor) since it was opened, the save is refused and offers "overwrite / load remote version / show difference" instead of overwriting silently; image preview, **document previews** (Markdown/HTML, SVG, CSV/TSV tables, PDF, Office converted to PDF by the host officeKit (remote LibreOffice fallback), audio/video; text sources offer source/preview switching); closing a tab, reloading and switching workspace all **ask first** when there are unsaved edits (a workspace switch clears every tab, so it asks); `Ctrl+S` works globally, even when the editor is not focused; **a page reload reopens the file tabs you had** (per workspace, at most 12; paths only, never contents; tabs that no longer open are skipped and counted; caret and scroll position are not restored); **Ctrl+G goes to a line** and **Ctrl+D selects the next occurrence of the selection**; **inline blame** (author + age; click the gutter cell to open that commit's details) and the file's **commit history** (`git log --follow`; click a row for that version's diff); **symbol outline** (`Ctrl+Shift+O`, language/indentation-based list of classes, functions and fields, click to jump) |
101
+ | Multi-tab editor | Open/save/reload, dirty marks, several files at once; **saves are atomic** (side file + rename, writing through symlinks and keeping the mode bits); **a save is checked against the remote baseline** — when the file was written by someone else (an agent through the transparent route, a terminal, another editor) since it was opened, the save is refused and offers "overwrite / load remote version / show difference" instead of overwriting silently; image preview, **document previews** (Markdown/HTML, SVG, CSV/TSV tables, PDF, Office converted to PDF by the host officeKit (remote LibreOffice fallback), audio/video; text sources offer source/preview switching); closing a tab, reloading and switching workspace all **ask first** when there are unsaved edits (a workspace switch clears every tab, so it asks); `Ctrl+S` works globally, even when the editor is not focused; **a page reload reopens the file tabs you had** (per workspace, at most 12; paths only, never contents; tabs that no longer open are skipped and counted; caret and scroll position are not restored); **Ctrl+G goes to a line** and **Ctrl+D selects the next occurrence of the selection**; **inline blame** (off by default; enable it with the `B` toggle in the info bar — author + age; click the gutter cell to open that commit's details) and the file's **commit history** (`git log --follow`; click a row for that version's diff); **symbol outline** (`Ctrl+Shift+O`, language/indentation-based list of classes, functions and fields, click to jump) |
112
102
  | Floating editor | Three entries: "Open in floating editor" in the file-tree / search-hit / source-control context menus, plus **double-clicking the "remote editor" tab** to float the editor as it stands (same tabs, previews, diff, find and change marks — not a second, thinner editor). Drag the title bar to move, drag any of the eight edges/corners to resize, maximize/restore (or double-click the title bar); **minimize to a draggable floating ball** (dirty dot on it, click or press Enter to restore, drag to park it anywhere); `Ctrl+wheel` zooms the editor text. Position, size, font size and the ball's spot survive a page refresh |
113
103
  | Syntax highlighting | VS Code **Dark+ / Light+** palettes; covers java/aidl/smali, c/c++, go, rust, js/ts, json, py, yaml, xml, html/css, md, sh, properties/rc/toml, diff …; a **fallback colorer** takes over when no grammar matches, so a file is never left monochrome. Honest caveat: kotlin / gradle / smali are coloured by the Java grammar (no dedicated package), which gets keywords, strings and comments right but does not split their own syntax |
114
104
  | Find | In-editor `Ctrl+F` (`Aa` / `ab_` / `.*`, `3/17` count, ↑↓, `F3`/`Shift+F3`, `Esc`); **selected text is carried into the box by `Ctrl+F`**; the widget is pinned to the top-right and does not scroll away; the `n/N` count refreshes on `F3`, clicks and caret moves |
@@ -233,7 +223,7 @@ dsh_remote_vs/
233
223
  ├── vendor/dsh-remote-helpers/ # helper seeds (shipped, seeded into cache at startup, see below)
234
224
  ├── docs/ # local-only working docs (only docs/media/ screenshots ship)
235
225
  │ ├── MAINTENANCE.md # local-only (.gitignore), not shipped: upgrade impact, checklist, pitfalls, release
236
- │ ├── VERSION-HISTORY.md # local-only: per-release change log (0.7.1 → 0.27.0)
226
+ │ ├── VERSION-HISTORY.md # local-only: per-release change log (0.7.1 → 0.28.0)
237
227
  │ └── GATES.md # local-only: local gate inventory and measured assertion counts
238
228
  ├── locale/ # bilingual plugin metadata
239
229
  └── lib/ # build output (**must be committed**; only .map is ignored; restart after link install)
@@ -351,16 +341,72 @@ with zero change events).
351
341
  right with the composer card; click the header to collapse/expand, `⟳` forces an immediate rescan. With no
352
342
  changes it says "this session has not changed any file yet"; when it cannot compute, it states the
353
343
  **specific reason** (see the limits below) instead of handing you an empty list to guess about.
344
+ - **Scope switch: session total / this turn** (the default is still the session total; nothing changes unless
345
+ you switch). The two small buttons in the header appear only when the host really published a completed
346
+ turn (not before the first turn ends, and not against an older host). In "This turn" the title becomes
347
+ **"Turn #N · HH:MM"** and both the rows and `+a −b` describe the **most recent completed turn** only — a file
348
+ some earlier turn changed but this turn did not is absent. The choice is remembered per browser
349
+ (`rvs.changes.scope`). N is a **completed** turn number: the turn the session is running right now is never
350
+ folded in early.
351
+ - **Opening a row in turn mode** uses the same marks/undo machinery as the cumulative view, but the baseline
352
+ is **what the file looked like when the previous turn closed**: `n/N ↑↓`, the hover "Undo this change"
353
+ (reverse-applies that turn's hunk) and the row's "Revert all changes in this file" (the turn's whole-file
354
+ reverse patch) all undo **this turn's** work only. If the file was modified after the turn closed, the host
355
+ answers "stale" and the panel **says so and switches back to the session-total view** before fetching that
356
+ comparison — it never paints line numbers from a comparison that no longer describes the file. Turn mode
357
+ has no "undo the new file (delete it)" entry (that needs git's index copy, and the turn cache keeps
358
+ patches only); the row menu says to delete it from the session-total view or the Source Control panel.
359
+ - **A successful revert hides the row from the turn list**: the turn view is the delta FROZEN when the
360
+ turn closed, and the host never rewrites it — so "reverted, but the row is still there" is finished by
361
+ the **client presentation layer**. After a single-change revert (that file had exactly one change this
362
+ turn) or the row's "Revert all changes in this file", the row is filtered out and the file count /
363
+ `+a −b` are recomputed from the **visible** rows; the panel says how many were hidden, and when nothing
364
+ is left — and the view is COMPLETE — it says "all changes from this turn have been reverted" (not
365
+ "this turn changed no file"). A partial view or a still-pending scan keeps the "N hidden" sentence:
366
+ the panel does not assert what it cannot prove.
367
+ Records are keyed by `(session, turn, path)` in browser storage (`rvs.changes.reverted.<session>`) and
368
+ survive a page reload. A PARTIAL undo of a multi-hunk file does **not** hide it (the remaining changes
369
+ must stay visible), a failed revert never hides anything, and a browser with storage disabled simply
370
+ does not remember (the list stays as before) — no remote write is ever affected, and the host's frozen
371
+ accounting is unchanged.
354
372
  - **Clicking a file** opens it in the remote editor with change marks: added lines get a **green line
355
373
  background**, deleted characters are drawn as an **inline struck-through chip** (a deleted character does
356
374
  not exist in the new file, so it can only be an inserted widget), and the left gutter carries a change bar.
357
375
  - **Jumping between change points**: the floating `n/N ↑↓` control at the editor's top-right
358
376
  (`Alt+Shift+Cmd/Ctrl+↓/↑`) cycles through them; typing in the editor invalidates the marks and says
359
- "position may be out of date".
360
- - **Undo this change**: hover a changed line and click → remote `git apply -R`. When the context no longer
377
+ "position may be out of date". **The panel's 3-second rescan invalidates open tabs too** (the session or
378
+ the remote side changed the same file again, or the file left the list): the same "positions stale" badge
379
+ appears and clicking that row recomputes against what is there now — an open tab never keeps painting
380
+ marks nobody knows are out of date.
381
+ - **View diff (read-only)**: right-click a row → "View diff" opens the file as a **side-by-side** diff whose
382
+ data comes from the **session ledger** (baseline = session start), not from `git diff` (that compares
383
+ index/HEAD and may include uncommitted edits that predate the session). The before side is reconstructed
384
+ exactly from the served hunks plus the current file, reusing the existing side-by-side renderer. The page
385
+ is read-only: no editing, no per-hunk stage/revert, and reloading still goes through the ledger. Binary and
386
+ oversized rows keep the entry **visible but disabled**, with the reason in its hint (opening it could only
387
+ show an empty or fake view); when the content was withheld at the byte cap — or the "after" read hit the
388
+ 8 MiB cap — the page is **not opened** and says the comparison is incomplete (the two panes would be
389
+ misaligned).
390
+ - **The five outcomes of opening a row are stated**: a diff withheld at the byte cap says "the comparison is
391
+ incomplete (it may count the whole file as changed), so nothing is marked and nothing can be reverted"; an
392
+ oversized file says "no line-level comparison, no undo — open the file to read it"; binary files, files the
393
+ remote cannot read, and files whose change is already gone each get their own sentence instead of a silent
394
+ empty list.
395
+ - **Row-end `⋯` menu**: hovering a changed line puts a small `⋯` at the row's right end (one row tall, its
396
+ vertical centre locked to that row, so the pointer reaches it horizontally without entering another row);
397
+ clicking it opens "Undo this change" and "Keep this change".
398
+ - **Undo this change**: pick undo in that menu → remote `git apply -R`. When the context no longer
361
399
  matches, the far end refuses outright (not one byte of the file changes); a tab with unsaved edits is
362
400
  refused first, so a remote patch can never overwrite your buffer; on success the caret stays where it was
363
- and the marks are re-read (they do not simply vanish because something was undone).
401
+ and the marks are re-read (they do not simply vanish because something was undone). **Failures are
402
+ classified**: surroundings moved / the file is gone from the repository / permission denied / the
403
+ repository has a `dubious ownership` problem (set `safe.directory` or fix ownership) / the patch is corrupt
404
+ — each with the sentence that tells you what to do, plus git's raw wording.
405
+ - **Keep this change (per block, local only)**: the same menu carries a toggle, "Keep this change" —
406
+ "I read this block and agree with it". It **writes nothing, sends nothing, and does not touch the diff
407
+ data**; the state lives in browser storage per session, keyed by a stable block identity (file + the four
408
+ hunk-header numbers), so it survives a page reload. It is a **second level** and does **not** sync with the
409
+ row's ✓: a block note is "I looked at this piece", the ✓ stays a file-level manual mark. No bulk keep.
364
410
  - **Follow the session's workspace**: the sidebar, the editor's dropdown and the file tree all follow the
365
411
  workspace the **current session** lives in; after a manual switch they are not pulled back within that
366
412
  session, and a new session follows again. The capability lives in the store, so it works even when **the
@@ -377,17 +423,62 @@ with zero change events).
377
423
  usually catch up within a second or two); **new files** created in a shell are found by a **slow scan**
378
424
  whose single-run budget is up to **3 minutes**, re-run at a self-tuning interval (at least 5 seconds,
379
425
  naturally longer on a huge checkout). `⟳` forces an immediate rescan.
426
+ - **How fast a manual edit shows up**: with no turn event (you changed a file from a terminal or an editor)
427
+ the panel's self-heal rescans on a window derived from the **last `git status` cost**
428
+ (`clamp(scan × 4, 5s, 30s)`): a small repository (100ms class) → **5 seconds**; an AOSP-class tree
429
+ (1.7s measured) → **6.8 seconds**; the **30-second ceiling only applies once a scan costs ≥ 7.5s**.
430
+ The cost is therefore calculable: on such a tree, with the 3-second poll, roughly **one `git status`
431
+ every ~9 seconds** — about **3×** the old 30-second window (the price of keeping the 4× design, paid
432
+ for surfacing manual edits in ~7s instead of 30s).
433
+ - **Coming back to the page** (tab shown again, or the window regaining focus) asks the host for **one
434
+ immediate rescan**, and it is NOT the same thing as `⟳`: only tracked files are re-scanned
435
+ (`trackedOnly`), the slow walk's cadence is untouched and a written-off `git ls-files --others` is NOT
436
+ re-armed (11s on the reference tree, minutes cold — focus can happen every few seconds). `⟳` is the one
437
+ that re-runs everything. Both are debounced by 5 seconds, skipped while the page is hidden, and skipped
438
+ when a request is already in flight (in-flight for over 60 seconds counts as a failed request, so one
439
+ stuck fetch cannot disable the refresh forever).
440
+ - **Note**: `⟳` and "coming back" only SCHEDULE the rescan — the response still carries the previous
441
+ summary, and the fresh numbers arrive on the next poll (≤ 3 seconds), not with the refresh call itself.
380
442
  - A non-git workspace, or one holding several repositories with no repository directory set, shows the exact
381
443
  reason (`no git repository at the workspace root, and N candidates below it — set the repository directory
382
444
  in Source Control`) rather than an empty list.
383
445
  - Binary and oversized files are marked "binary / too large" on the row and get no character-level diff;
384
446
  **non-UTF-8 text (GBK and friends) is treated as binary** (no counts, no undo) so it cannot produce
385
447
  garbage numbers and an undo that always fails.
448
+ - **Oversized files get no line-level comparison**: the list pins their `+a −b` to `0/0` (not real counts),
449
+ so opening one only opens the file with the sentence "too large, no line-level comparison" — no marks and
450
+ no undo, which also keeps `0/0` from being compared against real line counts and mislabelling the tab
451
+ "positions stale".
452
+ - **The turn view covers the most recent completed turn only** (no per-turn history): at each turn close the
453
+ host records every listed file's text and diffs the next close against it, so the turn the session is
454
+ running right now is never mixed in.
455
+ - **The turn's patches and hunk text have a budget (4 MiB by default)**: it counts whole-file reverse
456
+ patches plus hunk lines only; both full texts and the previous-close snapshot are bounded separately by
457
+ the scan caps (resident cost is roughly 4 MiB + those texts, worst case ≈ 20 MiB per active session).
458
+ Over budget, that session's turn view keeps **the real counts only** — no marks, no undo, the reason
459
+ stated, and the host **stops computing turn views for the rest of the session**. Continuing would
460
+ compare the next turn against a snapshot that was never advanced and attribute old work to it. The
461
+ session-total view is unaffected.
462
+ - **New files are found by the slow scan**: a turn close first uses whatever scan result is cached and the
463
+ list says "still waiting for the new-file scan"; after the slow walk (`git ls-files --others`) lands the
464
+ **same turn is recomputed** and that marker clears. When the walk is written off, the list was cut by the
465
+ file cap, or a PREVIOUS turn never finished its correction, the turn view stays marked partial — and a
466
+ path whose previous side was withheld (binary / too large) is dropped rather than reported as a
467
+ whole-file creation.
468
+ - Binary/oversized files keep "binary / too large" in the turn view too, with no line-level comparison; the
469
+ turn cache does not keep their bytes.
386
470
  - When the untracked scan gives up (e.g. the far end refuses), the panel **states the reason** and keeps the
387
471
  refresh entry point instead of silently listing fewer rows.
388
472
  - Undo carries **provenance** (session / binding / repository directory), so a patch can never be applied to
389
473
  another host after switching sessions or bindings; a file this session created whole is not offered for
390
474
  undo (a reverse patch must never delete an untracked file).
475
+ - Binary/oversized rows show "View diff" **disabled with its reason**; content withheld at the byte cap (or
476
+ an "after" read over 8 MiB) opens no diff at all, because those hunks are a whole-file fake comparison
477
+ that could never be reverted.
478
+ - When a file is back at its session baseline, opening the row says "no diff to show right now" instead of
479
+ claiming the remote cannot read it.
480
+ - "Positions stale" is only a **notice**, never an automatic re-read: that happens when you click the row (or
481
+ after a successful save).
391
482
 
392
483
  ## P2 transparent remote execution (Windows native)
393
484
 
package/README.md CHANGED
@@ -6,8 +6,7 @@
6
6
 
7
7
  Host 进程内的 SSH 主机管理 + helper 推送流水线 + **VS Code 式远端工作台**
8
8
  (资源管理器 / 搜索 / 源代码管理 / 提交图与提交详情面板 / 多标签编辑器 / 悬浮编辑器 / 并排 Diff / 多终端 / 端口转发)。
9
- 主机配在 DSH 设置里(“远程主机”项);装了 `dsh-better-sidebar` 时另有
10
- 独立“远程工作台”tab,没装则退到原生右侧栏“远程工作台”页(同内容,引导页自助开,per-session 实例)。
9
+ 主机配在 DSH 设置里(“远程主机”项);右侧栏“远程工作台”页。
11
10
  **侧栏「远程工作台」的编辑器是默认面**:打开文件即整栏切到编辑器,关闭最后一个文件自动回到目录,
12
11
  外观对齐本地侧边栏插件(VS Code 不透明代码背景、标签条、信息栏、图片预览、查找/换行/字号)。
13
12
  会话视图槽里的**远程编辑器**标签是可选的全宽面 —— 信息栏的展开按钮切过去、收回按钮切回来,两个面共用同一份缓冲区。
@@ -15,15 +14,15 @@ P2 起原生工具在远端工作区里透明跑远端(见下)。
15
14
 
16
15
  ```text
17
16
  ┌─ 本机 DSH Host ─────────────────────────────────┐
18
- │ 本插件 Host 半 │ Client 半(浏览器) │
19
- │ 主机/密钥/推送/路由 │ 设置两节 + 原生入口接管 │
17
+ │ 本插件 Host 半 │ Client 半(浏览器) │
18
+ │ 主机/密钥/推送/路由 │ 设置两节 + 原生入口接管 │
20
19
  │ /api/dsh-remote/* │ 工作台(右侧栏 + 会话视图)│
21
20
  └──────────────────────┴──────────────────────────┘
22
21
  │ ssh2(文件/进程/终端)+ helper RPC(远端 fs)
23
22
  ▼
24
23
  ┌─ 远端 Linux ─────────────────────────────────┐
25
24
  │ ~/.dsh-helpers/<ver>/<arch>/dsh-ssh-helper │
26
- │ 用户指定的远端工作目录 │
25
+ │ 用户指定的远端工作目录 │
27
26
  └──────────────────────────────────────────────┘
28
27
  ```
29
28
 
@@ -36,8 +35,8 @@ dsh plugin --profile web add dsh-remote-vs
36
35
  (从 npm 装,推荐;也可以直接跟仓库装:`dsh plugin --profile web add github:xiray-xia/dsh-remote-vs`。)
37
36
 
38
37
  **需要 DSH `0.2.2-rc.5` 及以上、`0.3.0` 以下**(`engines.dsh` 门到底;已按 rc.5 适配并通过类型检查与本地全量门禁)。
39
- Host 仍是 `0.2.2-rc.4` 的请用插件 `0.23.0`;`0.2.2-rc.2` / `0.2.2-rc.3` 的请用插件 `0.22.0`;`0.2.2-alpha.3` / `0.2.2-rc.1` 的请用 `0.20.1`;`0.2.2-alpha.2` 一代请用 `0.17.0`;`0.2.1-rc.2` 一代请用 `0.9.3`。
40
- `--profile web` 指明装进哪个 profile —— 本插件是 Web 插件,
38
+ Host 仍是 `0.2.2-rc.4` 的请用插件 `0.23.0`;`0.2.2-rc.2` / `0.2.2-rc.3` 的请用插件 `0.22.0`;`0.2.2-alpha.3` / `0.2.2-rc.1` 的请用 `0.20.1`;`0.2.2-alpha.2` 一代请用 `0.17.0`。
39
+ `--profile web` 指明装进哪个 profile,
41
40
  要装进 Web GUI 所用的那个(`web` 是常见命名,以你自己的 profile 名为准);
42
41
  桌面端用的是保留 profile `desktop`,见下面「桌面端」。
43
42
 
@@ -45,12 +44,6 @@ Host 仍是 `0.2.2-rc.4` 的请用插件 `0.23.0`;`0.2.2-rc.2` / `0.2.2-rc.3`
45
44
  > 首次连接该主机时自动重推新 helper(本机缓存里还留有旧版构建即可自动判定;缓存被清理过时,在设置页点一次
46
45
  > 「推送」即可),每台主机首次会多一次约 47 MB 的上传。旧 helper 目录会保留,回滚就是推回旧版本。
47
46
 
48
- **这一条命令就够了,不需要放行任何构建脚本**:包本身没有 `prepare`/`postinstall`,依赖树里也没有任何
49
- 带安装脚本的包(`ssh2` 是**打进产物**的,不是依赖);走仓库安装时还带着构建好的 `lib/`。
50
- 以前需要「在 profile 的 `pnpm-workspace.yaml` 里放行构建脚本后重跑」,那是 pnpm 12 对
51
- 「带安装脚本的依赖」的硬策略门(`ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED` / `ERR_PNPM_IGNORED_BUILDS`),
52
- 依赖侧无法豁免,只能从树里消掉。装完重启 `dsh web`,打开设置 → 远程主机开配。
53
-
54
47
  ### 桌面端(DSH Desktop)
55
48
 
56
49
  桌面端是 Electron 壳 + 完整的 dsh Web 应用,但它跑在**独立的保留 profile `desktop`**
@@ -86,11 +79,11 @@ Host 转发(终端按 `__DSH_TRANSPORT__.streamBaseUrl` 解析地址),无
86
79
  | 搜索 | 两档:**文件名**(远端 `find`)与**内容**(远端 `grep`)。内容档带范围目录、`Aa`(大小写)/`ab_`(全字)/`.*`(正则)、结果按文件分组、命中高亮,点条目跳到该行;**内容档可中止**(改写或清空查询会终止正在跑的远端 `grep`;老 Host 无流式路由时退化为不可取消的一次性查询),成功但远端给了 stderr 警告时在结果上方提示;文件名档里命中**目录**时在树中定位,而不是当文件打开 |
87
80
  | 连接状态与离线只读 | 顶部栏与编辑器信息栏显示当前工作区的 SSH 连接状态(**连接正常 / 连接异常 / 就绪·按需连接**):断线不再静默——已打开的编辑器标签保留缓存内容并切为**只读**(保存被拦截并说明原因),目录树继续显示已缓存目录、后台刷新静默,未缓存目录显示离线提示;连接恢复后自动刷新目录、Git 状态、**未修改的文件标签和只读 diff 标签**(有未保存改动的标签不动并提示)。错误态不会无限重连:每 30 秒最多自动重试 3 次,之后点状态图标手动重试。断线时「撤销这处改动」和 diff 的 hunk 操作同样被拦截;**单次操作的超时(deadline)不当作链路故障**——chip 保持正常,只有该次操作失败并说明原因;断线且该工作区没有缓存时,SCM 面板直接说明无法读取,而不是停在「加载中」。**不做**跨页面刷新的持久化缓存(远端源码不落盘),这是有意的隐私取舍 |
88
81
  | 源代码管理 | **仓库目录选择器**(工作区里的 git 在子目录时用:浏览远端目录、一键跳到工作区内发现的仓库、手输相对/绝对路径,并逐目录提示会落在哪个仓库);变更/暂存/未跟踪/忽略分桶,**未跟踪目录行可点击展开**,逐文件与**逐 hunk** 暂存/还原、丢弃(带确认)、提交;分支/远程/stash 面板,**分支可重命名**、**远程可改 URL**、非仓库目录可直接**初始化仓库**(均需确认);同步(fetch/pull/push),**推送支持自定义 refspec**(如 Gerrit `HEAD:refs/for/<分支>`;留空 = 普通 `git push`,非空值会记住);fetch/pull/push/sync 有**实时输出面板**(SSE 流式显示 git/远端输出、运行计时、**可取消**(杀掉远端进程组)、完成后可复制完整输出;老 Host 无流式路由时自动回退到一次性结果) |
89
- | 会话改动审阅 | 输入框上方的**可收纳**面板,按**会话**列出改了什么(一行一个文件、文件类型图标、右侧 `+a −b`);头部可**只看未审阅**并**跳到下一个未审阅**(回绕、不自动打 ✓);点文件在远程编辑器里打开并画**整行着色 + 行内字符级差异**,右上角 `n/N ↑↓` 跳改动点,悬浮改动行可**撤销**这处改动(远端 `git apply -R`)。详见下文「会话改动审阅」 |
82
+ | 会话改动审阅 | 输入框上方的**可收纳**面板,按**会话**列出改了什么,可一键切到**本轮**(最近一个已完成轮次,默认仍是会话累计);一行一个文件(文件类型图标 + 右侧 `+a −b`);头部可**只看未审阅**并**跳到下一个未审阅**(回绕、不自动打 ✓);点文件在远程编辑器里打开并画**整行着色 + 行内字符级差异**,右上角 `n/N ↑↓` 跳改动点;悬浮改动行时行尾出现 `⋯` 菜单:**撤销**这处改动(远端 `git apply -R`,失败原因分类说明)或**确认保留**(块级、纯本地、与文件级 ✓ 不联动);行右键**查看差异**打开账本基线的**只读并排 diff**;已打开标签页的标记会随面板轮询被标成「位置已过期」。详见下文「会话改动审阅」 |
90
83
  | 并排 Diff | 左右**严格等分** + 中间 gutter 逐 hunk 按钮 + **顶部横向滚动条**(一行很长也不会破坏对称)+ 行号钉在左侧,**只渲染视口内的行**(3000 行文件从 9000 个行容器降到约 174 个,滚动范围与整篇渲染完全一致);可切「变更前 / 变更后」,变更后可编辑并保存(保存写回工作树文件;超过 8MiB 的差异只读,避免把截断内容写回去) |
91
84
  | 提交图 | SVG 分支/合并图;点选提交后,下方**可调高度 / 可全屏**的提交详情面板给出三个视图:**提交详情**(标题、作者、时间、完整哈希+复制、父提交、ref、正文、检出)、**内容**(改动文件按目录分组、可折叠、可过滤,单击看差异、右键或行尾按钮在编辑器中打开)、**差异**(默认只展开前约 1500 行、其余文件折叠;双行号、`+/−` 计数、自动换行、上一/下一个文件、复制文件补丁或整个补丁)。合并提交按**首父**展示(git 对 merge 默认不给文件列表) |
92
85
  | AI 审查 | 单文件 diff 与**整个提交**都能一键把审查请求追加到对话草稿(**只预填,不自动发送**,发送前可自行修改):≤32 KiB 内嵌完整 diff;更大或被 2 MB 静默截断时改为「文件/提交信息 + 变更块头 + 自行 `git show`」的摘要式请求(2 MB diff 约几十万 token,硬塞没有意义);未跟踪/二进制文件只给路径让 AI 自行读取。入口:并排 diff 工具栏、提交详情「差异」工具栏;当前会话不在该远端工作区、或宿主没有可用的对话输入通道时按钮禁用并写明原因 |
93
- | 多标签编辑器 | 打开/保存/重载、脏标记、多文件标签并存;**保存是原子的**(侧文件 + 重命名,写穿符号链接并保留权限位);**保存前校验远端基线**:文件在打开之后被别人(Agent 的透明路由、终端、另一个编辑器)改过时保存被拒绝,并给出「覆盖 / 载入远端版本 / 查看差异」,不再静默覆盖;图片预览、**文档预览**(Markdown/HTML、SVG、CSV/TSV 表格、PDF、Office 经宿主 officeKit 转 PDF(失败回退远端 LibreOffice)、音视频;文本源支持源码/预览切换);**Ctrl+G 转到行**、**Ctrl+D 选中下一个相同文本**;关闭标签、重载、切工作区遇到未保存改动都会**先确认**(切工作区会清空全部标签,所以先问);`Ctrl+S` 全局生效,焦点不在编辑器里也能保存;**刷新页面后自动恢复上次打开的文件标签**(按工作区记,最多 12 个;只存路径不存内容,打不开的会跳过并提示数量;光标与滚动位置不恢复);**行内 blame**(作者 + 相对时间;点击行号旁格跳到该提交详情)与当前文件的**提交历史**(`git log --follow`,点条目看该版本的 diff);**符号大纲**(`Ctrl+Shift+O`,按语言/缩进生成类、方法、字段列表,点击跳转) |
86
+ | 多标签编辑器 | 打开/保存/重载、脏标记、多文件标签并存;**保存是原子的**(侧文件 + 重命名,写穿符号链接并保留权限位);**保存前校验远端基线**:文件在打开之后被别人(Agent 的透明路由、终端、另一个编辑器)改过时保存被拒绝,并给出「覆盖 / 载入远端版本 / 查看差异」,不再静默覆盖;图片预览、**文档预览**(Markdown/HTML、SVG、CSV/TSV 表格、PDF、Office 经宿主 officeKit 转 PDF(失败回退远端 LibreOffice)、音视频;文本源支持源码/预览切换);**Ctrl+G 转到行**、**Ctrl+D 选中下一个相同文本**;关闭标签、重载、切工作区遇到未保存改动都会**先确认**(切工作区会清空全部标签,所以先问);`Ctrl+S` 全局生效,焦点不在编辑器里也能保存;**刷新页面后自动恢复上次打开的文件标签**(按工作区记,最多 12 个;只存路径不存内容,打不开的会跳过并提示数量;光标与滚动位置不恢复);**行内 blame**(默认关闭,信息栏 `B` 开关打开;作者 + 相对时间;点击行号旁格跳到该提交详情)与当前文件的**提交历史**(`git log --follow`,点条目看该版本的 diff);**符号大纲**(`Ctrl+Shift+O`,按语言/缩进生成类、方法、字段列表,点击跳转) |
94
87
  | 悬浮编辑器 | 三个入口:文件树 / 搜索结果 / 源代码管理右键「在悬浮编辑器中打开」,以及**双击会话视图的「远程编辑器」标签**把当前编辑器整体浮出(同一套标签、预览、Diff、查找、改动标记,不是另写一个编辑器)。窗口可拖标题栏移动、拖八个边角缩放、最大化/还原、双击标题栏切换最大化;**最小化成一个可拖动的悬浮球**(球上有未保存脏点,点一下或按 Enter 恢复,拖动可换位置);`Ctrl+滚轮` 缩放编辑器字号;位置、大小、字号和球的位置跨刷新记住 |
95
88
  | 语法高亮 | VS Code **Dark+ / Light+** 配色;覆盖 java/aidl/smali、c/c++、go、rust、js/ts、json、py、yaml、xml、html/css、md、sh、properties/rc/toml、diff 等;**兜底着色器**在语法包没命中时自动接管,不会出现整篇无色。诚实说明:kotlin / gradle / smali 用 Java 语法着色(没有专用语法包),效果是关键字/字符串/注释正确、专有语法不细分 |
96
89
  | 查找 | 编辑器内 `Ctrl+F`(`Aa`/`ab_`/`.*`、`3/17` 计数、↑↓、`F3`/`Shift+F3`、`Esc`);**选中文本按 `Ctrl+F` 直接填入**;查找框钉在右上角,滚动不带走;`n/N` 计数随 `F3`、点击和光标移动刷新 |
@@ -215,7 +208,7 @@ dsh_remote_vs/
215
208
  ├── vendor/dsh-remote-helpers/ # helper 种子(随包发布,启动铺缓存,见下)
216
209
  ├── docs/ # 本地工作文档(不推送 GitHub;只有 docs/media/ 的截图随仓库公开)
217
210
  │ ├── MAINTENANCE.md # 本地私有(.gitignore,不入库):升级影响面/检查清单/踩坑/发布流程
218
- │ ├── VERSION-HISTORY.md # 本地私有:逐版本变更纪要(0.7.1 → 0.27.0)
211
+ │ ├── VERSION-HISTORY.md # 本地私有:逐版本变更纪要(0.7.1 → 0.28.0)
219
212
  │ └── GATES.md # 本地私有:本地门禁清单与实跑条数
220
213
  ├── locale/ # 插件元信息双语
221
214
  └── lib/ # 构建产物(**必须入库**,只有 .map 忽略;link 安装后重启即生效)
@@ -313,13 +306,52 @@ dsh_remote_vs/
313
306
  - **面板**:一行一个文件(文件类型图标 + 相对路径 + 右侧 `+a −b`),宽度与输入卡**左右对齐**;
314
307
  点标题栏折叠/展开,`⟳` 强制立即重扫。没有改动时显示「本会话还没有改动文件。」;统计不出来时显示
315
308
  **具体原因**(见下面的边界),不会丢一个空列表让人猜。
309
+ - **作用域切换:会话累计 / 本轮**(默认仍是会话累计,行为不变)。头部那两个小按钮只在 Host
310
+ 真的给出了一轮时出现(没关闭过轮次、或连的是更老的 Host 时不出现)。切到「本轮」后标题变成
311
+ **「本轮 #N · HH:MM」**,行与 `+a −b` 只算**最近一个已完成轮次**的改动(更早轮次改过、这一轮
312
+ 没碰的文件不会出现在列表里);选择记在浏览器本地(`rvs.changes.scope`)。这里的 N 是**已完成**
313
+ 的轮次编号——会话正在跑下一轮时不会提前把它算进来。
314
+ - **本轮模式下点开一行**与累计视图同一套标记/撤销,但比较的基点是**上一轮关闭时**的内容:
315
+ 行内 `n/N ↑↓`、悬浮「撤销这处改动」(反向应用这一轮的 hunk)、行右键「撤销该文件的全部改动」
316
+ (本轮整文件反向补丁)都只回退**这一轮**的改动。若该文件在本轮关闭之后又被改过,Host 答
317
+ 「已过期」,面板**提示并把视图切回会话累计**再取那份比较——不会拿一份作废的行号去画。
318
+ - **撤销成功后从本轮列表隐藏**:本轮视图是轮次关闭时**冻结**的那份 delta,宿主不会回头改它,
319
+ 所以"撤销了但列表还在"这件事由**客户端呈现层**收尾——单处撤销(该文件本轮只有一处改动)或
320
+ 行菜单「撤销该文件的全部改动」成功后,面板把这一行过滤掉,并按**可见行**重算文件数与
321
+ `+a −b`;隐藏了几行会说明,全部隐藏**且视图完整**时显示「本轮改动已全部撤销」(不是
322
+ 「本轮没有改动文件」),视图不完整或还在等扫描时仍用「已撤销 N 个」——面板不证明它不知道的事。
323
+ 记录按 `(会话, 轮次, 文件)` 存在浏览器本地(`rvs.changes.reverted.<会话>`),刷新页面后仍生效;
324
+ 多 hunk 文件的部分撤销**不隐藏**(剩下的改动还得看得见),撤销失败也不隐藏;浏览器禁用存储时
325
+ 只是不再记住(列表照旧显示),不影响任何远端写。宿主那份冻结算账完全不变。
326
+ 本轮视图没有「撤销新建(删除文件)」这一项(那需要 git 索引里的副本,本轮缓存只给补丁);
327
+ 右键菜单会直接说明去会话累计视图或「源代码管理」面板删。
316
328
  - **点文件**在远程编辑器里打开,并画上改动标记:新增行**绿色行背景**,删除的字符用**行内删除线 chip**
317
329
  表示(被删的字符在新文件里不存在,只能用插入的 widget 画),左侧 gutter 一列改动色条。
318
330
  - **跳改动点**:编辑器右上角悬浮 `n/N ↑↓`(快捷键 `Alt+Shift+Cmd/Ctrl+↓/↑`),在改动点之间循环跳转;
319
- 编辑器里一敲字,标记即作废并提示「位置已过期」。
320
- - **撤销这处改动**:悬浮在改动行上点一下 → 远端 `git apply -R`。上下文对不上时远端直接拒绝(文件一个
331
+ 编辑器里一敲字,标记即作废并提示「位置已过期」;**面板每 3 秒的新统计也会让已打开标签页的标记
332
+ 过期**(远端/会话又改了同一个文件、或文件从列表里消失时),提示同样是「位置已过期」,点该行即可
333
+ 按当前内容重算 —— 不会一直画着一份没人知道已经过时的标记。
334
+ - **查看差异(只读)**:行右键 →「查看差异」,打开该文件**并排两栏**的 diff。数据来自**会话账本**
335
+ (会话起点为基线),不是 `git diff`(后者比的是索引/HEAD,可能还带着会话开始前的未提交改动);
336
+ 改前全文由 Host 给的 hunk 从当前内容精确还原,复用现有的并排 diff 渲染器。这一页只读:不能编辑、
337
+ 也没有 hunk 暂存/撤销,重新载入仍走账本。二进制/超大文件这一项**保留但置灰**并写明原因(点开只会
338
+ 是空视图或假差异);内容被字节上限扣下、或改后一栏的读取撞上 8 MiB 上限时,**不打开**并说明比较
339
+ 不完整(两栏会错位)。
340
+ - **点开一行的五种结局都会说明**:改动内容被字节上限扣下时说明「比较不完整(可能整篇都算改动),
341
+ **不标改动、也不能撤销**」;文件过大时说明「不做行级比较、不能撤销,可打开文件自行查看」;二进制
342
+ 文件、远端读不到的文件、行还在但当前已无差异的文件各有自己的说明,不会只留一片空白让人以为
343
+ "没有改动"。
344
+ - **行尾 `⋯` 菜单**:悬浮在改动行上,行尾出现一枚 `⋯`(只有一行高、纵向锁在那一行上,指针从行内
345
+ 水平移过去就能点到),点开是「撤销这处改动」和「确认保留」两个动作。
346
+ - **撤销这处改动**:点菜单里的撤销 → 远端 `git apply -R`。上下文对不上时远端直接拒绝(文件一个
321
347
  字节都不动);标签页里有未保存内容时先拒绝,绝不会用远端补丁盖掉你的编辑;成功后光标留在原处,
322
- 标记自动重读刷新(不会因为"撤销了"就整片标记消失)。
348
+ 标记自动重读刷新(不会因为"撤销了"就整片标记消失)。**失败原因会分类说清**:上下文已变 / 文件
349
+ 已经不在仓库里 / 权限拒绝 / 仓库所有权不对(git 的 `dubious ownership`,提示配置 `safe.directory`
350
+ 或修所有权)/ 补丁已损坏,给出的都是各自可操作的那一句,git 原话附在后面。
351
+ - **确认保留(块级,纯本地)**:同一个菜单里还有一个切换式项「确认保留」——「这一处我看过了、
352
+ 同意保留」。它**不写远端、不发请求、不动 diff 数据**,状态按会话存在浏览器本地,按块身份
353
+ (文件 + hunk 头四个数字)记忆,刷新页面后仍在。与面板行上的 ✓ 是**两级**语义、**不联动**:
354
+ 块确认是编辑器内"这一处我看过",✓ 仍是文件级人工标记;没有批量确认。
323
355
  - **跟随会话工作区**:侧栏、编辑器下拉、文件树三者跟着**当前会话所在的工作区**走;用户手动切换后同一
324
356
  会话内不再被拉回,换会话重新跟随。跟随能力在 store 层,**侧栏从未打开过也照样跟随**;在改动面板点
325
357
  文件属于"看结果",不算手动切换。
@@ -332,11 +364,42 @@ dsh_remote_vs/
332
364
  - 已跟踪文件的数字随**轮次结束**刷新(面板每 3 秒轮询兜底,通常一两秒内跟上);**新文件**(在 shell 里
333
365
  创建的)靠**慢扫描**发现,单次预算最长约 **3 分钟**,重扫间隔按上次耗时自适应(至少 5 秒,大仓库会
334
366
  自然拉长);点 `⟳` 可强制立即重扫。
367
+ - **手动改动多久能看到**:没有轮次事件时(你在终端/编辑器里改文件),面板靠自愈重扫发现,阈值按
368
+ **上一次 `git status` 耗时自适应**(`clamp(耗时×4, 5s, 30s)`):小仓库(100ms 级)→ **5 秒**;
369
+ AOSP 级(实测 1.7s)→ **6.8 秒**;**30 秒上限只在耗时 ≥ 7.5 秒时才生效**。所以成本是可算的:
370
+ AOSP 树上配合 3 秒轮询,大约 **每 9 秒一次 `git status`**,约为旧 30 秒窗口的 **3 倍**(这是保留 4×
371
+ 设计的代价,换来手动改动 30s→约 7s 的可见性)。
372
+ - **回到页面**(切回标签页、或窗口重新获得焦点)会请求宿主**立即重扫一次**,但它与 `⟳` **不是同一件事**:
373
+ 这里只重扫 tracked 文件(`trackedOnly`),**不重置慢扫描的节流、也不重新武装被写掉的
374
+ `git ls-files --others`**(参考树 11s、冷树分钟级;focus 可能每几秒一次,不能每次都把整棵树的走查
375
+ 重新打开)。`⟳` 才是"连慢扫描一起重来"。两条路径都有 5 秒去抖、隐藏期间不刷、已有请求在飞则跳过
376
+ (在飞超过 60 秒视为那次请求已失败,避免一次挂住的请求让强制刷新永久失效)。
377
+ - **注意**:`⟳` 和"回到页面"都只是**安排**宿主重扫,这次响应里仍是上一次摘要 —— 新数字要等下一轮轮询
378
+ (≤ 3 秒)才回来,不是刷新动作自己把结果带回。
335
379
  - 非 git 工作区、或工作区里有多个仓库而没指定仓库目录时,面板显示明确原因
336
380
  (`no git repository at the workspace root, and N candidates below it — set the repository directory in Source Control`),不显示空列表。
337
381
  - 二进制文件与超大文件只在行尾标「二进制 / 过大」,不给字符级差异;**非 UTF-8(如 GBK)文本按二进制处理**(不给计数、不提供撤销,避免乱码计数和必然失败的 `git apply -R`)。
382
+ - **超大文件不做行级比较**:列表对这类行把增删数字钉成 `0/0`(不是真实行数),点开只打开文件并说明
383
+ 「文件太大、不做行级比较」,不画标记也不提供撤销 —— 避免拿 0/0 与真实行数比较而误报「位置已过期」。
384
+ - **本轮视图只覆盖「最近一个已完成轮次」**(不做多轮历史):每次轮次关闭时 Host 记下当时各文件的
385
+ 文本,下一次关闭时求差;轮次结束后才会更新,所以会话正在跑的下一轮**不会**混进「本轮」。
386
+ - **本轮的补丁与 hunk 文本有预算(默认 4 MiB)**:这个预算只算整文件反向补丁 + hunk 行;两侧
387
+ 全文与上一轮快照按扫描读取上限另计(实际驻留约 4 MiB + 两侧文本,最坏约 20 MiB/活跃会话)。
388
+ 超过预算时,该会话的「本轮」**只
389
+ 保留增删统计**(数字仍真实),不提供块标记与撤销,并写明原因、**本会话后续不再计算**本轮视图——
390
+ 否则下一轮会拿一份没推进的快照去比,把旧改动算到新轮次头上。会话累计视图不受影响。
391
+ - **新文件靠慢扫描发现**:本轮关闭时先用已缓存的扫描结果算一次,此时列表会标「新文件扫描还没
392
+ 落地」;慢扫描(`git ls-files --others`)落地后会**重算同一轮**补上新文件并清掉该标记。扫描被
393
+ 写掉、结果受文件上限截断、或上一轮从未完成校正时,本轮列表会**常驻标成不完整**(不是「没创建
394
+ 文件」,而是「这条路径无法归属,已丢弃」)——上一侧字节被扣下(二进制/过大)的文件同样如此,
395
+ 绝不被算成整份新增。
396
+ - 二进制/超大文件在「本轮」里同样只标「二进制 / 过大」、不给行级比较;本轮缓存不保存它们的字节。
338
397
  - 未跟踪扫描失效(例如远端拒绝)时面板会**说明原因**并保留刷新入口,不再只是静默少一行。
339
398
  - 撤销带 **provenance**:记录这处改动属于哪个会话 / 绑定 / 仓库目录,换会话或换绑定后不会把补丁应用到另一台主机;会话新建的整文件不提供撤销(避免反向补丁删掉未跟踪文件)。
399
+ - 二进制/超大文件的「查看差异」入口**可见但置灰**并写明原因;内容被字节上限扣下(或改后读取超 8 MiB)
400
+ 时不打开两栏 diff,只说明"比较不完整"——那种 diff 的 hunk 是对空文本算出来的整篇假差异,撤销也不可能成立。
401
+ - 文件被改回会话基线后,再点行会得到「现在没有可显示的差异」而不是「读不到这个文件」。
402
+ - 「位置已过期」只是**提示**,不会自动重读:点该行(或保存成功后)才会按当前远端内容重算。
340
403
 
341
404
  ## P2 透明远端执行(Windows 原生)
342
405