dsh-remote-vs 0.15.1 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +18 -10
- package/README.md +18 -10
- package/lib/client.js +1581 -18
- package/lib/index.js +692 -5
- package/lib/types/client/PortsView.d.ts +30 -0
- package/lib/types/client/ai-review.d.ts +116 -0
- package/lib/types/client/api.d.ts +29 -1
- package/lib/types/client/composer.d.ts +15 -0
- package/lib/types/client/drag-expand.d.ts +78 -0
- package/lib/types/client/store.d.ts +1 -1
- package/lib/types/forward.d.ts +114 -0
- package/lib/types/listen-ports.d.ts +56 -0
- package/lib/types/pool.d.ts +18 -0
- package/lib/types/protocol.d.ts +72 -0
- package/lib/types/routes.d.ts +7 -0
- package/package.json +1 -1
- package/src/client/PortsView.tsx +850 -0
- package/src/client/RemoteExplorer.tsx +201 -16
- package/src/client/RemoteRoot.tsx +7 -1
- package/src/client/ai-review.ts +428 -0
- package/src/client/api.ts +38 -0
- package/src/client/composer.ts +18 -0
- package/src/client/drag-expand.ts +128 -0
- package/src/client/i18n.ts +78 -0
- package/src/client/scm/CommitPane.tsx +71 -0
- package/src/client/scm/DiffView.tsx +85 -1
- package/src/client/store.tsx +2 -2
- package/src/client/vsc/vsc.css +183 -0
- package/src/forward.ts +445 -0
- package/src/index.ts +40 -1
- package/src/listen-ports.ts +241 -0
- package/src/pool.ts +63 -0
- package/src/protocol.ts +76 -0
- package/src/routes.ts +125 -0
package/src/client/i18n.ts
CHANGED
|
@@ -71,6 +71,7 @@ const zh: Record<string, string> = {
|
|
|
71
71
|
'tab.workspaces': '工作区',
|
|
72
72
|
'tab.files': '文件',
|
|
73
73
|
'tab.terminal': '终端',
|
|
74
|
+
'tab.ports': '端口',
|
|
74
75
|
'tab.remote': '远程',
|
|
75
76
|
'tab.remoteDesc': '远端文件、终端与 Git',
|
|
76
77
|
'hosts.title': '远程主机',
|
|
@@ -463,6 +464,15 @@ const zh: Record<string, string> = {
|
|
|
463
464
|
'scm.commitDiff': '提交差异',
|
|
464
465
|
'scm.checkoutCommitTitle': '检出提交(分离头指针)',
|
|
465
466
|
'scm.checkoutCommitText': '将把远端工作区切到 {hash},处于分离头指针状态。',
|
|
467
|
+
// -- AI 审查此 diff(只预填草稿,不自动发送)
|
|
468
|
+
'scm.aiReview': '让 AI 审查此 diff(只追加到对话草稿,不会自动发送)',
|
|
469
|
+
'scm.aiReviewNoSession': '当前会话与这个远端工作区没有绑定:绑定后才能把 diff 交给 AI 审查',
|
|
470
|
+
'scm.aiReviewNoContext': '插件上下文尚未就绪,暂时无法写入对话草稿',
|
|
471
|
+
'scm.aiReviewNoChannel': '当前宿主没有可用的对话输入通道,无法写入草稿(宿主版本可能不兼容)',
|
|
472
|
+
'scm.aiReviewAdded': '已追加到对话草稿,请检查后发送',
|
|
473
|
+
'scm.aiReviewAddedSummary': 'diff 较大(或已被截断),已按摘要方式追加到草稿,请检查后发送',
|
|
474
|
+
'scm.aiReviewAddedRead': '该文件没有可内嵌的 diff 文本(新增或未跟踪),已让 AI 自行读取,请检查后发送',
|
|
475
|
+
'scm.aiReviewFailed': '追加失败:当前会话的输入框不可用(可能正在发送或校验中),请稍后重试',
|
|
466
476
|
'history.filter': '过滤提交(信息 / 作者 / 哈希)',
|
|
467
477
|
'history.details': '提交详情',
|
|
468
478
|
'history.content': '内容',
|
|
@@ -490,6 +500,9 @@ const zh: Record<string, string> = {
|
|
|
490
500
|
'history.copyMessage': '复制提交信息',
|
|
491
501
|
'history.copyFilePatch': '复制该文件补丁',
|
|
492
502
|
'history.copyCommitPatch': '复制整个补丁',
|
|
503
|
+
// -- 按提交记录做 AI 审查(只预填草稿,不自动发送;v2)
|
|
504
|
+
'history.aiReview': '让 AI 审查此提交(只追加到对话草稿,不会自动发送)',
|
|
505
|
+
'history.aiReviewNoPatch': '该提交的 patch 尚未加载完成,或没有可内嵌的文本 diff',
|
|
493
506
|
'history.copiedMessage': '已复制提交信息',
|
|
494
507
|
'history.copiedHash': '已复制完整哈希',
|
|
495
508
|
'history.copiedSubject': '已复制提交标题',
|
|
@@ -599,12 +612,39 @@ const zh: Record<string, string> = {
|
|
|
599
612
|
'quickopen.noResults': '没有匹配的文件',
|
|
600
613
|
'quickopen.more': '匹配过多,请继续输入',
|
|
601
614
|
'quickopen.noWorkspace': '没有选定的远端工作区',
|
|
615
|
+
// -- 端口转发(ssh -L):把远端监听的端口映射到本机 127.0.0.1
|
|
616
|
+
'ports.selectHost': '选择主机',
|
|
617
|
+
'ports.refresh': '刷新',
|
|
618
|
+
'ports.remoteHost': '远端地址',
|
|
619
|
+
'ports.remotePort': '远端端口',
|
|
620
|
+
'ports.localPort': '本地端口(留空自动分配)',
|
|
621
|
+
'ports.add': '转发',
|
|
622
|
+
'ports.active': '已建转发',
|
|
623
|
+
'ports.listening': '远端监听端口',
|
|
624
|
+
'ports.emptyForwards': '还没有转发规则:上面的表单新建一条,或从下面的监听端口一键转发。',
|
|
625
|
+
'ports.noHosts': '还没有主机,请先去「设置 → 远程主机」配置。',
|
|
626
|
+
'ports.copyUrl': '复制本地 URL',
|
|
627
|
+
'ports.copied': '已复制',
|
|
628
|
+
'ports.open': '在浏览器中打开',
|
|
629
|
+
'ports.stop': '停止转发',
|
|
630
|
+
'ports.forward': '转发到本地',
|
|
631
|
+
'ports.stateListening': '监听中',
|
|
632
|
+
'ports.stateError': '连接失败',
|
|
633
|
+
'ports.connections': '{count} 个连接',
|
|
634
|
+
'ports.emptyListen': '远端没有列出监听端口。',
|
|
635
|
+
'ports.listenUnavailable': '无法枚举远端端口:远端既没有 ss 也没有 netstat。',
|
|
636
|
+
'ports.listenUnknown': '无法枚举远端端口:探测没有返回结果。',
|
|
637
|
+
'ports.badPort': '端口必须是 1–65535 的整数;本地端口留空表示自动分配。',
|
|
638
|
+
'ports.restoreFailed': '{count} 条已保存的转发规则未能恢复:本地端口可能被占用,或已超过每台主机的规则上限。',
|
|
639
|
+
'ports.forgetFailed': '移除这些规则',
|
|
640
|
+
'ports.remoteHostHint': '目标地址由远端主机拨号,可访问远端内网;本地监听只绑定 127.0.0.1。',
|
|
602
641
|
}
|
|
603
642
|
|
|
604
643
|
const en: Record<string, string> = {
|
|
605
644
|
'tab.workspaces': 'Workspaces',
|
|
606
645
|
'tab.files': 'Files',
|
|
607
646
|
'tab.terminal': 'Terminal',
|
|
647
|
+
'tab.ports': 'Ports',
|
|
608
648
|
'tab.remote': 'Remote',
|
|
609
649
|
'tab.remoteDesc': 'Remote files, terminal and Git',
|
|
610
650
|
'hosts.title': 'Remote hosts',
|
|
@@ -997,6 +1037,15 @@ const en: Record<string, string> = {
|
|
|
997
1037
|
'scm.commitDiff': 'commit diff',
|
|
998
1038
|
'scm.checkoutCommitTitle': 'Check out commit (detached HEAD)',
|
|
999
1039
|
'scm.checkoutCommitText': 'The remote working tree switches to {hash} in detached HEAD state.',
|
|
1040
|
+
// -- AI review of this diff (draft only: nothing is sent automatically)
|
|
1041
|
+
'scm.aiReview': 'Ask AI to review this diff (appends to the conversation draft; nothing is sent automatically)',
|
|
1042
|
+
'scm.aiReviewNoSession': 'No session is bound to this remote workspace — binding one is what lets the diff be handed to AI',
|
|
1043
|
+
'scm.aiReviewNoContext': 'The plugin context is not ready yet, so the draft cannot be written',
|
|
1044
|
+
'scm.aiReviewNoChannel': 'This host exposes no conversation input channel, so the draft cannot be written (the host version may be incompatible)',
|
|
1045
|
+
'scm.aiReviewAdded': 'Appended to the conversation draft — check it, then send',
|
|
1046
|
+
'scm.aiReviewAddedSummary': 'Large (or truncated) diff: appended as a summary — check it, then send',
|
|
1047
|
+
'scm.aiReviewAddedRead': 'This file has no inline diff (added or untracked), so AI was asked to read it — check the draft, then send',
|
|
1048
|
+
'scm.aiReviewFailed': 'Append failed: this session’s composer is not writable right now (it may be sending) — try again later',
|
|
1000
1049
|
'history.filter': 'Filter commits (message / author / hash)',
|
|
1001
1050
|
'history.details': 'Commit details',
|
|
1002
1051
|
'history.content': 'Contents',
|
|
@@ -1024,6 +1073,9 @@ const en: Record<string, string> = {
|
|
|
1024
1073
|
'history.copyMessage': 'Copy commit message',
|
|
1025
1074
|
'history.copyFilePatch': 'Copy file patch',
|
|
1026
1075
|
'history.copyCommitPatch': 'Copy whole patch',
|
|
1076
|
+
// -- AI review of a WHOLE commit (draft only: nothing is sent automatically; v2)
|
|
1077
|
+
'history.aiReview': 'Ask AI to review this commit (appends to the conversation draft; nothing is sent automatically)',
|
|
1078
|
+
'history.aiReviewNoPatch': 'This commit’s patch is not loaded yet, or it has no inline textual diff',
|
|
1027
1079
|
'history.copiedMessage': 'Commit message copied',
|
|
1028
1080
|
'history.copiedHash': 'Full hash copied',
|
|
1029
1081
|
'history.copiedSubject': 'Subject copied',
|
|
@@ -1133,6 +1185,32 @@ const en: Record<string, string> = {
|
|
|
1133
1185
|
'quickopen.noResults': 'No matching file',
|
|
1134
1186
|
'quickopen.more': 'Too many matches — keep typing',
|
|
1135
1187
|
'quickopen.noWorkspace': 'No remote workspace is selected',
|
|
1188
|
+
// -- Port forwards (ssh -L): map a remote listening port onto this machine
|
|
1189
|
+
'ports.selectHost': 'Select host',
|
|
1190
|
+
'ports.refresh': 'Refresh',
|
|
1191
|
+
'ports.remoteHost': 'Remote address',
|
|
1192
|
+
'ports.remotePort': 'Remote port',
|
|
1193
|
+
'ports.localPort': 'Local port (empty = auto)',
|
|
1194
|
+
'ports.add': 'Forward',
|
|
1195
|
+
'ports.active': 'Forwards',
|
|
1196
|
+
'ports.listening': 'Listening on the remote host',
|
|
1197
|
+
'ports.emptyForwards': 'No forwards yet — add one above, or forward a listening port below.',
|
|
1198
|
+
'ports.noHosts': 'No hosts yet. Configure one under Settings → Remote hosts first.',
|
|
1199
|
+
'ports.copyUrl': 'Copy local URL',
|
|
1200
|
+
'ports.copied': 'Copied',
|
|
1201
|
+
'ports.open': 'Open in browser',
|
|
1202
|
+
'ports.stop': 'Stop forward',
|
|
1203
|
+
'ports.forward': 'Forward to local',
|
|
1204
|
+
'ports.stateListening': 'Listening',
|
|
1205
|
+
'ports.stateError': 'Connection failed',
|
|
1206
|
+
'ports.connections': '{count} connection(s)',
|
|
1207
|
+
'ports.emptyListen': 'The remote host listed no listening ports.',
|
|
1208
|
+
'ports.listenUnavailable': 'Cannot enumerate remote ports: neither ss nor netstat is available on the host.',
|
|
1209
|
+
'ports.listenUnknown': 'Cannot enumerate remote ports: the probe did not answer.',
|
|
1210
|
+
'ports.badPort': 'Port must be an integer between 1 and 65535; leave the local port empty to auto-assign.',
|
|
1211
|
+
'ports.restoreFailed': '{count} saved forward(s) could not be restored — the local port may be taken, or the per-host rule limit reached.',
|
|
1212
|
+
'ports.forgetFailed': 'Forget these rules',
|
|
1213
|
+
'ports.remoteHostHint': 'The target is dialed from the remote host, so it can reach that host’s private network; the local listener binds 127.0.0.1 only.',
|
|
1136
1214
|
}
|
|
1137
1215
|
|
|
1138
1216
|
export type Lang = 'zh' | 'en'
|
|
@@ -30,6 +30,11 @@
|
|
|
30
30
|
import { useEffect, useMemo, useRef, useState, type KeyboardEvent, type MouseEvent, type ReactNode } from 'react'
|
|
31
31
|
import type { GitCommit, GitCommitFile } from '../../protocol.ts'
|
|
32
32
|
import type { Lang } from '../i18n.ts'
|
|
33
|
+
import { buildCommitReviewPrompt, diffByteLength, pickReviewMode } from '../ai-review.ts'
|
|
34
|
+
import { appendToDraft, canInsertDraft, sameLocalDir } from '../composer.ts'
|
|
35
|
+
import { GIT_CAP } from '../../git-ops.ts'
|
|
36
|
+
import { useExplorer } from '../store.tsx'
|
|
37
|
+
import { useRemoteChatTarget } from '../use-remote-chat-target.ts'
|
|
33
38
|
import {
|
|
34
39
|
ContextMenu,
|
|
35
40
|
FileIcon,
|
|
@@ -474,6 +479,61 @@ function DiffTab(props: CommitPaneProps & { hidden: boolean; wrap: boolean; onTo
|
|
|
474
479
|
}
|
|
475
480
|
const blockRefs = useRef(new Map<string, HTMLElement>())
|
|
476
481
|
const menu = useContextMenu()
|
|
482
|
+
|
|
483
|
+
// ------------------------------------------------- AI review (whole commit)
|
|
484
|
+
/**
|
|
485
|
+
* Hand THIS commit to the on-screen session as one review prompt (F6 v2).
|
|
486
|
+
*
|
|
487
|
+
* Same delivery rule as the single-file button in `DiffView`: draft only,
|
|
488
|
+
* never sent, and the same three reasons a click is refused. The patch is
|
|
489
|
+
* ALREADY in memory here (the 差异 tab renders with it), so this costs no
|
|
490
|
+
* extra remote round trip; `patchTruncated` comes from the loader that
|
|
491
|
+
* computed the byte cap — the one place that knows the read was cut.
|
|
492
|
+
*/
|
|
493
|
+
const store = useExplorer()
|
|
494
|
+
const chat = useRemoteChatTarget(store.ctx)
|
|
495
|
+
const viewedAliasPath = store.workspace === undefined ? undefined : store.aliasPaths[store.workspace.id]
|
|
496
|
+
const chatEnabled = chat.sessionId !== undefined
|
|
497
|
+
&& chat.sessionWorkspacePath !== undefined
|
|
498
|
+
&& viewedAliasPath !== undefined
|
|
499
|
+
&& sameLocalDir(chat.sessionWorkspacePath, viewedAliasPath)
|
|
500
|
+
let reviewBlocked: string | undefined
|
|
501
|
+
if (store.ctx === undefined) reviewBlocked = t('scm.aiReviewNoContext')
|
|
502
|
+
else if (!chatEnabled || chat.sessionId === undefined) reviewBlocked = t('scm.aiReviewNoSession')
|
|
503
|
+
else if (!canInsertDraft(store.ctx, chat.sessionId)) reviewBlocked = t('scm.aiReviewNoChannel')
|
|
504
|
+
else if (props.patch === undefined || props.patch === '') reviewBlocked = t('history.aiReviewNoPatch')
|
|
505
|
+
const reviewCommit = (): void => {
|
|
506
|
+
const ctx = store.ctx
|
|
507
|
+
const sessionId = chat.sessionId
|
|
508
|
+
if (reviewBlocked !== undefined || ctx === undefined || sessionId === undefined) {
|
|
509
|
+
toast(reviewBlocked ?? t('scm.aiReviewNoSession'), true)
|
|
510
|
+
return
|
|
511
|
+
}
|
|
512
|
+
const patch = props.patch ?? ''
|
|
513
|
+
// Bytes, not `.length`: the patch is a capped BYTE read (see `ai-review.ts`).
|
|
514
|
+
const bytes = diffByteLength(patch)
|
|
515
|
+
const capped = props.patchTruncated || bytes >= GIT_CAP
|
|
516
|
+
const mode = pickReviewMode({ bytes, hasDiff: patch !== '', capped })
|
|
517
|
+
const prompt = buildCommitReviewPrompt({
|
|
518
|
+
alias: store.alias,
|
|
519
|
+
root: store.repoRoot ?? store.root,
|
|
520
|
+
hash: props.commit.hash,
|
|
521
|
+
subject: props.commit.subject,
|
|
522
|
+
body: props.body,
|
|
523
|
+
files: props.files ?? [],
|
|
524
|
+
patch,
|
|
525
|
+
mode,
|
|
526
|
+
capped,
|
|
527
|
+
lang: props.lang,
|
|
528
|
+
})
|
|
529
|
+
if (!appendToDraft(ctx, sessionId, prompt)) {
|
|
530
|
+
toast(t('scm.aiReviewFailed'), true)
|
|
531
|
+
return
|
|
532
|
+
}
|
|
533
|
+
if (mode === 'full') toast(t('scm.aiReviewAdded'))
|
|
534
|
+
else if (mode === 'summary') toast(t('scm.aiReviewAddedSummary'))
|
|
535
|
+
else toast(t('scm.aiReviewAddedRead'))
|
|
536
|
+
}
|
|
477
537
|
const resolvedFocus = props.focusPath === undefined ? undefined : blockForPath(model, props.focusPath)
|
|
478
538
|
const currentPath = resolvedFocus ?? paths[0]
|
|
479
539
|
const currentIndex = currentPath === undefined ? -1 : paths.indexOf(currentPath)
|
|
@@ -558,6 +618,17 @@ function DiffTab(props: CommitPaneProps & { hidden: boolean; wrap: boolean; onTo
|
|
|
558
618
|
>
|
|
559
619
|
<IconCopy size={13} />
|
|
560
620
|
</IconButton>
|
|
621
|
+
{/* F6 v2: review the WHOLE commit (every file in one prompt) — the
|
|
622
|
+
history pane's counterpart of the single-file button in `DiffView`.
|
|
623
|
+
Text glyph for the same reason as there: the icon set has no "AI"
|
|
624
|
+
mark, and the `Aa` / `.*` marks set the precedent. */}
|
|
625
|
+
<IconButton
|
|
626
|
+
title={reviewBlocked ?? t('history.aiReview')}
|
|
627
|
+
onClick={reviewCommit}
|
|
628
|
+
disabled={reviewBlocked !== undefined}
|
|
629
|
+
>
|
|
630
|
+
<span className="rvs-glyph" aria-hidden="true" style={{ fontSize: 12 }}>AI</span>
|
|
631
|
+
</IconButton>
|
|
561
632
|
</div>
|
|
562
633
|
<div className="rvs-pscroll rvs-scroll">
|
|
563
634
|
{diffBody(props, model, blocks, props.wrap, folded, toggleFold, register, openBlockMenu)}
|
|
@@ -22,9 +22,11 @@ import { useExplorer } from '../store.tsx'
|
|
|
22
22
|
import { applyHunk, GitOpError } from './actions.ts'
|
|
23
23
|
import { diffCounts, hunkAtRow, stepHunk } from './diff-model.ts'
|
|
24
24
|
import type { DiffRow } from '../../protocol.ts'
|
|
25
|
+
import { GIT_CAP } from '../../git-ops.ts'
|
|
25
26
|
import { api } from '../api.ts'
|
|
26
27
|
import { CodeEditor, type CodeEditorHandle } from '../CodeEditor.tsx'
|
|
27
|
-
import {
|
|
28
|
+
import { buildReviewPrompt, diffByteLength, pickReviewMode, reviewScopeOf } from '../ai-review.ts'
|
|
29
|
+
import { appendToDraft, canInsertDraft, sameLocalDir } from '../composer.ts'
|
|
28
30
|
import { useRemoteChatTarget } from '../use-remote-chat-target.ts'
|
|
29
31
|
import { langFromPath, tokenizeDocument, type Token } from '../vsc/tokenize.ts'
|
|
30
32
|
import {
|
|
@@ -421,6 +423,26 @@ export function DiffView(props: { tab: EditorTab; visible: boolean; offline?: bo
|
|
|
421
423
|
&& viewedAliasPath !== undefined
|
|
422
424
|
&& sameLocalDir(chat.sessionWorkspacePath, viewedAliasPath)
|
|
423
425
|
|
|
426
|
+
/**
|
|
427
|
+
* Why the "AI review" button cannot run, or `undefined` when it can.
|
|
428
|
+
*
|
|
429
|
+
* Three different absences, three different sentences, checked from the most
|
|
430
|
+
* fundamental down:
|
|
431
|
+
* - `store.ctx`: the shared store boots asynchronously, so before it lands
|
|
432
|
+
* there is nothing to write into at all;
|
|
433
|
+
* - `chatEnabled`: the same binding gate the selection popup uses — a prompt
|
|
434
|
+
* that names a remote path means nothing in a session that does not live in
|
|
435
|
+
* this binding;
|
|
436
|
+
* - `canInsertDraft`: the conversation service is a SOFT, version-dependent
|
|
437
|
+
* read. A host that does not expose it must say so up front instead of
|
|
438
|
+
* failing on click with the "composer is busy" sentence, which would name
|
|
439
|
+
* the wrong cause.
|
|
440
|
+
*/
|
|
441
|
+
let reviewBlocked: string | undefined
|
|
442
|
+
if (store.ctx === undefined) reviewBlocked = t('scm.aiReviewNoContext')
|
|
443
|
+
else if (!chatEnabled || chat.sessionId === undefined) reviewBlocked = t('scm.aiReviewNoSession')
|
|
444
|
+
else if (!canInsertDraft(store.ctx, chat.sessionId)) reviewBlocked = t('scm.aiReviewNoChannel')
|
|
445
|
+
|
|
424
446
|
// Seed the editable buffer the first time the "变更后" pane is shown.
|
|
425
447
|
useEffect(() => {
|
|
426
448
|
if (mode !== 'after' || tab.staged || tab.text !== '' || tab.loading) return
|
|
@@ -514,6 +536,56 @@ export function DiffView(props: { tab: EditorTab; visible: boolean; offline?: bo
|
|
|
514
536
|
await store.reloadTab(tab.id)
|
|
515
537
|
}
|
|
516
538
|
|
|
539
|
+
/**
|
|
540
|
+
* Append an AI-review prompt for THIS tab's diff to the composer draft (F6).
|
|
541
|
+
*
|
|
542
|
+
* v1 stops at the DRAFT on purpose: `appendToDraft` is the only delivery
|
|
543
|
+
* channel used here — no `submit`/`send` call — so the user always sees the
|
|
544
|
+
* exact prompt (and can edit or discard it) before anything costs a turn. The
|
|
545
|
+
* host does expose submit facades (see `docs/.feasibility/review.md` §2);
|
|
546
|
+
* wiring them is a separate, opt-in feature.
|
|
547
|
+
*
|
|
548
|
+
* The prompt is built on CLICK, not during render: `diffByteLength` encodes
|
|
549
|
+
* the whole diff and the prompt can be tens of kilobytes, which must not be
|
|
550
|
+
* recomputed per frame while the user scrolls the diff.
|
|
551
|
+
*/
|
|
552
|
+
const reviewWithAi = (): void => {
|
|
553
|
+
const ctx = store.ctx
|
|
554
|
+
const sessionId = chat.sessionId
|
|
555
|
+
if (reviewBlocked !== undefined || ctx === undefined || sessionId === undefined) {
|
|
556
|
+
toast(reviewBlocked ?? t('scm.aiReviewNoSession'), true)
|
|
557
|
+
return
|
|
558
|
+
}
|
|
559
|
+
// Byte accounting, not `diff.length`: `GIT_CAP` is a `head -c` BYTE cap and
|
|
560
|
+
// the exec result does not flag the truncation (see `ai-review.ts`).
|
|
561
|
+
const diff = tab.diff?.diff ?? ''
|
|
562
|
+
const bytes = diffByteLength(diff)
|
|
563
|
+
const capped = bytes >= GIT_CAP
|
|
564
|
+
const mode = pickReviewMode({ bytes, hasDiff: diff !== '', capped })
|
|
565
|
+
const prompt = buildReviewPrompt({
|
|
566
|
+
alias: store.alias,
|
|
567
|
+
root: store.repoRoot ?? store.root,
|
|
568
|
+
rel: tab.rel,
|
|
569
|
+
fullPath: tab.fullPath,
|
|
570
|
+
scope: reviewScopeOf(tab.staged, tab.ref),
|
|
571
|
+
...(tab.ref === undefined ? {} : { commitRef: tab.ref }),
|
|
572
|
+
diff,
|
|
573
|
+
mode,
|
|
574
|
+
capped,
|
|
575
|
+
lang,
|
|
576
|
+
})
|
|
577
|
+
if (!appendToDraft(ctx, sessionId, prompt)) {
|
|
578
|
+
toast(t('scm.aiReviewFailed'), true)
|
|
579
|
+
return
|
|
580
|
+
}
|
|
581
|
+
// One sentence per shape, because the three mean different things and the
|
|
582
|
+
// "large diff" wording would be a lie for a file that has no diff at all
|
|
583
|
+
// (untracked / new: the prompt asks the model to read the file itself).
|
|
584
|
+
if (mode === 'full') toast(t('scm.aiReviewAdded'))
|
|
585
|
+
else if (mode === 'summary') toast(t('scm.aiReviewAddedSummary'))
|
|
586
|
+
else toast(t('scm.aiReviewAddedRead'))
|
|
587
|
+
}
|
|
588
|
+
|
|
517
589
|
if (tab.error !== undefined) {
|
|
518
590
|
return (
|
|
519
591
|
<div className="rvs-diff">
|
|
@@ -578,6 +650,18 @@ export function DiffView(props: { tab: EditorTab; visible: boolean; offline?: bo
|
|
|
578
650
|
</span>
|
|
579
651
|
)}
|
|
580
652
|
{busy && <MiniSpinner />}
|
|
653
|
+
{/* F6: hand THIS diff to the on-screen session as a review prompt. It
|
|
654
|
+
only fills the composer draft (see `reviewWithAi`); the title carries
|
|
655
|
+
the exact reason whenever the binding gate refuses. The glyph is
|
|
656
|
+
text because the icon set has no "AI" mark — the same precedent as
|
|
657
|
+
the search options' `Aa` / `.*` glyphs in `kit.tsx`. */}
|
|
658
|
+
<IconButton
|
|
659
|
+
title={reviewBlocked ?? t('scm.aiReview')}
|
|
660
|
+
onClick={reviewWithAi}
|
|
661
|
+
disabled={reviewBlocked !== undefined}
|
|
662
|
+
>
|
|
663
|
+
<span className="rvs-glyph" aria-hidden="true" style={{ fontSize: 12 }}>AI</span>
|
|
664
|
+
</IconButton>
|
|
581
665
|
<IconButton title={t('scm.reloadDiff')} onClick={() => { void reload() }} disabled={busy}>
|
|
582
666
|
<IconRefresh size={13} />
|
|
583
667
|
</IconButton>
|
package/src/client/store.tsx
CHANGED
|
@@ -219,7 +219,7 @@ interface State {
|
|
|
219
219
|
}
|
|
220
220
|
|
|
221
221
|
/** The sidebar rail destinations. */
|
|
222
|
-
export type RailView = 'explorer' | 'search' | 'scm' | 'history' | 'editor' | 'terminal' | 'workspaces'
|
|
222
|
+
export type RailView = 'explorer' | 'search' | 'scm' | 'history' | 'editor' | 'terminal' | 'ports' | 'workspaces'
|
|
223
223
|
|
|
224
224
|
/** One "search this folder" request coming from the tree. */
|
|
225
225
|
export interface SearchRequest {
|
|
@@ -415,7 +415,7 @@ function readStoredView(): RailView {
|
|
|
415
415
|
try {
|
|
416
416
|
const saved = localStorage.getItem(VIEW_KEY)
|
|
417
417
|
if (saved === 'explorer' || saved === 'search' || saved === 'scm' || saved === 'history'
|
|
418
|
-
|| saved === 'editor' || saved === 'terminal' || saved === 'workspaces') {
|
|
418
|
+
|| saved === 'editor' || saved === 'terminal' || saved === 'ports' || saved === 'workspaces') {
|
|
419
419
|
return saved
|
|
420
420
|
}
|
|
421
421
|
} catch {
|
package/src/client/vsc/vsc.css
CHANGED
|
@@ -3982,6 +3982,188 @@ body[data-ds-dark-theme] .rvs-execpanel {
|
|
|
3982
3982
|
|
|
3983
3983
|
|
|
3984
3984
|
|
|
3985
|
+
/* ------------------------------------------------------------ port forwards */
|
|
3986
|
+
|
|
3987
|
+
/**
|
|
3988
|
+
* The port panel: one form above two lists, all inside the sidebar column.
|
|
3989
|
+
*
|
|
3990
|
+
* The column can be dragged very narrow, so nothing here may assume a width: an
|
|
3991
|
+
* address/URL is ONE unbreakable token (`overflow-wrap: anywhere`), the action
|
|
3992
|
+
* row wraps instead of overflowing, and the form stacks vertically — a
|
|
3993
|
+
* three-input row is unusable at the panel's default width.
|
|
3994
|
+
*/
|
|
3995
|
+
.rvs-ports-body {
|
|
3996
|
+
flex: 1;
|
|
3997
|
+
min-height: 0;
|
|
3998
|
+
overflow: auto;
|
|
3999
|
+
padding: 8px 8px 14px;
|
|
4000
|
+
}
|
|
4001
|
+
|
|
4002
|
+
/**
|
|
4003
|
+
* The restore-failure banner: one sentence plus the "forget these rules"
|
|
4004
|
+
* action, side by side when there is room and stacked when the column is very
|
|
4005
|
+
* narrow (the action must never squeeze the explanation into a sliver).
|
|
4006
|
+
*/
|
|
4007
|
+
.rvs-ports-restore {
|
|
4008
|
+
display: flex;
|
|
4009
|
+
align-items: center;
|
|
4010
|
+
flex-wrap: wrap;
|
|
4011
|
+
gap: 6px;
|
|
4012
|
+
}
|
|
4013
|
+
|
|
4014
|
+
.rvs-ports-form {
|
|
4015
|
+
display: flex;
|
|
4016
|
+
flex-direction: column;
|
|
4017
|
+
gap: 6px;
|
|
4018
|
+
padding: 8px;
|
|
4019
|
+
border: 1px solid var(--rvs-border2);
|
|
4020
|
+
border-radius: 8px;
|
|
4021
|
+
}
|
|
4022
|
+
|
|
4023
|
+
.rvs-ports-field {
|
|
4024
|
+
display: flex;
|
|
4025
|
+
flex-direction: column;
|
|
4026
|
+
gap: 3px;
|
|
4027
|
+
min-width: 0;
|
|
4028
|
+
}
|
|
4029
|
+
|
|
4030
|
+
.rvs-ports-label {
|
|
4031
|
+
color: var(--rvs-fg3);
|
|
4032
|
+
font-size: 11px;
|
|
4033
|
+
}
|
|
4034
|
+
|
|
4035
|
+
/* `.rvs-input` carries `flex: 1`; in a COLUMN flex parent that would stretch
|
|
4036
|
+
the field's HEIGHT, so the input fills the width and keeps its own height. */
|
|
4037
|
+
.rvs-ports-input {
|
|
4038
|
+
flex: none;
|
|
4039
|
+
width: 100%;
|
|
4040
|
+
box-sizing: border-box;
|
|
4041
|
+
}
|
|
4042
|
+
|
|
4043
|
+
.rvs-ports-form-actions {
|
|
4044
|
+
display: flex;
|
|
4045
|
+
justify-content: flex-end;
|
|
4046
|
+
}
|
|
4047
|
+
|
|
4048
|
+
.rvs-ports-section {
|
|
4049
|
+
margin-top: 12px;
|
|
4050
|
+
border-top: 1px solid var(--rvs-border);
|
|
4051
|
+
}
|
|
4052
|
+
|
|
4053
|
+
.rvs-ports-sec-head {
|
|
4054
|
+
display: flex;
|
|
4055
|
+
align-items: center;
|
|
4056
|
+
gap: 6px;
|
|
4057
|
+
height: 26px;
|
|
4058
|
+
padding: 0 4px;
|
|
4059
|
+
color: var(--rvs-fg2);
|
|
4060
|
+
font-size: 11px;
|
|
4061
|
+
font-weight: 700;
|
|
4062
|
+
letter-spacing: .04em;
|
|
4063
|
+
text-transform: uppercase;
|
|
4064
|
+
user-select: none;
|
|
4065
|
+
}
|
|
4066
|
+
|
|
4067
|
+
.rvs-ports-count {
|
|
4068
|
+
padding: 0 6px;
|
|
4069
|
+
border-radius: 999px;
|
|
4070
|
+
background: var(--rvs-hover);
|
|
4071
|
+
color: var(--rvs-fg3);
|
|
4072
|
+
font-size: 10.5px;
|
|
4073
|
+
letter-spacing: 0;
|
|
4074
|
+
}
|
|
4075
|
+
|
|
4076
|
+
.rvs-ports-row {
|
|
4077
|
+
display: flex;
|
|
4078
|
+
flex-direction: column;
|
|
4079
|
+
gap: 3px;
|
|
4080
|
+
min-width: 0;
|
|
4081
|
+
padding: 6px 6px 7px;
|
|
4082
|
+
border-radius: 6px;
|
|
4083
|
+
}
|
|
4084
|
+
|
|
4085
|
+
.rvs-ports-row:hover {
|
|
4086
|
+
background: var(--rvs-hover);
|
|
4087
|
+
}
|
|
4088
|
+
|
|
4089
|
+
.rvs-ports-line {
|
|
4090
|
+
display: flex;
|
|
4091
|
+
align-items: baseline;
|
|
4092
|
+
gap: 6px;
|
|
4093
|
+
min-width: 0;
|
|
4094
|
+
}
|
|
4095
|
+
|
|
4096
|
+
.rvs-ports-addr {
|
|
4097
|
+
flex: 1;
|
|
4098
|
+
min-width: 0;
|
|
4099
|
+
overflow-wrap: anywhere;
|
|
4100
|
+
color: var(--rvs-fg);
|
|
4101
|
+
font-family: var(--rvs-mono);
|
|
4102
|
+
font-size: 11.5px;
|
|
4103
|
+
line-height: 1.45;
|
|
4104
|
+
}
|
|
4105
|
+
|
|
4106
|
+
.rvs-ports-proc {
|
|
4107
|
+
flex: 0 1 auto;
|
|
4108
|
+
min-width: 0;
|
|
4109
|
+
overflow: hidden;
|
|
4110
|
+
text-overflow: ellipsis;
|
|
4111
|
+
white-space: nowrap;
|
|
4112
|
+
color: var(--rvs-fg3);
|
|
4113
|
+
font-size: 11px;
|
|
4114
|
+
}
|
|
4115
|
+
|
|
4116
|
+
/* State is never colour-only: the dot carries the state word as its label. */
|
|
4117
|
+
.rvs-ports-dot {
|
|
4118
|
+
flex: none;
|
|
4119
|
+
width: 7px;
|
|
4120
|
+
height: 7px;
|
|
4121
|
+
border-radius: 50%;
|
|
4122
|
+
background: var(--rvs-fg3);
|
|
4123
|
+
}
|
|
4124
|
+
|
|
4125
|
+
.rvs-ports-dot.listening {
|
|
4126
|
+
background: var(--rvs-ok, #2ea043);
|
|
4127
|
+
}
|
|
4128
|
+
|
|
4129
|
+
.rvs-ports-dot.error {
|
|
4130
|
+
background: var(--rvs-danger);
|
|
4131
|
+
}
|
|
4132
|
+
|
|
4133
|
+
.rvs-ports-conn {
|
|
4134
|
+
color: var(--rvs-fg3);
|
|
4135
|
+
font-size: 11px;
|
|
4136
|
+
white-space: nowrap;
|
|
4137
|
+
}
|
|
4138
|
+
|
|
4139
|
+
.rvs-ports-err {
|
|
4140
|
+
color: var(--rvs-danger);
|
|
4141
|
+
font-size: 11px;
|
|
4142
|
+
line-height: 1.45;
|
|
4143
|
+
overflow-wrap: anywhere;
|
|
4144
|
+
}
|
|
4145
|
+
|
|
4146
|
+
.rvs-ports-actions {
|
|
4147
|
+
display: flex;
|
|
4148
|
+
align-items: center;
|
|
4149
|
+
flex-wrap: wrap;
|
|
4150
|
+
gap: 2px;
|
|
4151
|
+
min-width: 0;
|
|
4152
|
+
}
|
|
4153
|
+
|
|
4154
|
+
/* The "open" affordance is a real link styled as a header button. */
|
|
4155
|
+
.rvs-ports-open {
|
|
4156
|
+
text-decoration: none;
|
|
4157
|
+
}
|
|
4158
|
+
|
|
4159
|
+
.rvs-ports-hint {
|
|
4160
|
+
margin-top: 4px;
|
|
4161
|
+
color: var(--rvs-fg3);
|
|
4162
|
+
font-size: 11px;
|
|
4163
|
+
line-height: 1.45;
|
|
4164
|
+
overflow-wrap: anywhere;
|
|
4165
|
+
}
|
|
4166
|
+
|
|
3985
4167
|
/* ------------------------------------------------------ Ctrl+P quick open */
|
|
3986
4168
|
|
|
3987
4169
|
.rvs-qo-mask {
|
|
@@ -4147,3 +4329,4 @@ body[data-ds-dark-theme] .rvs-execpanel {
|
|
|
4147
4329
|
.rvs-qo-note.warn {
|
|
4148
4330
|
color: var(--rvs-git-m);
|
|
4149
4331
|
}
|
|
4332
|
+
|