dsh-remote 1.0.1 → 1.1.1
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 +38 -318
- package/README.md +36 -298
- package/lib/binding.js +4 -2
- package/lib/client.js +828 -62
- package/lib/file-changes.js +57 -0
- package/lib/index.js +29 -38
- package/lib/remote-fs.js +8 -2
- package/lib/remote-git.js +127 -0
- package/lib/remote-shell-child.cjs +59 -12
- package/lib/remote-shell.js +1 -1
- package/lib/remote-write.js +51 -0
- package/lib/routes-fs.js +72 -24
- package/lib/sftp-surface.js +1 -1
- package/lib/vendor/jsdiff/LICENSE +29 -0
- package/lib/vendor/jsdiff/SOURCE.md +4 -0
- package/lib/vendor/jsdiff/diff/base.js +254 -0
- package/lib/vendor/jsdiff/diff/line.js +66 -0
- package/lib/vendor/jsdiff/patch/create.js +229 -0
- package/lib/vendor/jsdiff/util/params.js +15 -0
- package/lib/workspace-search.js +219 -0
- package/package.json +6 -5
package/lib/client.js
CHANGED
|
@@ -27,7 +27,7 @@ window.__ModuleLoader__.load({
|
|
|
27
27
|
|
|
28
28
|
const React = require('react')
|
|
29
29
|
const name = 'dsh-remote'
|
|
30
|
-
const CLIENT_VERSION = '1.
|
|
30
|
+
const CLIENT_VERSION = '1.1.1'
|
|
31
31
|
|
|
32
32
|
// ── optional host primitives ────────────────────────────────────────────
|
|
33
33
|
// Issue #74: a remote session's .md link must open over SFTP, NOT via the
|
|
@@ -47,6 +47,7 @@ window.__ModuleLoader__.load({
|
|
|
47
47
|
const isComponentType = (value) => typeof value === 'function'
|
|
48
48
|
|| (typeof value === 'object' && value !== null && typeof value.$$typeof === 'symbol')
|
|
49
49
|
const MarkdownText = (Primitives && isComponentType(Primitives.MarkdownText)) ? Primitives.MarkdownText : null
|
|
50
|
+
const NativeDiffBlock = Primitives && isComponentType(Primitives.DiffBlock) ? Primitives.DiffBlock : null
|
|
50
51
|
// Host visual primitives adopted incrementally, always with a graceful
|
|
51
52
|
// fallback (the shared map's contents vary by host version — the bundle
|
|
52
53
|
// ships ~290 exports, older type packages fewer):
|
|
@@ -106,6 +107,95 @@ window.__ModuleLoader__.load({
|
|
|
106
107
|
const NS = 'dsh-remote'
|
|
107
108
|
const L = {
|
|
108
109
|
zh: {
|
|
110
|
+
'workbench.savedWithDraft': '已保存,仍有新的未保存输入',
|
|
111
|
+
'change.applied': "已应用到远端",
|
|
112
|
+
'change.unchanged': "内容未变化",
|
|
113
|
+
'change.expand': "展开其余 {n} 行",
|
|
114
|
+
'change.collapse': "收起差异",
|
|
115
|
+
'change.hunk': "改动片段 {n}",
|
|
116
|
+
'change.binary': "已写入。二进制内容不展示文本差异。",
|
|
117
|
+
'change.noBaseline': "已写入。原文件较大,未读取完整基线;不把本次覆盖误显示为新建文件。",
|
|
118
|
+
'change.truncated': "改动较大,仅展示部分差异。可打开远端文件查看当前内容。",
|
|
119
|
+
'change.legacy': "请求的替换片段 · 当前记录未保存完整差异",
|
|
120
|
+
|
|
121
|
+
'file.mixedEol': "混合换行",
|
|
122
|
+
'changes.title': "远端 Git 改动",
|
|
123
|
+
'changes.failed': "无法读取远端 Git 状态",
|
|
124
|
+
'changes.noGit': "远端未安装 Git,安装后点击刷新。",
|
|
125
|
+
'changes.noRepository': "此工作区不在 Git 仓库中。",
|
|
126
|
+
'changes.unsupportedShell': "当前 Windows 远端未检测到 Git Bash,暂不能查看 Git 状态。",
|
|
127
|
+
'changes.unavailable': "当前无法查看远端 Git 状态。",
|
|
128
|
+
'changes.binary': "二进制文件不提供文本差异。",
|
|
129
|
+
'changes.symlink': "此未跟踪项是符号链接,未读取链接目标。",
|
|
130
|
+
'changes.large': "文件较大,未读取完整内容。可打开文件查看受限预览。",
|
|
131
|
+
'changes.emptyFile': "新建的未跟踪空文件。",
|
|
132
|
+
'changes.noDiff': "当前模式下没有文本差异。",
|
|
133
|
+
'changes.openLine': "打开文件第 {line} 行",
|
|
134
|
+
'changes.detached': "分离 HEAD",
|
|
135
|
+
'changes.readOnly': "查看远端仓库,不自动提交或更改暂存区。",
|
|
136
|
+
'changes.staged': "已暂存",
|
|
137
|
+
'changes.working': "工作区",
|
|
138
|
+
'changes.filter': "筛选改动文件",
|
|
139
|
+
'changes.refreshing': "正在刷新远端状态…",
|
|
140
|
+
'changes.loading': "正在读取远端 Git 状态…",
|
|
141
|
+
'changes.stale': "当前显示上次成功读取的结果。",
|
|
142
|
+
'changes.partial': "改动列表过大或部分路径不受支持,仅显示部分结果。",
|
|
143
|
+
'changes.clean': "工作区干净,暂无改动。",
|
|
144
|
+
'changes.conflict': "冲突",
|
|
145
|
+
'changes.untracked': "未跟踪",
|
|
146
|
+
'changes.noMatch': "没有匹配的改动文件。",
|
|
147
|
+
'changes.emptyGroup': "此分组暂无改动。",
|
|
148
|
+
'changes.openFile': "打开远端文件",
|
|
149
|
+
'changes.stagedDiff': "已暂存改动 · 相对 HEAD",
|
|
150
|
+
'changes.workingDiff': "工作区改动 · 相对暂存区",
|
|
151
|
+
'changes.loadingDiff': "正在读取差异…",
|
|
152
|
+
'changes.diff': "远端文件差异",
|
|
153
|
+
'changes.partialDiff': "差异较大,当前仅显示部分内容。",
|
|
154
|
+
'changes.chooseFile': "选择改动文件查看差异。",
|
|
155
|
+
|
|
156
|
+
'ide.enter': 'IDE 模式', 'ide.exit': '返回普通模式', 'ide.files': '文件',
|
|
157
|
+
'ide.editor': '编辑器', 'ide.chat': '会话', 'ide.openEditor': '打开编辑区',
|
|
158
|
+
'ide.chooseFile': '从左侧选择远程文件,在这里编辑。',
|
|
159
|
+
'ide.unavailable': '当前宿主无法停靠原生会话,请返回普通模式继续工作。',
|
|
160
|
+
'ide.leftWidth': '调整文件栏宽度', 'ide.rightWidth': '调整会话栏宽度',
|
|
161
|
+
'ide.help': '切换布局会保留会话、任务和未保存的编辑。',
|
|
162
|
+
'ide.unsupported': '当前宿主未提供原生编辑区,无法启用 IDE 模式。',
|
|
163
|
+
|
|
164
|
+
'workspaceSearch.options': '搜索选项',
|
|
165
|
+
'workspaceSearch.details': '扫描详情',
|
|
166
|
+
'workspaceSearch.matches': '{n} 个结果',
|
|
167
|
+
'workspaceSearch.scanned': '已扫描 {n} 项',
|
|
168
|
+
'workspaceSearch.activeOptions': '搜索选项 · {n}',
|
|
169
|
+
|
|
170
|
+
'workspaceSearch.query': "搜索远程工作区",
|
|
171
|
+
'workspaceSearch.placeholder': "搜索名称,或切换到文件内容",
|
|
172
|
+
'workspaceSearch.mode': "搜索范围",
|
|
173
|
+
'workspaceSearch.names': "文件和目录",
|
|
174
|
+
'workspaceSearch.files': "仅文件",
|
|
175
|
+
'workspaceSearch.directories': "仅目录",
|
|
176
|
+
'workspaceSearch.content': "文件内容",
|
|
177
|
+
'workspaceSearch.caseSensitive': "区分大小写",
|
|
178
|
+
'workspaceSearch.includeIgnored': "包含忽略目录",
|
|
179
|
+
'workspaceSearch.ignoreHint': "默认跳过依赖、构建目录及配置的忽略项;内容搜索跳过二进制和超大文件。",
|
|
180
|
+
'workspaceSearch.results': "远程搜索结果",
|
|
181
|
+
'workspaceSearch.starting': "准备搜索…",
|
|
182
|
+
'workspaceSearch.running': "正在搜索…",
|
|
183
|
+
'workspaceSearch.completed': "搜索完成",
|
|
184
|
+
'workspaceSearch.partial': "已找到部分结果",
|
|
185
|
+
'workspaceSearch.cancelled': "搜索已停止",
|
|
186
|
+
'workspaceSearch.failed': "搜索失败",
|
|
187
|
+
'workspaceSearch.progress': "{dirs} 个目录 · {files} 个文件 · {results} 个结果 · {seconds} 秒",
|
|
188
|
+
'workspaceSearch.stop': "停止",
|
|
189
|
+
'workspaceSearch.retry': "重新搜索",
|
|
190
|
+
'workspaceSearch.partialHint': "达到搜索预算、结果上限或有目录无法读取。缩小关键词范围后重试,当前结果仍可打开。",
|
|
191
|
+
'workspaceSearch.skipped': "跳过 {skipped} 项 · {errors} 项读取失败",
|
|
192
|
+
'workspaceSearch.wait': "正在遍历远端目录,找到的结果会陆续显示。",
|
|
193
|
+
'workspaceSearch.empty': "未找到匹配项。可切换搜索范围,或包含忽略目录后重试。",
|
|
194
|
+
'workspaceSearch.noneYet': "尚无结果。可修改关键词或重新搜索。",
|
|
195
|
+
'workspaceSearch.directory': "目录",
|
|
196
|
+
'workspaceSearch.file': "文件",
|
|
197
|
+
'workspaceSearch.line': "第 {n} 行",
|
|
198
|
+
|
|
109
199
|
'settings.sshConfigEditorTitle': "SSH 配置",
|
|
110
200
|
'settings.sshConfigEditorHint': "编辑运行 DSH 的主机上的 SSH 配置,保存后重新检测主机。",
|
|
111
201
|
'settings.sshConfigReload': "重新载入",
|
|
@@ -189,8 +279,7 @@ window.__ModuleLoader__.load({
|
|
|
189
279
|
'workbench.explorer': '资源管理器',
|
|
190
280
|
'workbench.openTerminal': '打开远程终端',
|
|
191
281
|
'workbench.terminalUnavailable': '远程终端尚不可用,请检查宿主终端插件与 remote ssh Shell。',
|
|
192
|
-
'workbench.filter': '
|
|
193
|
-
'workbench.noFilteredFiles': '没有匹配的已加载文件',
|
|
282
|
+
'workbench.filter': '搜索远程工作区',
|
|
194
283
|
'workbench.collapse': '折叠全部目录',
|
|
195
284
|
'workbench.remote': '远程工作区',
|
|
196
285
|
'workbench.backToFiles': '返回文件树',
|
|
@@ -489,6 +578,7 @@ window.__ModuleLoader__.load({
|
|
|
489
578
|
'picker.homeBtn': '🏠',
|
|
490
579
|
'picker.goHome': '回家目录',
|
|
491
580
|
'picker.hintKeys': '↑↓ 选择补全 · Enter 补全/确认 · Esc 返回 · Ctrl/⌘+Enter 打开工作区',
|
|
581
|
+
'picker.hintBrowse': 'Enter 进入目录 · Esc 返回路径输入',
|
|
492
582
|
'picker.star': '⭐ Star dsh-remote',
|
|
493
583
|
'picker.feedback': '反馈 / 提 issue',
|
|
494
584
|
'explorer.refresh': '刷新',
|
|
@@ -558,6 +648,95 @@ window.__ModuleLoader__.load({
|
|
|
558
648
|
'common.confirm': '确认',
|
|
559
649
|
},
|
|
560
650
|
en: {
|
|
651
|
+
'workbench.savedWithDraft': 'Saved; newer edits are still unsaved',
|
|
652
|
+
'change.applied': "Applied on remote",
|
|
653
|
+
'change.unchanged': "Content unchanged",
|
|
654
|
+
'change.expand': "Expand {n} more lines",
|
|
655
|
+
'change.collapse': "Collapse diff",
|
|
656
|
+
'change.hunk': "Change hunk {n}",
|
|
657
|
+
'change.binary': "Written successfully. Binary content has no text diff.",
|
|
658
|
+
'change.noBaseline': "Written successfully. The original file was too large to capture a baseline; this overwrite is not shown as a new file.",
|
|
659
|
+
'change.truncated': "The change is large; only part of its diff is shown. Open the remote file to inspect current content.",
|
|
660
|
+
'change.legacy': "Requested replacement · full applied diff is unavailable in this record",
|
|
661
|
+
|
|
662
|
+
'file.mixedEol': "Mixed EOL",
|
|
663
|
+
'changes.title': "Remote Git changes",
|
|
664
|
+
'changes.failed': "Could not read remote Git status",
|
|
665
|
+
'changes.noGit': "Git is unavailable on the remote host. Install it, then refresh.",
|
|
666
|
+
'changes.noRepository': "This workspace is not inside a Git repository.",
|
|
667
|
+
'changes.unsupportedShell': "Git inspection requires Git Bash on this Windows remote.",
|
|
668
|
+
'changes.unavailable': "Remote Git inspection is unavailable.",
|
|
669
|
+
'changes.binary': "Binary files have no text diff.",
|
|
670
|
+
'changes.symlink': "This untracked item is a symbolic link; its target was not read.",
|
|
671
|
+
'changes.large': "This file is large; open it for a bounded preview.",
|
|
672
|
+
'changes.emptyFile': "New untracked empty file.",
|
|
673
|
+
'changes.noDiff': "No text diff in this mode.",
|
|
674
|
+
'changes.openLine': "Open file at line {line}",
|
|
675
|
+
'changes.detached': "Detached HEAD",
|
|
676
|
+
'changes.readOnly': "Inspect the remote repository without changing commits or the index.",
|
|
677
|
+
'changes.staged': "Staged",
|
|
678
|
+
'changes.working': "Working tree",
|
|
679
|
+
'changes.filter': "Filter changed files",
|
|
680
|
+
'changes.refreshing': "Refreshing remote status…",
|
|
681
|
+
'changes.loading': "Reading remote Git status…",
|
|
682
|
+
'changes.stale': "Showing the last successfully read snapshot.",
|
|
683
|
+
'changes.partial': "The change list is large or has unsupported paths; showing partial results.",
|
|
684
|
+
'changes.clean': "The working tree is clean.",
|
|
685
|
+
'changes.conflict': "Conflict",
|
|
686
|
+
'changes.untracked': "Untracked",
|
|
687
|
+
'changes.noMatch': "No changed files match.",
|
|
688
|
+
'changes.emptyGroup': "No changes in this group.",
|
|
689
|
+
'changes.openFile': "Open remote file",
|
|
690
|
+
'changes.stagedDiff': "Staged changes · against HEAD",
|
|
691
|
+
'changes.workingDiff': "Working changes · against the index",
|
|
692
|
+
'changes.loadingDiff': "Loading diff…",
|
|
693
|
+
'changes.diff': "Remote file diff",
|
|
694
|
+
'changes.partialDiff': "This diff is large; showing partial content.",
|
|
695
|
+
'changes.chooseFile': "Select a changed file to inspect its diff.",
|
|
696
|
+
|
|
697
|
+
'ide.enter': 'IDE mode', 'ide.exit': 'Return to standard mode', 'ide.files': 'Files',
|
|
698
|
+
'ide.editor': 'Editor', 'ide.chat': 'Chat', 'ide.openEditor': 'Open editor area',
|
|
699
|
+
'ide.chooseFile': 'Choose a remote file on the left to edit it here.',
|
|
700
|
+
'ide.unavailable': 'This host cannot dock the native conversation. Return to standard mode to continue.',
|
|
701
|
+
'ide.leftWidth': 'Resize file column', 'ide.rightWidth': 'Resize chat column',
|
|
702
|
+
'ide.help': 'Switch layouts without losing conversations, running tasks, or unsaved edits.',
|
|
703
|
+
'ide.unsupported': 'This host does not expose the native editor area required by IDE mode.',
|
|
704
|
+
|
|
705
|
+
'workspaceSearch.options': 'Search options',
|
|
706
|
+
'workspaceSearch.details': 'Scan details',
|
|
707
|
+
'workspaceSearch.matches': '{n} results',
|
|
708
|
+
'workspaceSearch.scanned': '{n} scanned',
|
|
709
|
+
'workspaceSearch.activeOptions': 'Search options · {n}',
|
|
710
|
+
|
|
711
|
+
'workspaceSearch.query': "Search remote workspace",
|
|
712
|
+
'workspaceSearch.placeholder': "Search names, or switch to file contents",
|
|
713
|
+
'workspaceSearch.mode': "Search scope",
|
|
714
|
+
'workspaceSearch.names': "Files and folders",
|
|
715
|
+
'workspaceSearch.files': "Files only",
|
|
716
|
+
'workspaceSearch.directories': "Folders only",
|
|
717
|
+
'workspaceSearch.content': "File contents",
|
|
718
|
+
'workspaceSearch.caseSensitive': "Match case",
|
|
719
|
+
'workspaceSearch.includeIgnored': "Include ignored folders",
|
|
720
|
+
'workspaceSearch.ignoreHint': "Skips dependencies, build folders and configured ignores by default; content search skips binary and oversized files.",
|
|
721
|
+
'workspaceSearch.results': "Remote search results",
|
|
722
|
+
'workspaceSearch.starting': "Preparing search…",
|
|
723
|
+
'workspaceSearch.running': "Searching…",
|
|
724
|
+
'workspaceSearch.completed': "Search complete",
|
|
725
|
+
'workspaceSearch.partial': "Partial results",
|
|
726
|
+
'workspaceSearch.cancelled': "Search stopped",
|
|
727
|
+
'workspaceSearch.failed': "Search failed",
|
|
728
|
+
'workspaceSearch.progress': "{dirs} folders · {files} files · {results} results · {seconds}s",
|
|
729
|
+
'workspaceSearch.stop': "Stop",
|
|
730
|
+
'workspaceSearch.retry': "Search again",
|
|
731
|
+
'workspaceSearch.partialHint': "Reached a search budget or result limit, or some folders were unreadable. Narrow the query and retry; current results remain available.",
|
|
732
|
+
'workspaceSearch.skipped': "{skipped} skipped · {errors} read failures",
|
|
733
|
+
'workspaceSearch.wait': "Scanning remote folders. Results will appear as they are found.",
|
|
734
|
+
'workspaceSearch.empty': "No matches. Change the search scope or include ignored folders and retry.",
|
|
735
|
+
'workspaceSearch.noneYet': "No results yet. Change the query or search again.",
|
|
736
|
+
'workspaceSearch.directory': "Folder",
|
|
737
|
+
'workspaceSearch.file': "File",
|
|
738
|
+
'workspaceSearch.line': "Line {n}",
|
|
739
|
+
|
|
561
740
|
'settings.sshConfigEditorTitle': "SSH configuration",
|
|
562
741
|
'settings.sshConfigEditorHint': "Edit SSH configuration on the host running DSH. Saving rechecks the host list.",
|
|
563
742
|
'settings.sshConfigReload': "Reload from disk",
|
|
@@ -641,8 +820,7 @@ window.__ModuleLoader__.load({
|
|
|
641
820
|
'workbench.explorer': 'Explorer',
|
|
642
821
|
'workbench.openTerminal': 'Open remote terminal',
|
|
643
822
|
'workbench.terminalUnavailable': 'Remote terminal is unavailable. Check the host terminal plugin and remote ssh shell.',
|
|
644
|
-
'workbench.filter': '
|
|
645
|
-
'workbench.noFilteredFiles': 'No matching loaded files',
|
|
823
|
+
'workbench.filter': 'Search remote workspace',
|
|
646
824
|
'workbench.collapse': 'Collapse all folders',
|
|
647
825
|
'workbench.remote': 'Remote workspace',
|
|
648
826
|
'workbench.backToFiles': 'Back to explorer',
|
|
@@ -934,6 +1112,7 @@ window.__ModuleLoader__.load({
|
|
|
934
1112
|
'picker.homeBtn': '🏠',
|
|
935
1113
|
'picker.goHome': 'Go to home',
|
|
936
1114
|
'picker.hintKeys': '↑↓ select · Enter completes/confirms · Esc goes back · Ctrl/⌘+Enter opens workspace',
|
|
1115
|
+
'picker.hintBrowse': 'Enter opens a folder · Esc returns to the path input',
|
|
937
1116
|
'picker.star': '⭐ Star dsh-remote',
|
|
938
1117
|
'picker.feedback': 'Feedback / report issue',
|
|
939
1118
|
'explorer.refresh': 'Refresh',
|
|
@@ -1159,6 +1338,10 @@ window.__ModuleLoader__.load({
|
|
|
1159
1338
|
const CHROME_CSS_ID = 'dsh-remote-chrome'
|
|
1160
1339
|
const CHROME_CSS_TEXT = [
|
|
1161
1340
|
'[data-rw-settings-legacy-icon]{position:relative}[data-rw-settings-legacy-icon]>svg{opacity:0}[data-rw-settings-legacy-icon]::before{content:"";position:absolute;left:12px;top:50%;transform:translateY(-50%);width:16px;height:16px;background:currentColor;mask:url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.6%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M3%204h18v12H3zM8%2020h8M12%2016v4M7%208l3%202-3%202M13%2012h4%22%2F%3E%3C%2Fsvg%3E") center/contain no-repeat;-webkit-mask:url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.6%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M3%204h18v12H3zM8%2020h8M12%2016v4M7%208l3%202-3%202M13%2012h4%22%2F%3E%3C%2Fsvg%3E") center/contain no-repeat;pointer-events:none}',
|
|
1341
|
+
'.dsh-rw-search-scope{display:flex;gap:8px;align-items:center;margin-top:6px;font-size:11px}.dsh-rw-search-options{position:relative;flex-shrink:0}.dsh-rw-search-options>summary{cursor:pointer;padding:4px 0;color:var(--dsw-alias-label-tertiary,#777);white-space:nowrap}.dsh-rw-search-option-body{position:absolute;right:0;top:100%;z-index:45;width:220px;max-width:calc(100vw - 40px);box-sizing:border-box;padding:12px;background:var(--dsw-alias-bg-base,#fff);border:1px solid var(--dsw-alias-border-l2,#ddd);border-radius:8px;box-shadow:0 4px 16px #0002}.dsh-rw-search-option-body label{display:flex;gap:7px;align-items:center;padding:5px 0}.dsh-rw-search-option-body p{font-size:10px;color:var(--dsw-alias-label-tertiary,#777);line-height:1.6;margin:8px 0 0}.dsh-rw-search-details{flex:1;min-width:0;font-size:11px}.dsh-rw-search-details>summary{cursor:pointer;padding:4px 0;list-style-position:inside}.dsh-rw-search-status{display:inline;line-height:1.6}.dsh-rw-search-status>span+span:before{content:" · ";color:var(--dsw-alias-label-tertiary,#777)}.dsh-rw-search-detail-body{padding:7px 0 2px;line-height:1.7;color:var(--dsw-alias-label-tertiary,#777)}',
|
|
1342
|
+
'.dsh-rw-search-controls{margin-top:8px;min-width:0}.dsh-rw-search-panel{display:flex;flex-direction:column;flex:1;min-height:0;min-width:0}.dsh-rw-search-progress{display:flex;align-items:flex-start;gap:8px;padding:7px 10px;border-bottom:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.2));font-size:12px}.dsh-rw-search-progress button{flex-shrink:0;white-space:nowrap}.dsh-rw-search-indicator{width:100%;height:3px;flex-shrink:0;border:0}.dsh-rw-search-results{overflow:auto;flex:1;min-height:0}.dsh-rw-search-result{width:100%;box-sizing:border-box;display:flex;gap:8px;align-items:flex-start;text-align:left;border:0;border-bottom:1px solid rgba(128,128,128,.12);background:transparent;color:inherit;padding:9px 10px;cursor:pointer}.dsh-rw-search-result:hover{background:rgba(128,128,128,.08)}.dsh-rw-search-result:focus-visible{outline:2px solid var(--dsw-alias-button-primary-fill,#2563eb);outline-offset:-2px}',
|
|
1343
|
+
'.dsh-rw-git{height:100%;min-height:0;display:flex;flex-direction:column;font-size:12px;overflow:hidden;color:inherit}.dsh-rw-git-header{padding:10px;display:flex;flex-direction:column;gap:7px;border-bottom:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.2));flex-shrink:0}.dsh-rw-git-title{display:flex;align-items:center;gap:7px}.dsh-rw-git-title>strong{flex:1}.dsh-rw-git-repo{font-size:11px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dsh-rw-git-hint{font-size:11px;opacity:.7;line-height:1.5}.dsh-rw-git-mode{display:flex;gap:6px}.dsh-rw-git-mode button{padding:4px 8px;white-space:nowrap}.dsh-rw-git-mode button[aria-pressed=true]{font-weight:600;background:rgba(128,128,128,.14)}.dsh-rw-git-header input{box-sizing:border-box;width:100%;font-size:12px}.dsh-rw-git-message{padding:10px;line-height:1.6;overflow-wrap:anywhere}.dsh-rw-git-message button{margin-left:8px}.dsh-rw-git-files{flex:0 1 auto;max-height:34%;overflow:auto;padding:4px;min-height:40px;border-bottom:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.2))}.dsh-rw-git-file{display:flex;gap:7px;align-items:center;width:100%;min-height:30px;padding:5px 8px;border:0;border-radius:4px;background:transparent;color:inherit;cursor:pointer;text-align:left}.dsh-rw-git-file:hover,.dsh-rw-git-file[aria-selected=true]{background:rgba(128,128,128,.13)}.dsh-rw-git-file:focus-visible{outline:2px solid var(--dsw-alias-button-primary-fill,#2563eb);outline-offset:-2px}.dsh-rw-git-file-path{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dsh-rw-git-status{flex-shrink:0;font-size:11px;font-family:monospace}.dsh-rw-git-preview{flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden}.dsh-rw-git-preview-title{display:flex;align-items:center;gap:8px;padding:8px 10px}.dsh-rw-git-preview-title>strong{font-size:12px;flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dsh-rw-git-preview>.dsh-rw-git-hint{padding:0 10px 7px}.dsh-rw-git-diff{flex:1;min-height:0;overflow:auto;font:11px/1.6 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;tab-size:4;padding:4px 0}.dsh-rw-git-diff-line{display:flex;min-width:max-content;white-space:pre}.dsh-rw-git-diff-line>span:last-child{padding-right:12px}.dsh-rw-git-diff-line[data-rw-diff-kind=added]{background:rgba(34,197,94,.11)}.dsh-rw-git-diff-line[data-rw-diff-kind=removed]{background:rgba(239,68,68,.11)}.dsh-rw-git-diff-line[data-rw-diff-kind=hunk]{background:rgba(59,130,246,.1)}.dsh-rw-git-line-number{box-sizing:border-box;flex:0 0 48px;width:48px;padding:0 7px;border:0;background:transparent;color:inherit;opacity:.6;font:inherit;text-align:right;user-select:none}.dsh-rw-git-diff button.dsh-rw-git-line-number{cursor:pointer}.dsh-rw-git-diff button.dsh-rw-git-line-number:hover{opacity:1;text-decoration:underline}',
|
|
1344
|
+
'.dsh-rw-applied-change{border-top:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.2));min-width:0;overflow:hidden}.dsh-rw-change-heading{display:flex;gap:8px;align-items:center;padding:7px 10px;font-size:11px}.dsh-rw-change-heading strong{font-weight:500}.dsh-rw-change-hunk{margin:0 8px 6px}.dsh-rw-change-hunk>summary{font-size:11px;cursor:pointer;padding:4px 2px}',
|
|
1162
1345
|
'.dsh-rw-btn{transition:background .12s ease,opacity .12s ease,border-color .12s ease}',
|
|
1163
1346
|
'.dsh-rw-btn:hover:not(:disabled){background:rgba(128,128,128,.18)}',
|
|
1164
1347
|
'.dsh-rw-btn:focus-visible{outline:2px solid var(--dsw-alias-button-primary-fill,#2563eb);outline-offset:1px}',
|
|
@@ -3201,24 +3384,25 @@ window.__ModuleLoader__.load({
|
|
|
3201
3384
|
|
|
3202
3385
|
function renderDirPopup() {
|
|
3203
3386
|
if (!levels || !levels.length) {
|
|
3204
|
-
return React.createElement('div', { style: { opacity: 0.6, fontSize: 12 } }, (loading ? tr('picker.loading') : tr('picker.readingRoot')))
|
|
3387
|
+
return React.createElement('div', { 'data-rw-directory-browser': true, role: 'status', style: { flex: '1 1 0', minHeight: 120, padding: 16, opacity: 0.6, fontSize: 12 } }, (loading ? tr('picker.loading') : tr('picker.readingRoot')))
|
|
3205
3388
|
}
|
|
3206
3389
|
const last = levels[levels.length - 1]
|
|
3207
3390
|
const entries = last.all || []
|
|
3208
|
-
return React.createElement('div', { style: { border: '1px solid ' + T.borderStrong, borderRadius:
|
|
3209
|
-
React.createElement('div', { style: { display: 'flex', gap: 6, alignItems: 'center', padding: '6px 10px', borderBottom: '1px solid ' + T.border } },
|
|
3391
|
+
return React.createElement('div', { 'data-rw-directory-browser': true, style: { border: '1px solid ' + T.borderStrong, borderRadius: 8, background: v('--dsw-alias-bg-overlay', '#1e1e1e'), display: 'flex', flexDirection: 'column', flex: '1 1 0', minHeight: 0, overflow: 'hidden' } },
|
|
3392
|
+
React.createElement('div', { style: { display: 'flex', gap: 6, alignItems: 'center', flexShrink: 0, padding: '6px 10px', borderBottom: '1px solid ' + T.border } },
|
|
3210
3393
|
React.createElement('button', { style: { ...buttonS, padding: '2px 8px' }, onClick: goUp, disabled: loading || (levels.length <= 1 && !parentOf(last.path)) }, tr('picker.back')),
|
|
3211
|
-
React.createElement('div', { style: { fontSize: 11, opacity: 0.75, fontFamily: 'monospace', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', flex: 1 } }, breadcrumb(!!machineId, last.path, win, (p) =>
|
|
3394
|
+
React.createElement('div', { style: { fontSize: 11, opacity: 0.75, fontFamily: 'monospace', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', flex: 1 } }, breadcrumb(!!machineId, last.path, win, (p) => { if (loading) return; const cut = (levels || []).findIndex((lv) => lv.path === p); if (cut >= 0) setLevels(levels.slice(0, cut + 1)); else loadLevels(machineId, p, 0) })),
|
|
3212
3395
|
React.createElement('button', { style: { ...buttonS, padding: '2px 8px' }, onClick: mkdirHere }, tr('picker.newDir')),
|
|
3213
3396
|
React.createElement('button', { style: { ...buttonS, padding: '2px 8px' }, onClick: () => setPopOpen(false) }, tr('picker.closeBtn')),
|
|
3214
3397
|
),
|
|
3215
|
-
React.createElement('div', { style: { overflowY: 'auto', overflowX: 'hidden' } },
|
|
3398
|
+
React.createElement('div', { 'data-rw-directory-list': true, role: 'region', 'aria-label': tr('picker.browse'), style: { flex: 1, minHeight: 0, overflowY: 'auto', overflowX: 'hidden' } },
|
|
3216
3399
|
loading ? React.createElement('div', { style: { opacity: 0.7, padding: 12 } }, tr('picker.loading'))
|
|
3217
3400
|
: (entries.length ? entries.slice(0, 400).map((it, i) => React.createElement('div', {
|
|
3218
|
-
key: i, title: it.drive ? tr('picker.enterDrive', { name: it.name }) : (it.dir ? tr('picker.enterDir', { name: it.name }) : tr('picker.fileAt', { name: it.name })),
|
|
3401
|
+
key: it.path || i, role: it.dir ? 'button' : undefined, tabIndex: it.dir ? 0 : undefined, title: it.drive ? tr('picker.enterDrive', { name: it.name }) : (it.dir ? tr('picker.enterDir', { name: it.name }) : tr('picker.fileAt', { name: it.name })),
|
|
3219
3402
|
onClick: it.dir ? () => enterDir(it) : undefined,
|
|
3403
|
+
onKeyDown: it.dir ? (e) => { if (!e.isComposing && e.keyCode !== 229 && (e.key === 'Enter' || e.key === ' ')) { e.preventDefault(); e.stopPropagation(); enterDir(it) } } : undefined,
|
|
3220
3404
|
className: it.dir ? 'dsh-rw-list-item' : undefined,
|
|
3221
|
-
style: { padding: '6px 10px', cursor: it.dir ? 'pointer' : 'default', color: T.label, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis', display: 'flex', gap: 8, alignItems: 'center', fontSize: 13, borderBottom: '1px solid ' + T.border },
|
|
3405
|
+
style: { padding: '6px 10px', minHeight: 32, boxSizing: 'border-box', cursor: it.dir ? 'pointer' : 'default', color: T.label, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis', display: 'flex', gap: 8, alignItems: 'center', fontSize: 13, borderBottom: '1px solid ' + T.border },
|
|
3222
3406
|
},
|
|
3223
3407
|
React.createElement('span', { style: { flexShrink: 0, display: 'inline-flex', color: T.label, fontSize: 13 } }, it.drive ? '💽' : (it.dir
|
|
3224
3408
|
? IconFolder()
|
|
@@ -3227,9 +3411,9 @@ window.__ModuleLoader__.load({
|
|
|
3227
3411
|
React.createElement('span', { style: { fontSize: 11, opacity: 0.55, flexShrink: 0, fontFamily: 'monospace' } }, it.dir ? '' : (humanSize(it.size) + (it.mtime ? ' ' + fmtTime(it.mtime) : ''))),
|
|
3228
3412
|
)) : React.createElement('div', { style: { opacity: 0.6, padding: 12 } }, tr('picker.emptyDir'))),
|
|
3229
3413
|
),
|
|
3230
|
-
React.createElement('div', { style: { display: 'flex', gap: 8, justifyContent: 'flex-end', alignItems: 'center', padding: '6px 10px', borderTop: '1px solid ' + T.border } },
|
|
3414
|
+
React.createElement('div', { style: { display: 'flex', gap: 8, justifyContent: 'flex-end', alignItems: 'center', flexShrink: 0, padding: '6px 10px', borderTop: '1px solid ' + T.border } },
|
|
3231
3415
|
React.createElement('span', { style: { fontSize: 11, opacity: 0.75, fontFamily: 'monospace', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', flex: 1 } }, tr('picker.selected', { path: (last.path || (win ? tr('picker.driveRoot') : '/')) })),
|
|
3232
|
-
React.createElement('button', { type: 'button', className: 'dsh-rw-btn dsh-rw-primary', style: primaryBtnS, onClick: () => { acceptBrowserPick(last.path); setPopOpen(false) } }, tr('picker.chooseThis')),
|
|
3416
|
+
React.createElement('button', { type: 'button', className: 'dsh-rw-btn dsh-rw-primary', style: { ...primaryBtnS, whiteSpace: 'nowrap' }, disabled: loading || busy || !last.path, onClick: () => { acceptBrowserPick(last.path); setPopOpen(false) } }, tr('picker.chooseThis')),
|
|
3233
3417
|
),
|
|
3234
3418
|
)
|
|
3235
3419
|
}
|
|
@@ -3316,7 +3500,7 @@ window.__ModuleLoader__.load({
|
|
|
3316
3500
|
// backdrop dismisses now.
|
|
3317
3501
|
onClick: (e) => { if (backdrop.onClick(e) && !externalBusy && !mkdirPrompt) closePicker() },
|
|
3318
3502
|
},
|
|
3319
|
-
React.createElement('div', { ref: pickerLayerRef, tabIndex: -1, role: 'dialog', 'aria-modal': true, 'aria-labelledby': suggestListId + '-title', className: 'dsh-rw-modal-panel', style: { background: v('--dsw-alias-bg-layer-1', '#18181b'), color: T.label, border: '1px solid ' + T.borderStrong, borderRadius: 12, boxShadow: '0 12px 48px rgba(0,0,0,0.5)', width: 'min(
|
|
3503
|
+
React.createElement('div', { ref: pickerLayerRef, tabIndex: -1, role: 'dialog', 'aria-modal': true, 'aria-labelledby': suggestListId + '-title', 'data-rw-dir-picker': true, className: 'dsh-rw-modal-panel', style: { background: v('--dsw-alias-bg-layer-1', '#18181b'), color: T.label, border: '1px solid ' + T.borderStrong, borderRadius: 12, boxShadow: '0 12px 48px rgba(0,0,0,0.5)', width: 'min(720px, 94vw)', height: popOpen && tab === 'remote' ? 'min(760px, calc(100dvh - 32px))' : undefined, maxHeight: 'min(760px, calc(100dvh - 32px))', display: 'flex', flexDirection: 'column', padding: 16, boxSizing: 'border-box' }, onClick: (e) => e.stopPropagation() },
|
|
3320
3504
|
React.createElement('div', { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 10 } },
|
|
3321
3505
|
React.createElement('div', { id: suggestListId + '-title', style: { fontSize: 15, fontWeight: 650 } }, tr('picker.title')),
|
|
3322
3506
|
React.createElement('button', { type: 'button', className: 'dsh-rw-btn', style: { ...buttonS, padding: '2px 8px' }, onClick: closePicker, disabled: !!externalBusy }, tr('picker.close')),
|
|
@@ -3361,7 +3545,7 @@ window.__ModuleLoader__.load({
|
|
|
3361
3545
|
},
|
|
3362
3546
|
onProject: (m, p) => { setMachineId(m.id); setRecent(m.recentWorkspaces || []); setPath(p); setChoosingProject(false); commitPath(p, m.id) },
|
|
3363
3547
|
})
|
|
3364
|
-
: React.createElement('div', { style: { display: 'flex', flexDirection: 'column', gap: 8, minHeight: 0, overflowY: 'auto' } },
|
|
3548
|
+
: React.createElement('div', { 'data-rw-picker-remote': true, style: { display: 'flex', flexDirection: 'column', flex: popOpen ? '1 1 0' : '0 1 auto', gap: 8, minHeight: 0, overflowY: popOpen ? 'hidden' : 'auto' } },
|
|
3365
3549
|
React.createElement('button', { type: 'button', className: 'dsh-rw-btn', disabled: busy, style: { ...buttonS, alignSelf: 'flex-start', fontSize: 12 }, onClick: () => { killSuggestions(); resetPickerFetchState(); setPath(''); setChoosingProject(true) } }, '‹ ' + tr('project.back')),
|
|
3366
3550
|
React.createElement('div', { style: { display: 'flex', gap: 6, alignItems: 'center' } },
|
|
3367
3551
|
React.createElement('label', { style: { fontSize: 12, opacity: 0.8, whiteSpace: 'nowrap' } }, tr('picker.remoteMachine')),
|
|
@@ -3378,10 +3562,10 @@ window.__ModuleLoader__.load({
|
|
|
3378
3562
|
: null,
|
|
3379
3563
|
),
|
|
3380
3564
|
),
|
|
3381
|
-
recent.length ? React.createElement('div', { style: { display: 'flex', gap: 4, alignItems: 'center', flexWrap: 'wrap' } },
|
|
3565
|
+
!popOpen && recent.length ? React.createElement('div', { style: { display: 'flex', gap: 4, alignItems: 'center', flexWrap: 'wrap' } },
|
|
3382
3566
|
React.createElement('span', { style: { fontSize: 11, opacity: 0.6, whiteSpace: 'nowrap' } }, tr('picker.recent')),
|
|
3383
3567
|
recent.map((w, i) => React.createElement('button', { type: 'button', className: 'dsh-rw-btn', key: w + i, onClick: () => { setPath(w); setErr(''); continueSuggest(w) }, style: { ...buttonS, padding: '2px 8px', fontSize: 11, fontFamily: 'monospace' } }, w))) : null,
|
|
3384
|
-
React.createElement('div', { ref: suggestRef, style: { position: 'relative' } },
|
|
3568
|
+
React.createElement('div', { ref: suggestRef, style: { position: 'relative', flexShrink: 0 } },
|
|
3385
3569
|
React.createElement('div', { style: { display: 'flex', gap: 6, flexWrap: 'wrap' } },
|
|
3386
3570
|
React.createElement('input', {
|
|
3387
3571
|
className: 'dsh-rw-input',
|
|
@@ -3416,12 +3600,12 @@ window.__ModuleLoader__.load({
|
|
|
3416
3600
|
placeholder: (machineId ? (win ? tr('picker.pathPlaceholderWin') : tr('picker.pathPlaceholder')) : tr('picker.chooseMachineFirst')),
|
|
3417
3601
|
disabled: !machineId || busy, 'data-modal-autofocus': true, style: { ...inputS, flex: 1, minWidth: 120 },
|
|
3418
3602
|
}),
|
|
3419
|
-
React.createElement('button', { type: 'button', className: 'dsh-rw-btn', style: { ...buttonS, whiteSpace: 'nowrap' }, onClick: () => { if (!machineId) return; const p = path.trim(); loadLevels(machineId, p || '', 0); setPopOpen(true) }, disabled: !machineId || busy }, tr('picker.browse')),
|
|
3603
|
+
React.createElement('button', { type: 'button', className: 'dsh-rw-btn', style: { ...buttonS, whiteSpace: 'nowrap' }, onClick: () => { if (!machineId) return; killSuggestions(); if (suggestTimer.current) clearTimeout(suggestTimer.current); const p = path.trim(); loadLevels(machineId, p || '', 0); setPopOpen(true) }, disabled: !machineId || busy }, tr('picker.browse')),
|
|
3420
3604
|
React.createElement('button', { type: 'button', className: 'dsh-rw-btn', style: { ...buttonS, whiteSpace: 'nowrap' }, onClick: pickHome, disabled: !machineId || busy }, tr('picker.home')),
|
|
3421
3605
|
),
|
|
3422
3606
|
// Reserve the same space with or without results: suggestions
|
|
3423
3607
|
// never move the dialog or sit beneath the workspace action.
|
|
3424
|
-
React.createElement('div', { className: 'dsh-rw-suggestions', style: { position: 'relative', height: 'min(180px, 25vh)', marginTop: 8, border: '1px solid ' + T.border, borderRadius: 8, background: T.bg } },
|
|
3608
|
+
!popOpen ? React.createElement('div', { className: 'dsh-rw-suggestions', style: { position: 'relative', height: 'min(180px, 25vh)', marginTop: 8, border: '1px solid ' + T.border, borderRadius: 8, background: T.bg } },
|
|
3425
3609
|
(suggestOpen && suggest.length)
|
|
3426
3610
|
? React.createElement('div', { id: suggestListId, role: 'listbox', 'aria-label': tr('picker.pathPlaceholder'), style: { position: 'absolute', top: 0, bottom: 0, left: 0, right: 0, zIndex: 60, background: v('--dsw-alias-bg-overlay', '#1e1e1e'), color: T.label, borderRadius: 8, maxHeight: 200, overflowY: 'auto' } },
|
|
3427
3611
|
// Issue #52 defect 1, local belt-and-braces: swallow the
|
|
@@ -3430,16 +3614,16 @@ window.__ModuleLoader__.load({
|
|
|
3430
3614
|
suggest.map((s, i) => React.createElement('div', { key: s + i, id: suggestListId + '-' + i, role: 'option', 'aria-selected': i === activeSuggestion, onMouseEnter: () => setSuggestIndex(i), className: 'dsh-rw-list-item', onMouseDown: (e) => { e.preventDefault(); e.stopPropagation(); selectSuggestion(s) }, style: { padding: '6px 10px', background: i === activeSuggestion ? T.hoverBg : undefined, cursor: 'pointer', fontSize: 12, fontFamily: 'monospace', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' } }, s)),
|
|
3431
3615
|
)
|
|
3432
3616
|
: React.createElement('div', { style: { padding: '24px 16px', color: T.muted, fontSize: 12, lineHeight: 1.6, textAlign: 'center' } }, tr('picker.suggestionsHint')),
|
|
3433
|
-
),
|
|
3617
|
+
) : null,
|
|
3434
3618
|
),
|
|
3435
3619
|
popOpen ? renderDirPopup() : null,
|
|
3436
3620
|
err ? React.createElement(ProjectOpenError, { error: err }) : null,
|
|
3437
3621
|
// The action stays below the reserved results region, in a
|
|
3438
3622
|
// separate opaque layer with a stable hit target.
|
|
3439
|
-
React.createElement('div', { style: { display: 'flex', gap: 8, justifyContent: 'flex-end', alignItems: 'center', position: 'relative', zIndex: 70, background: v('--dsw-alias-bg-layer-1', '#18181b') } },
|
|
3623
|
+
!popOpen ? React.createElement('div', { 'data-rw-picker-commit': true, style: { display: 'flex', gap: 8, justifyContent: 'flex-end', alignItems: 'center', position: 'relative', zIndex: 70, background: v('--dsw-alias-bg-layer-1', '#18181b') } },
|
|
3440
3624
|
React.createElement('span', { title: path, style: { fontSize: 11, opacity: 0.75, fontFamily: 'monospace', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', flex: 1 } }, path ? tr('picker.selected', { path }) : ''),
|
|
3441
3625
|
React.createElement('button', { type: 'button', className: 'dsh-rw-btn dsh-rw-primary', style: primaryBtnS, onClick: () => commitPath(path), disabled: busy || !machineId || !path.trim() }, busy ? tr('project.opening') : tr('picker.setRemoteWs')),
|
|
3442
|
-
),
|
|
3626
|
+
) : null,
|
|
3443
3627
|
),
|
|
3444
3628
|
choosingProject && !path && err ? React.createElement('div', {},
|
|
3445
3629
|
React.createElement(ProjectOpenError, { error: err }),
|
|
@@ -3448,7 +3632,7 @@ window.__ModuleLoader__.load({
|
|
|
3448
3632
|
React.createElement('span', { style: { flex: 1, color: T.muted } }, tr('project.opening')),
|
|
3449
3633
|
React.createElement('button', { type: 'button', className: 'dsh-rw-btn', style: buttonS, onClick: () => { cancelOperation(); setErr(tr('project.cancelled')) } }, tr('project.cancel'))) : null,
|
|
3450
3634
|
React.createElement('div', { style: { display: 'flex', flexWrap: 'wrap', gap: '4px 12px', fontSize: 11, color: T.muted, paddingTop: 8 } },
|
|
3451
|
-
(tab === 'remote' ? tr('picker.hintKeys') : 'Enter · Esc').split(' · ').map((hint) => React.createElement('span', { key: hint, style: { whiteSpace: 'nowrap' } }, hint))),
|
|
3635
|
+
(tab === 'remote' ? tr(popOpen ? 'picker.hintBrowse' : 'picker.hintKeys') : 'Enter · Esc').split(' · ').map((hint) => React.createElement('span', { key: hint, style: { whiteSpace: 'nowrap' } }, hint))),
|
|
3452
3636
|
(tab === 'local') ? React.createElement('div', { style: { display: 'flex', gap: 8, justifyContent: 'flex-end' } }, React.createElement('button', { type: 'button', className: 'dsh-rw-btn', style: buttonS, onClick: onCancel }, tr('picker.cancel'))) : null,
|
|
3453
3637
|
mkdirPrompt ? React.createElement(PromptDialog, {
|
|
3454
3638
|
title: tr('picker.newDirName', { path: mkdirPrompt.base || '/' }),
|
|
@@ -4057,6 +4241,7 @@ window.__ModuleLoader__.load({
|
|
|
4057
4241
|
refresh: 'M13 6a5 5 0 1 0 0 5M13 2v4H9',
|
|
4058
4242
|
collapse: 'M4 5h9v8H4zM1 10V2h8',
|
|
4059
4243
|
search: 'M10.5 10.5 14 14M11.5 7a4.5 4.5 0 1 1-9 0 4.5 4.5 0 0 1 9 0',
|
|
4244
|
+
branch: 'M5 2v8a3 3 0 0 0 3 3h3M5 5h4a2 2 0 0 0 2-2M4 2h2M10 2h2M10 13h2',
|
|
4060
4245
|
close: 'm4 4 8 8m0-8-8 8',
|
|
4061
4246
|
copy: 'M5 5h8v9H5zM2 11V2h8',
|
|
4062
4247
|
wrap: 'M2 4h12M2 8h9a2 2 0 0 1 0 4H8m2-2-2 2 2 2M2 12h3',
|
|
@@ -4075,6 +4260,85 @@ window.__ModuleLoader__.load({
|
|
|
4075
4260
|
|
|
4076
4261
|
// Tree-style remote file explorer. Data is listed live from the remote host
|
|
4077
4262
|
// over /dsh-remote/ls, rooted at this session's remote workspace dir.
|
|
4263
|
+
function RemoteWorkspaceSearch(props) {
|
|
4264
|
+
const { sessionId, query, mode, includeIgnored, caseSensitive } = props
|
|
4265
|
+
const viewKey = JSON.stringify([sessionId, props.root, query, mode, includeIgnored, caseSensitive])
|
|
4266
|
+
const [state, setState] = React.useState(null)
|
|
4267
|
+
const [retry, setRetry] = React.useState(0)
|
|
4268
|
+
const [focused, setFocused] = React.useState(0)
|
|
4269
|
+
const stopRef = React.useRef(null)
|
|
4270
|
+
React.useEffect(() => {
|
|
4271
|
+
let disposed = false, id = null, pollTimer = null
|
|
4272
|
+
const initial = { viewKey, query, mode, status: 'starting', results: [], scannedDirs: 0, scannedFiles: 0, skipped: 0, errors: 0, elapsedMs: 0 }
|
|
4273
|
+
setState(initial); setFocused(0)
|
|
4274
|
+
const cancelRemote = () => { if (id) void api('POST', '/dsh-remote/search', withSessionBody({ action: 'cancel', id }, sessionId)).catch(() => {}) }
|
|
4275
|
+
const stop = () => {
|
|
4276
|
+
if (disposed) return
|
|
4277
|
+
disposed = true; clearTimeout(startTimer); if (pollTimer) clearTimeout(pollTimer)
|
|
4278
|
+
cancelRemote(); setState(old => ({ ...(old || initial), status: 'cancelled' }))
|
|
4279
|
+
}
|
|
4280
|
+
stopRef.current = stop
|
|
4281
|
+
const receive = response => {
|
|
4282
|
+
if (!response?.ok || !response.search) throw new Error(response?.error || tr('workspaceSearch.failed'))
|
|
4283
|
+
const search = response.search
|
|
4284
|
+
id = search.id
|
|
4285
|
+
if (disposed) { cancelRemote(); return }
|
|
4286
|
+
setState({ ...search, viewKey })
|
|
4287
|
+
if (search.status === 'running') pollTimer = setTimeout(poll, 750)
|
|
4288
|
+
}
|
|
4289
|
+
const failed = error => { if (!disposed) setState(old => ({ ...(old || initial), status: 'failed', error: error.message || String(error) })) }
|
|
4290
|
+
const poll = () => {
|
|
4291
|
+
if (!disposed && id) api('GET', withSessionQuery('/dsh-remote/search?id=' + encodeURIComponent(id), sessionId)).then(receive).catch(failed)
|
|
4292
|
+
}
|
|
4293
|
+
const startTimer = setTimeout(() => {
|
|
4294
|
+
api('POST', '/dsh-remote/search', withSessionBody({ action: 'start', query, mode, includeIgnored, caseSensitive }, sessionId)).then(receive).catch(failed)
|
|
4295
|
+
}, props.retryKey || retry ? 0 : 350)
|
|
4296
|
+
return () => { disposed = true; clearTimeout(startTimer); if (pollTimer) clearTimeout(pollTimer); cancelRemote(); if (stopRef.current === stop) stopRef.current = null }
|
|
4297
|
+
}, [sessionId, props.root, query, mode, includeIgnored, caseSensitive, props.retryKey, retry])
|
|
4298
|
+
const current = state && state.viewKey === viewKey ? state : { status: 'starting', results: [], scannedDirs: 0, scannedFiles: 0, elapsedMs: 0 }
|
|
4299
|
+
const running = current.status === 'starting' || current.status === 'running'
|
|
4300
|
+
const statusKey = ({ starting: 'workspaceSearch.starting', running: 'workspaceSearch.running', completed: 'workspaceSearch.completed', partial: 'workspaceSearch.partial', cancelled: 'workspaceSearch.cancelled', failed: 'workspaceSearch.failed' })[current.status] || 'workspaceSearch.starting'
|
|
4301
|
+
const navigate = event => {
|
|
4302
|
+
if (event.isComposing || !['ArrowDown','ArrowUp','Home','End'].includes(event.key)) return
|
|
4303
|
+
const rows = Array.from(event.currentTarget.querySelectorAll('[data-rw-search-result]'))
|
|
4304
|
+
const index = rows.indexOf(event.target.closest?.('[data-rw-search-result]'))
|
|
4305
|
+
if (index < 0) return
|
|
4306
|
+
event.preventDefault()
|
|
4307
|
+
const next = event.key === 'Home' ? 0 : event.key === 'End' ? rows.length - 1 : Math.max(0, Math.min(rows.length - 1, index + (event.key === 'ArrowDown' ? 1 : -1)))
|
|
4308
|
+
setFocused(next); rows[next]?.focus()
|
|
4309
|
+
}
|
|
4310
|
+
return React.createElement('section', { className: 'dsh-rw-search-panel', 'aria-label': tr('workspaceSearch.results'), 'aria-busy': running },
|
|
4311
|
+
React.createElement('div', { className: 'dsh-rw-search-progress' },
|
|
4312
|
+
React.createElement('details', { className: 'dsh-rw-search-details' },
|
|
4313
|
+
React.createElement('summary', { title: tr('workspaceSearch.details'), 'aria-label': tr('workspaceSearch.details') },
|
|
4314
|
+
React.createElement('span', { role: 'status', 'aria-live': 'polite', className: 'dsh-rw-search-status' },
|
|
4315
|
+
React.createElement('span', {}, tr(statusKey)),
|
|
4316
|
+
React.createElement('span', { style: { color: T.muted } }, tr('workspaceSearch.matches', { n: current.results.length })),
|
|
4317
|
+
running ? React.createElement('span', { style: { color: T.muted } }, tr('workspaceSearch.scanned', { n: (current.scannedDirs || 0) + (current.scannedFiles || 0) })) : null)),
|
|
4318
|
+
React.createElement('div', { className: 'dsh-rw-search-detail-body' },
|
|
4319
|
+
React.createElement('div', {}, tr('workspaceSearch.progress', { dirs: current.scannedDirs || 0, files: current.scannedFiles || 0, results: current.results.length, seconds: ((current.elapsedMs || 0) / 1000).toFixed(1) })),
|
|
4320
|
+
current.skipped || current.errors ? React.createElement('div', {}, tr('workspaceSearch.skipped', { skipped: current.skipped || 0, errors: current.errors || 0 })) : null,
|
|
4321
|
+
current.currentPath ? React.createElement('div', { className: 'dsh-rw-path', title: current.currentPath }, current.currentPath) : null)),
|
|
4322
|
+
React.createElement('button', { type: 'button', className: 'dsh-rw-btn', style: { ...buttonS, fontSize: 11, padding: '3px 7px' }, onClick: () => running ? stopRef.current?.() : setRetry(value => value + 1) }, tr(running ? 'workspaceSearch.stop' : 'workspaceSearch.retry'))),
|
|
4323
|
+
current.error ? React.createElement('div', { role: 'alert', style: { padding: '8px 10px', fontSize: 12, color: T.danger, overflowWrap: 'anywhere' } }, current.error) : null,
|
|
4324
|
+
current.status === 'partial' ? React.createElement('div', { style: { padding: '6px 10px', fontSize: 11, color: T.warn } }, tr('workspaceSearch.partialHint')) : null,
|
|
4325
|
+
running ? React.createElement('progress', { className: 'dsh-rw-search-indicator', 'aria-label': tr('workspaceSearch.running') }) : null,
|
|
4326
|
+
React.createElement('div', { role: 'list', 'aria-label': tr('workspaceSearch.results'), className: 'dsh-rw-search-results', onKeyDown: navigate },
|
|
4327
|
+
current.results.map((result, index) => React.createElement('button', {
|
|
4328
|
+
key: result.path + ':' + (result.line || 0), type: 'button', role: 'listitem', className: 'dsh-rw-search-result', 'data-rw-search-result': result.relative,
|
|
4329
|
+
tabIndex: index === focused ? 0 : -1, onFocus: () => setFocused(index), title: result.path,
|
|
4330
|
+
onClick: () => result.type === 'directory' ? props.onRevealDirectory(result.path) : props.onOpenFile(result.path, result.line),
|
|
4331
|
+
},
|
|
4332
|
+
React.createElement('span', { style: { marginTop: 2, flexShrink: 0 } }, result.type === 'directory' ? IconFolder(false) : IconFile(result.name)),
|
|
4333
|
+
React.createElement('span', { style: { minWidth: 0, flex: 1 } },
|
|
4334
|
+
React.createElement('span', { style: { display: 'flex', gap: 6, alignItems: 'baseline' } },
|
|
4335
|
+
React.createElement('strong', { className: 'dsh-rw-path', style: { fontWeight: 500, flex: 1 } }, result.name),
|
|
4336
|
+
React.createElement('span', { style: { color: T.muted, fontSize: 10, flexShrink: 0 } }, result.line ? tr('workspaceSearch.line', { n: result.line }) : null)),
|
|
4337
|
+
React.createElement('span', { className: 'dsh-rw-path', style: { display: 'block', color: T.muted, fontSize: 11, marginTop: 3 } }, result.relative.includes('/') ? result.relative.slice(0, result.relative.lastIndexOf('/')) : ''),
|
|
4338
|
+
result.text != null ? React.createElement('span', { style: { display: 'block', marginTop: 4, fontFamily: 'monospace', fontSize: 11, whiteSpace: 'pre-wrap', overflowWrap: 'anywhere' } }, result.text) : null))),
|
|
4339
|
+
!current.results.length ? React.createElement('div', { style: { padding: '20px 12px', fontSize: 12, color: T.muted, lineHeight: 1.7 } }, tr(running ? 'workspaceSearch.wait' : current.status === 'completed' ? 'workspaceSearch.empty' : 'workspaceSearch.noneYet')) : null))
|
|
4340
|
+
}
|
|
4341
|
+
|
|
4078
4342
|
function RemoteExplorerTab(props) {
|
|
4079
4343
|
const [status, setStatus] = React.useState(null)
|
|
4080
4344
|
const [root, setRoot] = React.useState('') // remote root path for this session
|
|
@@ -4091,6 +4355,11 @@ window.__ModuleLoader__.load({
|
|
|
4091
4355
|
const [selectedPath, setSelectedPath] = React.useState(() => explorerMemory.get(props.scope?.sessionId || '')?.selected || '')
|
|
4092
4356
|
const [filter, setFilter] = React.useState('')
|
|
4093
4357
|
const [filterOpen, setFilterOpen] = React.useState(false)
|
|
4358
|
+
const [searchMode, setSearchMode] = React.useState('names')
|
|
4359
|
+
const [searchIgnored, setSearchIgnored] = React.useState(false)
|
|
4360
|
+
const [searchCase, setSearchCase] = React.useState(false)
|
|
4361
|
+
const [searchRetry, setSearchRetry] = React.useState(0)
|
|
4362
|
+
const revealPending = React.useRef(null)
|
|
4094
4363
|
const filterRef = React.useRef(null)
|
|
4095
4364
|
const remoteTerminal = useRemoteTerminal(props.scope && props.scope.sessionId)
|
|
4096
4365
|
const [namePrompt, setNamePrompt] = React.useState(null) // { kind, path, name }
|
|
@@ -4297,13 +4566,13 @@ window.__ModuleLoader__.load({
|
|
|
4297
4566
|
// identically in both compositions — and it needs no better-sidebar
|
|
4298
4567
|
// descriptor, whose only effect would have been a switch that unregisters
|
|
4299
4568
|
// the viewer.
|
|
4300
|
-
const openFile = (p) => {
|
|
4301
|
-
if (props.onOpenFile) { props.onOpenFile(p); return }
|
|
4569
|
+
const openFile = (p, line) => {
|
|
4570
|
+
if (props.onOpenFile) { props.onOpenFile(p, line); return }
|
|
4302
4571
|
const sessionId = (props.scope && props.scope.sessionId) || ''
|
|
4303
4572
|
try {
|
|
4304
4573
|
const right = props.ctx && props.ctx.get && props.ctx.get('sidebarRight')
|
|
4305
4574
|
if (right && typeof right.openResource === 'function') {
|
|
4306
|
-
right.openResource(remoteFileAddress(sessionId, p))
|
|
4575
|
+
right.openResource(remoteFileAddress(sessionId, p), Number.isSafeInteger(line) && line > 0 ? { params: { line } } : undefined)
|
|
4307
4576
|
return
|
|
4308
4577
|
}
|
|
4309
4578
|
} catch (e) {
|
|
@@ -4313,6 +4582,24 @@ window.__ModuleLoader__.load({
|
|
|
4313
4582
|
console.warn('[dsh-remote] no right-sidebar resource opener; remote file not opened')
|
|
4314
4583
|
}
|
|
4315
4584
|
|
|
4585
|
+
const revealDirectory = (path) => {
|
|
4586
|
+
setFilter(''); setFilterOpen(false); setRootOpen(true)
|
|
4587
|
+
const relative = String(path).slice(String(root).replace(/[\\/]+$/, '').length).replace(/^[\\/]+/, '')
|
|
4588
|
+
let current = root
|
|
4589
|
+
loadDir(root, { force: true })
|
|
4590
|
+
for (const segment of relative.split(/[\\/]+/).filter(Boolean)) {
|
|
4591
|
+
current = joinRemote(current, segment)
|
|
4592
|
+
if (!expandedRef.current.includes(current)) props.onToggleDir?.(current)
|
|
4593
|
+
loadDir(current, { force: true })
|
|
4594
|
+
}
|
|
4595
|
+
rememberRemoteSelection(sessionId, path); revealPending.current = path
|
|
4596
|
+
}
|
|
4597
|
+
React.useEffect(() => {
|
|
4598
|
+
if (!revealPending.current || !treeRef.current) return
|
|
4599
|
+
const row = Array.from(treeRef.current.querySelectorAll('[data-rw-tree-row]')).find(element => element.getAttribute('data-rw-tree-row') === revealPending.current)
|
|
4600
|
+
if (row) { row.scrollIntoView?.({ block: 'nearest' }); row.focus?.(); revealPending.current = null }
|
|
4601
|
+
}, [data, expanded, filterOpen])
|
|
4602
|
+
|
|
4316
4603
|
const doFs = (op, payload, refreshParent) => {
|
|
4317
4604
|
const view = viewRef.current
|
|
4318
4605
|
setBusy(op)
|
|
@@ -4462,12 +4749,11 @@ window.__ModuleLoader__.load({
|
|
|
4462
4749
|
if (level.error !== undefined) {
|
|
4463
4750
|
return React.createElement('div', { key: dir + ':err', style: { display: 'flex', alignItems: 'center', gap: 6, padding: '5px 8px', paddingLeft: depth * 22 + 6, fontSize: 13, color: T.danger } }, React.createElement('span', { role: 'alert' }, level.error), React.createElement('button', { type: 'button', className: 'dsh-rw-btn', style: buttonS, onClick: () => loadDir(dir, { force: true }) }, tr('project.retry')))
|
|
4464
4751
|
}
|
|
4465
|
-
const
|
|
4466
|
-
const items = (level.entries || []).filter((it) => it.type === 'dir' || !needle || String(it.name).toLowerCase().includes(needle))
|
|
4752
|
+
const items = level.entries || []
|
|
4467
4753
|
const soft = level.softError
|
|
4468
4754
|
? React.createElement('div', { key: dir + ':softerr', style: { display: 'flex', alignItems: 'center', gap: 6, padding: '5px 8px', paddingLeft: depth * 22 + 6, fontSize: 11, opacity: 0.6, color: T.warn } }, tr('explorer.softError', { msg: level.softError }), React.createElement('button', { type: 'button', className: 'dsh-rw-btn', style: buttonS, onClick: () => loadDir(dir, { force: true }) }, tr('project.retry')))
|
|
4469
4755
|
: null
|
|
4470
|
-
if (!items.length) return soft || React.createElement('div', { style: { padding: '8px 12px', paddingLeft: depth * 22 + 6, color: T.muted, fontSize: 12 } }, tr(
|
|
4756
|
+
if (!items.length) return soft || React.createElement('div', { style: { padding: '8px 12px', paddingLeft: depth * 22 + 6, color: T.muted, fontSize: 12 } }, tr('explorer.emptyFolder'))
|
|
4471
4757
|
return React.createElement('div', { key: dir + ':list' },
|
|
4472
4758
|
items.map((it) => row({ ...it, path: joinRemote(dir, it.name) }, depth)),
|
|
4473
4759
|
soft,
|
|
@@ -4489,10 +4775,11 @@ window.__ModuleLoader__.load({
|
|
|
4489
4775
|
|
|
4490
4776
|
return React.createElement('div', { style: { display: 'flex', flexDirection: 'column', height: '100%', minHeight: 0 } },
|
|
4491
4777
|
React.createElement('div', { style: { padding: '10px 10px 6px', borderBottom: '1px solid ' + T.border } },
|
|
4492
|
-
React.createElement('div', { style: { display: 'flex', alignItems: 'center', gap: 6 } },
|
|
4493
|
-
React.createElement('span', { style: { flex: 1, minWidth: 0, fontSize: 12, fontWeight: 600 } }, tr('workbench.explorer')),
|
|
4778
|
+
React.createElement('div', { 'data-rw-explorer-toolbar': '', style: { display: 'flex', alignItems: 'center', gap: 6 } },
|
|
4779
|
+
React.createElement('span', { 'data-rw-explorer-title': '', style: { flex: 1, minWidth: 0, fontSize: 12, fontWeight: 600, whiteSpace: 'nowrap' } }, tr('workbench.explorer')),
|
|
4494
4780
|
React.createElement(WorkbenchAction, { icon: 'terminal', label: tr('workbench.openTerminal'), disabled: !root || remoteTerminal.pending, onClick: remoteTerminal.open }),
|
|
4495
|
-
React.createElement(WorkbenchAction, { icon: '
|
|
4781
|
+
React.createElement(WorkbenchAction, { icon: 'branch', label: tr('changes.title'), disabled: !root, onClick: () => { if (props.onOpenChanges) props.onOpenChanges(); else if (SIDEBAR_RIGHT?.openTabIn) SIDEBAR_RIGHT.openTabIn(sessionId, NATIVE_CHANGES); else if (SIDEBAR_RIGHT?.mounted?.getSnapshot?.() === sessionId) SIDEBAR_RIGHT.openTab?.(NATIVE_CHANGES) } }),
|
|
4782
|
+
React.createElement(WorkbenchAction, { icon: 'search', label: tr('workbench.filter'), pressed: filterOpen, disabled: !root, onClick: () => { setFilterOpen((v) => !v); setFilter('') } }),
|
|
4496
4783
|
React.createElement(WorkbenchAction, { icon: 'refresh', label: tr('explorer.refresh'), onClick: () => refreshStatus({ force: true }) }),
|
|
4497
4784
|
React.createElement(WorkbenchAction, { icon: 'collapse', label: tr('workbench.collapse'), disabled: !root, onClick: () => { props.onCollapseAll?.(); setRootOpen(true) } }),
|
|
4498
4785
|
),
|
|
@@ -4500,23 +4787,26 @@ window.__ModuleLoader__.load({
|
|
|
4500
4787
|
React.createElement('span', { 'aria-hidden': true, style: { width: 6, height: 6, borderRadius: '50%', flexShrink: 0, background: connectionState === 'ready' ? T.ok : connectionState === 'interrupted' ? T.warn : T.muted } }),
|
|
4501
4788
|
React.createElement('span', { style: { overflow: 'hidden', textOverflow: 'ellipsis' } }, status && status.host ? (status.username ? status.username + '@' : '') + status.host : tr('workbench.remote')),
|
|
4502
4789
|
root ? React.createElement('span', { style: { marginLeft: 'auto', fontSize: 10 } }, rootName) : null),
|
|
4503
|
-
filterOpen ? React.createElement('
|
|
4790
|
+
filterOpen ? React.createElement('div', { className: 'dsh-rw-search-controls' },
|
|
4791
|
+
React.createElement('input', { ref: filterRef, type: 'search', className: 'dsh-rw-input', 'aria-label': tr('workspaceSearch.query'), placeholder: tr('workspaceSearch.placeholder'), value: filter, onChange: e => setFilter(e.target.value), onKeyDown: e => { if (e.isComposing) return; if (e.key === 'Escape') { e.stopPropagation(); setFilter(''); setFilterOpen(false) } else if (e.key === 'Enter') { e.preventDefault(); setSearchRetry(value => value + 1) } }, style: { ...inputS, boxSizing: 'border-box', width: '100%', fontSize: 12 } }),
|
|
4792
|
+
React.createElement('div', { className: 'dsh-rw-search-scope' },
|
|
4793
|
+
React.createElement('select', { 'aria-label': tr('workspaceSearch.mode'), value: searchMode, onChange: e => setSearchMode(e.target.value), style: { ...inputS, width: 'auto', flex: 1, minWidth: 0, fontSize: 11, padding: '4px 6px' } }, ['names','files','directories','content'].map(value => React.createElement('option', { key: value, value }, tr(({ names: 'workspaceSearch.names', files: 'workspaceSearch.files', directories: 'workspaceSearch.directories', content: 'workspaceSearch.content' })[value])))),
|
|
4794
|
+
React.createElement('details', { className: 'dsh-rw-search-options' },
|
|
4795
|
+
React.createElement('summary', { 'aria-label': tr('workspaceSearch.options') }, searchCase || searchIgnored ? tr('workspaceSearch.activeOptions', { n: Number(searchCase) + Number(searchIgnored) }) : tr('workspaceSearch.options')),
|
|
4796
|
+
React.createElement('div', { className: 'dsh-rw-search-option-body' },
|
|
4797
|
+
React.createElement('label', {}, React.createElement('input', { type: 'checkbox', checked: searchCase, onChange: e => setSearchCase(e.target.checked) }), tr('workspaceSearch.caseSensitive')),
|
|
4798
|
+
React.createElement('label', {}, React.createElement('input', { type: 'checkbox', checked: searchIgnored, onChange: e => setSearchIgnored(e.target.checked) }), tr('workspaceSearch.includeIgnored')),
|
|
4799
|
+
React.createElement('p', {}, tr('workspaceSearch.ignoreHint')))))) : null,
|
|
4504
4800
|
),
|
|
4505
4801
|
connectionState === 'interrupted' && root ? React.createElement('div', { role: 'status', style: { padding: '6px 10px', display: 'flex', gap: 6, fontSize: 11, color: T.warn, background: T.bg } },
|
|
4506
4802
|
React.createElement('span', { style: { flex: 1 } }, tr('explorer.connection.interrupted')),
|
|
4507
4803
|
React.createElement('button', { type: 'button', className: 'dsh-rw-btn', style: buttonS, onClick: () => refreshStatus({ force: true }) }, tr('project.retry'))) : null,
|
|
4508
4804
|
remoteTerminal.error ? React.createElement('div', { role: 'alert', style: { padding: '6px 10px', color: T.danger, fontSize: 12 } }, remoteTerminal.error) : null,
|
|
4509
|
-
root && status && status.sync ? React.createElement('details', { style: { padding: '4px 8px', fontSize: 11, color: T.muted, borderBottom: '1px solid ' + T.border } },
|
|
4510
|
-
React.createElement('summary', { style: { cursor: 'pointer' } }, tr(({ unknown: 'sync.unknown', running: 'sync.running', completed: 'sync.completed', partial: 'sync.partial', conflicts: 'sync.conflicts', failed: 'sync.failed', pending: 'sync.pending' })[status.sync.phase] || 'sync.unknown')),
|
|
4511
|
-
React.createElement('div', { style: { padding: '6px 0', whiteSpace: 'pre-wrap', overflowWrap: 'anywhere', lineHeight: 1.6 } },
|
|
4512
|
-
status.sync.updatedAt ? new Date(status.sync.updatedAt).toLocaleString() : tr('sync.explain'),
|
|
4513
|
-
status.sync.error ? '\n' + status.sync.error : '',
|
|
4514
|
-
(status.sync.conflicts || []).map((c) => '\n' + c.path + (c.reason ? ' · ' + c.reason : '')).join(''),
|
|
4515
|
-
status.sync.phase === 'conflicts' ? '\n' + tr('sync.conflictHelp') : '')) : null,
|
|
4516
4805
|
picker ? React.createElement('div', { style: { padding: 8 } }, React.createElement(DirPicker, {
|
|
4517
4806
|
open: true, busy: false, registerWorkspace: false, initialTab: 'remote', onPicked: () => { setPicker(false); refreshStatus() }, onCancel: () => setPicker(false),
|
|
4518
4807
|
})) : null,
|
|
4519
|
-
React.createElement(
|
|
4808
|
+
root && filterOpen && filter.trim() ? React.createElement(RemoteWorkspaceSearch, { key: sessionId + ':' + root, root, sessionId, query: filter.trim(), mode: searchMode, includeIgnored: searchIgnored, caseSensitive: searchCase, retryKey: searchRetry, onOpenFile: openFile, onRevealDirectory: revealDirectory }) : null,
|
|
4809
|
+
React.createElement('div', { role: 'tree', 'aria-label': tr('explorer.tabTitle'), ref: treeRef, onScroll: (e) => explorerMemory.set(sessionId || '', { ...explorerMemory.get(sessionId || ''), scrollTop: e.currentTarget.scrollTop }), onKeyDown: treeKeyDown, style: { flex: 1, overflowY: 'auto', minHeight: 0, padding: '2px 0', display: filterOpen && filter.trim() ? 'none' : undefined } },
|
|
4520
4810
|
!root
|
|
4521
4811
|
? React.createElement('div', { style: { opacity: 0.6, padding: 12, fontSize: 13 } }, err ? tr('explorer.cannotResolve') : tr('explorer.localSession'))
|
|
4522
4812
|
: React.createElement('div', { key: root },
|
|
@@ -4535,9 +4825,9 @@ window.__ModuleLoader__.load({
|
|
|
4535
4825
|
rootLevel && rootOpen ? renderLevel(root, 1) : null,
|
|
4536
4826
|
),
|
|
4537
4827
|
),
|
|
4538
|
-
React.createElement('div', { style: { display: 'flex', gap: 6, padding: '6px 10px', borderTop: '1px solid ' + T.border, alignItems: 'center' } },
|
|
4828
|
+
!(filterOpen && filter.trim()) ? React.createElement('div', { style: { display: 'flex', gap: 6, padding: '6px 10px', borderTop: '1px solid ' + T.border, alignItems: 'center' } },
|
|
4539
4829
|
React.createElement('span', { className: 'dsh-rw-path', style: { flex: 1 }, title: root }, root),
|
|
4540
|
-
React.createElement('button', { type: 'button', className: 'dsh-rw-btn', style: { ...buttonS, fontSize: 11, padding: '3px 8px' }, disabled: !root || !!busy, onClick: () => setNamePrompt({ kind: 'mkdir', path: root, name: '' }) }, tr('explorer.newDir'))),
|
|
4830
|
+
React.createElement('button', { type: 'button', className: 'dsh-rw-btn', style: { ...buttonS, fontSize: 11, padding: '3px 8px' }, disabled: !root || !!busy, onClick: () => setNamePrompt({ kind: 'mkdir', path: root, name: '' }) }, tr('explorer.newDir')) ) : null,
|
|
4541
4831
|
// context menu — host Menu primitive when available (anchored at the
|
|
4542
4832
|
// pointer, body-portaled), otherwise the DOM portal in the effect above
|
|
4543
4833
|
menu && HostMenu ? React.createElement(HostMenu, {
|
|
@@ -4688,6 +4978,7 @@ window.__ModuleLoader__.load({
|
|
|
4688
4978
|
}
|
|
4689
4979
|
|
|
4690
4980
|
const remoteDrafts = new Map()
|
|
4981
|
+
const pendingFileSaves = new Map()
|
|
4691
4982
|
function RemoteFileTab(props) {
|
|
4692
4983
|
const { tab, scope } = props
|
|
4693
4984
|
const path = tab.path || ''
|
|
@@ -4766,8 +5057,8 @@ window.__ModuleLoader__.load({
|
|
|
4766
5057
|
setDraft(text)
|
|
4767
5058
|
const prev = remoteDrafts.get(draftKey)
|
|
4768
5059
|
const baseText = prev ? prev.baseText : originalText
|
|
4769
|
-
if (text === baseText) remoteDrafts.delete(draftKey)
|
|
4770
|
-
else remoteDrafts.set(draftKey, { text, baseText, baseMtime: prev ? prev.baseMtime : data && data.mtime })
|
|
5060
|
+
if (text === baseText && !pendingFileSaves.has(draftKey)) remoteDrafts.delete(draftKey)
|
|
5061
|
+
else remoteDrafts.set(draftKey, { text, baseText, baseMtime: prev ? prev.baseMtime : data && data.mtime, baseRevision: prev ? prev.baseRevision : data?.revision, baseEol: prev ? prev.baseEol : data?.eol })
|
|
4771
5062
|
}
|
|
4772
5063
|
|
|
4773
5064
|
React.useEffect(() => { ensureChromeCss() }, [])
|
|
@@ -4799,7 +5090,7 @@ window.__ModuleLoader__.load({
|
|
|
4799
5090
|
.then((d) => { if (!cancelled && fileViewRef.current === draftKey) {
|
|
4800
5091
|
keepView({ data: d }); setData(d); setLoading(false)
|
|
4801
5092
|
const saved = remoteDrafts.get(draftKey)
|
|
4802
|
-
if (saved) { setDraft(saved.text); setEdit(true); setSaveConflict(!!d.truncated || (saved.baseMtime != null && d.mtime !== saved.baseMtime)) }
|
|
5093
|
+
if (saved) { setDraft(saved.text); setEdit(true); setSaveConflict(!!d.truncated || (saved.baseMtime != null && d.mtime !== saved.baseMtime) || (saved.baseRevision != null && saved.baseRevision !== d.revision)) }
|
|
4803
5094
|
} })
|
|
4804
5095
|
.catch((e) => { if (!cancelled && fileViewRef.current === draftKey) { setErr(String((e && e.message) || e)); setLoading(false) } })
|
|
4805
5096
|
return () => { cancelled = true }
|
|
@@ -4812,25 +5103,34 @@ window.__ModuleLoader__.load({
|
|
|
4812
5103
|
setEdit(true); setErr(''); setSaveConflict(false)
|
|
4813
5104
|
}
|
|
4814
5105
|
const saveRemote = () => {
|
|
4815
|
-
if (saving || saveConflict || (data && data.truncated) || saveTokenRef.current === draftKey) return
|
|
5106
|
+
if (saving || saveConflict || (data && data.truncated) || saveTokenRef.current === draftKey || pendingFileSaves.has(draftKey)) return
|
|
4816
5107
|
saveTokenRef.current = draftKey
|
|
5108
|
+
const submittedText = draft
|
|
5109
|
+
const submittedEol = draftRecord?.baseEol || data?.eol
|
|
5110
|
+
const request = { submittedText }
|
|
5111
|
+
pendingFileSaves.set(draftKey, request)
|
|
4817
5112
|
setSaving(true); setErr('')
|
|
4818
|
-
apiRaw('POST', '/dsh-remote/write', withSessionBody({ path, content: draft, expectedMtime: draftRecord ? draftRecord.baseMtime : data && data.mtime }, fileSessionId))
|
|
5113
|
+
apiRaw('POST', '/dsh-remote/write', withSessionBody({ path, content: (draftRecord?.baseEol || data?.eol) === 'crlf' ? draft.replace(/\r?\n/g, '\r\n') : draft, expectedMtime: draftRecord ? draftRecord.baseMtime : data && data.mtime, expectedRevision: draftRecord ? draftRecord.baseRevision : data?.revision }, fileSessionId))
|
|
4819
5114
|
.then((r) => {
|
|
4820
|
-
if (r.status
|
|
4821
|
-
if (fileViewRef.current !== draftKey) return
|
|
5115
|
+
if (r.status >= 400 && fileViewRef.current !== draftKey) return
|
|
4822
5116
|
if (r.status === 409) {
|
|
4823
5117
|
setSaveConflict(true); setErr(String((r.data && r.data.error) || tr('file.conflict')))
|
|
4824
5118
|
return
|
|
4825
5119
|
}
|
|
4826
5120
|
if (r.status >= 400) throw new Error((r.data && (r.data.error || r.data.message)) || 'HTTP ' + r.status)
|
|
4827
|
-
remoteDrafts.
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
5121
|
+
const latest = remoteDrafts.get(draftKey)
|
|
5122
|
+
const newerDraft = latest && latest.text !== submittedText
|
|
5123
|
+
if (newerDraft) remoteDrafts.set(draftKey, { ...latest, baseText: submittedText, baseMtime: r.data?.mtime, baseRevision: r.data?.revision, baseEol: submittedEol })
|
|
5124
|
+
else remoteDrafts.delete(draftKey)
|
|
5125
|
+
const savedData = { ...(fileViewMemory.get(draftKey)?.data || data), content: submittedText, mtime: r.data?.mtime ?? data?.mtime, revision: r.data?.revision, size: r.data?.bytes ?? data?.size, eol: submittedEol }
|
|
5126
|
+
keepView({ data: savedData })
|
|
5127
|
+
if (fileViewRef.current !== draftKey) return
|
|
5128
|
+
setCopyNote(tr(newerDraft ? 'workbench.savedWithDraft' : 'workbench.saved'))
|
|
5129
|
+
if (newerDraft) { setData(savedData); setDraft(latest.text); setEdit(true); setSaveConflict(false) }
|
|
5130
|
+
else { setEdit(false); load() }
|
|
4831
5131
|
})
|
|
4832
5132
|
.catch((e) => { if (fileViewRef.current === draftKey) setErr(String((e && e.message) || e)) })
|
|
4833
|
-
.finally(() => { if (saveTokenRef.current === draftKey) saveTokenRef.current = null; if (fileViewRef.current === draftKey) setSaving(false) })
|
|
5133
|
+
.finally(() => { if (pendingFileSaves.get(draftKey) === request) pendingFileSaves.delete(draftKey); if (saveTokenRef.current === draftKey) saveTokenRef.current = null; if (fileViewRef.current === draftKey) setSaving(false) })
|
|
4834
5134
|
}
|
|
4835
5135
|
const downloadMirror = () => {
|
|
4836
5136
|
setSaving(true); setErr('')
|
|
@@ -4966,6 +5266,7 @@ window.__ModuleLoader__.load({
|
|
|
4966
5266
|
React.createElement('span', {}, edit ? tr('workbench.position', cursor) : tr('workbench.lines', { n: originalText.split('\n').length })),
|
|
4967
5267
|
React.createElement('span', {}, data && data.size != null ? humanSize(data.size) : ''),
|
|
4968
5268
|
React.createElement('span', {}, baseName.includes('.') ? baseName.split('.').pop().toUpperCase() : 'TEXT'),
|
|
5269
|
+
data?.eol ? React.createElement('span', {}, data.eol === 'crlf' ? 'CRLF' : data.eol === 'mixed' ? tr('file.mixedEol') : 'LF') : null,
|
|
4969
5270
|
React.createElement('span', { style: { marginLeft: 'auto', color: copyNote ? T.ok : T.muted } }, copyNote || (loading && data ? tr('workbench.refreshing') : edit ? tr('file.editing') : tr('file.readonly')))),
|
|
4970
5271
|
)
|
|
4971
5272
|
}
|
|
@@ -5043,6 +5344,7 @@ window.__ModuleLoader__.load({
|
|
|
5043
5344
|
// paths are local filesystem resources. Each address is session-scoped.
|
|
5044
5345
|
const NATIVE_EXPLORER = 'dsh-remote/explorer'
|
|
5045
5346
|
const NATIVE_FILE = 'dsh-remote/file'
|
|
5347
|
+
const NATIVE_CHANGES = 'dsh-remote/changes'
|
|
5046
5348
|
// Issue #55: the address the CORE emits for a file link, which is NOT the
|
|
5047
5349
|
// one this plugin mints for its own explorer. A model-emitted
|
|
5048
5350
|
// `[x](src/main.c)` (or a `@src/main.c` chip) is turned into
|
|
@@ -5165,13 +5467,14 @@ window.__ModuleLoader__.load({
|
|
|
5165
5467
|
expanded,
|
|
5166
5468
|
onToggleDir: (path) => updateExpanded((old) => old.includes(path) ? old.filter((p) => p !== path) : [...old, path]),
|
|
5167
5469
|
onCollapseAll: () => updateExpanded([]),
|
|
5168
|
-
|
|
5470
|
+
onOpenChanges: () => info.tab.actions.openTab(NATIVE_CHANGES),
|
|
5471
|
+
onOpenFile: (path, line) => info.tab.actions.openResource(remoteFileAddress(props.sessionId, path), Number.isSafeInteger(line) && line > 0 ? { params: { line } } : undefined),
|
|
5169
5472
|
})
|
|
5170
5473
|
}
|
|
5171
5474
|
function NativeFile(props) {
|
|
5172
5475
|
const info = props.useTabInfo()
|
|
5173
5476
|
const path = remoteFilePath(info.tab.navigation.address)
|
|
5174
|
-
return React.createElement(RemoteFileTab, { key: path, tab: { path }, scope: { sessionId: props.sessionId }, navigationRevision: info.tab.navigation.revision })
|
|
5477
|
+
return React.createElement(RemoteFileTab, { key: path, tab: { path }, scope: { sessionId: props.sessionId }, jumpLine: Number.isSafeInteger(info.tab.navigation.params?.line) && info.tab.navigation.params.line > 0 ? info.tab.navigation.params.line : null, navigationRevision: info.tab.navigation.revision })
|
|
5175
5478
|
}
|
|
5176
5479
|
/**
|
|
5177
5480
|
* The body for a CORE file link in a remote Session (issue #55).
|
|
@@ -5350,6 +5653,7 @@ window.__ModuleLoader__.load({
|
|
|
5350
5653
|
try { syncExplorerType() } catch (e) { console.warn('[dsh-remote] start-page card handover skipped:', e) }
|
|
5351
5654
|
}, 'dsh-remote.start-card-owner')
|
|
5352
5655
|
})
|
|
5656
|
+
inner.effect(() => tabs.register({ id: NATIVE_CHANGES, kind: NATIVE_CHANGES, title: () => tr('changes.title') }), 'dsh-remote.native-changes-type')
|
|
5353
5657
|
inner.effect(() => tabs.register({
|
|
5354
5658
|
id: NATIVE_FILE, kind: NATIVE_FILE,
|
|
5355
5659
|
patterns: ['dsh-resource://dsh-remote/**'],
|
|
@@ -5422,6 +5726,7 @@ window.__ModuleLoader__.load({
|
|
|
5422
5726
|
const disposers = [
|
|
5423
5727
|
slots.register({ name: 'sidebar.right.pane.tab', key: NATIVE_EXPLORER }, NativeExplorer),
|
|
5424
5728
|
slots.register({ name: 'sidebar.right.pane.tab', key: NATIVE_FILE }, NativeFile),
|
|
5729
|
+
slots.register({ name: 'sidebar.right.pane.tab', key: NATIVE_CHANGES }, NativeChanges),
|
|
5425
5730
|
]
|
|
5426
5731
|
// Only register the link body when its type was accepted: a body under a
|
|
5427
5732
|
// kind nothing claims would never render, and on a build that rejected
|
|
@@ -5434,6 +5739,183 @@ window.__ModuleLoader__.load({
|
|
|
5434
5739
|
}
|
|
5435
5740
|
|
|
5436
5741
|
|
|
5742
|
+
// Native read-only Git workbench. Its requests and file navigation always
|
|
5743
|
+
// carry the tab's session identity, including after a late response.
|
|
5744
|
+
const gitViewMemory = new Map()
|
|
5745
|
+
const gitFilesForMode = (files, staged) => (files || []).filter(file => staged
|
|
5746
|
+
? file.indexStatus !== ' ' && file.indexStatus !== '?' && file.indexStatus !== '!'
|
|
5747
|
+
: file.untracked || file.worktreeStatus !== ' ' && file.worktreeStatus !== '!')
|
|
5748
|
+
|
|
5749
|
+
function NativeChanges(props) {
|
|
5750
|
+
const info = props.useTabInfo()
|
|
5751
|
+
return React.createElement(RemoteGitTab, {
|
|
5752
|
+
key: props.sessionId, sessionId: props.sessionId, visible: info.tab.visible,
|
|
5753
|
+
openFile: (path, line) => info.tab.actions.openResource(remoteFileAddress(props.sessionId, path), line ? { params: { line } } : undefined),
|
|
5754
|
+
})
|
|
5755
|
+
}
|
|
5756
|
+
|
|
5757
|
+
function RemoteGitTab(props) {
|
|
5758
|
+
const key = String(props.sessionId || '')
|
|
5759
|
+
const initial = gitViewMemory.get(key)
|
|
5760
|
+
const [git, setGit] = React.useState({ key, data: null, error: '', busy: false, revision: 0 })
|
|
5761
|
+
const [selected, setSelected] = React.useState(initial?.selected || '')
|
|
5762
|
+
const [staged, setStaged] = React.useState(initial?.staged || false)
|
|
5763
|
+
const [filter, setFilter] = React.useState('')
|
|
5764
|
+
const [diff, setDiff] = React.useState(null)
|
|
5765
|
+
const identity = React.useRef(key)
|
|
5766
|
+
identity.current = key
|
|
5767
|
+
const statusRequest = React.useRef({ sequence: 0, controller: null, pending: false })
|
|
5768
|
+
const diffRequest = React.useRef({ sequence: 0, controller: null })
|
|
5769
|
+
const alive = React.useRef(true)
|
|
5770
|
+
const data = git.key === key ? git.data : null
|
|
5771
|
+
const files = gitFilesForMode(data?.files, staged)
|
|
5772
|
+
const chosen = files.find(file => file.path === selected) || null
|
|
5773
|
+
const selectionKey = key + '\0' + (data?.repo || '') + '\0' + (staged ? 'staged' : 'working') + '\0' + selected
|
|
5774
|
+
const currentDiff = diff?.key === selectionKey ? diff : null
|
|
5775
|
+
const inputRef = React.useRef(null)
|
|
5776
|
+
React.useEffect(() => {
|
|
5777
|
+
alive.current = true
|
|
5778
|
+
return () => { alive.current = false; statusRequest.current.controller?.abort(); diffRequest.current.controller?.abort() }
|
|
5779
|
+
}, [])
|
|
5780
|
+
React.useEffect(() => {
|
|
5781
|
+
gitViewMemory.set(key, { selected, staged })
|
|
5782
|
+
while (gitViewMemory.size > 64) gitViewMemory.delete(gitViewMemory.keys().next().value)
|
|
5783
|
+
}, [key, selected, staged])
|
|
5784
|
+
const refresh = React.useCallback(async () => {
|
|
5785
|
+
if (!key || statusRequest.current.pending) return
|
|
5786
|
+
const request = statusRequest.current
|
|
5787
|
+
request.controller?.abort()
|
|
5788
|
+
const controller = new AbortController(), ticket = ++request.sequence
|
|
5789
|
+
request.controller = controller; request.pending = true
|
|
5790
|
+
const current = () => alive.current && identity.current === key && request.sequence === ticket && !controller.signal.aborted
|
|
5791
|
+
setGit(old => ({ key, data: old.key === key ? old.data : null, error: '', busy: true, revision: old.revision }))
|
|
5792
|
+
try {
|
|
5793
|
+
const result = await api('GET', withSessionQuery('/dsh-remote/git?action=status', key), undefined, controller.signal)
|
|
5794
|
+
if (!current()) return
|
|
5795
|
+
if (!result?.ok) throw new Error(result?.error || tr('changes.failed'))
|
|
5796
|
+
setGit(old => ({ key, data: result, error: '', busy: false, revision: old.revision + 1 }))
|
|
5797
|
+
} catch (error) {
|
|
5798
|
+
if (current()) setGit(old => ({ ...old, key, busy: false, error: String(error?.message || error) }))
|
|
5799
|
+
} finally { if (request.sequence === ticket) request.pending = false }
|
|
5800
|
+
}, [key])
|
|
5801
|
+
React.useEffect(() => {
|
|
5802
|
+
// In a normal host the keyed wrapper remounts on session changes. Keep
|
|
5803
|
+
// the independent guard for embeddings that reuse this component.
|
|
5804
|
+
statusRequest.current.controller?.abort(); statusRequest.current.pending = false
|
|
5805
|
+
const saved = gitViewMemory.get(key)
|
|
5806
|
+
setSelected(saved?.selected || ''); setStaged(saved?.staged || false); setFilter(''); setDiff(null)
|
|
5807
|
+
void refresh()
|
|
5808
|
+
return () => { statusRequest.current.sequence++; statusRequest.current.controller?.abort(); statusRequest.current.pending = false }
|
|
5809
|
+
}, [key])
|
|
5810
|
+
React.useEffect(() => {
|
|
5811
|
+
if (props.visible === false) return
|
|
5812
|
+
const timer = setInterval(() => { void refresh() }, 15000)
|
|
5813
|
+
const focus = () => { void refresh() }
|
|
5814
|
+
if (typeof window !== 'undefined') window.addEventListener?.('focus', focus)
|
|
5815
|
+
return () => { clearInterval(timer); if (typeof window !== 'undefined') window.removeEventListener?.('focus', focus) }
|
|
5816
|
+
}, [key, props.visible])
|
|
5817
|
+
React.useEffect(() => {
|
|
5818
|
+
if (!data?.available) { setSelected(''); return }
|
|
5819
|
+
if (files.some(file => file.path === selected)) return
|
|
5820
|
+
setSelected(files[0]?.path || '')
|
|
5821
|
+
}, [data, staged, selected])
|
|
5822
|
+
React.useEffect(() => {
|
|
5823
|
+
const request = diffRequest.current, controller = new AbortController(), ticket = ++request.sequence
|
|
5824
|
+
request.controller?.abort(); request.controller = controller
|
|
5825
|
+
if (!chosen || !data?.available) { setDiff(null); return () => controller.abort() }
|
|
5826
|
+
const current = () => alive.current && identity.current === key && ticket === request.sequence && !controller.signal.aborted
|
|
5827
|
+
setDiff({ key: selectionKey, busy: true, data: null, error: '' })
|
|
5828
|
+
api('GET', withSessionQuery('/dsh-remote/git?action=diff&path=' + encodeURIComponent(chosen.path) + '&staged=' + (staged ? '1' : '0'), key), undefined, controller.signal)
|
|
5829
|
+
.then(result => {
|
|
5830
|
+
if (!current()) return
|
|
5831
|
+
if (!result?.ok) throw new Error(result?.error || tr('changes.failed'))
|
|
5832
|
+
if (result.available === false) throw new Error(result.reason === 'not-repository' ? tr('changes.noRepository') : result.reason === 'git-unavailable' ? tr('changes.noGit') : tr('changes.unavailable'))
|
|
5833
|
+
setDiff({ key: selectionKey, busy: false, data: result, error: '' })
|
|
5834
|
+
})
|
|
5835
|
+
.catch(error => { if (current()) setDiff({ key: selectionKey, busy: false, data: null, error: String(error?.message || error) }) })
|
|
5836
|
+
return () => controller.abort()
|
|
5837
|
+
}, [key, selectionKey, git.revision])
|
|
5838
|
+
const openFile = (line) => {
|
|
5839
|
+
if (!alive.current || identity.current !== key || !chosen || chosen.deleted || typeof props.openFile !== 'function') return
|
|
5840
|
+
props.openFile(chosen.absolutePath, line)
|
|
5841
|
+
}
|
|
5842
|
+
const missingReason = data?.reason === 'git-unavailable' ? tr('changes.noGit')
|
|
5843
|
+
: data?.reason === 'not-repository' ? tr('changes.noRepository')
|
|
5844
|
+
: data?.reason === 'unsupported-shell' ? tr('changes.unsupportedShell') : tr('changes.unavailable')
|
|
5845
|
+
const previewReason = currentDiff?.data?.reason === 'binary' ? tr('changes.binary')
|
|
5846
|
+
: currentDiff?.data?.reason === 'symlink' ? tr('changes.symlink')
|
|
5847
|
+
: currentDiff?.data?.reason === 'too-large' ? tr('changes.large')
|
|
5848
|
+
: currentDiff?.data?.empty ? tr('changes.emptyFile') : tr('changes.noDiff')
|
|
5849
|
+
const visibleFiles = files.filter(file => file.path.toLocaleLowerCase().includes(filter.trim().toLocaleLowerCase()))
|
|
5850
|
+
const patch = currentDiff?.data?.patch || ''
|
|
5851
|
+
const patchLines = patch.split('\n')
|
|
5852
|
+
if (patchLines[patchLines.length - 1] === '') patchLines.pop()
|
|
5853
|
+
let nextLine = null
|
|
5854
|
+
const rows = patchLines.slice(0, 1800).map((text, index) => {
|
|
5855
|
+
const hunk = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(text)
|
|
5856
|
+
let line = null, kind = 'meta'
|
|
5857
|
+
if (hunk) { nextLine = Number(hunk[1]); kind = 'hunk' }
|
|
5858
|
+
else if (nextLine !== null && !/^--- |^\+\+\+ /.test(text)) {
|
|
5859
|
+
if (text[0] === '+') { line = nextLine++; kind = 'added' }
|
|
5860
|
+
else if (text[0] === ' ') { line = nextLine++; kind = 'context' }
|
|
5861
|
+
else if (text[0] === '-') kind = 'removed'
|
|
5862
|
+
}
|
|
5863
|
+
const canOpen = !!line && line > 0 && !chosen?.deleted && typeof props.openFile === 'function'
|
|
5864
|
+
return React.createElement('div', { key: index, className: 'dsh-rw-git-diff-line', 'data-rw-diff-kind': kind },
|
|
5865
|
+
canOpen ? React.createElement('button', { type: 'button', className: 'dsh-rw-git-line-number', 'data-rw-diff-line': line, title: tr('changes.openLine', { line }), 'aria-label': tr('changes.openLine', { line }), onClick: () => openFile(line) }, line)
|
|
5866
|
+
: React.createElement('span', { className: 'dsh-rw-git-line-number', 'aria-hidden': true }, ''),
|
|
5867
|
+
React.createElement('span', {}, text || ' '))
|
|
5868
|
+
})
|
|
5869
|
+
const workingCount = gitFilesForMode(data?.files, false).length, stagedCount = gitFilesForMode(data?.files, true).length
|
|
5870
|
+
const switchMode = value => { if (staged === value) return; setStaged(value); setDiff(null) }
|
|
5871
|
+
return React.createElement('section', { className: 'dsh-rw-git', 'data-rw-git': true, 'aria-label': tr('changes.title') },
|
|
5872
|
+
React.createElement('header', { className: 'dsh-rw-git-header' },
|
|
5873
|
+
React.createElement('div', { className: 'dsh-rw-git-title' },
|
|
5874
|
+
React.createElement(WorkbenchIcon, { name: 'branch' }), React.createElement('strong', {}, tr('changes.title')),
|
|
5875
|
+
React.createElement(WorkbenchAction, { icon: 'refresh', label: tr('explorer.refresh'), disabled: git.busy, onClick: refresh })),
|
|
5876
|
+
data?.available ? React.createElement('div', { className: 'dsh-rw-git-repo', title: data.repo }, data.detached ? tr('changes.detached') : data.branch, ' · ', data.workspace) : null,
|
|
5877
|
+
React.createElement('div', { className: 'dsh-rw-git-hint' }, tr('changes.readOnly')),
|
|
5878
|
+
data?.available ? React.createElement('div', { className: 'dsh-rw-git-mode' },
|
|
5879
|
+
[false,true].map(value => React.createElement('button', { key: String(value), type: 'button', className: 'dsh-rw-btn', style: { ...buttonS, padding: '5px 10px', fontSize: 12, borderRadius: 6 }, 'aria-pressed': staged === value, onClick: () => switchMode(value) },
|
|
5880
|
+
tr(value ? 'changes.staged' : 'changes.working'), ' · ', value ? stagedCount : workingCount))) : null,
|
|
5881
|
+
data?.available && data.files?.length ? React.createElement('input', { ref: inputRef, type: 'search', className: 'dsh-rw-input', style: { ...inputS, width: '100%', fontSize: 12, boxSizing: 'border-box' }, 'aria-label': tr('changes.filter'), placeholder: tr('changes.filter'), value: filter, onChange: e => setFilter(e.target.value), onKeyDown: e => { if (e.key === 'Escape' && !e.isComposing) { e.stopPropagation(); setFilter('') } } }) : null),
|
|
5882
|
+
git.busy ? React.createElement('div', { role: 'status', className: 'dsh-rw-git-message' }, data ? tr('changes.refreshing') : tr('changes.loading')) : null,
|
|
5883
|
+
git.error ? React.createElement('div', { role: 'alert', className: 'dsh-rw-git-message', style: { color: T.danger } }, git.error,
|
|
5884
|
+
React.createElement('button', { type: 'button', className: 'dsh-rw-btn', onClick: refresh, disabled: git.busy }, tr('project.retry')),
|
|
5885
|
+
data ? React.createElement('div', {}, tr('changes.stale')) : null) : null,
|
|
5886
|
+
data && !data.available ? React.createElement('div', { role: 'status', className: 'dsh-rw-git-message' }, missingReason) : null,
|
|
5887
|
+
data?.truncated ? React.createElement('div', { role: 'status', className: 'dsh-rw-git-message', style: { color: T.warn } }, tr('changes.partial')) : null,
|
|
5888
|
+
data?.available && !data.files.length ? React.createElement('div', { role: 'status', className: 'dsh-rw-git-message' }, tr('changes.clean')) : null,
|
|
5889
|
+
data?.available && data.files.length ? React.createElement(React.Fragment, {},
|
|
5890
|
+
React.createElement('div', { className: 'dsh-rw-git-files', role: 'listbox', 'aria-label': staged ? tr('changes.staged') : tr('changes.working'), onKeyDown: e => {
|
|
5891
|
+
if (e.isComposing || e.ctrlKey || e.altKey || e.metaKey || !['ArrowDown','ArrowUp','Home','End'].includes(e.key)) return
|
|
5892
|
+
const options = Array.from(e.currentTarget.querySelectorAll('[data-rw-git-file]'))
|
|
5893
|
+
const at = options.indexOf(e.target.closest('[data-rw-git-file]'))
|
|
5894
|
+
if (at < 0) return
|
|
5895
|
+
e.preventDefault()
|
|
5896
|
+
const next = e.key === 'Home' ? 0 : e.key === 'End' ? options.length - 1 : Math.max(0, Math.min(options.length - 1, at + (e.key === 'ArrowDown' ? 1 : -1)))
|
|
5897
|
+
options[next]?.focus(); options[next]?.click()
|
|
5898
|
+
} },
|
|
5899
|
+
visibleFiles.length ? visibleFiles.map((file, index) => React.createElement('button', { key: file.path, role: 'option', type: 'button', className: 'dsh-rw-git-file', 'aria-selected': selected === file.path, tabIndex: selected === file.path || index === 0 && !visibleFiles.some(value => value.path === selected) ? 0 : -1,
|
|
5900
|
+
'data-rw-git-file': file.path, 'data-rw-git-stage': staged ? 'staged' : 'working', title: file.previousPath ? file.previousPath + ' → ' + file.path : file.path, onClick: () => setSelected(file.path) },
|
|
5901
|
+
React.createElement(WorkbenchIcon, { name: 'file' }), React.createElement('span', { className: 'dsh-rw-git-file-path' }, file.path),
|
|
5902
|
+
React.createElement('span', { className: 'dsh-rw-git-status', style: { color: file.conflict ? T.danger : file.untracked ? T.ok : T.muted } },
|
|
5903
|
+
file.conflict ? tr('changes.conflict') : file.untracked ? tr('changes.untracked') : (staged ? file.indexStatus : file.worktreeStatus))))
|
|
5904
|
+
: React.createElement('div', { role: 'status', className: 'dsh-rw-git-message' }, filter.trim() ? tr('changes.noMatch') : tr('changes.emptyGroup'))),
|
|
5905
|
+
chosen ? React.createElement('div', { className: 'dsh-rw-git-preview' },
|
|
5906
|
+
React.createElement('div', { className: 'dsh-rw-git-preview-title' },
|
|
5907
|
+
React.createElement('strong', { title: chosen.path }, chosen.path),
|
|
5908
|
+
React.createElement(WorkbenchAction, { icon: 'file', label: tr('changes.openFile'), disabled: chosen.deleted || typeof props.openFile !== 'function', onClick: () => openFile() })),
|
|
5909
|
+
React.createElement('div', { className: 'dsh-rw-git-hint' }, staged ? tr('changes.stagedDiff') : tr('changes.workingDiff')),
|
|
5910
|
+
!currentDiff || currentDiff.busy ? React.createElement('div', { role: 'status', className: 'dsh-rw-git-message' }, tr('changes.loadingDiff'))
|
|
5911
|
+
: currentDiff.error ? React.createElement('div', { role: 'alert', className: 'dsh-rw-git-message', style: { color: T.danger } }, currentDiff.error,
|
|
5912
|
+
React.createElement('button', { type: 'button', className: 'dsh-rw-btn', onClick: refresh, disabled: git.busy }, tr('project.retry')))
|
|
5913
|
+
: patch ? React.createElement('div', { className: 'dsh-rw-git-diff', role: 'region', 'aria-label': tr('changes.diff'), tabIndex: 0 }, rows)
|
|
5914
|
+
: React.createElement('div', { role: 'status', className: 'dsh-rw-git-message' }, previewReason),
|
|
5915
|
+
currentDiff?.data?.truncated || patchLines.length > 1800 ? React.createElement('div', { role: 'status', className: 'dsh-rw-git-message', style: { color: T.warn } }, tr('changes.partialDiff')) : null)
|
|
5916
|
+
: React.createElement('div', { className: 'dsh-rw-git-message' }, tr('changes.chooseFile'))) : null)
|
|
5917
|
+
}
|
|
5918
|
+
|
|
5437
5919
|
// Native Tool views are keyed by wire name; older hosts simply omit this seat.
|
|
5438
5920
|
const REMOTE_TOOL_TITLES = {
|
|
5439
5921
|
rw_exec: 'exec', rw_read_file: 'read', rw_edit: 'edit', rw_write_file: 'write', rw_append: 'write',
|
|
@@ -5471,8 +5953,36 @@ window.__ModuleLoader__.load({
|
|
|
5471
5953
|
if (!seen.has(key)) { seen.add(key); diagnostics.push(item) }
|
|
5472
5954
|
if (diagnostics.length >= 200) break
|
|
5473
5955
|
}
|
|
5474
|
-
|
|
5956
|
+
const change = done && !block.isError ? appliedChangeMeta(block.meta) : null
|
|
5957
|
+
return { args, output, status, code, facts, diagnostics, change }
|
|
5958
|
+
}
|
|
5959
|
+
function appliedChangeMeta(meta) {
|
|
5960
|
+
if (!meta || meta.kind !== 'dsh-remote.change' || meta.version !== 1 || meta.applied !== true || typeof meta.path !== 'string' || !Array.isArray(meta.diffs)) return null
|
|
5961
|
+
if (meta.diffs.length > 30 || !meta.diffs.every(diff => diff && typeof diff.path === 'string' && (diff.oldText === null || typeof diff.oldText === 'string') && typeof diff.newText === 'string')) return null
|
|
5962
|
+
return meta
|
|
5963
|
+
}
|
|
5964
|
+
function AppliedChangeView({ change }) {
|
|
5965
|
+
const labels = {
|
|
5966
|
+
codeLabel: tr('file.markdown.code'), wrapLabel: tr('file.markdown.wrap'), unwrapLabel: tr('file.markdown.unwrap'),
|
|
5967
|
+
copy: tr('file.markdown.copy'), copied: tr('file.markdown.copied'), collapseAria: tr('change.collapse'), collapse: tr('change.collapse'),
|
|
5968
|
+
expandAria: count => tr('change.expand', { n: count }), expand: count => tr('change.expand', { n: count }),
|
|
5969
|
+
}
|
|
5970
|
+
return React.createElement('div', { className: 'dsh-rw-applied-change', 'data-rw-applied-change': true, 'data-rw-change-path': change.path },
|
|
5971
|
+
React.createElement('div', { className: 'dsh-rw-change-heading' },
|
|
5972
|
+
React.createElement('strong', {}, tr(change.unchanged ? 'change.unchanged' : 'change.applied')),
|
|
5973
|
+
change.diffs.length ? React.createElement('span', { style: { marginLeft: 'auto', fontFamily: 'monospace', whiteSpace: 'nowrap' } },
|
|
5974
|
+
React.createElement('span', { style: { color: T.ok } }, '+' + (change.additions || 0)), ' ', React.createElement('span', { style: { color: T.danger } }, '−' + (change.deletions || 0))) : null),
|
|
5975
|
+
change.diffs.length ? NativeDiffBlock
|
|
5976
|
+
? React.createElement(NativeDiffBlock, { diffs: change.diffs, labels, maxLines: 12 })
|
|
5977
|
+
: React.createElement('div', {}, change.diffs.map((diff, index) => React.createElement('details', { key: index, open: index === 0, className: 'dsh-rw-change-hunk' },
|
|
5978
|
+
React.createElement('summary', {}, tr('change.hunk', { n: index + 1 })),
|
|
5979
|
+
React.createElement('div', { style: { color: T.muted, padding: '3px 10px', fontSize: 11 } }, tr('agent.before')),
|
|
5980
|
+
React.createElement('pre', { className: 'dsh-rw-agent-output', style: { color: T.danger, background: 'rgba(239,68,68,.06)' } }, diff.oldText ?? ''),
|
|
5981
|
+
React.createElement('div', { style: { color: T.muted, padding: '3px 10px', fontSize: 11 } }, tr('agent.after')),
|
|
5982
|
+
React.createElement('pre', { className: 'dsh-rw-agent-output', style: { color: T.ok, background: 'rgba(34,197,94,.06)' } }, diff.newText)))) : null,
|
|
5983
|
+
change.truncated ? React.createElement('div', { role: 'status', style: { padding: '7px 10px', color: T.muted, fontSize: 11, lineHeight: 1.6 } }, tr(change.reason === 'binary' ? 'change.binary' : change.reason === 'baseline-unavailable' ? 'change.noBaseline' : 'change.truncated')) : null)
|
|
5475
5984
|
}
|
|
5985
|
+
|
|
5476
5986
|
function RemoteToolCard(props) {
|
|
5477
5987
|
const view = remoteToolView(props)
|
|
5478
5988
|
const failed = view.status === 'failed' || view.status === 'timeout'
|
|
@@ -5481,14 +5991,14 @@ window.__ModuleLoader__.load({
|
|
|
5481
5991
|
const [localOpen, setLocalOpen] = React.useState(attention)
|
|
5482
5992
|
const disclosure = props.useDisclosure ? props.useDisclosure() : null
|
|
5483
5993
|
const [touched, setTouched] = React.useState(false)
|
|
5484
|
-
const open = attention && !touched || (disclosure ? disclosure.expanded : localOpen)
|
|
5994
|
+
const open = (attention || !!view.change?.diffs.length) && !touched || (disclosure ? disclosure.expanded : localOpen)
|
|
5485
5995
|
const setOpen = disclosure ? disclosure.setExpanded : setLocalOpen
|
|
5486
5996
|
|
|
5487
5997
|
const [copied, setCopied] = React.useState(false)
|
|
5488
5998
|
const copyTimer = React.useRef(null)
|
|
5489
5999
|
React.useEffect(() => () => { if (copyTimer.current) clearTimeout(copyTimer.current) }, [])
|
|
5490
6000
|
const title = tr(`agent.${REMOTE_TOOL_TITLES[props.toolName] || 'other'}`)
|
|
5491
|
-
const filePath = view.args.path || view.args.file_path || ''
|
|
6001
|
+
const filePath = view.change?.path || view.args.path || view.args.file_path || ''
|
|
5492
6002
|
const summary = props.toolName === 'rw_exec' ? view.args.command || '' : filePath || view.args.query || ''
|
|
5493
6003
|
const color = attention ? T.danger : view.status === 'completed' ? T.ok : ['stopped', 'unknown', 'timeout'].includes(view.status) ? T.warn : T.muted
|
|
5494
6004
|
const bodyId = React.useId()
|
|
@@ -5527,7 +6037,9 @@ window.__ModuleLoader__.load({
|
|
|
5527
6037
|
view.diagnostics.length ? React.createElement('div', { style: { padding: '6px 12px', borderTop: '1px solid ' + T.border } },
|
|
5528
6038
|
React.createElement('strong', { style: { fontSize: 12 } }, tr('agent.diagnostics') + ' · ' + view.diagnostics.length),
|
|
5529
6039
|
view.diagnostics.map((item, index) => React.createElement('button', { key: index, type: 'button', className: 'dsh-rw-agent-diagnostic', disabled: !props.openFile, 'aria-label': tr('agent.open', item), onClick: () => openPath(item.path, item.line), style: { color: /error/.test(item.severity) ? T.danger : T.warn } }, item.path + ':' + item.line + ':' + item.column + ' · ' + item.message))) : null,
|
|
5530
|
-
|
|
6040
|
+
view.change ? React.createElement(AppliedChangeView, { change: view.change }) : null,
|
|
6041
|
+
!view.change && view.status === 'completed' && props.toolName === 'rw_edit' && typeof (view.args.old ?? view.args.old_string) === 'string' ? React.createElement('div', { style: { borderTop: '1px solid ' + T.border, fontSize: 11 } },
|
|
6042
|
+
React.createElement('div', { style: { padding: '5px 12px', color: T.muted } }, tr('change.legacy')),
|
|
5531
6043
|
React.createElement('div', { style: { padding: '4px 12px', color: T.muted } }, tr('agent.before')),
|
|
5532
6044
|
React.createElement('pre', { className: 'dsh-rw-agent-output', style: { color: T.danger } }, String(view.args.old ?? view.args.old_string).slice(0, 20000)),
|
|
5533
6045
|
React.createElement('div', { style: { padding: '4px 12px', color: T.muted } }, tr('agent.after')),
|
|
@@ -5538,6 +6050,259 @@ window.__ModuleLoader__.load({
|
|
|
5538
6050
|
)
|
|
5539
6051
|
}
|
|
5540
6052
|
|
|
6053
|
+
// Optional IDE shell. DOM stays owned by the host React roots: only public
|
|
6054
|
+
// session markers and reversible geometry attributes are used for docking.
|
|
6055
|
+
// Design reference: MIT dsh-gufa-code (Jeff nan); no host sources patched.
|
|
6056
|
+
const REMOTE_IDE_KEY = 'dsh-remote.ide-layout.v1'
|
|
6057
|
+
const remoteIdeWatchers = new Set()
|
|
6058
|
+
let remoteIdeController = null
|
|
6059
|
+
function remoteIdeRead() {
|
|
6060
|
+
try {
|
|
6061
|
+
const value = JSON.parse(window.localStorage.getItem(REMOTE_IDE_KEY) || '{}')
|
|
6062
|
+
return { enabled: value.enabled === true, left: Number(value.left) || 240, right: Number(value.right) || 400 }
|
|
6063
|
+
} catch { return { enabled: false, left: 240, right: 400 } }
|
|
6064
|
+
}
|
|
6065
|
+
let remoteIdeState = remoteIdeRead()
|
|
6066
|
+
function remoteIdeSet(change) {
|
|
6067
|
+
remoteIdeState = { ...remoteIdeState, ...change }
|
|
6068
|
+
try { window.localStorage.setItem(REMOTE_IDE_KEY, JSON.stringify(remoteIdeState)) } catch { /* private browsing */ }
|
|
6069
|
+
for (const fn of remoteIdeWatchers) fn()
|
|
6070
|
+
}
|
|
6071
|
+
function remoteIdeWidths(width, preferred) {
|
|
6072
|
+
// Width preferences are never overwritten by a temporary small viewport.
|
|
6073
|
+
const available = Math.max(0, Number(width) || 0)
|
|
6074
|
+
const left = Math.max(180, Math.min(380, Number(preferred.left) || 240, available - 320 - 280 - 12))
|
|
6075
|
+
const right = Math.max(280, Math.min(700, Number(preferred.right) || 400, available - left - 320 - 12))
|
|
6076
|
+
return { left, right, narrow: available < 960 }
|
|
6077
|
+
}
|
|
6078
|
+
function useRemoteIdeState() {
|
|
6079
|
+
const [state, setState] = React.useState(remoteIdeState)
|
|
6080
|
+
React.useEffect(() => {
|
|
6081
|
+
const update = () => setState(remoteIdeState)
|
|
6082
|
+
remoteIdeWatchers.add(update); update()
|
|
6083
|
+
return () => remoteIdeWatchers.delete(update)
|
|
6084
|
+
}, [])
|
|
6085
|
+
return state
|
|
6086
|
+
}
|
|
6087
|
+
function RemoteIdeToggle(props) {
|
|
6088
|
+
const mirror = useSessionMirror(props.sessionId, props.useSessions)
|
|
6089
|
+
const state = useRemoteIdeState()
|
|
6090
|
+
if (!mirror) return null
|
|
6091
|
+
const supported = !!remoteIdeController?.mounted?.getSnapshot && typeof remoteIdeController.openResourceIn === 'function'
|
|
6092
|
+
return React.createElement('button', {
|
|
6093
|
+
type: 'button', 'data-rw-ide-toggle': '', 'aria-pressed': state.enabled,
|
|
6094
|
+
disabled: !supported, title: tr(supported ? 'ide.help' : 'ide.unsupported'),
|
|
6095
|
+
onClick: () => remoteIdeSet({ enabled: !state.enabled }),
|
|
6096
|
+
style: { ...buttonS, padding: '3px 7px', fontSize: 11, whiteSpace: 'nowrap', display: 'inline-flex', alignItems: 'center', gap: 5 },
|
|
6097
|
+
}, React.createElement('svg', { width: 14, height: 14, viewBox: '0 0 20 20', fill: 'none', stroke: 'currentColor', 'aria-hidden': true },
|
|
6098
|
+
React.createElement('rect', { x: 2, y: 3, width: 16, height: 14, rx: 2 }),
|
|
6099
|
+
React.createElement('path', { d: 'M6 3v14M13 3v14' })), tr('ide.enter'))
|
|
6100
|
+
}
|
|
6101
|
+
const REMOTE_IDE_CSS = `
|
|
6102
|
+
[data-rw-ide-shell]{position:fixed;inset:var(--dsh-windows-titlebar-height,0px) 0 0;z-index:24;background:var(--dsw-alias-bg-base,#fff);color:var(--dsw-alias-label-primary,#222);display:flex;flex-direction:column;min-width:0;min-height:0;font-size:12px}
|
|
6103
|
+
[data-rw-ide-header]{height:38px;min-height:38px;display:flex;align-items:center;gap:10px;padding:0 12px;border-bottom:1px solid var(--dsw-alias-border-l2,#ddd);background:var(--dsw-specific-sidebar-fill,var(--dsw-alias-bg-base,#fff))}
|
|
6104
|
+
[data-rw-ide-title]{font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0;flex:1}
|
|
6105
|
+
[data-rw-ide-body]{flex:1;min-height:0;min-width:0;display:grid}
|
|
6106
|
+
[data-rw-ide-tree]{min-width:0;min-height:0;overflow:hidden;display:flex;flex-direction:column;border-right:1px solid var(--dsw-alias-border-l2,#ddd)}
|
|
6107
|
+
[data-rw-ide-tree]>div{flex:1;min-height:0}
|
|
6108
|
+
[data-rw-ide-tree] [data-rw-explorer-toolbar]{flex-wrap:wrap}
|
|
6109
|
+
[data-rw-ide-tree] [data-rw-explorer-title]{flex-basis:100%!important}
|
|
6110
|
+
[data-rw-ide-seat]{min-width:0;min-height:0;position:relative;display:flex;align-items:center;justify-content:center;overflow:hidden}
|
|
6111
|
+
[data-rw-ide-placeholder]{max-width:320px;padding:24px;line-height:1.7;text-align:center;color:var(--dsw-alias-label-tertiary,#777)}
|
|
6112
|
+
[data-rw-ide-divider]{width:6px;cursor:col-resize;touch-action:none;position:relative;outline:none;z-index:1;background:var(--dsw-alias-bg-base,#fff)}
|
|
6113
|
+
[data-rw-ide-divider]:hover,[data-rw-ide-divider]:focus-visible{background:var(--dsw-static-blue-500,#3b82f6)}
|
|
6114
|
+
[data-rw-ide-editor],[data-rw-ide-chat]{position:fixed!important;top:var(--rw-ide-y)!important;left:var(--rw-ide-x)!important;right:auto!important;bottom:auto!important;width:var(--rw-ide-w)!important;height:var(--rw-ide-h)!important;max-width:none!important;max-height:none!important;margin:0!important;z-index:36!important;box-sizing:border-box!important;background:var(--dsw-alias-bg-base,#fff);border-radius:0!important;overflow:hidden!important;transition:none!important}
|
|
6115
|
+
[data-rw-ide-editor]{--dsh-sidebar-width:var(--rw-ide-w)!important;border-right:1px solid var(--dsw-alias-border-l2,#ddd)}
|
|
6116
|
+
[data-rw-ide-editor] [data-sidebar-right-mode],[data-rw-ide-editor] [data-sidebar-right-toggle]{display:none!important}
|
|
6117
|
+
[data-rw-ide-chat]{--dsh-chat-user-width:calc(var(--rw-ide-w) - 48px)!important;--dsh-conversation-column-width:var(--rw-ide-w)!important;border-left:1px solid var(--dsw-alias-border-l2,#ddd)}
|
|
6118
|
+
[data-rw-ide-chat] [data-conversation-content]{--dsh-chat-content-width:calc(var(--rw-ide-w) - 48px)!important;--dsh-composer-card-max-width:calc(var(--rw-ide-w) - 16px)!important}
|
|
6119
|
+
[data-rw-ide-chat] [data-conversation-header-leading]{display:none!important}
|
|
6120
|
+
[data-rw-ide-editor][data-rw-ide-hidden],[data-rw-ide-chat][data-rw-ide-hidden]{visibility:hidden!important;pointer-events:none!important}
|
|
6121
|
+
[data-rw-ide-navigation]{display:flex;gap:3px}
|
|
6122
|
+
[data-rw-ide-navigation] button[aria-pressed=true]{background:var(--dsw-alias-interactive-bg-hover,#eee);font-weight:600}
|
|
6123
|
+
@media(max-width:600px){[data-rw-ide-header]{gap:5px;padding:0 6px}[data-rw-ide-title]{display:none}[data-rw-ide-header] button{font-size:11px!important;padding:4px 6px!important}}
|
|
6124
|
+
`
|
|
6125
|
+
// Returns a disposer that restores only the attributes/variables we own.
|
|
6126
|
+
// No innerHTML, appendChild, React portal, clone or second conversation.
|
|
6127
|
+
function remoteIdeDock(node, kind) {
|
|
6128
|
+
const marker = 'data-rw-ide-' + kind
|
|
6129
|
+
const names = [marker, 'data-rw-ide-hidden', 'inert']
|
|
6130
|
+
const attrs = names.map(name => [name, node.getAttribute(name)])
|
|
6131
|
+
const vars = ['--rw-ide-x', '--rw-ide-y', '--rw-ide-w', '--rw-ide-h']
|
|
6132
|
+
const values = vars.map(name => [name, node.style.getPropertyValue(name), node.style.getPropertyPriority(name)])
|
|
6133
|
+
node.setAttribute(marker, '')
|
|
6134
|
+
return {
|
|
6135
|
+
node,
|
|
6136
|
+
position(rect, visible) {
|
|
6137
|
+
node.toggleAttribute('data-rw-ide-hidden', !visible)
|
|
6138
|
+
if (visible) {
|
|
6139
|
+
// Respect an original inert value, and otherwise remove our own.
|
|
6140
|
+
const original = attrs.find(([name]) => name === 'inert')[1]
|
|
6141
|
+
if (original == null) node.removeAttribute('inert')
|
|
6142
|
+
else node.setAttribute('inert', original)
|
|
6143
|
+
} else node.setAttribute('inert', '')
|
|
6144
|
+
const dimensions = [rect.left, rect.top, rect.width, rect.height]
|
|
6145
|
+
vars.forEach((name, i) => {
|
|
6146
|
+
const value = Math.max(0, dimensions[i]) + 'px'
|
|
6147
|
+
if (node.style.getPropertyValue(name) !== value) node.style.setProperty(name, value)
|
|
6148
|
+
})
|
|
6149
|
+
},
|
|
6150
|
+
dispose() {
|
|
6151
|
+
for (const [name, value] of attrs) { if (value == null) node.removeAttribute(name); else node.setAttribute(name, value) }
|
|
6152
|
+
for (const [name, value, priority] of values) { if (value) node.style.setProperty(name, value, priority); else node.style.removeProperty(name) }
|
|
6153
|
+
},
|
|
6154
|
+
}
|
|
6155
|
+
}
|
|
6156
|
+
function RemoteIdeShell() {
|
|
6157
|
+
const state = useRemoteIdeState()
|
|
6158
|
+
const [sessionId, setSessionId] = React.useState('')
|
|
6159
|
+
const [, refresh] = React.useState(0)
|
|
6160
|
+
const [width, setWidth] = React.useState(() => typeof window.innerWidth === 'number' ? window.innerWidth : 1280)
|
|
6161
|
+
const [mobilePane, setMobilePane] = React.useState('chat')
|
|
6162
|
+
const [availability, setAvailability] = React.useState({ chat: true, editor: true })
|
|
6163
|
+
const [expanded, setExpanded] = React.useState([])
|
|
6164
|
+
const editorSeat = React.useRef(null), chatSeat = React.useRef(null), shellRef = React.useRef(null)
|
|
6165
|
+
const dragCleanup = React.useRef(null)
|
|
6166
|
+
const controller = remoteIdeController
|
|
6167
|
+
const sizes = remoteIdeWidths(width, state)
|
|
6168
|
+
const mirror = sessionId ? mirrorForCwd(sessionCwdFor(sessionId), MIRRORS.list) : null
|
|
6169
|
+
const active = !!(state.enabled && sessionId && mirror && controller)
|
|
6170
|
+
React.useEffect(() => {
|
|
6171
|
+
const update = () => {
|
|
6172
|
+
setSessionId(String(controller?.mounted?.getSnapshot?.() || ''))
|
|
6173
|
+
refresh(n => n + 1)
|
|
6174
|
+
}
|
|
6175
|
+
const unsubscribers = []
|
|
6176
|
+
if (controller?.mounted?.subscribe) unsubscribers.push(controller.mounted.subscribe(update))
|
|
6177
|
+
if (SESSIONS?.list?.subscribe) unsubscribers.push(SESSIONS.list.subscribe(update))
|
|
6178
|
+
mirrorWatchers.add(update); ensureMirrors(); update()
|
|
6179
|
+
const onResize = () => setWidth(window.innerWidth)
|
|
6180
|
+
window.addEventListener('resize', onResize)
|
|
6181
|
+
return () => { unsubscribers.forEach(dispose => dispose?.()); mirrorWatchers.delete(update); window.removeEventListener('resize', onResize); dragCleanup.current?.() }
|
|
6182
|
+
}, [controller])
|
|
6183
|
+
React.useEffect(() => { setExpanded(explorerMemory.get(sessionId)?.expanded || []) }, [sessionId])
|
|
6184
|
+
React.useEffect(() => {
|
|
6185
|
+
if (!active) return
|
|
6186
|
+
const node = document.createElement('style')
|
|
6187
|
+
node.setAttribute('data-rw-ide-css', '')
|
|
6188
|
+
node.textContent = REMOTE_IDE_CSS
|
|
6189
|
+
document.head.appendChild(node)
|
|
6190
|
+
return () => node.remove()
|
|
6191
|
+
}, [active])
|
|
6192
|
+
React.useEffect(() => {
|
|
6193
|
+
if (!active || !editorSeat.current || !chatSeat.current) return
|
|
6194
|
+
let stopped = false, frame = 0, dockChat = null, dockEditor = null
|
|
6195
|
+
const wasExpanded = typeof controller.isExpanded === 'function' ? controller.isExpanded() : true
|
|
6196
|
+
// Use the public controller so aria-hidden, focus and the tab domain
|
|
6197
|
+
// agree. It reveals the EXISTING editor, without opening/replacing tabs.
|
|
6198
|
+
if (!wasExpanded && typeof controller.toggleExpanded === 'function') controller.toggleExpanded()
|
|
6199
|
+
const find = (selector, attribute) => [...document.querySelectorAll(selector)].find(node => node.getAttribute(attribute) === sessionId)
|
|
6200
|
+
const update = () => {
|
|
6201
|
+
frame = 0
|
|
6202
|
+
if (stopped) return
|
|
6203
|
+
if (!dockChat?.node.isConnected) {
|
|
6204
|
+
dockChat?.dispose()
|
|
6205
|
+
const content = find('[data-conversation-content][data-conversation-session]', 'data-conversation-session')
|
|
6206
|
+
const root = content?.closest('[data-phase]')
|
|
6207
|
+
dockChat = root ? remoteIdeDock(root, 'chat') : null
|
|
6208
|
+
}
|
|
6209
|
+
if (!dockEditor?.node.isConnected) {
|
|
6210
|
+
dockEditor?.dispose()
|
|
6211
|
+
const panel = find('[data-sidebar-right-panel][data-sidebar-right-session]', 'data-sidebar-right-session')
|
|
6212
|
+
dockEditor = panel ? remoteIdeDock(panel, 'editor') : null
|
|
6213
|
+
}
|
|
6214
|
+
const chatRect = chatSeat.current?.getBoundingClientRect()
|
|
6215
|
+
const editorRect = editorSeat.current?.getBoundingClientRect()
|
|
6216
|
+
if (dockChat && chatRect) dockChat.position(chatRect, chatRect.width > 0 && chatRect.height > 0)
|
|
6217
|
+
if (dockEditor && editorRect) dockEditor.position(editorRect, editorRect.width > 0 && editorRect.height > 0)
|
|
6218
|
+
const chat = !!dockChat
|
|
6219
|
+
const editor = !!dockEditor && dockEditor.node.getAttribute('aria-hidden') !== 'true'
|
|
6220
|
+
setAvailability(old => old.chat === chat && old.editor === editor ? old : { chat, editor })
|
|
6221
|
+
}
|
|
6222
|
+
const schedule = () => { if (!stopped && !frame) frame = window.requestAnimationFrame(update) }
|
|
6223
|
+
const observer = typeof ResizeObserver === 'function' ? new ResizeObserver(schedule) : null
|
|
6224
|
+
observer?.observe(editorSeat.current); observer?.observe(chatSeat.current)
|
|
6225
|
+
// React may replace roots during session navigation. Child-list changes
|
|
6226
|
+
// are coalesced; no text/attribute observer loops during token streaming.
|
|
6227
|
+
const mutations = typeof MutationObserver === 'function' ? new MutationObserver(() => {
|
|
6228
|
+
if (!dockChat?.node.isConnected || !dockEditor?.node.isConnected) schedule()
|
|
6229
|
+
}) : null
|
|
6230
|
+
mutations?.observe(document.body, { childList: true, subtree: true })
|
|
6231
|
+
const unsub = controller.openTabs?.subscribe?.(schedule)
|
|
6232
|
+
window.addEventListener('resize', schedule)
|
|
6233
|
+
update()
|
|
6234
|
+
return () => {
|
|
6235
|
+
stopped = true; if (frame) window.cancelAnimationFrame(frame)
|
|
6236
|
+
observer?.disconnect(); mutations?.disconnect(); unsub?.(); window.removeEventListener('resize', schedule)
|
|
6237
|
+
dockChat?.dispose(); dockEditor?.dispose()
|
|
6238
|
+
if (!wasExpanded && controller.mounted?.getSnapshot?.() === sessionId && controller.isExpanded?.()) controller.toggleExpanded?.()
|
|
6239
|
+
}
|
|
6240
|
+
}, [active, sessionId, controller, mobilePane, sizes.narrow])
|
|
6241
|
+
if (!active) return null
|
|
6242
|
+
const updateExpanded = fn => setExpanded(old => {
|
|
6243
|
+
const next = typeof fn === 'function' ? fn(old) : fn
|
|
6244
|
+
explorerMemory.set(sessionId, { ...explorerMemory.get(sessionId), expanded: next })
|
|
6245
|
+
return next
|
|
6246
|
+
})
|
|
6247
|
+
const resizeBy = (side, delta) => remoteIdeSet({ [side]: Math.max(side === 'left' ? 180 : 280, Math.min(side === 'left' ? 380 : 700, sizes[side] + delta)) })
|
|
6248
|
+
const divider = side => React.createElement('div', {
|
|
6249
|
+
key: side, role: 'separator', tabIndex: 0, 'aria-orientation': 'vertical',
|
|
6250
|
+
'aria-label': tr(side === 'left' ? 'ide.leftWidth' : 'ide.rightWidth'),
|
|
6251
|
+
'aria-valuemin': side === 'left' ? 180 : 280, 'aria-valuemax': side === 'left' ? 380 : 700,
|
|
6252
|
+
'aria-valuenow': sizes[side], 'data-rw-ide-divider': side,
|
|
6253
|
+
onDoubleClick: () => remoteIdeSet({ [side]: side === 'left' ? 240 : 400 }),
|
|
6254
|
+
onKeyDown: event => {
|
|
6255
|
+
if (!['ArrowLeft', 'ArrowRight', 'Home'].includes(event.key)) return
|
|
6256
|
+
event.preventDefault()
|
|
6257
|
+
if (event.key === 'Home') remoteIdeSet({ [side]: side === 'left' ? 240 : 400 })
|
|
6258
|
+
else resizeBy(side, (event.key === 'ArrowLeft' ? -16 : 16) * (side === 'left' ? 1 : -1))
|
|
6259
|
+
},
|
|
6260
|
+
onPointerDown: event => {
|
|
6261
|
+
if (event.button !== 0) return
|
|
6262
|
+
event.preventDefault(); dragCleanup.current?.()
|
|
6263
|
+
const start = event.clientX, initial = sizes[side]
|
|
6264
|
+
const move = e => remoteIdeSet({ [side]: Math.max(side === 'left' ? 180 : 280, Math.min(side === 'left' ? 380 : 700, initial + (e.clientX - start) * (side === 'left' ? 1 : -1))) })
|
|
6265
|
+
const end = () => { window.removeEventListener('pointermove', move); window.removeEventListener('pointerup', end); window.removeEventListener('pointercancel', end); dragCleanup.current = null }
|
|
6266
|
+
dragCleanup.current = end
|
|
6267
|
+
window.addEventListener('pointermove', move); window.addEventListener('pointerup', end); window.addEventListener('pointercancel', end)
|
|
6268
|
+
},
|
|
6269
|
+
})
|
|
6270
|
+
const openEditor = () => { if (!controller.isExpanded?.()) controller.toggleExpanded?.() }
|
|
6271
|
+
return React.createElement('section', { ref: shellRef, 'data-rw-ide-shell': sessionId, 'aria-label': tr('ide.enter') },
|
|
6272
|
+
React.createElement('header', { 'data-rw-ide-header': '' },
|
|
6273
|
+
React.createElement('span', { 'data-rw-ide-title': '', title: mirror.remotePath }, (mirror.name || mirror.host || '') + ' · ' + (String(mirror.remotePath || '').split(/[\\/]/).filter(Boolean).pop() || '/')),
|
|
6274
|
+
sizes.narrow ? React.createElement('nav', { 'data-rw-ide-navigation': '', 'aria-label': tr('ide.enter') }, ['files', 'editor', 'chat'].map(pane => React.createElement('button', {
|
|
6275
|
+
key: pane, type: 'button', style: { ...buttonS, padding: '4px 9px', fontSize: 12 },
|
|
6276
|
+
'aria-pressed': mobilePane === pane, onClick: () => setMobilePane(pane),
|
|
6277
|
+
}, tr({ files: 'ide.files', editor: 'ide.editor', chat: 'ide.chat' }[pane])))) : null,
|
|
6278
|
+
React.createElement('button', { type: 'button', 'data-rw-ide-exit': '', style: { ...buttonS, padding: '4px 9px', fontSize: 12 }, title: tr('ide.help'), onClick: () => remoteIdeSet({ enabled: false }) }, tr('ide.exit'))),
|
|
6279
|
+
React.createElement('div', { 'data-rw-ide-body': '', style: { gridTemplateColumns: sizes.narrow ? 'minmax(0,1fr)' : sizes.left + 'px 6px minmax(320px,1fr) 6px ' + sizes.right + 'px' } },
|
|
6280
|
+
React.createElement('aside', { 'data-rw-ide-tree': '', 'aria-label': tr('ide.files'), style: { display: sizes.narrow && mobilePane !== 'files' ? 'none' : undefined } },
|
|
6281
|
+
React.createElement(RemoteExplorerTab, {
|
|
6282
|
+
key: sessionId, scope: { sessionId }, visible: true, expanded,
|
|
6283
|
+
onToggleDir: path => updateExpanded(old => old.includes(path) ? old.filter(value => value !== path) : [...old, path]),
|
|
6284
|
+
onCollapseAll: () => updateExpanded([]),
|
|
6285
|
+
onOpenFile: (path, line) => { controller.openResourceIn(sessionId, remoteFileAddress(sessionId, path), Number.isSafeInteger(line) && line > 0 ? { params: { line } } : undefined); setMobilePane('editor') },
|
|
6286
|
+
onOpenChanges: () => { controller.openTabIn(sessionId, NATIVE_CHANGES); setMobilePane('editor') },
|
|
6287
|
+
})),
|
|
6288
|
+
sizes.narrow ? null : divider('left'),
|
|
6289
|
+
React.createElement('main', { ref: editorSeat, 'data-rw-ide-seat': 'editor', style: { display: sizes.narrow && mobilePane !== 'editor' ? 'none' : undefined } },
|
|
6290
|
+
React.createElement('div', { 'data-rw-ide-placeholder': '' }, tr('ide.chooseFile'), !availability.editor ? React.createElement('div', null, React.createElement('button', { type: 'button', style: buttonS, onClick: openEditor }, tr('ide.openEditor'))) : null)),
|
|
6291
|
+
sizes.narrow ? null : divider('right'),
|
|
6292
|
+
React.createElement('aside', { ref: chatSeat, 'data-rw-ide-seat': 'chat', 'aria-label': tr('ide.chat'), style: { display: sizes.narrow && mobilePane !== 'chat' ? 'none' : undefined } },
|
|
6293
|
+
!availability.chat ? React.createElement('p', { 'data-rw-ide-placeholder': '', role: 'status' }, tr('ide.unavailable')) : null)))
|
|
6294
|
+
}
|
|
6295
|
+
function installRemoteIde(ctx) {
|
|
6296
|
+
const slots = ctx.get('slots')
|
|
6297
|
+
slots.inject('conversation.session.header.actions', () => slots.register({ name: 'conversation.session.header.actions', id: 'dsh-remote-ide-toggle', order: 40 }, RemoteIdeToggle))
|
|
6298
|
+
ctx.inject(['sidebarRight'], inner => {
|
|
6299
|
+
const controller = inner.get('sidebarRight')
|
|
6300
|
+
remoteIdeController = controller
|
|
6301
|
+
inner.effect(() => () => { if (remoteIdeController === controller) remoteIdeController = null }, 'dsh-remote.ide-controller')
|
|
6302
|
+
slots.inject('shell.overlay', () => slots.register({ name: 'shell.overlay', id: 'dsh-remote-ide-shell', order: 10 }, RemoteIdeShell))
|
|
6303
|
+
})
|
|
6304
|
+
}
|
|
6305
|
+
|
|
5541
6306
|
function apply(ctx) {
|
|
5542
6307
|
ensureChromeCss()
|
|
5543
6308
|
const slots = ctx.get('slots')
|
|
@@ -5605,6 +6370,7 @@ window.__ModuleLoader__.load({
|
|
|
5605
6370
|
slots.inject('conversation.session.header.utilities', () =>
|
|
5606
6371
|
slots.register({ name: 'conversation.session.header.utilities', id: 'dsh-remote-remote-chip', order: 15 }, RemoteSessionChip),
|
|
5607
6372
|
)
|
|
6373
|
+
installRemoteIde(ctx)
|
|
5608
6374
|
}
|
|
5609
6375
|
|
|
5610
6376
|
exports.name = name
|