dsh-remote-vs 0.26.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 (75) hide show
  1. package/README.en.md +112 -28
  2. package/README.md +84 -25
  3. package/THIRD-PARTY-NOTICES.md +7 -2
  4. package/lib/client.js +1237 -254
  5. package/lib/index.js +821 -17
  6. package/lib/types/changes/recorder.d.ts +119 -2
  7. package/lib/types/client/CodeEditor.d.ts +29 -0
  8. package/lib/types/client/OutlinePanel.d.ts +22 -0
  9. package/lib/types/client/ProcessesSection.d.ts +19 -0
  10. package/lib/types/client/api.d.ts +22 -2
  11. package/lib/types/client/blame-model.d.ts +77 -0
  12. package/lib/types/client/changes/apply-failure.d.ts +41 -0
  13. package/lib/types/client/changes/block-confirm.d.ts +97 -0
  14. package/lib/types/client/changes/diff-outcome.d.ts +56 -0
  15. package/lib/types/client/changes/freshness.d.ts +51 -0
  16. package/lib/types/client/changes/model.d.ts +19 -1
  17. package/lib/types/client/changes/session-diff.d.ts +100 -0
  18. package/lib/types/client/changes/staleness.d.ts +98 -0
  19. package/lib/types/client/changes/turn-reverted.d.ts +82 -0
  20. package/lib/types/client/changes/turn-view.d.ts +131 -0
  21. package/lib/types/client/changes/undo-affordance.d.ts +44 -10
  22. package/lib/types/client/changes/undo-target.d.ts +12 -0
  23. package/lib/types/client/i18n.d.ts +1 -1
  24. package/lib/types/client/outline-model.d.ts +59 -0
  25. package/lib/types/client/scm/actions.d.ts +12 -1
  26. package/lib/types/client/store.d.ts +109 -1
  27. package/lib/types/client/vsc/blame.d.ts +19 -0
  28. package/lib/types/client/vsc/change-marks.d.ts +21 -0
  29. package/lib/types/client/vsc/kit.d.ts +0 -2
  30. package/lib/types/client/vsc/preview-document.d.ts +46 -0
  31. package/lib/types/client/vsc/preview-model.d.ts +31 -0
  32. package/lib/types/client/vsc/preview-services.d.ts +24 -0
  33. package/lib/types/git-ops.d.ts +18 -0
  34. package/lib/types/processes.d.ts +43 -0
  35. package/lib/types/protocol.d.ts +133 -1
  36. package/package.json +2 -1
  37. package/src/changes/recorder.ts +851 -8
  38. package/src/client/CodeEditor.tsx +86 -4
  39. package/src/client/EditorPane.tsx +581 -41
  40. package/src/client/MonitorView.tsx +16 -5
  41. package/src/client/OutlinePanel.tsx +287 -0
  42. package/src/client/ProcessesSection.tsx +292 -0
  43. package/src/client/api.ts +38 -3
  44. package/src/client/blame-model.ts +242 -0
  45. package/src/client/changes/ChangesDock.tsx +539 -54
  46. package/src/client/changes/apply-failure.ts +73 -0
  47. package/src/client/changes/block-confirm.ts +180 -0
  48. package/src/client/changes/changes.css +45 -0
  49. package/src/client/changes/diff-outcome.ts +97 -0
  50. package/src/client/changes/freshness.ts +68 -0
  51. package/src/client/changes/model.ts +56 -1
  52. package/src/client/changes/session-diff.ts +187 -0
  53. package/src/client/changes/staleness.ts +148 -0
  54. package/src/client/changes/turn-reverted.ts +254 -0
  55. package/src/client/changes/turn-view.ts +195 -0
  56. package/src/client/changes/undo-affordance.ts +295 -63
  57. package/src/client/changes/undo-target.ts +12 -0
  58. package/src/client/i18n.ts +294 -2
  59. package/src/client/index.tsx +4 -0
  60. package/src/client/outline-model.ts +775 -0
  61. package/src/client/scm/DiffView.tsx +32 -13
  62. package/src/client/scm/HistoryPanel.tsx +38 -1
  63. package/src/client/scm/actions.ts +55 -2
  64. package/src/client/store.tsx +446 -21
  65. package/src/client/vsc/blame.ts +147 -0
  66. package/src/client/vsc/change-marks.ts +21 -0
  67. package/src/client/vsc/kit.tsx +3 -11
  68. package/src/client/vsc/preview-document.tsx +326 -0
  69. package/src/client/vsc/preview-model.ts +216 -0
  70. package/src/client/vsc/preview-services.ts +118 -0
  71. package/src/client/vsc/vsc.css +965 -39
  72. package/src/git-ops.ts +34 -0
  73. package/src/processes.ts +177 -0
  74. package/src/protocol.ts +138 -1
  75. package/src/routes.ts +138 -9
