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
|
@@ -0,0 +1,216 @@
|
|
|
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 =
|
|
9
|
+
| 'text' | 'image' | 'markdown' | 'html' | 'svg' | 'table' | 'pdf' | 'office' | 'media'
|
|
10
|
+
|
|
11
|
+
const IMAGE_EXTENSIONS = new Set(['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp', 'ico', 'avif'])
|
|
12
|
+
|
|
13
|
+
const KIND_BY_EXTENSION: Readonly<Record<string, PreviewKind>> = {
|
|
14
|
+
md: 'markdown', markdown: 'markdown', mdown: 'markdown', mkd: 'markdown', mdx: 'markdown',
|
|
15
|
+
html: 'html', htm: 'html', xhtml: 'html',
|
|
16
|
+
csv: 'table', tsv: 'table',
|
|
17
|
+
svg: 'svg',
|
|
18
|
+
pdf: 'pdf',
|
|
19
|
+
// Only the six extensions a LibreOffice/office-kit conversion can actually
|
|
20
|
+
// claim; odt/ods/odp/docm/... fall through to the binary notice instead of a
|
|
21
|
+
// guaranteed conversion error.
|
|
22
|
+
doc: 'office', docx: 'office', ppt: 'office', pptx: 'office', xls: 'office', xlsx: 'office',
|
|
23
|
+
mp3: 'media', wav: 'media', ogg: 'media', oga: 'media', opus: 'media', m4a: 'media',
|
|
24
|
+
aac: 'media', flac: 'media', weba: 'media', mp4: 'media', m4v: 'media', webm: 'media',
|
|
25
|
+
ogv: 'media', mov: 'media',
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const MEDIA_MIME: Readonly<Record<string, { kind: 'audio' | 'video'; mime: string }>> = {
|
|
29
|
+
mp3: { kind: 'audio', mime: 'audio/mpeg' },
|
|
30
|
+
wav: { kind: 'audio', mime: 'audio/wav' },
|
|
31
|
+
ogg: { kind: 'audio', mime: 'audio/ogg' },
|
|
32
|
+
oga: { kind: 'audio', mime: 'audio/ogg' },
|
|
33
|
+
opus: { kind: 'audio', mime: 'audio/ogg' },
|
|
34
|
+
m4a: { kind: 'audio', mime: 'audio/mp4' },
|
|
35
|
+
aac: { kind: 'audio', mime: 'audio/aac' },
|
|
36
|
+
flac: { kind: 'audio', mime: 'audio/flac' },
|
|
37
|
+
weba: { kind: 'audio', mime: 'audio/webm' },
|
|
38
|
+
mp4: { kind: 'video', mime: 'video/mp4' },
|
|
39
|
+
m4v: { kind: 'video', mime: 'video/mp4' },
|
|
40
|
+
webm: { kind: 'video', mime: 'video/webm' },
|
|
41
|
+
ogv: { kind: 'video', mime: 'video/ogg' },
|
|
42
|
+
mov: { kind: 'video', mime: 'video/quicktime' },
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function extensionOf(path: string): string {
|
|
46
|
+
const name = path.slice(Math.max(path.lastIndexOf('/'), path.lastIndexOf('\\')) + 1)
|
|
47
|
+
const dot = name.lastIndexOf('.')
|
|
48
|
+
return dot <= 0 ? '' : name.slice(dot + 1).toLowerCase()
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function previewKindOf(path: string): PreviewKind {
|
|
52
|
+
const ext = extensionOf(path)
|
|
53
|
+
if (IMAGE_EXTENSIONS.has(ext)) return 'image'
|
|
54
|
+
return Object.hasOwn(KIND_BY_EXTENSION, ext) ? KIND_BY_EXTENSION[ext] as PreviewKind : 'text'
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function isBytePreview(kind: PreviewKind): kind is 'pdf' | 'office' | 'media' {
|
|
58
|
+
return kind === 'pdf' || kind === 'office' || kind === 'media'
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function hasTextSource(kind: PreviewKind): boolean {
|
|
62
|
+
return kind === 'markdown' || kind === 'html' || kind === 'svg' || kind === 'table'
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function previewKindLabel(kind: PreviewKind): string | undefined {
|
|
66
|
+
const labels: Record<PreviewKind, string | undefined> = {
|
|
67
|
+
text: undefined,
|
|
68
|
+
image: 'Image',
|
|
69
|
+
markdown: 'Markdown',
|
|
70
|
+
html: 'HTML',
|
|
71
|
+
svg: 'SVG',
|
|
72
|
+
table: 'Table',
|
|
73
|
+
pdf: 'PDF',
|
|
74
|
+
office: 'Office',
|
|
75
|
+
media: 'Media',
|
|
76
|
+
}
|
|
77
|
+
return labels[kind]
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function mediaTypeOf(path: string): { kind: 'audio' | 'video'; mime: string } | undefined {
|
|
81
|
+
return MEDIA_MIME[extensionOf(path)]
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function tableDelimiterOf(path: string): string {
|
|
85
|
+
return extensionOf(path) === 'tsv' ? '\t' : ','
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface TableLimits {
|
|
89
|
+
maxRows: number
|
|
90
|
+
maxColumns: number
|
|
91
|
+
maxCells: number
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export const DEFAULT_TABLE_LIMITS: TableLimits = {
|
|
95
|
+
maxRows: 5000,
|
|
96
|
+
maxColumns: 512,
|
|
97
|
+
maxCells: 200_000,
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface TableData {
|
|
101
|
+
rows: string[][]
|
|
102
|
+
columns: number
|
|
103
|
+
truncated: boolean
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** RFC 4180 parser with explicit row/column/cell bounds. */
|
|
107
|
+
export function parseDelimited(
|
|
108
|
+
text: string,
|
|
109
|
+
delimiter: string,
|
|
110
|
+
limits: TableLimits = DEFAULT_TABLE_LIMITS,
|
|
111
|
+
): TableData {
|
|
112
|
+
if (limits.maxColumns <= 0 || limits.maxRows <= 0) {
|
|
113
|
+
return { rows: [], columns: 0, truncated: text.trim() !== '' }
|
|
114
|
+
}
|
|
115
|
+
const rows: string[][] = []
|
|
116
|
+
let row: string[] = []
|
|
117
|
+
let field = ''
|
|
118
|
+
let quoted = false
|
|
119
|
+
let columns = 0
|
|
120
|
+
let stoppedAt = -1
|
|
121
|
+
let dropped = false
|
|
122
|
+
let touched = false
|
|
123
|
+
|
|
124
|
+
const finishField = (): boolean => {
|
|
125
|
+
if (row.length >= limits.maxColumns) return false
|
|
126
|
+
row.push(field)
|
|
127
|
+
field = ''
|
|
128
|
+
touched = true
|
|
129
|
+
return true
|
|
130
|
+
}
|
|
131
|
+
const finishRow = (at: number): boolean => {
|
|
132
|
+
if (!finishField()) {
|
|
133
|
+
if (touched && rows.length < limits.maxRows) {
|
|
134
|
+
if (row.length > columns) columns = row.length
|
|
135
|
+
rows.push(row)
|
|
136
|
+
}
|
|
137
|
+
row = []
|
|
138
|
+
field = ''
|
|
139
|
+
touched = false
|
|
140
|
+
dropped = true
|
|
141
|
+
stoppedAt = at
|
|
142
|
+
return false
|
|
143
|
+
}
|
|
144
|
+
if (!touched || (row.length === 1 && row[0] === '')) {
|
|
145
|
+
row = []
|
|
146
|
+
touched = false
|
|
147
|
+
return true
|
|
148
|
+
}
|
|
149
|
+
if (rows.length >= limits.maxRows) {
|
|
150
|
+
dropped = true
|
|
151
|
+
stoppedAt = at
|
|
152
|
+
return false
|
|
153
|
+
}
|
|
154
|
+
if (rows.length > 0 && (rows.length + 1) * Math.max(columns, row.length) > limits.maxCells) {
|
|
155
|
+
dropped = true
|
|
156
|
+
stoppedAt = at
|
|
157
|
+
return false
|
|
158
|
+
}
|
|
159
|
+
if (row.length > columns) columns = row.length
|
|
160
|
+
rows.push(row)
|
|
161
|
+
row = []
|
|
162
|
+
touched = false
|
|
163
|
+
return true
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const source = text.charCodeAt(0) === 0xfeff ? text.slice(1) : text
|
|
167
|
+
for (let index = 0; index < source.length; index += 1) {
|
|
168
|
+
const char = source[index] as string
|
|
169
|
+
if (quoted) {
|
|
170
|
+
if (char === '"') {
|
|
171
|
+
if (source[index + 1] === '"') {
|
|
172
|
+
field += '"'
|
|
173
|
+
index += 1
|
|
174
|
+
} else {
|
|
175
|
+
quoted = false
|
|
176
|
+
}
|
|
177
|
+
} else {
|
|
178
|
+
field += char
|
|
179
|
+
}
|
|
180
|
+
continue
|
|
181
|
+
}
|
|
182
|
+
if (char === '"' && field === '') {
|
|
183
|
+
quoted = true
|
|
184
|
+
touched = true
|
|
185
|
+
continue
|
|
186
|
+
}
|
|
187
|
+
if (char === delimiter) {
|
|
188
|
+
if (!finishField()) {
|
|
189
|
+
if (touched && rows.length < limits.maxRows) {
|
|
190
|
+
if (row.length > columns) columns = row.length
|
|
191
|
+
rows.push(row)
|
|
192
|
+
}
|
|
193
|
+
row = []
|
|
194
|
+
field = ''
|
|
195
|
+
touched = false
|
|
196
|
+
dropped = true
|
|
197
|
+
stoppedAt = index
|
|
198
|
+
break
|
|
199
|
+
}
|
|
200
|
+
continue
|
|
201
|
+
}
|
|
202
|
+
if (char === '\r') {
|
|
203
|
+
if (source[index + 1] === '\n') index += 1
|
|
204
|
+
if (!finishRow(index)) break
|
|
205
|
+
continue
|
|
206
|
+
}
|
|
207
|
+
if (char === '\n') {
|
|
208
|
+
if (!finishRow(index)) break
|
|
209
|
+
continue
|
|
210
|
+
}
|
|
211
|
+
field += char
|
|
212
|
+
touched = true
|
|
213
|
+
}
|
|
214
|
+
if (stoppedAt === -1 && (touched || field !== '' || row.length > 0)) finishRow(source.length)
|
|
215
|
+
return { rows, columns, truncated: dropped }
|
|
216
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
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
|
+
|
|
13
|
+
export type PreviewFailureReason = 'unavailable' | 'too-large' | 'not-found' | 'remote' | 'failed'
|
|
14
|
+
|
|
15
|
+
export type PreviewBytesResult =
|
|
16
|
+
| { ok: true; data: Uint8Array; size: number }
|
|
17
|
+
| { ok: false; reason: PreviewFailureReason; detail: string }
|
|
18
|
+
|
|
19
|
+
type RemoteCallResult =
|
|
20
|
+
| { ok: true; value: { data: Uint8Array; bytes?: number } }
|
|
21
|
+
| { ok: false; error: { code?: unknown; message?: unknown; details?: unknown } }
|
|
22
|
+
|
|
23
|
+
interface WorkspaceFilesRemote {
|
|
24
|
+
readBytes?: (sessionId: string, path: string, options: Record<string, unknown>, signal?: AbortSignal) => Promise<RemoteCallResult>
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface OfficeKitRemote {
|
|
28
|
+
render?: (sessionId: string, path: string, priority: 'foreground' | 'background', signal?: AbortSignal) => Promise<RemoteCallResult>
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let rootCtx: Context | undefined
|
|
32
|
+
|
|
33
|
+
export function installPreviewServices(ctx: Context): () => void {
|
|
34
|
+
rootCtx = ctx
|
|
35
|
+
return () => {
|
|
36
|
+
if (rootCtx === ctx) rootCtx = undefined
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function remoteNamespace(name: string): Record<string, unknown> | undefined {
|
|
41
|
+
const ctx = rootCtx
|
|
42
|
+
if (ctx === undefined) return undefined
|
|
43
|
+
try {
|
|
44
|
+
const raw: unknown = (ctx as unknown as { get(service: string): unknown }).get(name)
|
|
45
|
+
return typeof raw === 'object' && raw !== null ? raw as Record<string, unknown> : undefined
|
|
46
|
+
} catch {
|
|
47
|
+
return undefined
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function failureReason(code: string, reason?: string): PreviewFailureReason {
|
|
52
|
+
const lowered = `${code} ${reason ?? ''}`.toLowerCase()
|
|
53
|
+
if (lowered.includes('too-large') || lowered.includes('too_large')) return 'too-large'
|
|
54
|
+
if (lowered.includes('workspace-file/not-found') || lowered.includes('not-regular-file')) return 'not-found'
|
|
55
|
+
if (lowered.includes('unavailable') || lowered.includes('missing')) return 'unavailable'
|
|
56
|
+
return 'failed'
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function toBytesResult(outcome: RemoteCallResult | undefined, fallbackDetail: string): PreviewBytesResult {
|
|
60
|
+
if (outcome === undefined) return { ok: false, reason: 'unavailable', detail: fallbackDetail }
|
|
61
|
+
if (outcome.ok) {
|
|
62
|
+
const data = outcome.value.data
|
|
63
|
+
if (!(data instanceof Uint8Array) || data.byteLength === 0) {
|
|
64
|
+
return { ok: false, reason: 'failed', detail: 'empty payload' }
|
|
65
|
+
}
|
|
66
|
+
return { ok: true, data, size: typeof outcome.value.bytes === 'number' ? outcome.value.bytes : data.byteLength }
|
|
67
|
+
}
|
|
68
|
+
const code = typeof outcome.error.code === 'string' ? outcome.error.code : ''
|
|
69
|
+
const message = typeof outcome.error.message === 'string' ? outcome.error.message : ''
|
|
70
|
+
const details = outcome.error.details
|
|
71
|
+
const reason = typeof details === 'object' && details !== null
|
|
72
|
+
&& typeof (details as { reason?: unknown }).reason === 'string'
|
|
73
|
+
? (details as { reason: string }).reason
|
|
74
|
+
: undefined
|
|
75
|
+
return {
|
|
76
|
+
ok: false,
|
|
77
|
+
reason: failureReason(code, reason),
|
|
78
|
+
detail: [code, reason, message].filter(part => typeof part === 'string' && part !== '').join(': '),
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export async function readWorkspaceBytes(
|
|
83
|
+
sessionId: string,
|
|
84
|
+
path: string,
|
|
85
|
+
signal?: AbortSignal,
|
|
86
|
+
): Promise<PreviewBytesResult> {
|
|
87
|
+
if (sessionId === '') return { ok: false, reason: 'unavailable', detail: 'no session' }
|
|
88
|
+
const service = remoteNamespace('remote.workspaceFiles') as WorkspaceFilesRemote | undefined
|
|
89
|
+
if (typeof service?.readBytes !== 'function') {
|
|
90
|
+
return { ok: false, reason: 'unavailable', detail: 'remote.workspaceFiles is not mounted' }
|
|
91
|
+
}
|
|
92
|
+
let outcome: RemoteCallResult
|
|
93
|
+
try {
|
|
94
|
+
outcome = await service.readBytes(sessionId, path, {}, signal)
|
|
95
|
+
} catch (error) {
|
|
96
|
+
return { ok: false, reason: 'failed', detail: error instanceof Error ? error.message : String(error) }
|
|
97
|
+
}
|
|
98
|
+
return toBytesResult(outcome, 'remote.workspaceFiles is not mounted')
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export async function renderOfficePdf(
|
|
102
|
+
sessionId: string,
|
|
103
|
+
path: string,
|
|
104
|
+
signal?: AbortSignal,
|
|
105
|
+
): Promise<PreviewBytesResult> {
|
|
106
|
+
if (sessionId === '') return { ok: false, reason: 'unavailable', detail: 'no session' }
|
|
107
|
+
const service = remoteNamespace('remote.officeKit') as OfficeKitRemote | undefined
|
|
108
|
+
if (typeof service?.render !== 'function') {
|
|
109
|
+
return { ok: false, reason: 'unavailable', detail: 'remote.officeKit is not mounted' }
|
|
110
|
+
}
|
|
111
|
+
let outcome: RemoteCallResult
|
|
112
|
+
try {
|
|
113
|
+
outcome = await service.render(sessionId, path, 'foreground', signal)
|
|
114
|
+
} catch (error) {
|
|
115
|
+
return { ok: false, reason: 'failed', detail: error instanceof Error ? error.message : String(error) }
|
|
116
|
+
}
|
|
117
|
+
return toBytesResult(outcome, 'remote.officeKit is not mounted')
|
|
118
|
+
}
|
|
@@ -40,8 +40,12 @@ export interface SaveShortcutEvent {
|
|
|
40
40
|
* A terminal (xterm) forwards keys to the remote shell and a themed dialog's
|
|
41
41
|
* input is mid-edit; hijacking the key there would be a surprise, and for the
|
|
42
42
|
* shell it would also steal a control character (`^S`).
|
|
43
|
+
*
|
|
44
|
+
* Exported so the plugin's OTHER window-level shortcut (Ctrl+P in `RemoteRoot`)
|
|
45
|
+
* draws the same line instead of re-inventing a narrower one — it used to
|
|
46
|
+
* exclude only `.xterm` and hijacked the host's chat composer.
|
|
43
47
|
*/
|
|
44
|
-
const FOREIGN_TARGET = '.xterm, textarea, input, [contenteditable="true"]'
|
|
48
|
+
export const FOREIGN_TARGET = '.xterm, textarea, input, [contenteditable="true"]'
|
|
45
49
|
|
|
46
50
|
/**
|
|
47
51
|
* Is this the save shortcut this module should act on?
|
|
@@ -86,8 +90,50 @@ const resolvers = new Set<SaveShortcutResolver>()
|
|
|
86
90
|
/** True while the single window listener is installed. */
|
|
87
91
|
let listening = false
|
|
88
92
|
|
|
93
|
+
/**
|
|
94
|
+
* The layers that own the keyboard while they are open.
|
|
95
|
+
*
|
|
96
|
+
* Mirrors the modal selector the host's own shortcut dispatcher trims commands
|
|
97
|
+
* with (`[role="dialog"][aria-modal="true"], [role="menu"]` in
|
|
98
|
+
* `@deepseek-ai/dsh-client-shortcuts`). These window listeners register nothing
|
|
99
|
+
* with `ctx.shortcuts`, so no host mechanism keeps them from firing THROUGH a
|
|
100
|
+
* dialog. Blanket on purpose: our own `.rvs-modal-mask`, QuickOpen and the
|
|
101
|
+
* context menus are modal too, and a global shortcut must not pierce those
|
|
102
|
+
* either. A caller that owns a layer and wants a toggle inside it (Ctrl+P
|
|
103
|
+
* closes QuickOpen) skips this check while its own layer is up.
|
|
104
|
+
*
|
|
105
|
+
* `role="menu"` is the one exception to the blanket: it is what the host's
|
|
106
|
+
* dispatcher treats as modal, but a NON-modal picker floats over the editor
|
|
107
|
+
* while the editor is still the surface in use, so swallowing Ctrl+S there was
|
|
108
|
+
* a real regression (audit NIT-5). Such a menu opts out with
|
|
109
|
+
* `[data-rvs-nonmodal]` — the breadcrumb dropdown (`vsc/breadcrumb.tsx`) carries
|
|
110
|
+
* it now, so no class-name bridge is needed.
|
|
111
|
+
* RESIDUAL, deliberately conservative: any future non-modal menu that carries
|
|
112
|
+
* neither marker still swallows Ctrl+S, and a modal layer that lacks
|
|
113
|
+
* `aria-modal="true"` is not caught by the dialog branch. Failing safe matters
|
|
114
|
+
* more here than a missed save: the alternative is writing a remote file
|
|
115
|
+
* underneath a layer the user is answering.
|
|
116
|
+
*/
|
|
117
|
+
const MODAL_LAYER = '[role="dialog"][aria-modal="true"], '
|
|
118
|
+
+ '[role="menu"]:not([data-rvs-nonmodal])'
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Is a modal layer (host approval / settings, our own dialog, an open menu) on
|
|
122
|
+
* screen right now?
|
|
123
|
+
*
|
|
124
|
+
* Called from the DOM listener entry points only: `isSaveShortcut` stays a pure
|
|
125
|
+
* predicate on the event. Without it Ctrl+S silently saved the remote file
|
|
126
|
+
* underneath a pending host approval dialog — a write the user never confirmed.
|
|
127
|
+
*/
|
|
128
|
+
export function isModalLayerOpen(): boolean {
|
|
129
|
+
if (typeof document === 'undefined') return false
|
|
130
|
+
return document.querySelector(MODAL_LAYER) !== null
|
|
131
|
+
}
|
|
132
|
+
|
|
89
133
|
function onKeyDown(event: KeyboardEvent): void {
|
|
90
134
|
if (!isSaveShortcut(event)) return
|
|
135
|
+
// A dialog or menu on screen owns the keyboard (see `isModalLayerOpen`).
|
|
136
|
+
if (isModalLayerOpen()) return
|
|
91
137
|
for (const resolve of [...resolvers].reverse()) {
|
|
92
138
|
const save = resolve()
|
|
93
139
|
if (save === undefined) continue
|
|
@@ -15,7 +15,16 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import type { ITheme } from '@xterm/xterm'
|
|
17
17
|
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* The dark scheme palette.
|
|
20
|
+
*
|
|
21
|
+
* Contrast is measured against `background` (#0e0e13): the VS Code Dark+ ANSI
|
|
22
|
+
* set, with red / blue / magenta / brightBlack lifted just past 4.5:1 (`black`
|
|
23
|
+
* is left at #000000 on purpose — ANSI black is a background-fill colour by
|
|
24
|
+
* convention and is not read as text; 1.09:1). `brightCyan` is lifted off the
|
|
25
|
+
* plain cyan (#29b8db sat only ΔE76 6.0 from #11a8cd — the pair read as one
|
|
26
|
+
* colour) to #4dd0e1: ΔE76 18.5, 10.5:1 on the terminal surface.
|
|
27
|
+
*/
|
|
19
28
|
export const DARK_TERMINAL_THEME: ITheme = {
|
|
20
29
|
background: '#0e0e13',
|
|
21
30
|
foreground: '#e8e8e8',
|
|
@@ -23,24 +32,41 @@ export const DARK_TERMINAL_THEME: ITheme = {
|
|
|
23
32
|
selectionBackground: '#264f78',
|
|
24
33
|
selectionInactiveBackground: '#333c48',
|
|
25
34
|
black: '#000000',
|
|
26
|
-
red: '#
|
|
35
|
+
red: '#d54f4f',
|
|
27
36
|
green: '#0dbc79',
|
|
28
37
|
yellow: '#e5e910',
|
|
29
|
-
blue: '#
|
|
30
|
-
magenta: '#
|
|
38
|
+
blue: '#2f7fd6',
|
|
39
|
+
magenta: '#cc55cc',
|
|
31
40
|
cyan: '#11a8cd',
|
|
32
41
|
white: '#e5e5e5',
|
|
33
|
-
brightBlack: '#
|
|
42
|
+
brightBlack: '#858585',
|
|
34
43
|
brightRed: '#f14c4c',
|
|
35
44
|
brightGreen: '#23d18b',
|
|
36
45
|
brightYellow: '#f5f543',
|
|
37
46
|
brightBlue: '#3b8eea',
|
|
38
47
|
brightMagenta: '#d670d6',
|
|
39
|
-
brightCyan: '#
|
|
48
|
+
brightCyan: '#4dd0e1',
|
|
40
49
|
brightWhite: '#ffffff',
|
|
41
50
|
}
|
|
42
51
|
|
|
43
|
-
/**
|
|
52
|
+
/**
|
|
53
|
+
* The light scheme palette.
|
|
54
|
+
*
|
|
55
|
+
* Re-taken for a WHITE background (2026-11-23): the Dark+ ANSI set this used to
|
|
56
|
+
* copy measured 1.0–3.6:1 on #ffffff (brightWhite was white-on-white = 1.00,
|
|
57
|
+
* brightYellow 1.17). Text here is targeted at ≥4.5:1, and every colour is.
|
|
58
|
+
*
|
|
59
|
+
* "Bright" cannot mean "lighter" on white, so the bright group is the more
|
|
60
|
+
* saturated sibling of its hue rather than a lighter one; where a hue had to be
|
|
61
|
+
* re-picked the normal/bright pair keeps a visible difference. `brightWhite` is
|
|
62
|
+
* the one colour that has no readable white-ish form: it is #767676, the
|
|
63
|
+
* lightest neutral of the ramp, which keeps "bright white" distinguishable from
|
|
64
|
+
* `white`/`brightBlack` while reaching 4.54:1 (VS Code Light+ ships #e5e5e5,
|
|
65
|
+
* 1.05:1 — unreadable). `black` stays #000000 (ANSI background-fill convention).
|
|
66
|
+
* `brightCyan` moves to the teal step #0f766e: the previous #0e7490 sat ΔE76
|
|
67
|
+
* 4.0 from `cyan` (#0b6d84) and read as the same colour; the new value is ΔE76
|
|
68
|
+
* 20.5 away at 5.47:1.
|
|
69
|
+
*/
|
|
44
70
|
export const LIGHT_TERMINAL_THEME: ITheme = {
|
|
45
71
|
background: '#ffffff',
|
|
46
72
|
foreground: '#1a1a1a',
|
|
@@ -48,21 +74,21 @@ export const LIGHT_TERMINAL_THEME: ITheme = {
|
|
|
48
74
|
selectionBackground: '#add6ff',
|
|
49
75
|
selectionInactiveBackground: '#d7e7f5',
|
|
50
76
|
black: '#000000',
|
|
51
|
-
red: '#
|
|
52
|
-
green: '#
|
|
53
|
-
yellow: '#
|
|
77
|
+
red: '#b02a2a',
|
|
78
|
+
green: '#0b6b0b',
|
|
79
|
+
yellow: '#6f5f00',
|
|
54
80
|
blue: '#0451a5',
|
|
55
81
|
magenta: '#bc05bc',
|
|
56
|
-
cyan: '#
|
|
82
|
+
cyan: '#0b6d84',
|
|
57
83
|
white: '#555555',
|
|
58
84
|
brightBlack: '#666666',
|
|
59
|
-
brightRed: '#
|
|
60
|
-
brightGreen: '#
|
|
61
|
-
brightYellow: '#
|
|
62
|
-
brightBlue: '#
|
|
63
|
-
brightMagenta: '#
|
|
64
|
-
brightCyan: '#
|
|
65
|
-
brightWhite: '#
|
|
85
|
+
brightRed: '#cd3131',
|
|
86
|
+
brightGreen: '#107c10',
|
|
87
|
+
brightYellow: '#8a6d00',
|
|
88
|
+
brightBlue: '#1a6fc4',
|
|
89
|
+
brightMagenta: '#bd31bd',
|
|
90
|
+
brightCyan: '#0f766e',
|
|
91
|
+
brightWhite: '#767676',
|
|
66
92
|
}
|
|
67
93
|
|
|
68
94
|
/** The palette for one scheme. */
|