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.
- package/README.en.md +110 -19
- package/README.md +82 -19
- package/lib/client.js +6789 -6607
- package/lib/index.js +546 -16
- package/lib/types/changes/recorder.d.ts +119 -2
- package/lib/types/client/CodeEditor.d.ts +15 -0
- package/lib/types/client/api.d.ts +17 -1
- package/lib/types/client/changes/apply-failure.d.ts +41 -0
- package/lib/types/client/changes/block-confirm.d.ts +97 -0
- package/lib/types/client/changes/diff-outcome.d.ts +56 -0
- package/lib/types/client/changes/freshness.d.ts +51 -0
- package/lib/types/client/changes/model.d.ts +19 -1
- package/lib/types/client/changes/session-diff.d.ts +100 -0
- package/lib/types/client/changes/staleness.d.ts +98 -0
- package/lib/types/client/changes/turn-reverted.d.ts +82 -0
- package/lib/types/client/changes/turn-view.d.ts +131 -0
- package/lib/types/client/changes/undo-affordance.d.ts +44 -10
- package/lib/types/client/changes/undo-target.d.ts +12 -0
- package/lib/types/client/i18n.d.ts +1 -1
- package/lib/types/client/store.d.ts +91 -1
- package/lib/types/client/vsc/change-marks.d.ts +21 -0
- package/lib/types/protocol.d.ts +99 -1
- package/package.json +1 -1
- package/src/changes/recorder.ts +851 -8
- package/src/client/CodeEditor.tsx +43 -3
- package/src/client/EditorPane.tsx +64 -7
- package/src/client/api.ts +30 -3
- package/src/client/changes/ChangesDock.tsx +539 -54
- package/src/client/changes/apply-failure.ts +73 -0
- package/src/client/changes/block-confirm.ts +180 -0
- package/src/client/changes/changes.css +45 -0
- package/src/client/changes/diff-outcome.ts +97 -0
- package/src/client/changes/freshness.ts +68 -0
- package/src/client/changes/model.ts +56 -1
- package/src/client/changes/session-diff.ts +187 -0
- package/src/client/changes/staleness.ts +148 -0
- package/src/client/changes/turn-reverted.ts +254 -0
- package/src/client/changes/turn-view.ts +195 -0
- package/src/client/changes/undo-affordance.ts +295 -63
- package/src/client/changes/undo-target.ts +12 -0
- package/src/client/i18n.ts +102 -4
- package/src/client/scm/DiffView.tsx +32 -13
- package/src/client/store.tsx +392 -16
- package/src/client/vsc/change-marks.ts +21 -0
- package/src/client/vsc/preview-document.tsx +4 -1
- package/src/client/vsc/vsc.css +6642 -6509
- package/src/protocol.ts +101 -1
- package/src/routes.ts +20 -9
package/src/protocol.ts
CHANGED
|
@@ -532,6 +532,84 @@ export interface RemoteChangedFile {
|
|
|
532
532
|
revert?: 'patch' | 'delete'
|
|
533
533
|
}
|
|
534
534
|
|
|
535
|
+
/**
|
|
536
|
+
* The most recent COMPLETED turn, as the review panel switches to it.
|
|
537
|
+
*
|
|
538
|
+
* "This turn" is answered from the ledger's own turn boundaries: the host keeps
|
|
539
|
+
* every listed path's text at each turn close and compares the next close
|
|
540
|
+
* against it. Deliberately ONE turn deep — a per-turn history would need the
|
|
541
|
+
* full text of every file at every boundary, and the panel's job is "what did
|
|
542
|
+
* the turn I just ran change", not a time machine.
|
|
543
|
+
*/
|
|
544
|
+
export interface RemoteChangesTurnView {
|
|
545
|
+
/** Turn number the delta describes (0 = no turn has closed yet). */
|
|
546
|
+
turn: number
|
|
547
|
+
/** Files this turn changed, with THIS TURN's counts (not the session total). */
|
|
548
|
+
files: RemoteChangedFile[]
|
|
549
|
+
added: number
|
|
550
|
+
deleted: number
|
|
551
|
+
/** Wall-clock ms when the delta was computed. */
|
|
552
|
+
at: number
|
|
553
|
+
/**
|
|
554
|
+
* Whether the per-file hunks behind `turnDiff` are cached.
|
|
555
|
+
*
|
|
556
|
+
* `false` = the turn's contents were too large for the memory budget (or the
|
|
557
|
+
* file cap made attribution unreliable): the counts above are still real, but
|
|
558
|
+
* clicking a row cannot paint hunks or revert. Honest degradation — the
|
|
559
|
+
* alternative would be comparing the next turn against a half-updated
|
|
560
|
+
* snapshot and attributing old changes to it.
|
|
561
|
+
*/
|
|
562
|
+
cached: boolean
|
|
563
|
+
/** Why `cached` is false (shown to the user, never swallowed). */
|
|
564
|
+
reason?: string
|
|
565
|
+
/**
|
|
566
|
+
* This view is INCOMPLETE — and it is not "a prefix of a longer list".
|
|
567
|
+
*
|
|
568
|
+
* Three ways rows go missing:
|
|
569
|
+
* - the file cap cut the list (`files` is the first N of the scanned paths);
|
|
570
|
+
* - the previous turn's snapshot was cut by that cap, or a previous side was
|
|
571
|
+
* withheld (binary / over the read cap), so a path that cannot be compared is
|
|
572
|
+
* DROPPED instead of being guessed as a whole-file creation;
|
|
573
|
+
* - the previous turn's slow scan never landed before this turn closed, so a
|
|
574
|
+
* file missing from that snapshot cannot be proven new either.
|
|
575
|
+
*
|
|
576
|
+
* A partial view must say so: "these rows are what this turn provably changed",
|
|
577
|
+
* not "this is everything the turn changed".
|
|
578
|
+
*/
|
|
579
|
+
truncated?: true
|
|
580
|
+
/**
|
|
581
|
+
* The turn's slow scan (`git ls-files --others`) has not landed yet.
|
|
582
|
+
*
|
|
583
|
+
* The same turn is REBUILT when it does (`correctTurn`), so this list may still
|
|
584
|
+
* grow — it is never relabelled as the next turn. When a newer turn closes
|
|
585
|
+
* first, the view stops waiting and `truncated` records that it never caught
|
|
586
|
+
* up.
|
|
587
|
+
*/
|
|
588
|
+
pending?: true
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
/**
|
|
592
|
+
* Body of `op: 'list'` on the changes route (the request half of
|
|
593
|
+
* {@link RemoteChangesSummary}).
|
|
594
|
+
*
|
|
595
|
+
* The two refresh intents are separated because they cost very different things
|
|
596
|
+
* on the remote:
|
|
597
|
+
* - {@link RemoteChangesListRequest.force} (`⟳`) — tracked scan NOW and re-arm the
|
|
598
|
+
* slow `git ls-files --others` walk (clears its write-off). Deliberate click.
|
|
599
|
+
* - {@link RemoteChangesListRequest.trackedOnly} — "the user came back to the
|
|
600
|
+
* page": tracked files now, but the slow walk keeps its cadence and its
|
|
601
|
+
* written-off verdict. Focus events repeat every few seconds; re-arming an 11s
|
|
602
|
+
* (cold: minutes) walk on each one would multiply the remote load.
|
|
603
|
+
*/
|
|
604
|
+
export interface RemoteChangesListRequest {
|
|
605
|
+
op: 'list'
|
|
606
|
+
sessionId: string
|
|
607
|
+
force?: true
|
|
608
|
+
trackedOnly?: true
|
|
609
|
+
/** Repository directory from the Source Control panel ('' = the session root). */
|
|
610
|
+
repoSubdir?: string
|
|
611
|
+
}
|
|
612
|
+
|
|
535
613
|
/**
|
|
536
614
|
* What one session changed on its remote host since the session's baseline.
|
|
537
615
|
*
|
|
@@ -573,11 +651,31 @@ export interface RemoteChangesSummary {
|
|
|
573
651
|
pending: boolean
|
|
574
652
|
/** Why this session has no ledger (local session, no git, timeout, …). */
|
|
575
653
|
unavailable?: string
|
|
654
|
+
/**
|
|
655
|
+
* The last completed turn's delta, when the host computed one.
|
|
656
|
+
*
|
|
657
|
+
* Optional on purpose: an older host (or a session with no closed turn yet)
|
|
658
|
+
* omits it and the panel stays on the session-cumulative view it has always
|
|
659
|
+
* shown. A client that does not know the field ignores it.
|
|
660
|
+
*/
|
|
661
|
+
turnView?: RemoteChangesTurnView
|
|
576
662
|
}
|
|
577
663
|
|
|
578
664
|
/** One file's whole-session comparison, ready for editor decorations. */
|
|
579
665
|
export interface RemoteChangesDiff {
|
|
580
|
-
|
|
666
|
+
/**
|
|
667
|
+
* `unavailable` / `stale` belong to the per-turn comparison only.
|
|
668
|
+
*
|
|
669
|
+
* - `unavailable`: the host has no cached per-turn hunks for this session
|
|
670
|
+
* (memory budget, file cap, or no completed turn) — `reason` says which;
|
|
671
|
+
* - `stale`: the file changed after the turn closed, so the cached comparison
|
|
672
|
+
* no longer describes what is on disk; the client falls back to the
|
|
673
|
+
* session-cumulative view instead of painting wrong lines.
|
|
674
|
+
*
|
|
675
|
+
* The whole-session `diff` never returns them, so a client that switches on
|
|
676
|
+
* the old three kinds keeps working unchanged.
|
|
677
|
+
*/
|
|
678
|
+
kind: 'text' | 'binary' | 'missing' | 'unavailable' | 'stale'
|
|
581
679
|
/** Remote absolute POSIX path. */
|
|
582
680
|
path: string
|
|
583
681
|
display: string
|
|
@@ -596,6 +694,8 @@ export interface RemoteChangesDiff {
|
|
|
596
694
|
status?: 'A' | 'M' | 'D' | 'R' | 'C' | 'T' | 'U'
|
|
597
695
|
/** The diff was cut at the byte cap: `hunks` is a prefix. */
|
|
598
696
|
truncated?: true
|
|
697
|
+
/** For `unavailable` / `stale`: what happened, in words the panel can show. */
|
|
698
|
+
reason?: string
|
|
599
699
|
}
|
|
600
700
|
|
|
601
701
|
/** One row of the side-by-side diff projection. */
|
package/src/routes.ts
CHANGED
|
@@ -1288,7 +1288,7 @@ export function makeRoutes(deps: RemoteRoutesDeps): {
|
|
|
1288
1288
|
// ------------------------------------------- session change ledger
|
|
1289
1289
|
// What one live session changed on its remote host. The ledger itself is
|
|
1290
1290
|
// fed by turn events (see index.ts); the browser only ever reads it, which
|
|
1291
|
-
// is why
|
|
1291
|
+
// is why all three ops are side-effect free and answer null instead of 404 when
|
|
1292
1292
|
// the session has no ledger yet (the panel shows its pending/absent state).
|
|
1293
1293
|
{
|
|
1294
1294
|
kind: 'exact',
|
|
@@ -1307,8 +1307,8 @@ export function makeRoutes(deps: RemoteRoutesDeps): {
|
|
|
1307
1307
|
const body = read.body
|
|
1308
1308
|
const sessionId = typeof body?.sessionId === 'string' ? body.sessionId : ''
|
|
1309
1309
|
const op = typeof body?.op === 'string' ? body.op : ''
|
|
1310
|
-
if (sessionId === '' || (op !== 'list' && op !== 'diff')) {
|
|
1311
|
-
writeJson(res, 400, { error: 'op (list|diff) and a non-empty sessionId are required' })
|
|
1310
|
+
if (sessionId === '' || (op !== 'list' && op !== 'diff' && op !== 'turnDiff')) {
|
|
1311
|
+
writeJson(res, 400, { error: 'op (list|diff|turnDiff) and a non-empty sessionId are required' })
|
|
1312
1312
|
return
|
|
1313
1313
|
}
|
|
1314
1314
|
const ledger = deps.changes
|
|
@@ -1331,22 +1331,33 @@ export function makeRoutes(deps: RemoteRoutesDeps): {
|
|
|
1331
1331
|
const cwd = liveSessionCwd(ctx, sessionId)
|
|
1332
1332
|
if (cwd !== undefined) ledger.beginTurn({ sessionId, cwd })
|
|
1333
1333
|
}
|
|
1334
|
-
//
|
|
1335
|
-
//
|
|
1336
|
-
//
|
|
1337
|
-
//
|
|
1334
|
+
// Three refresh intents, deliberately different in COST:
|
|
1335
|
+
// - `force` = the panel's ⟳ button: tracked scan now AND re-arm the slow
|
|
1336
|
+
// new-file walk (clears its write-off). A human click can afford it.
|
|
1337
|
+
// - `trackedOnly` = the panel's "back to the page" refresh: tracked files
|
|
1338
|
+
// now, but the slow walk keeps its cadence and its written-off verdict.
|
|
1339
|
+
// A window focus can happen every few seconds, and re-arming an 11s
|
|
1340
|
+
// (cold: minutes) walk on each one would multiply remote load.
|
|
1341
|
+
// - neither = the ordinary poll, which self-heals once data is stale.
|
|
1338
1342
|
if (body?.force === true) ledger.rescan(sessionId)
|
|
1343
|
+
else if (body?.trackedOnly === true) ledger.touch(sessionId, 0)
|
|
1339
1344
|
else ledger.touch(sessionId)
|
|
1340
1345
|
writeJson(res, 200, { summary: ledger.summary(sessionId) })
|
|
1341
1346
|
return
|
|
1342
1347
|
}
|
|
1343
1348
|
const path = typeof body?.path === 'string' ? body.path : ''
|
|
1344
1349
|
if (path === '') {
|
|
1345
|
-
writeJson(res, 400, { error:
|
|
1350
|
+
writeJson(res, 400, { error: `path is required for op=${op}` })
|
|
1346
1351
|
return
|
|
1347
1352
|
}
|
|
1348
1353
|
try {
|
|
1349
|
-
|
|
1354
|
+
// `turnDiff` answers the same shape from the ledger's last completed
|
|
1355
|
+
// turn (cached hunks, plus a `stale` verdict when the file moved on).
|
|
1356
|
+
writeJson(res, 200, {
|
|
1357
|
+
diff: op === 'turnDiff'
|
|
1358
|
+
? await ledger.turnDiff(sessionId, path)
|
|
1359
|
+
: await ledger.diff(sessionId, path),
|
|
1360
|
+
})
|
|
1350
1361
|
} catch (error) {
|
|
1351
1362
|
// Reading the diff is a remote (git) round trip: it failed upstream.
|
|
1352
1363
|
writeRouteError(res, error)
|