@@ -1,6 +1,7 @@
1
1
  import type { Context } from '@deepseek-ai/cordis';
2
- import type { DiffModel, GitStatusDetail, RemoteHostSummary, RemoteRoutingStatus, RemoteWorkspaceBinding } from '../protocol.ts';
2
+ import type { DiffModel, GitStatusDetail, RemoteChangedFile, RemoteChangesTurnView, RemoteHostSummary, RemoteRoutingStatus, RemoteWorkspaceBinding } from '../protocol.ts';
3
3
  import type { ChangeMark, ChangeSet } from './vsc/change-marks.ts';
4
+ import { type DiffNotice } from './changes/diff-outcome.ts';
4
5
  import { type StatusBuckets, type TreeMarks } from './scm/status-map.ts';
5
6
  import { type DiffPayload } from './scm/actions.ts';
6
7
  import { type DirExpansions } from './scm/untracked-dirs.ts';
@@ -94,10 +95,32 @@ export interface EditorTab {
94
95
  activeHunk?: number;
95
96
  /** 编辑器报告文档已与 `changeSet` 脱钩(用户敲过字),上层该重新拉数据。 */
96
97
  changeStale?: boolean;
98
+ /**
99
+ * 这批改动标记的建立时刻(`Date.now()`,`applyChangeSet` 写入)。
100
+ *
101
+ * 面板的轮询用它和 `RemoteChangesSummary.at` 比先后:标记比列表新时(保存/撤销
102
+ * 刚重读过),那份更早的列表不能证明标记过期(见 `changes/staleness.ts`)。
103
+ */
104
+ changeSetAt?: number;
97
105
  /** 改动点跳转目标行(1-based)。与 `line` 分开,两条跳转链路互不干扰。 */
98
106
  revealHunkLine?: number;
99
107
  /** 改动点跳转的 nonce,语义同 `lineNonce`。 */
100
108
  revealHunkNonce?: number;
109
+ /**
110
+ * 「会话改动」面板那一行的只读 diff(不是 git 工作区 diff)。
111
+ *
112
+ * 有它 = 这一页是账本轮次的比较:两栏都只读(改前是还原出来的基线、改后是远端
113
+ * 当前内容),没有 hunk 暂存/撤销,重新载入走账本而不是 `git diff`。`reloadTab`
114
+ * 与 `saveTargetOf` 都按它分流。
115
+ */
116
+ sessionDiff?: {
117
+ sessionId: string;
118
+ alias: string;
119
+ /** 会话账本的仓库根(`git apply -R` 的目标目录,也是仓库目录的答案)。 */
120
+ root: string;
121
+ /** 面板显示路径(标签条与 diff 头用它,不参与任何写操作)。 */
122
+ display: string;
123
+ };
101
124
  /**
102
125
  * 重读(`reloadTab`)成功后递增的 nonce。
103
126
  *
@@ -152,6 +175,12 @@ export interface TerminalRequest {
152
175
  /** Absolute remote directory the fresh shell should `cd` into. */
153
176
  dir: string;
154
177
  }
178
+ /** One "show this commit in the history rail" request. */
179
+ export interface CommitFocusRequest {
180
+ /** Monotonic id so selecting the same commit twice still re-triggers. */
181
+ id: number;
182
+ hash: string;
183
+ }
155
184
  /** Stored repository sub-directory for one binding ('' = the workspace root). */
156
185
  export declare function readRepoSubdir(workspaceId: string): string;
157
186
  /** Everything a view can read, plus the actions. */
