@deepseek-harness-tui/dsh-tui 0.17.0 → 0.19.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 +43 -16
- package/bin/dsh-tui.js +46 -3
- 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/codex-backend.en.md +2 -2
- package/guide/dsh-tui-guide/codex-backend.md +2 -2
- package/guide/dsh-tui-guide/configuration.en.md +8 -2
- package/guide/dsh-tui-guide/configuration.md +8 -2
- package/guide/dsh-tui-guide/getting-started.en.md +174 -6
- package/guide/dsh-tui-guide/getting-started.md +125 -15
- package/guide/dsh-tui-guide/interaction.en.md +30 -8
- package/guide/dsh-tui-guide/interaction.md +18 -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 +32 -17
- package/guide/dsh-tui-guide/user-guide.md +23 -12
- 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 +10 -2
- package/lib/types/adapter/ports/channel-ui.d.ts.map +1 -1
- package/lib/types/adapter/ports/channel-view.d.ts +31 -5
- 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 +16 -3
- package/lib/types/agent/events.d.ts.map +1 -1
- package/lib/types/agent/session.d.ts +5 -0
- package/lib/types/agent/session.d.ts.map +1 -1
- package/lib/types/backends/claude/translate/core.d.ts +2 -2
- package/lib/types/backends/claude/translate/core.d.ts.map +1 -1
- package/lib/types/backends/claude/translate/core.js +10 -6
- package/lib/types/backends/codex/session/commands.d.ts +2 -0
- package/lib/types/backends/codex/session/commands.d.ts.map +1 -1
- package/lib/types/backends/codex/session/commands.js +8 -4
- package/lib/types/backends/codex/session/input.d.ts +11 -7
- package/lib/types/backends/codex/session/input.d.ts.map +1 -1
- package/lib/types/backends/codex/session/input.js +68 -15
- package/lib/types/backends/codex/session/session.d.ts.map +1 -1
- package/lib/types/backends/codex/session/session.js +2 -3
- package/lib/types/channel/projection.d.ts.map +1 -1
- package/lib/types/channel/projection.js +78 -10
- package/lib/types/channel/questions.d.ts +19 -3
- package/lib/types/channel/questions.d.ts.map +1 -1
- package/lib/types/channel/sanitize.d.ts.map +1 -1
- package/lib/types/channel/sanitize.js +8 -4
- package/lib/types/channel/subagent-failure.d.ts +49 -0
- package/lib/types/channel/subagent-failure.d.ts.map +1 -0
- package/lib/types/channel/subagent-failure.js +59 -0
- package/lib/types/channel/transcript.d.ts +17 -0
- package/lib/types/channel/transcript.d.ts.map +1 -1
- package/lib/types/channel/transcript.js +35 -0
- package/lib/types/commands.js +2 -2
- 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 +14 -9
- 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.d.ts.map +1 -1
- package/lib/types/components/PromptInput.js +63 -8
- package/lib/types/components/SubagentDashboard.d.ts.map +1 -1
- package/lib/types/components/SubagentDashboard.js +17 -1
- 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 +16 -7
- 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/questions/AskUserQuestionPanel.d.ts +5 -8
- package/lib/types/components/questions/AskUserQuestionPanel.d.ts.map +1 -1
- package/lib/types/components/questions/AskUserQuestionPanel.js +7 -4
- package/lib/types/components/questions/PlanReviewPanel.d.ts +3 -6
- package/lib/types/components/questions/PlanReviewPanel.d.ts.map +1 -1
- package/lib/types/components/revealScope.d.ts +15 -0
- package/lib/types/components/revealScope.d.ts.map +1 -0
- package/lib/types/components/revealScope.js +17 -0
- package/lib/types/components/sidePanel/btw/BtwComposer.d.ts +41 -1
- package/lib/types/components/sidePanel/btw/BtwComposer.d.ts.map +1 -1
- package/lib/types/components/sidePanel/btw/BtwComposer.js +123 -6
- package/lib/types/components/sidePanel/btw/BtwPanelAdapter.d.ts.map +1 -1
- package/lib/types/components/sidePanel/btw/BtwPanelAdapter.js +9 -2
- 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 +9 -2
- 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/components/smoothReveal.d.ts +36 -6
- package/lib/types/components/smoothReveal.d.ts.map +1 -1
- package/lib/types/components/smoothReveal.js +92 -21
- package/lib/types/components/workspaces/HomeWorkspaceRow.d.ts +4 -14
- package/lib/types/components/workspaces/HomeWorkspaceRow.d.ts.map +1 -1
- package/lib/types/components/workspaces/HomeWorkspaceRow.js +26 -17
- 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 +74 -6
- package/lib/types/dsh-adapter/backend/translate.d.ts.map +1 -1
- package/lib/types/dsh-adapter/backend/translate.js +15 -6
- 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/attached-context.d.ts +15 -2
- package/lib/types/dsh-adapter/channel/attached-context.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/attached-context.js +26 -3
- package/lib/types/dsh-adapter/channel/binding-events.d.ts +3 -0
- package/lib/types/dsh-adapter/channel/binding-events.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/binding-events.js +43 -2
- 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 +3 -7
- package/lib/types/dsh-adapter/channel/context-bookkeeping.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/context-bookkeeping.js +16 -6
- 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 +3 -7
- package/lib/types/dsh-adapter/channel/core/compose.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/core/compose.js +6 -1
- package/lib/types/dsh-adapter/channel/core/local-actions.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/core/local-actions.js +3 -26
- package/lib/types/dsh-adapter/channel/emitter.js +1 -1
- package/lib/types/dsh-adapter/channel/extensions.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/extensions.js +8 -0
- package/lib/types/dsh-adapter/channel/input-actions.d.ts +4 -4
- package/lib/types/dsh-adapter/channel/input-actions.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/input-actions.js +59 -5
- package/lib/types/dsh-adapter/channel/input-delivery.d.ts +3 -7
- package/lib/types/dsh-adapter/channel/input-delivery.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/input-delivery.js +21 -8
- 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/model-actions.d.ts +4 -1
- package/lib/types/dsh-adapter/channel/model-actions.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/model-actions.js +26 -9
- package/lib/types/dsh-adapter/channel/model-selection.d.ts +27 -2
- package/lib/types/dsh-adapter/channel/model-selection.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/model-selection.js +81 -37
- package/lib/types/dsh-adapter/channel/model-switch.d.ts +1 -1
- package/lib/types/dsh-adapter/channel/model-switch.d.ts.map +1 -1
- 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 +9 -3
- 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 +11 -5
- package/lib/types/dsh-adapter/channel/settings-host.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/settings-host.js +6 -3
- package/lib/types/dsh-adapter/channel/transcript.d.ts +3 -2
- package/lib/types/dsh-adapter/channel/transcript.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/transcript.js +13 -4
- package/lib/types/dsh-adapter/channel/types.d.ts +11 -2
- package/lib/types/dsh-adapter/channel/types.d.ts.map +1 -1
- package/lib/types/dsh-adapter/contract.d.ts +27 -3
- package/lib/types/dsh-adapter/contract.d.ts.map +1 -1
- package/lib/types/dsh-adapter/contract.js +47 -5
- 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/fresh-agent.d.ts +1 -1
- package/lib/types/dsh-adapter/fresh-agent.d.ts.map +1 -1
- package/lib/types/dsh-adapter/fresh-agent.js +60 -11
- 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 +114 -15
- package/lib/types/dsh-adapter/host-contract.d.ts +1 -1
- package/lib/types/dsh-adapter/host-contract.d.ts.map +1 -1
- package/lib/types/dsh-adapter/host-contract.js +5 -3
- package/lib/types/dsh-adapter/host-dsh.d.ts +0 -8
- package/lib/types/dsh-adapter/host-dsh.d.ts.map +1 -1
- package/lib/types/dsh-adapter/host-dsh.js +27 -6
- package/lib/types/dsh-adapter/host-entry.js +4 -0
- 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/oauth/profiles.d.ts.map +1 -1
- package/lib/types/dsh-adapter/oauth/profiles.js +14 -1
- 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 +203 -58
- 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 +41 -10
- package/lib/types/dsh-adapter/presets.d.ts.map +1 -1
- package/lib/types/dsh-adapter/presets.js +59 -12
- 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/questions.d.ts +3 -4
- package/lib/types/dsh-adapter/questions.d.ts.map +1 -1
- package/lib/types/dsh-adapter/questions.js +1 -1
- 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/session-list-metadata.js +2 -2
- package/lib/types/dsh-adapter/subagents.d.ts +5 -0
- package/lib/types/dsh-adapter/subagents.d.ts.map +1 -1
- package/lib/types/dsh-adapter/subagents.js +22 -1
- package/lib/types/dsh-adapter/team-mode.d.ts +17 -10
- package/lib/types/dsh-adapter/team-mode.d.ts.map +1 -1
- package/lib/types/dsh-adapter/team-mode.js +19 -12
- package/lib/types/dsh-adapter/tool-scope.d.ts +24 -0
- package/lib/types/dsh-adapter/tool-scope.d.ts.map +1 -0
- package/lib/types/dsh-adapter/tool-scope.js +127 -0
- package/lib/types/dsh-adapter/types.d.ts +2 -1
- package/lib/types/dsh-adapter/types.d.ts.map +1 -1
- 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 +75 -0
- package/lib/types/heldInputs.d.ts.map +1 -0
- package/lib/types/heldInputs.js +409 -0
- package/lib/types/i18n.d.ts +577 -34
- package/lib/types/i18n.d.ts.map +1 -1
- package/lib/types/i18n.js +230 -22
- package/lib/types/ink/components/App.d.ts +2 -0
- package/lib/types/ink/components/App.d.ts.map +1 -1
- package/lib/types/ink/components/App.js +8 -0
- package/lib/types/ink/events/input-event.d.ts.map +1 -1
- package/lib/types/ink/events/input-event.js +7 -6
- package/lib/types/ink/hit-test.d.ts +2 -0
- package/lib/types/ink/hit-test.d.ts.map +1 -1
- package/lib/types/ink/hit-test.js +10 -0
- package/lib/types/ink/hooks/use-program-status.d.ts +1 -1
- package/lib/types/ink/hooks/use-program-status.d.ts.map +1 -1
- package/lib/types/ink/hooks/use-program-status.js +3 -2
- package/lib/types/ink/ink.d.ts +1 -0
- package/lib/types/ink/ink.d.ts.map +1 -1
- package/lib/types/ink/ink.js +5 -2
- package/lib/types/ink/parse-keypress.d.ts.map +1 -1
- package/lib/types/ink/parse-keypress.js +25 -0
- package/lib/types/ink/terminal.d.ts +13 -2
- package/lib/types/ink/terminal.d.ts.map +1 -1
- package/lib/types/ink/terminal.js +29 -5
- 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 +133 -32
- 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/screens/SessionSupervisor.d.ts +3 -6
- package/lib/types/screens/SessionSupervisor.d.ts.map +1 -1
- package/lib/types/screens/SessionSupervisor.js +5 -8
- package/lib/types/screens/sessionSupervisor/ForeignSessionPanes.d.ts +1 -2
- package/lib/types/screens/sessionSupervisor/ForeignSessionPanes.d.ts.map +1 -1
- package/lib/types/screens/sessionSupervisor/ForeignSessionPanes.js +2 -2
- package/lib/types/screens/sessionSupervisor/model.d.ts +1 -1
- package/lib/types/screens/sessionSupervisor/model.js +1 -1
- package/lib/types/sessionMounts.d.ts +12 -5
- package/lib/types/sessionMounts.d.ts.map +1 -1
- package/lib/types/sessionMounts.js +33 -6
- package/lib/types/settings/definitions.js +2 -2
- package/lib/types/update.d.ts +412 -20
- package/lib/types/update.d.ts.map +1 -1
- package/lib/types/update.js +2094 -193
- package/lib/types/updateHost.d.ts +198 -0
- package/lib/types/updateHost.d.ts.map +1 -0
- package/lib/types/updateHost.js +608 -0
- 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/lib/types/utils/processName.d.ts +16 -0
- package/lib/types/utils/processName.d.ts.map +1 -0
- package/lib/types/utils/processName.js +27 -0
- package/package.json +114 -108
- package/tui-profile/feed/README.md +1 -1
- package/tui-profile/feed/first-party.json +1 -1
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { Box, Text, InputCaret } from '../../../ui.js';
|
|
2
|
+
import { Box, Text, InputCaret, useTerminalSize } from '../../../ui.js';
|
|
3
3
|
import { t } from '../../../i18n.js';
|
|
4
|
+
import { actionMatches } from '../../../utils/keymap.js';
|
|
5
|
+
import { flattenInline, flattenPasteInline } from '../../../channel/sanitize.js';
|
|
6
|
+
import { stringWidth } from '../../../ink/stringWidth.js';
|
|
7
|
+
import { getGraphemeSegmenter } from '../../../utils/intl.js';
|
|
4
8
|
import { nextCodePoint, previousCodePoint } from '../../AgentMessageComposer.js';
|
|
5
9
|
/**
|
|
6
10
|
* 单行 composer 的键语义。返回 null = 未消费(面板形态交宿主回退键,
|
|
@@ -15,6 +19,20 @@ export function btwComposerKey(state, input, key) {
|
|
|
15
19
|
// The caret is per surface while the draft is shared through the store:
|
|
16
20
|
// an edit on the other surface can leave this caret past the end.
|
|
17
21
|
const caret = Math.min(state.caret, state.text.length);
|
|
22
|
+
// 终端原生粘贴(Ctrl+Shift+V / 右键 / 终端自己接管的 Ctrl+V)整块到达并
|
|
23
|
+
// 打上 isPasted:单行框先压成一行再插,纯换行的块是文本、绝不是 Enter。
|
|
24
|
+
// 必须排在 plainReturn 之前——粘贴块也可能带着 return 标记。
|
|
25
|
+
if (key.isPasted === true) {
|
|
26
|
+
const text = flattenPasteInline(input);
|
|
27
|
+
// 纯换行/空白压完是空格,trim 后为空 = 没有可插入的文本(不是 Enter)。
|
|
28
|
+
if (text.trim() === '')
|
|
29
|
+
return {};
|
|
30
|
+
return { state: { text: state.text.slice(0, caret) + text + state.text.slice(caret), caret: caret + text.length } };
|
|
31
|
+
}
|
|
32
|
+
// Ctrl+V / Alt+V(keymap 的 paste 动作,可在 /settings 重映射):读剪贴板
|
|
33
|
+
// 是异步的,纯函数只交出意图,由 surface 侧按实时草稿与 caret 落字。
|
|
34
|
+
if (actionMatches('paste', input, key))
|
|
35
|
+
return { paste: true };
|
|
18
36
|
const plainReturn = (key.return_ === true || key.return === true || /^[\r\n]+$/u.test(input))
|
|
19
37
|
&& key.ctrl !== true && key.meta !== true && key.shift !== true;
|
|
20
38
|
if (plainReturn)
|
|
@@ -53,13 +71,112 @@ export function btwComposerKey(state, input, key) {
|
|
|
53
71
|
if (key.end === true)
|
|
54
72
|
return { state: { ...state, caret: state.text.length } };
|
|
55
73
|
if (input !== '' && key.ctrl !== true && key.meta !== true) {
|
|
56
|
-
|
|
74
|
+
// 整块文本不一定带 isPasted:忽略 bracketed paste 的终端会把换行原样
|
|
75
|
+
// 送进这里,而单行窗口的 Text 会按 LF 折出第二行(被 overflow 裁掉、
|
|
76
|
+
// caret 与可见文本脱节)。等长压平后再插,caret 偏移保持不变。
|
|
77
|
+
const typed = flattenInline(input);
|
|
78
|
+
return { state: { text: state.text.slice(0, caret) + typed + state.text.slice(caret), caret: caret + typed.length } };
|
|
57
79
|
}
|
|
58
80
|
return null;
|
|
59
81
|
}
|
|
60
|
-
|
|
82
|
+
/**
|
|
83
|
+
* 单行输入框的窗口(issue #1812):按显示列把草稿裁成 head + at + tail,
|
|
84
|
+
* caret 始终留在框内;两侧被裁时各补一个 `…`,让人知道那边还有字。
|
|
85
|
+
*
|
|
86
|
+
* 不能只靠 `wrap="truncate"`:截断把节点的宽度夹到可用宽度,排在它后面的
|
|
87
|
+
* `InputCaret` 必然落到框右缘之外。所以先算窗口再上屏。按字素累计列宽,
|
|
88
|
+
* CJK / 宽字符 / emoji 整格取舍,不在中间劈开;草稿由面板与全屏共享,另一个
|
|
89
|
+
* 编辑面可能把这个 caret 留在字素中间,此时吸附到后一个边界,绝不显示半个字。
|
|
90
|
+
*/
|
|
91
|
+
export function composerWindow(text, caret, budget) {
|
|
92
|
+
const width = Math.max(1, budget);
|
|
93
|
+
const cells = [];
|
|
94
|
+
const starts = [];
|
|
95
|
+
for (const { segment, index } of getGraphemeSegmenter().segment(text)) {
|
|
96
|
+
cells.push(segment);
|
|
97
|
+
starts.push(index);
|
|
98
|
+
}
|
|
99
|
+
const clamped = Math.max(0, Math.min(caret, text.length));
|
|
100
|
+
// caret 之前的完整字素个数:caret 正好落在边界上取它;落在字素中间则
|
|
101
|
+
// 取后一个边界(那个字素整个留在 head 里,caret 画在它之后)。
|
|
102
|
+
let index = cells.length;
|
|
103
|
+
for (let i = 0; i < starts.length; i += 1) {
|
|
104
|
+
if (starts[i] >= clamped) {
|
|
105
|
+
index = i;
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
const at = cells[index] ?? ' ';
|
|
110
|
+
const atWidth = stringWidth(at);
|
|
111
|
+
// 两侧各自还需要多少列:用来决定分配,也让「某侧其实放得下」时不浪费 `…`。
|
|
112
|
+
let leftNeed = 0;
|
|
113
|
+
for (let i = 0; i < index; i += 1)
|
|
114
|
+
leftNeed += stringWidth(cells[i]);
|
|
115
|
+
let rightNeed = 0;
|
|
116
|
+
for (let i = index + 1; i < cells.length; i += 1)
|
|
117
|
+
rightNeed += stringWidth(cells[i]);
|
|
118
|
+
const fitsAll = leftNeed + rightNeed <= width - atWidth;
|
|
119
|
+
/** 按给定预留列数做一次分配:两侧都超框时 caret 居中。 */
|
|
120
|
+
const allocate = (reserveLeft, reserveRight) => {
|
|
121
|
+
const content = Math.max(0, width - atWidth - reserveLeft - reserveRight);
|
|
122
|
+
// 两侧都有字时分一半(零头给左侧),否则整行给有字的那一侧。
|
|
123
|
+
let headLimit = leftNeed > 0 && rightNeed > 0 ? Math.ceil(content / 2) : content;
|
|
124
|
+
headLimit = Math.min(headLimit, leftNeed);
|
|
125
|
+
// 右侧用不完自己的份额:余量还给左侧(最多到它需要的量)。
|
|
126
|
+
if (rightNeed < content - headLimit)
|
|
127
|
+
headLimit = Math.min(leftNeed, content - rightNeed);
|
|
128
|
+
let head = index;
|
|
129
|
+
let headWidth = 0;
|
|
130
|
+
while (head > 0) {
|
|
131
|
+
const cellWidth = stringWidth(cells[head - 1]);
|
|
132
|
+
if (headWidth + cellWidth > headLimit)
|
|
133
|
+
break;
|
|
134
|
+
headWidth += cellWidth;
|
|
135
|
+
head -= 1;
|
|
136
|
+
}
|
|
137
|
+
const tailLimit = content - headWidth;
|
|
138
|
+
let tail = index + 1;
|
|
139
|
+
let tailWidth = 0;
|
|
140
|
+
while (tail < cells.length) {
|
|
141
|
+
const cellWidth = stringWidth(cells[tail]);
|
|
142
|
+
if (tailWidth + cellWidth > tailLimit)
|
|
143
|
+
break;
|
|
144
|
+
tailWidth += cellWidth;
|
|
145
|
+
tail += 1;
|
|
146
|
+
}
|
|
147
|
+
return { head, tail, headWidth, tailWidth };
|
|
148
|
+
};
|
|
149
|
+
// 两侧各留 1 列给 `…`,再按实际裁没裁掉把多余的预留收回来。预算连两个
|
|
150
|
+
// `…` 都不够时(极窄档)干脆不画:指示符不能把 caret 挤出框。
|
|
151
|
+
const room = Math.max(0, width - atWidth);
|
|
152
|
+
let reserveLeft = !fitsAll && index > 0 ? 1 : 0;
|
|
153
|
+
let reserveRight = !fitsAll && rightNeed > 0 ? 1 : 0;
|
|
154
|
+
if (reserveLeft + reserveRight > room) {
|
|
155
|
+
reserveLeft = 0;
|
|
156
|
+
reserveRight = 0;
|
|
157
|
+
}
|
|
158
|
+
let layout = allocate(reserveLeft, reserveRight);
|
|
159
|
+
// 收预留只会多出内容,不会让另一侧变得更紧,所以各检查一次就稳定。
|
|
160
|
+
if (layout.head === 0 && reserveLeft > 0) {
|
|
161
|
+
reserveLeft = 0;
|
|
162
|
+
layout = allocate(reserveLeft, reserveRight);
|
|
163
|
+
}
|
|
164
|
+
if (layout.tail === cells.length && reserveRight > 0) {
|
|
165
|
+
reserveRight = 0;
|
|
166
|
+
layout = allocate(reserveLeft, reserveRight);
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
head: cells.slice(layout.head, index).join(''),
|
|
170
|
+
at,
|
|
171
|
+
tail: cells.slice(index + 1, layout.tail).join(''),
|
|
172
|
+
clippedLeft: reserveLeft === 1,
|
|
173
|
+
clippedRight: reserveRight === 1,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
export function BtwComposer({ state, focused, busy, notice, width, onActivate, }) {
|
|
177
|
+
const { columns } = useTerminalSize();
|
|
61
178
|
const { text, caret } = state;
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
return (_jsxs(Box, { flexDirection: "column", flexShrink: 0, children: [_jsx(Box, { width: "100%", flexShrink: 0, borderStyle: "round", borderColor: focused ? 'accent' : undefined, onClick: onActivate === undefined ? undefined : () => onActivate(), children: _jsxs(Box, { flexDirection: "row", flexShrink: 0, paddingLeft: 1, paddingRight: 1, children: [_jsx(Text, { color: focused ? 'accent' : undefined, bold: true, children: '›' }), _jsx(Text, { children: ' ' }), focused ? (_jsxs(_Fragment, { children: [
|
|
179
|
+
// 边框 2 + 左右 padding 2 + 「› 」2 = 6 列不属于草稿。
|
|
180
|
+
const view = composerWindow(text, caret, Math.max(1, (width ?? columns) - 6));
|
|
181
|
+
return (_jsxs(Box, { flexDirection: "column", flexShrink: 0, children: [_jsx(Box, { width: "100%", flexShrink: 0, borderStyle: "round", borderColor: focused ? 'accent' : undefined, onClick: onActivate === undefined ? undefined : () => onActivate(), children: _jsxs(Box, { flexDirection: "row", height: 1, flexShrink: 1, minWidth: 0, paddingLeft: 1, paddingRight: 1, children: [_jsx(Box, { flexShrink: 0, children: _jsx(Text, { color: focused ? 'accent' : undefined, bold: true, children: '›' }) }), _jsx(Box, { flexShrink: 0, children: _jsx(Text, { children: ' ' }) }), focused ? (text === '' ? (_jsxs(_Fragment, { children: [_jsx(InputCaret, { children: ' ' }), _jsx(Box, { flexGrow: 1, flexShrink: 0, children: _jsx(Text, { children: " " }) }), _jsx(Box, { flexShrink: 1, minWidth: 0, children: _jsxs(Text, { dimColor: true, wrap: "truncate", children: [" ", t('btw-input-hint-edit')] }) })] })) : (_jsxs(Box, { flexDirection: "row", flexShrink: 1, minWidth: 0, height: 1, overflow: "hidden", children: [view.clippedLeft ? _jsx(Text, { wrap: "truncate", children: '…' }) : null, _jsx(Text, { wrap: "truncate", children: view.head }), _jsx(InputCaret, { children: view.at }), _jsx(Text, { wrap: "truncate", children: view.tail }), view.clippedRight ? _jsx(Text, { wrap: "truncate", children: '…' }) : null] }))) : (_jsx(Text, { dimColor: true, wrap: "truncate", children: text === '' ? t('btw-input-placeholder') : text }))] }) }), notice !== undefined && (_jsx(Text, { color: notice.failure ? 'error' : undefined, wrap: "truncate", children: notice.text }))] }));
|
|
65
182
|
}
|
|
@@ -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,CAqRhG"}
|
|
@@ -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
|
// 空线程不画头部:标题没有内容,`新话题` 在空线程上也无事可做(清空/换题的
|
|
@@ -278,5 +285,5 @@ export function BtwPanelAdapter({ width, height, focused, visible }) {
|
|
|
278
285
|
panelStore.setHint('btw', hintText);
|
|
279
286
|
return () => { panelStore.setHint('btw', ''); };
|
|
280
287
|
}, [hintText]);
|
|
281
|
-
return (_jsxs(Box, { flexDirection: "column", width: "100%", height: height, overflow: "hidden", children: [header, _jsx(BtwThreadView, { thread: thread, width: width, height: Math.max(3, height - (header === null ? 4 : 6)), alive: visible, selectedTurnId: listActive ? selectedId ?? undefined : undefined, onSelectTurn: selectTurn, scrollHandleRef: scrollRef }), _jsx(BtwComposer, { state: { text: thread?.draft ?? '', caret }, focused: composerFocus && focused && visible, busy: busy, notice: notice === undefined || notice === null ? undefined : notice, onActivate: activateComposer })] }));
|
|
288
|
+
return (_jsxs(Box, { flexDirection: "column", width: "100%", height: height, overflow: "hidden", children: [header, _jsx(BtwThreadView, { thread: thread, width: width, height: Math.max(3, height - (header === null ? 4 : 6)), alive: visible, selectedTurnId: listActive ? selectedId ?? undefined : undefined, onSelectTurn: selectTurn, scrollHandleRef: scrollRef }), _jsx(BtwComposer, { state: { text: thread?.draft ?? '', caret }, focused: composerFocus && focused && visible, busy: busy, notice: notice === undefined || notice === null ? undefined : notice, width: width, onActivate: activateComposer })] }));
|
|
282
289
|
}
|
|
@@ -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,CA2KlB"}
|
|
@@ -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);
|
|
@@ -175,5 +182,5 @@ export function BtwThreadScene({ channel, onClose, onFocusChat, }) {
|
|
|
175
182
|
event.stopImmediatePropagation();
|
|
176
183
|
}
|
|
177
184
|
});
|
|
178
|
-
return (_jsxs(Box, { flexDirection: "column", width: columns, height: rows, paddingX: 1, children: [_jsxs(Box, { flexDirection: "row", width: "100%", height: 1, flexShrink: 0, children: [_jsx(Text, { color: "warning", bold: true, children: t('btw-fullscreen-title') }), _jsx(Text, { dimColor: true, wrap: "truncate", children: ' ' + t('btw-scene-hints') })] }), _jsx(BtwThreadView, { thread: thread, width: columns - 2, height: Math.max(3, rows - 4), alive: true, selectedTurnId: composerFocus ? undefined : selectedId ?? undefined, onSelectTurn: selectTurn, scrollHandleRef: scrollRef }), _jsx(BtwComposer, { state: { text: thread?.draft ?? '', caret }, focused: composerFocus, busy: busy, notice: notice === null ? undefined : notice, onActivate: activateComposer })] }));
|
|
185
|
+
return (_jsxs(Box, { flexDirection: "column", width: columns, height: rows, paddingX: 1, children: [_jsxs(Box, { flexDirection: "row", width: "100%", height: 1, flexShrink: 0, children: [_jsx(Text, { color: "warning", bold: true, children: t('btw-fullscreen-title') }), _jsx(Text, { dimColor: true, wrap: "truncate", children: ' ' + t('btw-scene-hints') })] }), _jsx(BtwThreadView, { thread: thread, width: columns - 2, height: Math.max(3, rows - 4), alive: true, selectedTurnId: composerFocus ? undefined : selectedId ?? undefined, onSelectTurn: selectTurn, scrollHandleRef: scrollRef }), _jsx(BtwComposer, { state: { text: thread?.draft ?? '', caret }, focused: composerFocus, busy: busy, notice: notice === null ? undefined : notice, width: columns - 2, onActivate: activateComposer })] }));
|
|
179
186
|
}
|
|
@@ -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,CAAA;CAC9B;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB;0DACsD;IACtD,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,YAAY,CAAA;CAC/C;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAAA;CAClC;AAED,MAAM,WAAW,eAAe;IAC9B,oEAAoE;IACpE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,wCAAwC;I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,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,CAAA;AACxB,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAIrE,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAEnD,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,OAAO,CAAA;AAE7C,MAAM,WAAW,mBAAmB;IAClC,4EAA4E;IAC5E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAA;IAC5B,sEAAsE;IACtE,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAA;CAC7B;AAED,MAAM,WAAW,qBAAqB;IACpC,wBAAwB,CAAC,EAAE,MAAM,IAAI,CAAA;CACtC;AAED,MAAM,WAAW,mBAAmB;IAClC,kEAAkE;IAClE,QAAQ,CAAC,QAAQ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MD,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
|
|
@@ -12,18 +12,48 @@ export declare function subscribeReveal(listener: () => void): () => void;
|
|
|
12
12
|
export declare function getRevealVersion(): number;
|
|
13
13
|
/** Force-complete (and forget) a cursor: expanded card, replaced view, … */
|
|
14
14
|
export declare function snapReveal(key: string): void;
|
|
15
|
+
/**
|
|
16
|
+
* Key for `key` inside `scope`. Every Chat root owns its reveal memory: ids
|
|
17
|
+
* restart at 0 inside a root, so a sibling root's rebind must not clear (or
|
|
18
|
+
* inherit) another root's completed keys. `undefined` keeps the bare key —
|
|
19
|
+
* single-root scripts, tests, and any caller outside a Chat provider.
|
|
20
|
+
*/
|
|
21
|
+
export declare function scopeRevealKey(scope: string | undefined, key: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* Session boundary (agent switch, `/resume`, rewind adopt): row ids restart
|
|
24
|
+
* at 0, so a key from the previous session (`a12`) names a different row in
|
|
25
|
+
* the new one. Drop both the completed memory and any in-flight cursors —
|
|
26
|
+
* replayed rows read with `active: false` and paint complete anyway, while
|
|
27
|
+
* the new session's live rows must be free to animate from scratch. The
|
|
28
|
+
* scheduler, listeners and version store stay intact: the mounted tree keeps
|
|
29
|
+
* subscribing, and clearing both cursor tables stops the timer synchronously.
|
|
30
|
+
*
|
|
31
|
+
* Known residue: a backend `conversation_reset` also restarts row ids, but it
|
|
32
|
+
* is a channel-layer event that never crosses into the UI — that path keeps
|
|
33
|
+
* its stale keys, so the first rows after such a reset paint without a
|
|
34
|
+
* reveal. The old 2048 FIFO used to heal this by accident once a session had
|
|
35
|
+
* revealed past the cap; with no eviction it is permanent until the agent
|
|
36
|
+
* changes. Covering it needs a row-id-regression signal from the channel;
|
|
37
|
+
* tracked in #1795.
|
|
38
|
+
*/
|
|
39
|
+
export declare function resetRevealSession(scope: string): void;
|
|
15
40
|
export type RevealReadOptions = {
|
|
16
41
|
/** Master switch (settings `dsh-tui.smoothStreaming`); false = full text. */
|
|
17
42
|
enabled: boolean;
|
|
18
43
|
/**
|
|
19
44
|
* Whether this content arrived "just now" (live streaming row, freshly
|
|
20
45
|
* settled row, live-created tool card). The FIRST read with active=true
|
|
21
|
-
* creates the cursor at zero — that is what turns a one-shot
|
|
22
|
-
*
|
|
23
|
-
* (history / replayed content)
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
46
|
+
* creates the cursor at zero — that is what turns a one-shot non-streaming
|
|
47
|
+
* delivery into a smooth paint. A first TEXT read with active=false
|
|
48
|
+
* (history / replayed content) paints the whole text and registers a
|
|
49
|
+
* caught-up cursor (revealed == text.length, no timer), so replaying a
|
|
50
|
+
* transcript typewrites nothing while a later live continuation of the same
|
|
51
|
+
* row starts at the painted length instead of zero. The count reader
|
|
52
|
+
* (`revealLinesOf`) has no such cursor: an inactive read just returns the
|
|
53
|
+
* total, and the next active read starts a fresh cursor. `active` decides
|
|
54
|
+
* where a new cursor starts, not whether one exists; settling mid-reveal
|
|
55
|
+
* deliberately keeps revealing (the "non-streaming becomes streaming"
|
|
56
|
+
* contract).
|
|
27
57
|
*/
|
|
28
58
|
active: boolean;
|
|
29
59
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smoothReveal.d.ts","sourceRoot":"","sources":["../../../src/components/smoothReveal.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"smoothReveal.d.ts","sourceRoot":"","sources":["../../../src/components/smoothReveal.ts"],"names":[],"mappings":"AA6CA,oEAAoE;AACpE,eAAO,MAAM,eAAe,QAAY,CAAA;AACxC,gFAAgF;AAChF,eAAO,MAAM,eAAe,IAAI,CAAA;AAChC,8EAA8E;AAC9E,eAAO,MAAM,qBAAqB,IAAI,CAAA;AAEtC,kEAAkE;AAClE,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAElD;AAqJD,oEAAoE;AACpE,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAKhE;AAED,wEAAwE;AACxE,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,4EAA4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