@deepseek-harness-tui/dsh-tui 0.17.0 → 0.18.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.md +10 -8
- package/cli/adapters/dsh/index.mjs +2 -2
- package/guide/dsh-tui-guide/cli.en.md +1 -1
- package/guide/dsh-tui-guide/cli.md +1 -1
- package/guide/dsh-tui-guide/configuration.en.md +3 -2
- package/guide/dsh-tui-guide/configuration.md +3 -2
- package/guide/dsh-tui-guide/getting-started.en.md +6 -2
- package/guide/dsh-tui-guide/getting-started.md +4 -1
- package/guide/dsh-tui-guide/interaction.en.md +28 -7
- package/guide/dsh-tui-guide/interaction.md +17 -5
- package/guide/dsh-tui-guide/plugins.en.md +28 -7
- package/guide/dsh-tui-guide/plugins.md +18 -5
- package/guide/dsh-tui-guide/user-guide.en.md +29 -15
- package/guide/dsh-tui-guide/user-guide.md +20 -10
- package/lib/settings.json +3 -3
- package/lib/types/adapter/channel/ui-policy.d.ts +1 -0
- package/lib/types/adapter/channel/ui-policy.d.ts.map +1 -1
- package/lib/types/adapter/channel/ui-policy.js +1 -0
- package/lib/types/adapter/ports/channel-ui.d.ts +5 -0
- package/lib/types/adapter/ports/channel-ui.d.ts.map +1 -1
- package/lib/types/adapter/ports/channel-view.d.ts +3 -0
- package/lib/types/adapter/ports/channel-view.d.ts.map +1 -1
- package/lib/types/adapter/standard/grants.d.ts +60 -0
- package/lib/types/adapter/standard/grants.d.ts.map +1 -1
- package/lib/types/adapter/standard/grants.js +74 -0
- package/lib/types/agent/events.d.ts +7 -1
- package/lib/types/agent/events.d.ts.map +1 -1
- package/lib/types/commands.js +1 -1
- package/lib/types/components/GoalTodoPanel.d.ts +71 -6
- package/lib/types/components/GoalTodoPanel.d.ts.map +1 -1
- package/lib/types/components/GoalTodoPanel.js +165 -17
- package/lib/types/components/MessageList.d.ts.map +1 -1
- package/lib/types/components/MessageList.js +3 -2
- package/lib/types/components/PluginGrantList.d.ts +45 -0
- package/lib/types/components/PluginGrantList.d.ts.map +1 -0
- package/lib/types/components/PluginGrantList.js +126 -0
- package/lib/types/components/PluginInstallPane.d.ts.map +1 -1
- package/lib/types/components/PluginInstallPane.js +35 -6
- package/lib/types/components/PluginManagePane.d.ts.map +1 -1
- package/lib/types/components/PluginManagePane.js +65 -8
- package/lib/types/components/PromptInput.js +2 -2
- package/lib/types/components/SubagentDashboard.d.ts.map +1 -1
- package/lib/types/components/SubagentDashboard.js +10 -0
- package/lib/types/components/SubagentDetailScene.d.ts.map +1 -1
- package/lib/types/components/SubagentDetailScene.js +12 -0
- package/lib/types/components/messages/AssistantToolUseMessage.d.ts +2 -1
- package/lib/types/components/messages/AssistantToolUseMessage.d.ts.map +1 -1
- package/lib/types/components/messages/AssistantToolUseMessage.js +11 -5
- package/lib/types/components/onboardingModel.d.ts +2 -2
- package/lib/types/components/onboardingModel.js +3 -3
- package/lib/types/components/onboardingProviderPlan.d.ts +110 -0
- package/lib/types/components/onboardingProviderPlan.d.ts.map +1 -0
- package/lib/types/components/onboardingProviderPlan.js +78 -0
- package/lib/types/components/sidePanel/btw/BtwComposer.d.ts +7 -0
- package/lib/types/components/sidePanel/btw/BtwComposer.d.ts.map +1 -1
- package/lib/types/components/sidePanel/btw/BtwComposer.js +16 -0
- package/lib/types/components/sidePanel/btw/BtwPanelAdapter.d.ts.map +1 -1
- package/lib/types/components/sidePanel/btw/BtwPanelAdapter.js +8 -1
- package/lib/types/components/sidePanel/btw/BtwThreadScene.d.ts +7 -1
- package/lib/types/components/sidePanel/btw/BtwThreadScene.d.ts.map +1 -1
- package/lib/types/components/sidePanel/btw/BtwThreadScene.js +8 -1
- package/lib/types/components/sidePanel/btw/useBtwComposerPaste.d.ts +30 -0
- package/lib/types/components/sidePanel/btw/useBtwComposerPaste.d.ts.map +1 -0
- package/lib/types/components/sidePanel/btw/useBtwComposerPaste.js +94 -0
- package/lib/types/components/sidePanel/builtinPanels.d.ts.map +1 -1
- package/lib/types/components/sidePanel/builtinPanels.js +14 -2
- package/lib/types/components/sidePanel/types.d.ts +2 -0
- package/lib/types/components/sidePanel/types.d.ts.map +1 -1
- package/lib/types/components/sidePanel/useSidePanel.d.ts.map +1 -1
- package/lib/types/components/sidePanel/useSidePanel.js +15 -1
- package/lib/types/dsh-adapter/backend/session.d.ts +7 -1
- package/lib/types/dsh-adapter/backend/session.d.ts.map +1 -1
- package/lib/types/dsh-adapter/backend/session.js +62 -6
- package/lib/types/dsh-adapter/backend/translate.d.ts.map +1 -1
- package/lib/types/dsh-adapter/backend/translate.js +9 -5
- package/lib/types/dsh-adapter/channel/agent-view-projection.d.ts +1 -1
- package/lib/types/dsh-adapter/channel/agent-view-projection.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/agent-view-projection.js +3 -1
- package/lib/types/dsh-adapter/channel/composer-images.d.ts +2 -0
- package/lib/types/dsh-adapter/channel/composer-images.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/composer-images.js +10 -2
- package/lib/types/dsh-adapter/channel/composer-mentions.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/composer-mentions.js +22 -7
- package/lib/types/dsh-adapter/channel/context-bookkeeping.d.ts +1 -1
- package/lib/types/dsh-adapter/channel/context-bookkeeping.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/context-bookkeeping.js +9 -5
- package/lib/types/dsh-adapter/channel/core/binding-feed.d.ts +6 -0
- package/lib/types/dsh-adapter/channel/core/binding-feed.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/core/binding-feed.js +35 -1
- package/lib/types/dsh-adapter/channel/core/compose.d.ts +1 -1
- package/lib/types/dsh-adapter/channel/core/compose.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/core/compose.js +5 -0
- package/lib/types/dsh-adapter/channel/input-actions.d.ts +2 -2
- package/lib/types/dsh-adapter/channel/input-actions.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/input-actions.js +30 -0
- package/lib/types/dsh-adapter/channel/input-delivery.d.ts +1 -1
- package/lib/types/dsh-adapter/channel/input-delivery.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/input-delivery.js +8 -4
- package/lib/types/dsh-adapter/channel/mentions.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/mentions.js +21 -7
- package/lib/types/dsh-adapter/channel/paths.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/paths.js +11 -9
- package/lib/types/dsh-adapter/channel/session-live-adoption.d.ts +1 -1
- package/lib/types/dsh-adapter/channel/session-live-adoption.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/session-live-adoption.js +6 -1
- package/lib/types/dsh-adapter/channel/session-reset.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/session-reset.js +3 -1
- package/lib/types/dsh-adapter/channel/session-resume.d.ts +1 -1
- package/lib/types/dsh-adapter/channel/session-resume.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/session-resume.js +10 -3
- package/lib/types/dsh-adapter/channel/session-rewind.d.ts +1 -1
- package/lib/types/dsh-adapter/channel/session-rewind.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/session-rewind.js +3 -1
- package/lib/types/dsh-adapter/channel/session-tree-actions.d.ts +1 -1
- package/lib/types/dsh-adapter/channel/session-tree-actions.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/session-tree-actions.js +3 -1
- package/lib/types/dsh-adapter/contract.d.ts +4 -3
- package/lib/types/dsh-adapter/contract.d.ts.map +1 -1
- package/lib/types/dsh-adapter/contract.js +6 -3
- package/lib/types/dsh-adapter/entry-slot.d.ts +6 -0
- package/lib/types/dsh-adapter/entry-slot.d.ts.map +1 -1
- package/lib/types/dsh-adapter/experimental-bundles.d.ts +3 -0
- package/lib/types/dsh-adapter/experimental-bundles.d.ts.map +1 -1
- package/lib/types/dsh-adapter/experimental-bundles.js +4 -0
- package/lib/types/dsh-adapter/grant-file.d.ts +70 -0
- package/lib/types/dsh-adapter/grant-file.d.ts.map +1 -0
- package/lib/types/dsh-adapter/grant-file.js +178 -0
- package/lib/types/dsh-adapter/host-access.d.ts +4 -0
- package/lib/types/dsh-adapter/host-access.d.ts.map +1 -1
- package/lib/types/dsh-adapter/host-access.js +54 -4
- package/lib/types/dsh-adapter/host-contract.d.ts +1 -1
- package/lib/types/dsh-adapter/host-contract.js +2 -2
- package/lib/types/dsh-adapter/host-dsh.js +3 -3
- package/lib/types/dsh-adapter/index.d.ts.map +1 -1
- package/lib/types/dsh-adapter/index.js +8 -5
- package/lib/types/dsh-adapter/panels.d.ts +7 -1
- package/lib/types/dsh-adapter/panels.d.ts.map +1 -1
- package/lib/types/dsh-adapter/plugin-declaration.d.ts +28 -0
- package/lib/types/dsh-adapter/plugin-declaration.d.ts.map +1 -1
- package/lib/types/dsh-adapter/plugin-declaration.js +43 -1
- package/lib/types/dsh-adapter/plugin-install.d.ts +28 -1
- package/lib/types/dsh-adapter/plugin-install.d.ts.map +1 -1
- package/lib/types/dsh-adapter/plugin-install.js +160 -13
- package/lib/types/dsh-adapter/plugin-manage.d.ts +53 -10
- package/lib/types/dsh-adapter/plugin-manage.d.ts.map +1 -1
- package/lib/types/dsh-adapter/plugin-manage.js +240 -51
- package/lib/types/dsh-adapter/plugin.d.ts.map +1 -1
- package/lib/types/dsh-adapter/plugin.js +64 -18
- package/lib/types/dsh-adapter/plugins-info.d.ts +6 -7
- package/lib/types/dsh-adapter/plugins-info.d.ts.map +1 -1
- package/lib/types/dsh-adapter/plugins-info.js +34 -21
- package/lib/types/dsh-adapter/presets.d.ts +6 -2
- package/lib/types/dsh-adapter/presets.d.ts.map +1 -1
- package/lib/types/dsh-adapter/presets.js +23 -5
- package/lib/types/dsh-adapter/process-exit.d.ts +1 -1
- package/lib/types/dsh-adapter/process-exit.js +1 -1
- package/lib/types/dsh-adapter/providerWizard.d.ts +2 -0
- package/lib/types/dsh-adapter/providerWizard.d.ts.map +1 -1
- package/lib/types/dsh-adapter/providerWizard.js +11 -5
- package/lib/types/dsh-adapter/row-attachment.d.ts +30 -0
- package/lib/types/dsh-adapter/row-attachment.d.ts.map +1 -0
- package/lib/types/dsh-adapter/row-attachment.js +29 -0
- package/lib/types/dsh-adapter/worktree-tool.d.ts +27 -0
- package/lib/types/dsh-adapter/worktree-tool.d.ts.map +1 -0
- package/lib/types/dsh-adapter/worktree-tool.js +87 -0
- package/lib/types/heldInputs.d.ts +36 -0
- package/lib/types/heldInputs.d.ts.map +1 -0
- package/lib/types/heldInputs.js +173 -0
- package/lib/types/i18n.d.ts +352 -25
- package/lib/types/i18n.d.ts.map +1 -1
- package/lib/types/i18n.js +171 -18
- package/lib/types/onboardingDraft.d.ts +143 -0
- package/lib/types/onboardingDraft.d.ts.map +1 -0
- package/lib/types/onboardingDraft.js +71 -0
- package/lib/types/screens/Chat.d.ts.map +1 -1
- package/lib/types/screens/Chat.js +90 -30
- package/lib/types/screens/Onboarding.d.ts +22 -3
- package/lib/types/screens/Onboarding.d.ts.map +1 -1
- package/lib/types/screens/Onboarding.js +606 -36
- package/lib/types/settings/definitions.js +2 -2
- package/lib/types/utils/paths.d.ts +15 -0
- package/lib/types/utils/paths.d.ts.map +1 -1
- package/lib/types/utils/paths.js +25 -0
- package/package.json +111 -108
- package/tui-profile/feed/README.md +1 -1
- package/tui-profile/feed/first-party.json +1 -1
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/** Stable identity of one catalog row across snapshots. */
|
|
2
|
+
export function modelRefKey(ref) {
|
|
3
|
+
return `${ref.provider}/${ref.id}`;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Reduce a channel catalog to the diffable rows.
|
|
7
|
+
*
|
|
8
|
+
* @param models - `channel.listModels()` result (advisory order preserved).
|
|
9
|
+
* @returns One row per model, in the order the catalog listed them.
|
|
10
|
+
*/
|
|
11
|
+
export function modelRefsOf(models) {
|
|
12
|
+
return models.map(model => ({ provider: model.provider, id: model.id, name: model.name }));
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Models present now and absent from the baseline.
|
|
16
|
+
*
|
|
17
|
+
* @param baseline - Catalog snapshot taken BEFORE the action.
|
|
18
|
+
* @param current - Catalog snapshot taken after it.
|
|
19
|
+
* @param provider - Optional filter (the provider the action touched).
|
|
20
|
+
* @returns New rows in `current` order, deduped by provider/id.
|
|
21
|
+
*/
|
|
22
|
+
export function addedModelRefs(baseline, current, provider) {
|
|
23
|
+
const seen = new Set(baseline.map(modelRefKey));
|
|
24
|
+
const added = [];
|
|
25
|
+
for (const row of current) {
|
|
26
|
+
if (provider !== undefined && row.provider !== provider)
|
|
27
|
+
continue;
|
|
28
|
+
const key = modelRefKey(row);
|
|
29
|
+
if (seen.has(key))
|
|
30
|
+
continue;
|
|
31
|
+
seen.add(key);
|
|
32
|
+
added.push(row);
|
|
33
|
+
}
|
|
34
|
+
return added;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The whole step-1 decision in one call.
|
|
38
|
+
*
|
|
39
|
+
* Repeated calls with the same baseline are idempotent (`added` is a set
|
|
40
|
+
* difference), which is what lets a remount after a question panel re-run the
|
|
41
|
+
* same plan without asking about the same models twice — the baseline lives
|
|
42
|
+
* in `src/onboardingDraft.ts`, not in React state, exactly for that remount.
|
|
43
|
+
*
|
|
44
|
+
* @param input - Baseline and current catalogs, optional provider filter and
|
|
45
|
+
* the live route used to preselect the `ask` branch.
|
|
46
|
+
* @returns The plan described by {@link AdoptionPlan}.
|
|
47
|
+
*/
|
|
48
|
+
export function planModelAdoption(input) {
|
|
49
|
+
const added = addedModelRefs(input.baseline, input.current, input.provider);
|
|
50
|
+
const providers = new Set(added.map(row => row.provider));
|
|
51
|
+
const provider = input.provider
|
|
52
|
+
?? (added[0] === undefined ? undefined : added[0].provider);
|
|
53
|
+
const live = input.currentRoute === undefined
|
|
54
|
+
? undefined
|
|
55
|
+
: added.find(row => row.provider === input.currentRoute.provider && row.id === input.currentRoute.id);
|
|
56
|
+
return {
|
|
57
|
+
provider,
|
|
58
|
+
added,
|
|
59
|
+
multiProvider: providers.size > 1,
|
|
60
|
+
decision: added.length === 0 ? 'none' : added.length === 1 ? 'auto' : 'ask',
|
|
61
|
+
defaultPick: added.length === 0 ? undefined : live ?? added[0],
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Provider ids in first-appearance order — the group order for the adoption
|
|
66
|
+
* layer, so a batch is presented in the order the catalog produced it rather
|
|
67
|
+
* than in a second, arbitrary sort.
|
|
68
|
+
*
|
|
69
|
+
* @param added - The plan's `added` rows.
|
|
70
|
+
* @returns Distinct provider ids.
|
|
71
|
+
*/
|
|
72
|
+
export function addedProviderOrder(added) {
|
|
73
|
+
const order = [];
|
|
74
|
+
for (const row of added)
|
|
75
|
+
if (!order.includes(row.provider))
|
|
76
|
+
order.push(row.provider);
|
|
77
|
+
return order;
|
|
78
|
+
}
|
|
@@ -19,6 +19,11 @@ export interface BtwComposerKeyResult {
|
|
|
19
19
|
readonly submit?: boolean;
|
|
20
20
|
/** Esc/Tab:退出编辑焦点(草稿保留),焦点回落线程列表/宿主。 */
|
|
21
21
|
readonly exitFocus?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Ctrl+V / Alt+V:读剪贴板是异步的,纯函数只交出意图——surface 侧
|
|
24
|
+
* (useBtwComposerPaste)读完再按实时草稿与 caret 落字。
|
|
25
|
+
*/
|
|
26
|
+
readonly paste?: true;
|
|
22
27
|
}
|
|
23
28
|
/** 运行时补充键位(ink Key 实际携带;SidePanelKeyFlags 类型面未列)。 */
|
|
24
29
|
type BtwKeyFlags = SidePanelKeyFlags & {
|
|
@@ -28,6 +33,8 @@ type BtwKeyFlags = SidePanelKeyFlags & {
|
|
|
28
33
|
readonly home?: boolean;
|
|
29
34
|
readonly end?: boolean;
|
|
30
35
|
readonly return?: boolean;
|
|
36
|
+
/** 终端原生粘贴(bracketed paste)整块到达时置位。 */
|
|
37
|
+
readonly isPasted?: boolean;
|
|
31
38
|
};
|
|
32
39
|
/**
|
|
33
40
|
* 单行 composer 的键语义。返回 null = 未消费(面板形态交宿主回退键,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BtwComposer.d.ts","sourceRoot":"","sources":["../../../../../src/components/sidePanel/btw/BtwComposer.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"BtwComposer.d.ts","sourceRoot":"","sources":["../../../../../src/components/sidePanel/btw/BtwComposer.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAGpD,+CAA+C;AAC/C,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CACvB;AAED,8DAA8D;AAC9D,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,KAAK,CAAC,EAAE,gBAAgB,CAAA;IACjC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAA;IACzB,wCAAwC;IACxC,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAA;IAC5B;;;OAGG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,IAAI,CAAA;CACtB;AAED,qDAAqD;AACrD,KAAK,WAAW,GAAG,iBAAiB,GAAG;IACrC,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,CAAA;IACtB,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAA;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAA;IACvB,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,CAAA;IACtB,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAA;IACzB,sCAAsC;IACtC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAC5B,CAAA;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,GAAG,oBAAoB,GAAG,IAAI,CAkDpH;AAED,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,OAAO,EACP,IAAI,EACJ,MAAM,EACN,UAAU,GACX,EAAE;IACD,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAA;IAChC,2BAA2B;IAC3B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,2BAA2B;IAC3B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;IACtB,6BAA6B;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;KAAE,GAAG,SAAS,CAAA;IAClF,iCAAiC;IACjC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,IAAI,CAAA;CACjC,GAAG,KAAK,CAAC,SAAS,CA6ClB"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { Box, Text, InputCaret } from '../../../ui.js';
|
|
3
3
|
import { t } from '../../../i18n.js';
|
|
4
|
+
import { actionMatches } from '../../../utils/keymap.js';
|
|
5
|
+
import { flattenPasteInline } from '../../../channel/sanitize.js';
|
|
4
6
|
import { nextCodePoint, previousCodePoint } from '../../AgentMessageComposer.js';
|
|
5
7
|
/**
|
|
6
8
|
* 单行 composer 的键语义。返回 null = 未消费(面板形态交宿主回退键,
|
|
@@ -15,6 +17,20 @@ export function btwComposerKey(state, input, key) {
|
|
|
15
17
|
// The caret is per surface while the draft is shared through the store:
|
|
16
18
|
// an edit on the other surface can leave this caret past the end.
|
|
17
19
|
const caret = Math.min(state.caret, state.text.length);
|
|
20
|
+
// 终端原生粘贴(Ctrl+Shift+V / 右键 / 终端自己接管的 Ctrl+V)整块到达并
|
|
21
|
+
// 打上 isPasted:单行框先压成一行再插,纯换行的块是文本、绝不是 Enter。
|
|
22
|
+
// 必须排在 plainReturn 之前——粘贴块也可能带着 return 标记。
|
|
23
|
+
if (key.isPasted === true) {
|
|
24
|
+
const text = flattenPasteInline(input);
|
|
25
|
+
// 纯换行/空白压完是空格,trim 后为空 = 没有可插入的文本(不是 Enter)。
|
|
26
|
+
if (text.trim() === '')
|
|
27
|
+
return {};
|
|
28
|
+
return { state: { text: state.text.slice(0, caret) + text + state.text.slice(caret), caret: caret + text.length } };
|
|
29
|
+
}
|
|
30
|
+
// Ctrl+V / Alt+V(keymap 的 paste 动作,可在 /settings 重映射):读剪贴板
|
|
31
|
+
// 是异步的,纯函数只交出意图,由 surface 侧按实时草稿与 caret 落字。
|
|
32
|
+
if (actionMatches('paste', input, key))
|
|
33
|
+
return { paste: true };
|
|
18
34
|
const plainReturn = (key.return_ === true || key.return === true || /^[\r\n]+$/u.test(input))
|
|
19
35
|
&& key.ctrl !== true && key.meta !== true && key.shift !== true;
|
|
20
36
|
if (plainReturn)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BtwPanelAdapter.d.ts","sourceRoot":"","sources":["../../../../../src/components/sidePanel/btw/BtwPanelAdapter.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"BtwPanelAdapter.d.ts","sourceRoot":"","sources":["../../../../../src/components/sidePanel/btw/BtwPanelAdapter.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,MAAM,OAAO,CAAA;AAczB,OAAO,KAAK,EAAmB,UAAU,EAAE,MAAM,aAAa,CAAA;AAY9D,wBAAgB,eAAe,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,UAAU,GAAG,KAAK,CAAC,SAAS,CAoRhG"}
|
|
@@ -21,6 +21,7 @@ import { setClipboard } from '../../../ink/termio/osc.js';
|
|
|
21
21
|
import { btwThreads } from './threads.js';
|
|
22
22
|
import { getBtwContextBudget, getBtwContextTurns } from '../../../tuiDisplayPrefs.js';
|
|
23
23
|
import { BtwComposer, btwComposerKey } from './BtwComposer.js';
|
|
24
|
+
import { useBtwComposerPaste } from './useBtwComposerPaste.js';
|
|
24
25
|
import { BtwThreadView } from './BtwThreadView.js';
|
|
25
26
|
function useBtwThread(sessionId) {
|
|
26
27
|
return React.useSyncExternalStore(btwThreads.subscribe, () => btwThreads.get(sessionId));
|
|
@@ -59,6 +60,8 @@ export function BtwPanelAdapter({ width, height, focused, visible }) {
|
|
|
59
60
|
setCaretState(next);
|
|
60
61
|
}, []);
|
|
61
62
|
const [notice, setNotice] = React.useState(null);
|
|
63
|
+
// Ctrl+V / Alt+V:读剪贴板是异步的,落点用实时草稿与 caret(见 hook)。
|
|
64
|
+
const paste = useBtwComposerPaste({ sessionId, caretRef, setCaret, setNotice });
|
|
62
65
|
// 列表态的滚动句柄(阅读态:↑/↓/PgUp/PgDn 归线程,编辑态仍归输入框)。
|
|
63
66
|
const scrollRef = React.useRef(null);
|
|
64
67
|
// badge(镜像 jobs:version/visible 驱动;可见即已读)。
|
|
@@ -184,6 +187,10 @@ export function BtwPanelAdapter({ width, height, focused, visible }) {
|
|
|
184
187
|
submitDraft();
|
|
185
188
|
return true;
|
|
186
189
|
}
|
|
190
|
+
if (result.paste === true) {
|
|
191
|
+
paste();
|
|
192
|
+
return true;
|
|
193
|
+
}
|
|
187
194
|
if (result.state !== undefined) {
|
|
188
195
|
btwThreads.setDraft(sessionId, result.state.text);
|
|
189
196
|
setCaret(result.state.caret);
|
|
@@ -244,7 +251,7 @@ export function BtwPanelAdapter({ width, height, focused, visible }) {
|
|
|
244
251
|
// 其余不独占:返回 false 交宿主(Esc 回聊天、←/→ 切面板、1-9 跳面板)。
|
|
245
252
|
return false;
|
|
246
253
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
247
|
-
}, [sessionId, submitDraft, newTopic, sendToChat, copySelected, moveSelection, selectedTurnNow, height, setCaret]);
|
|
254
|
+
}, [sessionId, submitDraft, newTopic, sendToChat, copySelected, moveSelection, selectedTurnNow, height, setCaret, paste]);
|
|
248
255
|
usePanelInput(onKey, { active: focused && visible });
|
|
249
256
|
// ── 头部(只有线程后才画):首问标题 + 状态徽 + 新话题,下压一条细线 ──
|
|
250
257
|
// 空线程不画头部:标题没有内容,`新话题` 在空线程上也无事可做(清空/换题的
|
|
@@ -9,10 +9,16 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import React from 'react';
|
|
11
11
|
import type { ChannelUi } from '../../../adapter/channel/ui-policy.js';
|
|
12
|
-
|
|
12
|
+
import type { ClipboardRead } from '../../../utils/clipboard.js';
|
|
13
|
+
export declare function BtwThreadScene({ channel, onClose, onFocusChat, readClipboardOverride, }: {
|
|
13
14
|
readonly channel: ChannelUi;
|
|
14
15
|
readonly onClose: () => void;
|
|
15
16
|
/** 送聊天之后把焦点交回主输入框(宿主没接时只关场景)。 */
|
|
16
17
|
readonly onFocusChat?: (() => void) | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* 测试缝:composer 的 Ctrl+V 走这里读剪贴板(默认真实平台读取),
|
|
20
|
+
* 无头回归注入假 reader——与问卷面板 #786 的契约同型。
|
|
21
|
+
*/
|
|
22
|
+
readonly readClipboardOverride?: (() => Promise<ClipboardRead>) | undefined;
|
|
17
23
|
}): React.ReactNode;
|
|
18
24
|
//# sourceMappingURL=BtwThreadScene.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BtwThreadScene.d.ts","sourceRoot":"","sources":["../../../../../src/components/sidePanel/btw/BtwThreadScene.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAA;AAQtE,wBAAgB,cAAc,CAAC,EAC7B,OAAO,EACP,OAAO,EACP,WAAW,
|
|
1
|
+
{"version":3,"file":"BtwThreadScene.d.ts","sourceRoot":"","sources":["../../../../../src/components/sidePanel/btw/BtwThreadScene.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAA;AAQtE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAEhE,wBAAgB,cAAc,CAAC,EAC7B,OAAO,EACP,OAAO,EACP,WAAW,EACX,qBAAqB,GACtB,EAAE;IACD,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAA;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAA;IAC5B,iCAAiC;IACjC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAA;IAC/C;;;OAGG;IACH,QAAQ,CAAC,qBAAqB,CAAC,EAAE,CAAC,MAAM,OAAO,CAAC,aAAa,CAAC,CAAC,GAAG,SAAS,CAAA;CAC5E,GAAG,KAAK,CAAC,SAAS,CA0KlB"}
|
|
@@ -15,8 +15,9 @@ import { setClipboard } from '../../../ink/termio/osc.js';
|
|
|
15
15
|
import { btwThreads } from './threads.js';
|
|
16
16
|
import { getBtwContextBudget, getBtwContextTurns } from '../../../tuiDisplayPrefs.js';
|
|
17
17
|
import { BtwComposer, btwComposerKey } from './BtwComposer.js';
|
|
18
|
+
import { useBtwComposerPaste } from './useBtwComposerPaste.js';
|
|
18
19
|
import { BtwThreadView } from './BtwThreadView.js';
|
|
19
|
-
export function BtwThreadScene({ channel, onClose, onFocusChat, }) {
|
|
20
|
+
export function BtwThreadScene({ channel, onClose, onFocusChat, readClipboardOverride, }) {
|
|
20
21
|
const { columns, rows } = useTerminalSize();
|
|
21
22
|
const sessionId = String(channel.agentId);
|
|
22
23
|
const thread = React.useSyncExternalStore(btwThreads.subscribe, () => btwThreads.get(sessionId));
|
|
@@ -29,6 +30,8 @@ export function BtwThreadScene({ channel, onClose, onFocusChat, }) {
|
|
|
29
30
|
setCaretState(next);
|
|
30
31
|
};
|
|
31
32
|
const [notice, setNotice] = React.useState(null);
|
|
33
|
+
// Ctrl+V / Alt+V:与侧栏面板同一份实现(落点用实时草稿与 caret)。
|
|
34
|
+
const paste = useBtwComposerPaste({ sessionId, caretRef, setCaret, setNotice, readClipboardOverride });
|
|
32
35
|
const scrollRef = React.useRef(null);
|
|
33
36
|
const busy = thread !== undefined && thread.activeTurnId !== null;
|
|
34
37
|
// 选中轮与侧栏面板同源(线程 store):↑/↓ 移动、s 送聊天/撤回、c 复制。
|
|
@@ -107,6 +110,10 @@ export function BtwThreadScene({ channel, onClose, onFocusChat, }) {
|
|
|
107
110
|
}
|
|
108
111
|
return;
|
|
109
112
|
}
|
|
113
|
+
if (result.paste === true) {
|
|
114
|
+
paste();
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
110
117
|
if (result.state !== undefined) {
|
|
111
118
|
btwThreads.setDraft(sessionId, result.state.text);
|
|
112
119
|
setCaret(result.state.caret);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type ClipboardRead } from '../../../utils/clipboard.js';
|
|
2
|
+
/** 粘贴失败的本地提示(显示到下一次动作,与提交失败同一条通道)。 */
|
|
3
|
+
export interface BtwPasteNotice {
|
|
4
|
+
readonly text: string;
|
|
5
|
+
readonly failure: boolean;
|
|
6
|
+
}
|
|
7
|
+
/** 无头回归注入假 reader;传 undefined 还原真实读取。 */
|
|
8
|
+
export declare function setBtwClipboardReaderForTest(next?: () => Promise<ClipboardRead>): void;
|
|
9
|
+
/**
|
|
10
|
+
* 把一段文本按码点光标插入草稿。导出给回归脚本做纯函数断言。
|
|
11
|
+
* @param draft - 当前草稿。
|
|
12
|
+
* @param caret - 光标(会被夹到草稿长度内)。
|
|
13
|
+
* @param text - 已 flatten 的单行文本。
|
|
14
|
+
*/
|
|
15
|
+
export declare function insertBtwPaste(draft: string, caret: number, text: string): {
|
|
16
|
+
text: string;
|
|
17
|
+
caret: number;
|
|
18
|
+
};
|
|
19
|
+
export declare function useBtwComposerPaste(opts: {
|
|
20
|
+
readonly sessionId: string;
|
|
21
|
+
/** 当前 surface 的光标(ref:异步返回时读实时值)。 */
|
|
22
|
+
readonly caretRef: {
|
|
23
|
+
readonly current: number;
|
|
24
|
+
};
|
|
25
|
+
readonly setCaret: (caret: number) => void;
|
|
26
|
+
readonly setNotice: (notice: BtwPasteNotice | null) => void;
|
|
27
|
+
/** 全屏场景的注入缝;不传走模块级 reader(测试可覆盖)。 */
|
|
28
|
+
readonly readClipboardOverride?: (() => Promise<ClipboardRead>) | undefined;
|
|
29
|
+
}): () => void;
|
|
30
|
+
//# sourceMappingURL=useBtwComposerPaste.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBtwComposerPaste.d.ts","sourceRoot":"","sources":["../../../../../src/components/sidePanel/btw/useBtwComposerPaste.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAiB,KAAK,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAG/E,sCAAsC;AACtC,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAC1B;AAID,yCAAyC;AACzC,wBAAgB,4BAA4B,CAAC,IAAI,CAAC,EAAE,MAAM,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI,CAEtF;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAG1G;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE;IACxC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,qCAAqC;IACrC,QAAQ,CAAC,QAAQ,EAAE;QAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAA;IAC/C,QAAQ,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAC1C,QAAQ,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,KAAK,IAAI,CAAA;IAC3D,qCAAqC;IACrC,QAAQ,CAAC,qBAAqB,CAAC,EAAE,CAAC,MAAM,OAAO,CAAC,aAAa,CAAC,CAAC,GAAG,SAAS,CAAA;CAC5E,GAAG,MAAM,IAAI,CAsDb"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* btw composer 的剪贴板粘贴:面板(BtwPanelAdapter)与全屏场景
|
|
3
|
+
* (BtwThreadScene)共用一份实现。
|
|
4
|
+
*
|
|
5
|
+
* 键语义在 BtwComposer 的纯函数里(`{ paste: true }`),这里只负责异步
|
|
6
|
+
* 读取与落点,契约与主输入框 / 问卷面板一致:
|
|
7
|
+
*
|
|
8
|
+
* - 读取期间用户继续打字是安全的:落点用**实时**草稿与当前 caret,
|
|
9
|
+
* 不拿按键那一刻的快照覆盖草稿;
|
|
10
|
+
* - 一次读取在途时重复按键被忽略(防重入),组件卸载后不写 store;
|
|
11
|
+
* - btw 是纯文本单行输入:图片/文件剪贴板明确提示,绝不静默落到别处。
|
|
12
|
+
*
|
|
13
|
+
* 测试缝:面板由 registry 构造,传不进 prop,所以这里保留一个模块级
|
|
14
|
+
* reader 覆盖(仓内已有 `__setHandoffAckStateForTest` 等同类先例);
|
|
15
|
+
* 全屏场景另可经 prop 注入。
|
|
16
|
+
*/
|
|
17
|
+
import React from 'react';
|
|
18
|
+
import { t } from '../../../i18n.js';
|
|
19
|
+
import { flattenPasteInline } from '../../../channel/sanitize.js';
|
|
20
|
+
import { readClipboard } from '../../../utils/clipboard.js';
|
|
21
|
+
import { btwThreads } from './threads.js';
|
|
22
|
+
let clipboardReader = readClipboard;
|
|
23
|
+
/** 无头回归注入假 reader;传 undefined 还原真实读取。 */
|
|
24
|
+
export function setBtwClipboardReaderForTest(next) {
|
|
25
|
+
clipboardReader = next ?? readClipboard;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* 把一段文本按码点光标插入草稿。导出给回归脚本做纯函数断言。
|
|
29
|
+
* @param draft - 当前草稿。
|
|
30
|
+
* @param caret - 光标(会被夹到草稿长度内)。
|
|
31
|
+
* @param text - 已 flatten 的单行文本。
|
|
32
|
+
*/
|
|
33
|
+
export function insertBtwPaste(draft, caret, text) {
|
|
34
|
+
const at = Math.min(Math.max(0, caret), draft.length);
|
|
35
|
+
return { text: draft.slice(0, at) + text + draft.slice(at), caret: at + text.length };
|
|
36
|
+
}
|
|
37
|
+
export function useBtwComposerPaste(opts) {
|
|
38
|
+
const { sessionId, caretRef, setCaret, setNotice, readClipboardOverride } = opts;
|
|
39
|
+
// 读取在途:重复 Ctrl+V 不排队(一次粘贴只落一次字)。
|
|
40
|
+
const busyRef = React.useRef(false);
|
|
41
|
+
// 读取在途时会话可能切换(面板跨会话常驻):落点必须仍是按键时的会话,
|
|
42
|
+
// 否则文本写进旧草稿、光标却设到新 surface 上。沿用主输入框的租约语义:
|
|
43
|
+
// 上下文变了就丢弃这次读取,绝不覆盖更新的草稿。
|
|
44
|
+
const sessionRef = React.useRef(sessionId);
|
|
45
|
+
sessionRef.current = sessionId;
|
|
46
|
+
// 组件可能先卸载(面板切走/场景关闭),异步续体不得再写 store。
|
|
47
|
+
const mountedRef = React.useRef(true);
|
|
48
|
+
React.useEffect(() => () => { mountedRef.current = false; }, []);
|
|
49
|
+
return React.useCallback(() => {
|
|
50
|
+
if (busyRef.current)
|
|
51
|
+
return;
|
|
52
|
+
busyRef.current = true;
|
|
53
|
+
void (readClipboardOverride ?? clipboardReader)()
|
|
54
|
+
.then(content => {
|
|
55
|
+
if (!mountedRef.current)
|
|
56
|
+
return;
|
|
57
|
+
if (sessionRef.current !== sessionId)
|
|
58
|
+
return;
|
|
59
|
+
if (content === null) {
|
|
60
|
+
setNotice({ text: t('input-clipboard-empty'), failure: false });
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (content.kind === 'unavailable') {
|
|
64
|
+
setNotice({
|
|
65
|
+
text: t(content.wsl === true ? 'input-clipboard-unavailable-wsl' : 'input-clipboard-unavailable'),
|
|
66
|
+
failure: false,
|
|
67
|
+
});
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (content.kind !== 'text') {
|
|
71
|
+
// 图片/文件没有 btw 的文本形态:明确提示,不落到任何输入框。
|
|
72
|
+
setNotice({ text: t('question-paste-not-text'), failure: false });
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
// 单行框:换行/控制符压成空格,ANSI 序列整段剥掉(用户可控字节)。
|
|
76
|
+
// 只剩空白的粘贴没有可插入的内容(与问卷面板同判据)。
|
|
77
|
+
const text = flattenPasteInline(content.text);
|
|
78
|
+
if (text.trim() === '') {
|
|
79
|
+
setNotice({ text: t('input-clipboard-empty'), failure: false });
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const draft = btwThreads.get(sessionId)?.draft ?? '';
|
|
83
|
+
const next = insertBtwPaste(draft, caretRef.current, text);
|
|
84
|
+
btwThreads.setDraft(sessionId, next.text);
|
|
85
|
+
setCaret(next.caret);
|
|
86
|
+
setNotice(null);
|
|
87
|
+
})
|
|
88
|
+
.catch(() => {
|
|
89
|
+
if (mountedRef.current)
|
|
90
|
+
setNotice({ text: t('input-clipboard-read-failed'), failure: true });
|
|
91
|
+
})
|
|
92
|
+
.finally(() => { busyRef.current = false; });
|
|
93
|
+
}, [sessionId, caretRef, setCaret, setNotice, readClipboardOverride]);
|
|
94
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builtinPanels.d.ts","sourceRoot":"","sources":["../../../../src/components/sidePanel/builtinPanels.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"builtinPanels.d.ts","sourceRoot":"","sources":["../../../../src/components/sidePanel/builtinPanels.tsx"],"names":[],"mappings":"AAmPA,2BAA2B;AAC3B,wBAAgB,qBAAqB,IAAI,IAAI,CAmG5C"}
|
|
@@ -26,17 +26,29 @@ function TodoPanelAdapter({ width, height, focused, visible }) {
|
|
|
26
26
|
// 修复前头部行 onClick 没接(GoalTodoPanel 的 onToggle 未传),
|
|
27
27
|
// 侧栏里点折叠头是死控件。
|
|
28
28
|
const [collapsed, setCollapsed] = React.useState(false);
|
|
29
|
+
const scrollRef = React.useRef(null);
|
|
29
30
|
const toggleCollapsed = React.useCallback(() => setCollapsed(previous => !previous), []);
|
|
31
|
+
// v2.1 分发:活动面板先吃键。↑/↓ 滚动(内容超出时逐行),Enter/Space
|
|
32
|
+
// 折叠;Esc / Ctrl / Meta 返回 false,宿主回退与聊天全局键照旧。
|
|
30
33
|
usePanelInput((input, key) => {
|
|
31
34
|
if (key.ctrl || key.meta || key.escape)
|
|
32
35
|
return false;
|
|
36
|
+
if (key.upArrow === true) {
|
|
37
|
+
scrollRef.current?.scrollBy(-1);
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
if (key.downArrow === true) {
|
|
41
|
+
scrollRef.current?.scrollBy(1);
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
33
44
|
if (key.return_ !== true && input !== ' ')
|
|
34
45
|
return false;
|
|
35
46
|
toggleCollapsed();
|
|
36
47
|
return true;
|
|
37
48
|
}, { active: focused && visible });
|
|
38
|
-
//
|
|
39
|
-
|
|
49
|
+
// 行模型由组件按真实折行数(目标/状态/blocked/折叠头/todo)构建,宿主
|
|
50
|
+
// 不再猜预算;wrapWidth 仍是 todo 的折行宽。
|
|
51
|
+
return (_jsx(GoalTodoPanel, { channel: channel, variant: "panel", visible: visible, collapsed: collapsed, onToggle: toggleCollapsed, width: width, height: height, scrollRef: scrollRef,
|
|
40
52
|
// 折行宽 = 面板宽 − 左右 padding 2 − 树形前缀 3 − 状态 glyph 2,
|
|
41
53
|
// 再留 1 格余量防 ink 二次折行(长行溢出超过约束会把同行定宽列挤折)。
|
|
42
54
|
wrapWidth: Math.max(10, width - 8) }));
|
|
@@ -100,6 +100,8 @@ export interface SidePanelKeyFlags {
|
|
|
100
100
|
readonly ctrl?: boolean;
|
|
101
101
|
readonly meta?: boolean;
|
|
102
102
|
readonly shift?: boolean;
|
|
103
|
+
/** Cmd(macOS 平台主修饰键,kitty 键盘协议上报);paste 的 macOS 别名带它。 */
|
|
104
|
+
readonly super?: boolean;
|
|
103
105
|
}
|
|
104
106
|
/** 返回 true = 已消费(宿主回退键不再触发)。 */
|
|
105
107
|
export type PanelKeyHandler = (input: string, key: SidePanelKeyFlags) => boolean | void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/sidePanel/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAE5C,MAAM,MAAM,gBAAgB;AAC1B,uCAAuC;AACrC,QAAQ;AACV;;iCAEiC;GAC/B,SAAS,CAAA;AAEb,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAA;IAC5B,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAA;IACvB,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAA;IAC7B;uDACmD;IACnD,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAA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OAAO,CAAA;IAC5B,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAA;IAC7B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;IAC1B,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAA;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAC3B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;IAC1B,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAA;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAA;IACvB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;IACxB,yDAAyD;IACzD,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CACzB;AAED,gCAAgC;AAChC,MAAM,MAAM,eAAe,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,iBAAiB,KAAK,OAAO,GAAG,IAAI,CAAA;AAEvF;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,+CAA+C;IAC/C,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,KAAK,MAAM,IAAI,CAAA;IAC1F,wCAAwC;IACxC,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,iBAAiB,KAAK,OAAO,CAAA;CACjF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSidePanel.d.ts","sourceRoot":"","sources":["../../../../src/components/sidePanel/useSidePanel.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useSidePanel.d.ts","sourceRoot":"","sources":["../../../../src/components/sidePanel/useSidePanel.ts"],"names":[],"mappings":"AAyCA,OAAO,EAML,KAAK,cAAc,EACpB,MAAM,iBAAiB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,EAAE,MAAM,IAAI,CAAA;IACtB,KAAK,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAA;IACrC,8EAA8E;IAC9E,MAAM,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAA;IACrC,SAAS,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAA;IACpE,2DAA2D;IAC3D,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAA;IACjC,2EAA2E;IAC3E,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,iBAAiB,EAAE,KAAK,CAAC,EAAE,qBAAqB,KAAK,OAAO,CAAA;CAC7F;AAMD,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,mBAAmB,CAgT9E"}
|
|
@@ -17,7 +17,9 @@
|
|
|
17
17
|
* the focus is in the right column — the active panel's own keys (Phase 3
|
|
18
18
|
* dispatcher), then the host fallback below (panel switching, zoom,
|
|
19
19
|
* resize, Esc). Plain Ctrl combos fall through to Chat so interrupt /
|
|
20
|
-
* exit / redraw keep working from the panel
|
|
20
|
+
* exit / redraw keep working from the panel; the one exception is the
|
|
21
|
+
* keymap `paste` action while the column actually renders — it is owned by
|
|
22
|
+
* the panel column (issue #1767), see the branch in handleKey.
|
|
21
23
|
*/
|
|
22
24
|
import React from 'react';
|
|
23
25
|
import { actionMatches } from '../../utils/keymap.js';
|
|
@@ -195,6 +197,18 @@ export function useSidePanel(options) {
|
|
|
195
197
|
}
|
|
196
198
|
if (focus !== 'panel')
|
|
197
199
|
return false;
|
|
200
|
+
// 粘贴是 Ctrl/Alt 组合里唯一会把剪贴板内容写进草稿的动作:分栏渲染时
|
|
201
|
+
// 先给活动 Panel(btw composer 能接),它不接也必须吞掉——否则键继续
|
|
202
|
+
// 漏给仍处于 active 的主输入框(issue #1767)。分栏没渲染时(编辑器
|
|
203
|
+
// 展开 / 窄屏)不拦:PanelHost 已卸载、dispatchKey 必然落空,可见的
|
|
204
|
+
// 输入框只有主输入框/全屏编辑器。其余会改草稿的组合(Ctrl+W/U/K/Z、
|
|
205
|
+
// Alt+Backspace 等)仍照旧放行,属既有行为,不在本次范围。
|
|
206
|
+
if (split && actionMatches('paste', input, key)) {
|
|
207
|
+
if (activePanelId !== undefined)
|
|
208
|
+
runtime.dispatchKey(activePanelId, input, key);
|
|
209
|
+
stop();
|
|
210
|
+
return true;
|
|
211
|
+
}
|
|
198
212
|
// Panel-focused keys. Ctrl/Alt combos fall through to Chat
|
|
199
213
|
// (interrupt, exit, redraw and the other global actions keep working
|
|
200
214
|
// from the panel); plain keys are the panel surface's own. Esc is the
|
|
@@ -56,8 +56,14 @@ export declare function isAgentSession(value: unknown): value is AgentSession;
|
|
|
56
56
|
* `AgentSession`. Creating the wrapper acquires nothing: listeners exist only
|
|
57
57
|
* while `subscribe`/`subscribeRaw` subscriptions are live, and only `dispose()`
|
|
58
58
|
* releases the handle.
|
|
59
|
+
*
|
|
60
|
+
* `screenOutlivesContext`: the screen showing this session lives longer than
|
|
61
|
+
* `ctx` (the entry's screen over its profile row), so when `ctx` unloads the
|
|
62
|
+
* screen holds this session's queued inputs, and the agent must not run them.
|
|
59
63
|
*/
|
|
60
|
-
export declare function createDshSession(ctx: Context, target: DshSessionTarget
|
|
64
|
+
export declare function createDshSession(ctx: Context, target: DshSessionTarget, options?: {
|
|
65
|
+
readonly screenOutlivesContext?: boolean;
|
|
66
|
+
}): AgentSession;
|
|
61
67
|
/** The lifetime handle of a DSH session this process created or resumed;
|
|
62
68
|
* throws when the session borrows its agent (or is not a DSH session). */
|
|
63
69
|
export declare function dshHandleOf(session: AgentSession): AgentHandle;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../src/dsh-adapter/backend/session.ts"],"names":[],"mapp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AM,EAAE,SAAS,YAAY,EAAE,GAAG,SAAS,UAAU,EAAE,CAAA;QACvE,iFAAiF;QACjF,gBAAgB,IAAI,IAAI,CAAA;QACxB,gEAAgE;QAChE,QAAQ,CAAC,eAAe,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAA;QAC1D,QAAQ,CAAC,iBAAiB,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAA;KAC/D;CACF;AAED;2EAC2E;AAC3E,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,CAAA;CAAE,CAAA;AAUhH,wEAAwE;AACxE,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAIpE;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO,GAAE;IAAE,QAAQ,CAAC,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,YAAY,CAmRjJ;AAED;2EAC2E;AAC3E,wBAAgB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,WAAW,CAI9D"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createUserMessage, MessageId } from '@deepseek-ai/dsh-llm';
|
|
2
|
+
import { t } from '../../i18n.js';
|
|
2
3
|
import { isTokenDelta, tokenDeltaChars } from '../channel/usage.js';
|
|
3
4
|
import { snapshotLiveSessionEvents } from '../compat/liveSession.js';
|
|
4
5
|
import { createDshTranslator } from './translate.js';
|
|
@@ -19,8 +20,12 @@ export function isAgentSession(value) {
|
|
|
19
20
|
* `AgentSession`. Creating the wrapper acquires nothing: listeners exist only
|
|
20
21
|
* while `subscribe`/`subscribeRaw` subscriptions are live, and only `dispose()`
|
|
21
22
|
* releases the handle.
|
|
23
|
+
*
|
|
24
|
+
* `screenOutlivesContext`: the screen showing this session lives longer than
|
|
25
|
+
* `ctx` (the entry's screen over its profile row), so when `ctx` unloads the
|
|
26
|
+
* screen holds this session's queued inputs, and the agent must not run them.
|
|
22
27
|
*/
|
|
23
|
-
export function createDshSession(ctx, target) {
|
|
28
|
+
export function createDshSession(ctx, target, options = {}) {
|
|
24
29
|
const agent = target.agent;
|
|
25
30
|
const handle = isHandle(target) ? target : target.handle;
|
|
26
31
|
// The tools registry is read lazily, once per session, on the first
|
|
@@ -35,6 +40,20 @@ export function createDshSession(ctx, target) {
|
|
|
35
40
|
let disposed = false;
|
|
36
41
|
/** Inputs this session queued that the inbox has not claimed or discarded. */
|
|
37
42
|
const pending = new Map();
|
|
43
|
+
/** Set while this session's own call (a cancel, a retraction) drops queued
|
|
44
|
+
* inputs: the inbox reports those discards synchronously, inside the call.
|
|
45
|
+
* Any other discard is the kernel's own (the agent's teardown, a hook or
|
|
46
|
+
* parent cancel). */
|
|
47
|
+
let dropping = false;
|
|
48
|
+
const dropOwn = (drop) => {
|
|
49
|
+
dropping = true;
|
|
50
|
+
try {
|
|
51
|
+
return drop();
|
|
52
|
+
}
|
|
53
|
+
finally {
|
|
54
|
+
dropping = false;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
38
57
|
/**
|
|
39
58
|
* One `session/event` listener per subscription period, shared by raw and
|
|
40
59
|
* translated subscribers. Raw subscribers (the DSH extensions) see each
|
|
@@ -132,7 +151,7 @@ export function createDshSession(ctx, target) {
|
|
|
132
151
|
capabilities: {
|
|
133
152
|
pendingRetraction: {
|
|
134
153
|
remove(clientMessageId) {
|
|
135
|
-
const removed = agent.inbox.remove(MessageId(clientMessageId));
|
|
154
|
+
const removed = dropOwn(() => agent.inbox.remove(MessageId(clientMessageId)));
|
|
136
155
|
if (removed)
|
|
137
156
|
pending.delete(clientMessageId);
|
|
138
157
|
return removed;
|
|
@@ -163,9 +182,40 @@ export function createDshSession(ctx, target) {
|
|
|
163
182
|
disposed = true;
|
|
164
183
|
listener([{ type: 'session.status', status: 'disposed' }], QUIET);
|
|
165
184
|
}));
|
|
185
|
+
// Every listener here lives on `ctx`. When its fiber unloads (the
|
|
186
|
+
// dsh-tui row goes with the `agents` service it injects), they go
|
|
187
|
+
// with it, and the agent's closing `agent/status` / `agent/disposed`
|
|
188
|
+
// can no longer arrive: the screen would project the turn forever
|
|
189
|
+
// (#1651). Nothing can reach this agent through this session any
|
|
190
|
+
// more, so report it disposed. An unsubscribe has already cleared
|
|
191
|
+
// `active` when it releases this effect, so it reports nothing.
|
|
192
|
+
// Test doubles that serve only `on` have no fiber to follow.
|
|
193
|
+
own(ctx.effect?.(() => () => {
|
|
194
|
+
if (!active)
|
|
195
|
+
return;
|
|
196
|
+
active = false;
|
|
197
|
+
// The agent can outlive the row (a borrowed agent, a row reloaded
|
|
198
|
+
// alone) and would still run what this session queued, while the
|
|
199
|
+
// screen holds those inputs as never sent: take them back, quietly
|
|
200
|
+
// (the screen holds them from the status below). A screen that
|
|
201
|
+
// unloads with `ctx` holds nothing: a surviving agent keeps them.
|
|
202
|
+
if (options.screenOutlivesContext === true) {
|
|
203
|
+
for (const id of [...pending.keys()]) {
|
|
204
|
+
try {
|
|
205
|
+
if (agent.inbox.remove(MessageId(id)))
|
|
206
|
+
pending.delete(id);
|
|
207
|
+
}
|
|
208
|
+
catch { }
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
disposed = true;
|
|
212
|
+
listener([{ type: 'session.status', status: 'disposed' }], QUIET);
|
|
213
|
+
}, 'dsh-tui session listeners') ?? (() => undefined));
|
|
166
214
|
/**
|
|
167
215
|
* The inbox removed one message. Both events retire the pending entry;
|
|
168
|
-
* the channel retires attached context only for a discard.
|
|
216
|
+
* the channel retires attached context only for a discard. A discard
|
|
217
|
+
* this session did not ask for goes out as `dropped`: the input never
|
|
218
|
+
* ran, and the channel keeps it for the user.
|
|
169
219
|
* `agent/inbox/claimed` fires while the loop claims the batch, before
|
|
170
220
|
* the resident `agent/pre-step` listener can append the attachment
|
|
171
221
|
* (dsh-agent-loop: `inbox.claim()` → claimed event → `agent/pre-step`).
|
|
@@ -180,7 +230,9 @@ export function createDshSession(ctx, target) {
|
|
|
180
230
|
const items = [...pending.values()];
|
|
181
231
|
listener([how === 'claimed'
|
|
182
232
|
? { type: 'pending.changed', items, claimed: [messageId] }
|
|
183
|
-
:
|
|
233
|
+
: dropping
|
|
234
|
+
? { type: 'pending.changed', items, discarded: [messageId] }
|
|
235
|
+
: { type: 'pending.changed', items, dropped: [messageId] }], QUIET);
|
|
184
236
|
};
|
|
185
237
|
own(ctx.on('agent/inbox/claimed', payload => retire(payload, 'claimed')));
|
|
186
238
|
own(ctx.on('agent/inbox/discarded', payload => retire(payload, 'discarded')));
|
|
@@ -243,12 +295,16 @@ export function createDshSession(ctx, target) {
|
|
|
243
295
|
// and a synchronous throw reaches the caller synchronously (the input
|
|
244
296
|
// pipeline rolls its bookkeeping back on it).
|
|
245
297
|
submit(input, placement) {
|
|
298
|
+
// A disposed agent can neither run nor report this input: refuse it
|
|
299
|
+
// instead of queuing a preview nothing will ever retire.
|
|
300
|
+
if (disposed)
|
|
301
|
+
return Promise.resolve({ accepted: false, reason: t('input-session-disposed') });
|
|
246
302
|
const message = messageFor(input);
|
|
247
303
|
const queued = placement === 'steer' ? 'steer' : 'followup';
|
|
248
304
|
pending.set(message.id, { id: message.id, text: input.text, placement: queued });
|
|
249
305
|
try {
|
|
250
306
|
if (placement === 'now')
|
|
251
|
-
agent.cancel({ kind: 'user' });
|
|
307
|
+
dropOwn(() => agent.cancel({ kind: 'user' }));
|
|
252
308
|
if (placement === 'steer')
|
|
253
309
|
agent.steer(message);
|
|
254
310
|
else
|
|
@@ -269,7 +325,7 @@ export function createDshSession(ctx, target) {
|
|
|
269
325
|
if (cause === 'user')
|
|
270
326
|
agent.cancel({ kind: 'user' }, { keepInbox: true });
|
|
271
327
|
else
|
|
272
|
-
agent.cancel({ kind: 'user' });
|
|
328
|
+
dropOwn(() => agent.cancel({ kind: 'user' }));
|
|
273
329
|
// The kernel cancel settles its bookkeeping synchronously: the answer
|
|
274
330
|
// is definitive either way (kept ids for a 'user' cancel, an emptied
|
|
275
331
|
// queue otherwise).
|