@@ -202,6 +231,8 @@ export interface ExplorerValue {
202
231
  revealRequest: RevealRequest | undefined;
203
232
  /** Pending "open a terminal here" request (consumed by the terminal panel). */
204
233
  terminalRequest: TerminalRequest | undefined;
234
+ /** Pending "select this commit in the history rail" request. */
235
+ commitFocus: CommitFocusRequest | undefined;
205
236
  setView: (view: RailView) => void;
206
237
  /** Switch to the search panel (optionally scoped to a folder) — the tree's
207
238
  "find in folder" entry point. */
@@ -221,6 +252,8 @@ export interface ExplorerValue {
221
252
  * search results' "open in terminal" entry.
222
253
  */
223
254
  openTerminalAt: (dir: string) => void;
255
+ /** Open the history rail with this commit selected (blame / file history). */
256
+ focusCommit: (hash: string) => void;
224
257
  /**
225
258
  * The USER's pick — the workspace dropdowns and the wizard's "open files".
226
259
  *
@@ -460,6 +493,14 @@ export declare function jumpToTerminalPath(alias: string, token: string, hints?:
460
493
  * @param dir - absolute remote directory.
461
494
  */
462
495
  export declare function openTerminalAt(dir: string): void;
496
+ /**
497
+ * Open the history rail and select one commit.
498
+ *
499
+ * Blame cells and the file-history menu only know a hash; the history panel owns
500
+ * the list and the detail pane, so the selection travels as a request (the same
501
+ * pattern as `revealInExplorer` / `openTerminalAt`).
502
+ */
503
+ export declare function focusCommit(hash: string): void;
463
504
  /**
464
505
  * Select the binding every view works against — the USER's choice.
465
506
  *
@@ -878,6 +919,54 @@ export declare function gotoChange(tabId: string, dir: 1 | -1): number | undefin
878
919
  * 重新拉数据是上层的事,仓库在这一层不发起任何请求。
879
920
  */
880
921
  export declare function markChangeStale(tabId: string): void;
922
+ /**
923
+ * 面板拿到新统计后,指出哪些已开标签页的改动标记已经过期。
924
+ *
925
+ * 标记的失效原来只由"本地输入"触发(`markChangeStale` 由编辑器报告),所以远端或
926
+ * 会话继续改同一个文件时,屏幕上那份行号与补丁会一直画着、看起来仍然准确。面板每
927
+ * 3 秒重读一次账本,那份列表就是"这批标记还算不算数"的唯一证据 —— 这里把它翻成
928
+ * 既有那张「位置已过期」标记。
929
+ *
930
+ * 判据是纯函数(`changes/staleness.ts`),这里只负责选出**属于这个会话**的标签页:
931
+ * 换会话后屏幕上可能还留着上一个会话的标记,拿本会话的列表去比对只会误报。
932
+ * **不发起任何远端读**:重新计算是用户点该行时的事。
933
+ *
934
+ * @param sessionId - 面板当前会话。
935
+ * @param files - 这一轮列表的行。
936
+ * @param truncated - 列表自己被文件上限截断("找不到"不再算证据)。
937
+ * @param listedAt - 这份列表的重算时刻(`RemoteChangesSummary.at`)。
938
+ * @param turnView - 本轮视图;带本轮来源的标记要用它那一份行来判(见实现)。
939
+ */
940
+ export declare function syncChangeSetStaleness(sessionId: string, files: readonly RemoteChangedFile[], truncated?: boolean, listedAt?: number, turnView?: RemoteChangesTurnView): void;
941
+ /**
942
+ * 「会话改动」面板那一行的 → 只读并排 diff(见 `changes/session-diff.ts`)。
943
+ *
944
+ * 与 `openFile`/`openDiff` 的区别是数据来源:这里读的是会话账本(会话起点为基线),
945
+ * 而 `openDiff` 读的是 git 工作区(索引/HEAD 为基线)。两件事不能互相顶替 ——
946
+ * 工作区里可能有会话开始之前就存在的未提交改动。
947
+ *
948
+ * 结果里的 `notice` 就是面板要显示的那句话(截断 / 二进制 / 读不到 / 已无差异),
949
+ * 打开成功时为 `undefined`。调用方负责把它渲染出来,不要吞掉。
950
+ */
951
+ export interface ChangeDiffTarget {
952
+ sessionId: string;
953
+ alias: string;
954
+ /** 会话账本的仓库根(与 `revertFileChanges` 的 `root` 同源)。 */
955
+ root: string;
956
+ /** 远端绝对路径。 */
957
+ path: string;
958
+ /** 面板显示路径(标签条用)。 */
959
+ display: string;
960
+ /** 面板选定的仓库子目录(透传给账本的 `repoSubdir`,可省略)。 */
961
+ repoSubdir?: string;
962
+ }
963
+ export interface ChangeDiffResult {
964
+ opened: boolean;
965
+ /** 必须显示给用户的结论;`undefined` = 打开成功且没有任何要说明的。 */
966
+ notice?: DiffNotice;
967
+ }
968
+ /** 打开(或聚焦)一行的会话只读 diff。 */
969
+ export declare function openChangeDiff(target: ChangeDiffTarget): Promise<ChangeDiffResult>;
881
970
  export declare function undoChange(tabId: string, mark: ChangeMark): Promise<void>;
882
971
  /**
883
972
  * Coordinates for "undo everything this session did to this file".
@@ -895,6 +984,25 @@ export interface RevertFileTarget {
895
984
  path: string;
896
985
  display: string;
897
986
  mode: 'patch' | 'delete';
987
+ /**
988
+ * Which comparison the patch must come from.
989
+ *
990
+ * `turn` = "undo what THIS turn did to this file" (restore the previous turn's
991
+ * close); absent = the session baseline (unchanged default). The patch is
992
+ * re-fetched from the host rather than taken from the panel's poll, so the
993
+ * same argument decides WHICH host read to make.
994
+ */
995
+ scope?: 'session' | 'turn';
996
+ /**
997
+ * For `scope: 'turn'`: which turn the row came from.
998
+ *
999
+ * Used after a successful revert to hide that row from the turn list (the host's
1000
+ * frozen delta keeps listing it, by design). **Fail-closed**: when it is omitted
1001
+ * the row is NOT hidden — hiding is a claim about one specific turn, and guessing
1002
+ * it (e.g. from "the latest turn seen") could hide a row in a turn the user never
1003
+ * reverted. The only caller (the dock) always knows it.
1004
+ */
1005
+ turn?: number;
898
1006
  }
899
1007
  /**
900
1008
  * Revert one file's WHOLE session change set (the panel row's action).
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Inline blame gutter for the CodeMirror editor.
3
+ *
4
+ * The data is fetched by the editor pane (one `-L` window at a time) and handed
5
+ * in as a line→commit map; this module only paints it. Keeping the fetch out of
6
+ * here is deliberate: the same model is used by the gate without CodeMirror,
7
+ * and a scroll must not be able to start a request from inside a gutter
8
+ * callback.
9
+ */
10
+ import { type Extension } from '@codemirror/state';
11
+ import { type BlameLine } from '../blame-model.ts';
12
+ /**
13
+ * Build the gutter extension. Rebuilt by the editor's compartment whenever a
14
+ * blame window lands; `nowSeconds` is pinned so every cell in one render has
15
+ * the same clock.
16
+ */
17
+ export declare function blameExtension(entries: ReadonlyMap<number, BlameLine>, onOpen?: (entry: BlameLine) => void): Extension;
18
+ /** Internal export for the editor to forward viewport changes. */
19
+ export declare function blameViewportReporter(report: (first: number, last: number) => void): Extension;
@@ -119,6 +119,27 @@ export interface ChangeSet {
119
119
  * (新建 / 二进制 / 字节被上限扣下)。
120
120
  */
121
121
  filePatch?: string;
122
+ /**
123
+ * 这批 hunk 对应的增删行数(`--numstat` 语义:`+` / `-` 行的条数)。
124
+ *
125
+ * 面板每 3 秒重新统计一次,而屏幕上这批标记只会在这几行真的变了之后才作废;
126
+ * 把"这批标记当初代表多少行"记在数据里,才能拿它和新的统计行比对(见
127
+ * `changes/staleness.ts`)。省略 = 无可比数字:二进制 / 过大的行不做行级比较、
128
+ * 被字节上限扣下的 diff 也不会走到建标记这一步(`changes/diff-outcome.ts`),
129
+ * 所以它们都没有这两个字段,而不是"带一个前缀数字"。
130
+ */
131
+ added?: number;
132
+ deleted?: number;
133
+ /** 建立这批标记时列表行给出的状态(A/M/D/R/…);省略 = 未知,不参与比对。 */
134
+ status?: string;
135
+ /**
136
+ * 每个 hunk 的一枚稳定块标识(与 `patches` 同序,见 `changes/block-confirm.ts`)。
137
+ *
138
+ * 编辑器里的「确认保留」是**块级**本地记账,块必须有一个跨刷新稳定的名字;
139
+ * 行号会随远端变化,hunk 头里的四个数字 + 文件的远端绝对路径才代表"同一处改动"。
140
+ * 省略 = 调用方没有给出文件路径,编辑器的块笔记不启用。
141
+ */
142
+ blocks?: string[];
122
143
  }
123
144
  /** 换一份改动标记;`null` = 清空(有改动数据,但没有任何要画的东西)。 */
124
145
  export declare const setChangeSet: import("@codemirror/state").StateEffectType<ChangeSet | null>;
@@ -124,8 +124,6 @@ export declare function ExplorerFolderIcon(props: {
124
124
  className?: string;
125
125
  }): ReactNode;
126
126
  export declare function isImageFile(path: string): boolean;
127
- export declare function isMarkdownFile(path: string): boolean;
128
- export declare function isHtmlFile(path: string): boolean;
129
127
  export declare function mimeFor(path: string): string;
130
128
  /** True for a file that always opens as a preview, never as a diff. */
131
129
  export declare function isPreviewOnlyFile(path: string): boolean;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Document previews for remote files.
3
+ *
4
+ * Text sources (Markdown/HTML/SVG/CSV) are rendered from the editor buffer. PDF,
5
+ * audio/video and Office bytes never pass through `fs.read` (it is a UTF-8 API
6
+ * with a 4 MiB cap): they are streamed from the existing `/download` route into
7
+ * a blob URL, and Office is first converted to PDF by a LibreOffice already
8
+ * present on the REMOTE host. When that engine is missing the notice says so;
9
+ * the plugin never claims a corrupt file.
10
+ */
11
+ import { type ReactNode } from 'react';
12
+ /** Never assemble a larger preview body than this in the tab. */
13
+ export declare const MAX_PREVIEW_BYTES: number;
14
+ export declare function officeExtensionOf(path: string): string | undefined;
15
+ /**
16
+ * Convert one remote Office document to PDF on the remote host.
17
+ *
18
+ * Paths and the extension are quoted/validated here; the only value that ends
19
+ * up in the shell is the remote path. A missing engine is reported as
20
+ * `@@RVS_NO_SOFFICE` (notice), not as a corrupt document.
21
+ */
22
+ export declare function officeConvertCommand(path: string): string;
23
+ /** Fetch one remote file body through the streaming download route. */
24
+ export declare function fetchRemoteBytes(alias: string, path: string, signal?: AbortSignal): Promise<Uint8Array>;
25
+ export declare function BytePreview(props: {
26
+ alias: string;
27
+ path: string;
28
+ /** DSH session; lets the host workspaceFiles/officeKit remotes resolve the
29
+ * same remote workspace before the plugin's own download fallback. */
30
+ sessionId?: string;
31
+ kind: 'pdf' | 'office' | 'media';
32
+ revision: number;
33
+ t: (key: string) => string;
34
+ }): ReactNode;
35
+ export declare function SvgPreview(props: {
36
+ path: string;
37
+ text: string;
38
+ truncated: boolean;
39
+ t: (key: string) => string;
40
+ }): ReactNode;
41
+ export declare function TablePreview(props: {
42
+ path: string;
43
+ text: string;
44
+ truncated: boolean;
45
+ t: (key: string) => string;
46
+ }): ReactNode;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Remote document preview classification and table parsing.
3
+ *
4
+ * Pure functions only (no React/DOM/fetch): the editor shell, the preview
5
+ * component and the gate all read the same classification, and CSV/TSV parsing
6
+ * can be tested in Node.
7
+ */
8
+ export type PreviewKind = 'text' | 'image' | 'markdown' | 'html' | 'svg' | 'table' | 'pdf' | 'office' | 'media';
9
+ export declare function extensionOf(path: string): string;
10
+ export declare function previewKindOf(path: string): PreviewKind;
11
+ export declare function isBytePreview(kind: PreviewKind): kind is 'pdf' | 'office' | 'media';
12
+ export declare function hasTextSource(kind: PreviewKind): boolean;
13
+ export declare function previewKindLabel(kind: PreviewKind): string | undefined;
14
+ export declare function mediaTypeOf(path: string): {
15
+ kind: 'audio' | 'video';
16
+ mime: string;
17
+ } | undefined;
18
+ export declare function tableDelimiterOf(path: string): string;
19
+ export interface TableLimits {
20
+ maxRows: number;
21
+ maxColumns: number;
22
+ maxCells: number;
23
+ }
24
+ export declare const DEFAULT_TABLE_LIMITS: TableLimits;
25
+ export interface TableData {
26
+ rows: string[][];
27
+ columns: number;
28
+ truncated: boolean;
29
+ }
30
+ /** RFC 4180 parser with explicit row/column/cell bounds. */
31
+ export declare function parseDelimited(text: string, delimiter: string, limits?: TableLimits): TableData;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Host Client-Remote access for document previews.
3
+ *
4
+ * The reference local-workbench implementation reads bytes through
5
+ * `remote.workspaceFiles.readBytes` and converts Office through
6
+ * `remote.officeKit.render`. dsh-remote-vs replaces the global `fs` with a
7
+ * transparent RouterFs, so those services can route a remote session's
8
+ * workspace; this module keeps them as SOFT services (ctx.get) and reports
9
+ * `unavailable` when a profile does not mount them.
10
+ */
11
+ import type { Context } from '@deepseek-ai/cordis';
12
+ export type PreviewFailureReason = 'unavailable' | 'too-large' | 'not-found' | 'remote' | 'failed';
13
+ export type PreviewBytesResult = {
14
+ ok: true;
15
+ data: Uint8Array;
16
+ size: number;
17
+ } | {
18
+ ok: false;
19
+ reason: PreviewFailureReason;
20
+ detail: string;
21
+ };
22
+ export declare function installPreviewServices(ctx: Context): () => void;
23
+ export declare function readWorkspaceBytes(sessionId: string, path: string, signal?: AbortSignal): Promise<PreviewBytesResult>;
24
+ export declare function renderOfficePdf(sessionId: string, path: string, signal?: AbortSignal): Promise<PreviewBytesResult>;
@@ -137,6 +137,24 @@ export declare function commitPatchCommand(workdir: string, ref: string): string
137
137
  export declare function commitFileDiffCommand(workdir: string, ref: string, paths: readonly string[]): string;
138
138
  /** One file's content at a revision (`rev` may also be `:0` for the index). */
139
139
  export declare function fileAtRevCommand(workdir: string, rev: string, path: string): string;
140
+ /**
141
+ * One inclusive line window of `git blame` for a repo-relative file.
142
+ *
143
+ * The window is part of the command (not a post-filter): blame is one of the
144
+ * reads that can be very expensive on a large file, and the editor only ever
145
+ * needs the lines around the viewport. `--line-porcelain` repeats the commit
146
+ * header for every line, so the parser is stateless (see `blame-model.ts`).
147
+ */
148
+ export declare function blameCommand(workdir: string, path: string, from: number, to: number): string;
149
+ /**
150
+ * Commits that touched one file, newest first, with rename following.
151
+ *
152
+ * `--follow` works only for a single path; the format matches `parseLog`, so
153
+ * the existing history row type is reused without a second parser.
154
+ */
155
+ export declare function fileHistoryCommand(workdir: string, path: string, max?: number): string;
156
+ /** One commit's header fields, even when it is older than the log window. */
157
+ export declare function commitMetaCommand(workdir: string, ref: string): string;
140
158
  /** Local + remote-tracking branches with their upstream and tip. */
141
159
  export declare function allBranchesCommand(workdir: string): string;
142
160
  /** Every configured remote with its URLs. */
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Remote process snapshots for the monitor page.
3
+ *
4
+ * Same model as `listen-ports.ts`: one bounded POSIX probe (GNU `ps`, a BSD
5
+ * `ps` fallback, then an explicit `none`), with all parsing done host-side so
6
+ * the browser only receives a bounded table. A process is never killed by a
7
+ * command assembled in the browser: the route validates the PID against the
8
+ * latest snapshot and builds the one signal command here.
9
+ */
10
+ import type { RemoteProcessesResult } from './protocol.ts';
11
+ /** Marker proving which probe branch actually ran. */
12
+ export declare const PROCESSES_MARK = "@@RVS-PROCS";
13
+ /** Budget for the whole probe; a stuck process table must not pin a channel. */
14
+ export declare const PROCESSES_TIMEOUT_MS = 15000;
15
+ /** Hard cap on rows per snapshot (a container host can have thousands). */
16
+ export declare const PROCESSES_MAX = 500;
17
+ /** Longest command string sent to the browser per row. */
18
+ export declare const PROCESS_COMMAND_MAX = 300;
19
+ /**
20
+ * One bounded probe.
21
+ *
22
+ * GNU first (`--sort` + `etimes`), then the portable `ps aux` table for BSD /
23
+ * old systems (`ppid` and elapsed time are unknown there). The marker
24
+ * line is printed BEFORE the table so an interrupted probe is distinguishable
25
+ * from a genuinely empty one; the final marker lets the parser reject a
26
+ * truncated run.
27
+ */
28
+ export declare function processesCommand(max?: number): string;
29
+ /** A kill signal the route accepts; never an arbitrary string from the client. */
30
+ export type KillSignal = 'TERM' | 'KILL';
31
+ export declare function isKillSignal(value: unknown): value is KillSignal;
32
+ /** Assert a PID a process snapshot may contain (1 is the remote init). */
33
+ export declare function assertProcessPid(value: unknown): number;
34
+ /**
35
+ * Build the one kill command. The PID has already passed the snapshot check;
36
+ * single-quoting it keeps the command shape uniform with every other builder.
37
+ */
38
+ export declare function killCommand(pid: number, signal: KillSignal): string;
39
+ /**
40
+ * Parse one probe. `exitCode === null` (channel died) or a missing end marker
41
+ * means `unknown`, never an empty process table.
42
+ */
43
+ export declare function parseProcesses(stdout: string, exitCode: number | null): RemoteProcessesResult;
@@ -41,6 +41,8 @@ export declare const REMOTE_API: {
41
41
  readonly listenPorts: "/api/dsh-remote/listen-ports";
42
42
  /** Live system metrics for the monitor panel (one bounded probe per host). */
43
43
  readonly metrics: "/api/dsh-remote/metrics";
44
+ /** One bounded process table for the monitor page, plus TERM/KILL actions. */
45
+ readonly processes: "/api/dsh-remote/processes";
44
46
  };
45
47
  /**
46
48
  * Most entries one multi-selection download may archive. The selection rides in
@@ -519,6 +521,82 @@ export interface RemoteChangedFile {
519
521
  */
520
522
  revert?: 'patch' | 'delete';
521
523
  }
524
+ /**
525
+ * The most recent COMPLETED turn, as the review panel switches to it.
526
+ *
527
+ * "This turn" is answered from the ledger's own turn boundaries: the host keeps
528
+ * every listed path's text at each turn close and compares the next close
529
+ * against it. Deliberately ONE turn deep — a per-turn history would need the
530
+ * full text of every file at every boundary, and the panel's job is "what did
531
+ * the turn I just ran change", not a time machine.
532
+ */
533
+ export interface RemoteChangesTurnView {
534
+ /** Turn number the delta describes (0 = no turn has closed yet). */
535
+ turn: number;
536
+ /** Files this turn changed, with THIS TURN's counts (not the session total). */
537
+ files: RemoteChangedFile[];
538
+ added: number;
539
+ deleted: number;
540
+ /** Wall-clock ms when the delta was computed. */
541
+ at: number;
542
+ /**
543
+ * Whether the per-file hunks behind `turnDiff` are cached.
544
+ *
545
+ * `false` = the turn's contents were too large for the memory budget (or the
546
+ * file cap made attribution unreliable): the counts above are still real, but
547
+ * clicking a row cannot paint hunks or revert. Honest degradation — the
548
+ * alternative would be comparing the next turn against a half-updated
549
+ * snapshot and attributing old changes to it.
550
+ */
551
+ cached: boolean;
552
+ /** Why `cached` is false (shown to the user, never swallowed). */
553
+ reason?: string;
554
+ /**
555
+ * This view is INCOMPLETE — and it is not "a prefix of a longer list".
556
+ *
557
+ * Three ways rows go missing:
558
+ * - the file cap cut the list (`files` is the first N of the scanned paths);
559
+ * - the previous turn's snapshot was cut by that cap, or a previous side was
560
+ * withheld (binary / over the read cap), so a path that cannot be compared is
561
+ * DROPPED instead of being guessed as a whole-file creation;
562
+ * - the previous turn's slow scan never landed before this turn closed, so a
563
+ * file missing from that snapshot cannot be proven new either.
564
+ *
565
+ * A partial view must say so: "these rows are what this turn provably changed",
566
+ * not "this is everything the turn changed".
567
+ */
568
+ truncated?: true;
569
+ /**
570
+ * The turn's slow scan (`git ls-files --others`) has not landed yet.
571
+ *
572
+ * The same turn is REBUILT when it does (`correctTurn`), so this list may still
573
+ * grow — it is never relabelled as the next turn. When a newer turn closes
574
+ * first, the view stops waiting and `truncated` records that it never caught
575
+ * up.
576
+ */
577
+ pending?: true;
578
+ }
579
+ /**
580
+ * Body of `op: 'list'` on the changes route (the request half of
581
+ * {@link RemoteChangesSummary}).
582
+ *
583
+ * The two refresh intents are separated because they cost very different things
584
+ * on the remote:
585
+ * - {@link RemoteChangesListRequest.force} (`⟳`) — tracked scan NOW and re-arm the
586
+ * slow `git ls-files --others` walk (clears its write-off). Deliberate click.
587
+ * - {@link RemoteChangesListRequest.trackedOnly} — "the user came back to the
588
+ * page": tracked files now, but the slow walk keeps its cadence and its
589
+ * written-off verdict. Focus events repeat every few seconds; re-arming an 11s
590
+ * (cold: minutes) walk on each one would multiply the remote load.
591
+ */
592
+ export interface RemoteChangesListRequest {
593
+ op: 'list';
594
+ sessionId: string;
595
+ force?: true;
596
+ trackedOnly?: true;
597
+ /** Repository directory from the Source Control panel ('' = the session root). */
598
+ repoSubdir?: string;
599
+ }
522
600
  /**
523
601
  * What one session changed on its remote host since the session's baseline.
524
602
  *
@@ -560,10 +638,30 @@ export interface RemoteChangesSummary {
560
638
  pending: boolean;
561
639
  /** Why this session has no ledger (local session, no git, timeout, …). */
562
640
  unavailable?: string;
641
+ /**
642
+ * The last completed turn's delta, when the host computed one.
643
+ *
644
+ * Optional on purpose: an older host (or a session with no closed turn yet)
645
+ * omits it and the panel stays on the session-cumulative view it has always
646
+ * shown. A client that does not know the field ignores it.
647
+ */
648
+ turnView?: RemoteChangesTurnView;
563
649
  }
564
650
  /** One file's whole-session comparison, ready for editor decorations. */
565
651
  export interface RemoteChangesDiff {
566
- kind: 'text' | 'binary' | 'missing';
652
+ /**
653
+ * `unavailable` / `stale` belong to the per-turn comparison only.
654
+ *
655
+ * - `unavailable`: the host has no cached per-turn hunks for this session
656
+ * (memory budget, file cap, or no completed turn) — `reason` says which;
657
+ * - `stale`: the file changed after the turn closed, so the cached comparison
658
+ * no longer describes what is on disk; the client falls back to the
659
+ * session-cumulative view instead of painting wrong lines.
660
+ *
661
+ * The whole-session `diff` never returns them, so a client that switches on
662
+ * the old three kinds keeps working unchanged.
663
+ */
664
+ kind: 'text' | 'binary' | 'missing' | 'unavailable' | 'stale';
567
665
  /** Remote absolute POSIX path. */
568
666
  path: string;
569
667
  display: string;
@@ -582,6 +680,8 @@ export interface RemoteChangesDiff {
582
680
  status?: 'A' | 'M' | 'D' | 'R' | 'C' | 'T' | 'U';
583
681
  /** The diff was cut at the byte cap: `hunks` is a prefix. */
584
682
  truncated?: true;
683
+ /** For `unavailable` / `stale`: what happened, in words the panel can show. */
684
+ reason?: string;
585
685
  }
586
686
  /** One row of the side-by-side diff projection. */
587
687
  export interface DiffRow {
@@ -695,6 +795,38 @@ export interface RemoteListenPortsResult {
695
795
  /** Why the probe could not be used, when it could not. */
696
796
  error?: string;
697
797
  }
798
+ /** One row of the remote process table. */
799
+ export interface RemoteProcess {
800
+ pid: number;
801
+ /** Parent PID; 0 on a BSD `ps aux` table that does not print it. */
802
+ ppid: number;
803
+ user: string;
804
+ cpuPercent: number;
805
+ memPercent: number;
806
+ /** Elapsed seconds when the probe can provide them; null on BSD `ps aux`. */
807
+ elapsedSeconds: number | null;
808
+ command: string;
809
+ }
810
+ /**
811
+ * The remote process probe's answer.
812
+ *
813
+ * `tool: 'none' | 'unknown'` means "cannot enumerate", never "no processes";
814
+ * the monitor page must explain that instead of rendering an empty table.
815
+ */
816
+ export interface RemoteProcessesResult {
817
+ tool: 'gnu' | 'bsd' | 'none' | 'unknown';
818
+ processes: RemoteProcess[];
819
+ truncated: boolean;
820
+ error?: string;
821
+ }
822
+ /** Result of one TERM/KILL request (the route validates the PID first). */
823
+ export interface RemoteProcessKillResult {
824
+ ok: boolean;
825
+ pid: number;
826
+ signal: 'TERM' | 'KILL';
827
+ /** Remote error text when the signal was refused. */
828
+ error?: string;
829
+ }
698
830
  /**
699
831
  * How one host metrics sample ended.
700
832
  *
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-remote-vs",
3
3
  "description": "VSCode-style remote development for DSH: SSH host manager (key/password), helper deploy pipeline with version check, remote file explorer + editor + terminal in dsh-better-sidebar.",
4
- "version": "0.26.0",
4
+ "version": "0.28.0",
5
5
  "icon": "icon.svg",
6
6
  "keywords": [
7
7
  "dsh",
@@ -150,6 +150,7 @@
150
150
  "@deepseek-ai/dsh-api-remotes": "0.2.2-rc.5",
151
151
  "@deepseek-ai/dsh-bash-local": "0.2.2-rc.5",
152
152
  "@deepseek-ai/dsh-client-locale": "0.2.2-rc.5",
153
+ "@deepseek-ai/dsh-client-ui-primitives": "0.2.2-rc.5",
153
154
  "@deepseek-ai/dsh-client-ui-renderer": "0.2.2-rc.5",
154
155
  "@deepseek-ai/dsh-client-ui-settings": "0.2.2-rc.5",
155
156
  "@deepseek-ai/dsh-client-ui-sidebar-right": "0.2.2-rc.5",