@ahggg/dsh-side-chat 0.7.2 → 0.7.3
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 +3 -3
- package/README.zh-CN.md +3 -3
- package/lib/client/apply.d.ts +0 -1
- package/lib/client/apply.js +0 -1
- package/lib/client/contracts.d.ts +0 -1
- package/lib/client/contracts.js +0 -1
- package/lib/client/index.d.ts +0 -1
- package/lib/client/index.js +0 -1
- package/lib/client/model-preference.d.ts +0 -1
- package/lib/client/model-preference.js +0 -1
- package/lib/client/panel/SelectionQuote.d.ts +0 -1
- package/lib/client/panel/SelectionQuote.js +0 -1
- package/lib/client/panel/SendIcon.d.ts +0 -1
- package/lib/client/panel/SendIcon.js +0 -1
- package/lib/client/panel/SideChatBody.d.ts +0 -1
- package/lib/client/panel/SideChatBody.js +0 -1
- package/lib/client/panel/SideChatErrorState.d.ts +0 -1
- package/lib/client/panel/SideChatErrorState.js +0 -1
- package/lib/client/panel/SideChatHeader.d.ts +0 -1
- package/lib/client/panel/SideChatHeader.js +0 -1
- package/lib/client/panel/SideChatModelSelect.d.ts +0 -1
- package/lib/client/panel/SideChatModelSelect.js +0 -1
- package/lib/client/panel/SideChatPanel.d.ts +0 -1
- package/lib/client/panel/SideChatPanel.js +0 -1
- package/lib/client/panel/StopIcon.d.ts +0 -1
- package/lib/client/panel/StopIcon.js +0 -1
- package/lib/client/panel/messages.d.ts +0 -1
- package/lib/client/panel/messages.js +0 -1
- package/lib/client/panel/use-auto-growing-textarea.d.ts +0 -1
- package/lib/client/panel/use-auto-growing-textarea.js +0 -1
- package/lib/client/parent-composer/ParentConversationAnnotations.d.ts +0 -1
- package/lib/client/parent-composer/ParentConversationAnnotations.js +26 -3
- package/lib/client/parent-composer/add-to-conversation.d.ts +0 -1
- package/lib/client/parent-composer/add-to-conversation.js +99 -8
- package/lib/client/parent-composer/annotation-persistence.d.ts +0 -1
- package/lib/client/parent-composer/annotation-persistence.js +0 -1
- package/lib/client/parent-composer/composer-reference.d.ts +16 -7
- package/lib/client/parent-composer/composer-reference.js +34 -2
- package/lib/client/parent-composer/referenced-conversation.d.ts +1 -2
- package/lib/client/parent-composer/referenced-conversation.js +26 -8
- package/lib/client/rc6/ArchivedConversation.d.ts +2 -3
- package/lib/client/rc6/ArchivedConversation.js +6 -5
- package/lib/client/rc6/Rc6SideChatOverlay.d.ts +0 -1
- package/lib/client/rc6/Rc6SideChatOverlay.js +0 -1
- package/lib/client/rc6/SideChatTool.d.ts +1 -2
- package/lib/client/rc6/SideChatTool.js +18 -9
- package/lib/client/rc6/context.d.ts +9 -3
- package/lib/client/rc6/context.js +0 -1
- package/lib/client/rc6/primitive-labels.d.ts +7 -0
- package/lib/client/rc6/primitive-labels.js +60 -0
- package/lib/client/rc6/remote-adapter.d.ts +0 -1
- package/lib/client/rc6/remote-adapter.js +4 -3
- package/lib/client/rc6/runtime-compat.d.ts +120 -0
- package/lib/client/rc6/runtime-compat.js +187 -0
- package/lib/client/rc6/sessions-adapter.d.ts +7 -4
- package/lib/client/rc6/sessions-adapter.js +62 -45
- package/lib/client/selection/ConversationAnnotationMarkers.d.ts +0 -1
- package/lib/client/selection/ConversationAnnotationMarkers.js +0 -1
- package/lib/client/selection/SelectionActions.d.ts +0 -1
- package/lib/client/selection/SelectionActions.js +0 -1
- package/lib/client/selection/selection-controller.d.ts +0 -1
- package/lib/client/selection/selection-controller.js +0 -1
- package/lib/client/selection/selection-limits.d.ts +0 -1
- package/lib/client/selection/selection-limits.js +0 -1
- package/lib/client/selection/selection-normalizer.d.ts +0 -1
- package/lib/client/selection/selection-normalizer.js +0 -1
- package/lib/client/side-chat-controller.d.ts +0 -1
- package/lib/client/side-chat-controller.js +0 -1
- package/lib/client.js +1173 -8951
- package/lib/host/archived-fork-service.d.ts +0 -1
- package/lib/host/archived-fork-service.js +71 -26
- package/lib/host/index.d.ts +0 -1
- package/lib/host/index.js +0 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -1
- package/lib/remote.d.ts +0 -1
- package/lib/remote.js +0 -1
- package/lib/shared/archived-wire.d.ts +0 -1
- package/lib/shared/archived-wire.js +0 -1
- package/lib/shared/constants.d.ts +0 -1
- package/lib/shared/constants.js +0 -1
- package/lib/shared/contracts.d.ts +0 -1
- package/lib/shared/contracts.js +0 -1
- package/lib/shared/error-codes.d.ts +0 -1
- package/lib/shared/error-codes.js +0 -1
- package/lib/shared/observable.d.ts +0 -1
- package/lib/shared/observable.js +0 -1
- package/lib/typert.d.ts +0 -1
- package/lib/typert.js +64 -51
- package/package.json +60 -38
- package/lib/client/apply.d.ts.map +0 -1
- package/lib/client/apply.js.map +0 -1
- package/lib/client/contracts.d.ts.map +0 -1
- package/lib/client/contracts.js.map +0 -1
- package/lib/client/index.d.ts.map +0 -1
- package/lib/client/index.js.map +0 -1
- package/lib/client/model-preference.d.ts.map +0 -1
- package/lib/client/model-preference.js.map +0 -1
- package/lib/client/panel/SelectionQuote.d.ts.map +0 -1
- package/lib/client/panel/SelectionQuote.js.map +0 -1
- package/lib/client/panel/SendIcon.d.ts.map +0 -1
- package/lib/client/panel/SendIcon.js.map +0 -1
- package/lib/client/panel/SideChatBody.d.ts.map +0 -1
- package/lib/client/panel/SideChatBody.js.map +0 -1
- package/lib/client/panel/SideChatErrorState.d.ts.map +0 -1
- package/lib/client/panel/SideChatErrorState.js.map +0 -1
- package/lib/client/panel/SideChatHeader.d.ts.map +0 -1
- package/lib/client/panel/SideChatHeader.js.map +0 -1
- package/lib/client/panel/SideChatModelSelect.d.ts.map +0 -1
- package/lib/client/panel/SideChatModelSelect.js.map +0 -1
- package/lib/client/panel/SideChatPanel.d.ts.map +0 -1
- package/lib/client/panel/SideChatPanel.js.map +0 -1
- package/lib/client/panel/StopIcon.d.ts.map +0 -1
- package/lib/client/panel/StopIcon.js.map +0 -1
- package/lib/client/panel/messages.d.ts.map +0 -1
- package/lib/client/panel/messages.js.map +0 -1
- package/lib/client/panel/use-auto-growing-textarea.d.ts.map +0 -1
- package/lib/client/panel/use-auto-growing-textarea.js.map +0 -1
- package/lib/client/parent-composer/ParentConversationAnnotations.d.ts.map +0 -1
- package/lib/client/parent-composer/ParentConversationAnnotations.js.map +0 -1
- package/lib/client/parent-composer/add-to-conversation.d.ts.map +0 -1
- package/lib/client/parent-composer/add-to-conversation.js.map +0 -1
- package/lib/client/parent-composer/annotation-persistence.d.ts.map +0 -1
- package/lib/client/parent-composer/annotation-persistence.js.map +0 -1
- package/lib/client/parent-composer/composer-reference.d.ts.map +0 -1
- package/lib/client/parent-composer/composer-reference.js.map +0 -1
- package/lib/client/parent-composer/referenced-conversation.d.ts.map +0 -1
- package/lib/client/parent-composer/referenced-conversation.js.map +0 -1
- package/lib/client/rc6/ArchivedConversation.d.ts.map +0 -1
- package/lib/client/rc6/ArchivedConversation.js.map +0 -1
- package/lib/client/rc6/Rc6SideChatOverlay.d.ts.map +0 -1
- package/lib/client/rc6/Rc6SideChatOverlay.js.map +0 -1
- package/lib/client/rc6/SideChatTool.d.ts.map +0 -1
- package/lib/client/rc6/SideChatTool.js.map +0 -1
- package/lib/client/rc6/context.d.ts.map +0 -1
- package/lib/client/rc6/context.js.map +0 -1
- package/lib/client/rc6/remote-adapter.d.ts.map +0 -1
- package/lib/client/rc6/remote-adapter.js.map +0 -1
- package/lib/client/rc6/sessions-adapter.d.ts.map +0 -1
- package/lib/client/rc6/sessions-adapter.js.map +0 -1
- package/lib/client/selection/ConversationAnnotationMarkers.d.ts.map +0 -1
- package/lib/client/selection/ConversationAnnotationMarkers.js.map +0 -1
- package/lib/client/selection/SelectionActions.d.ts.map +0 -1
- package/lib/client/selection/SelectionActions.js.map +0 -1
- package/lib/client/selection/selection-controller.d.ts.map +0 -1
- package/lib/client/selection/selection-controller.js.map +0 -1
- package/lib/client/selection/selection-limits.d.ts.map +0 -1
- package/lib/client/selection/selection-limits.js.map +0 -1
- package/lib/client/selection/selection-normalizer.d.ts.map +0 -1
- package/lib/client/selection/selection-normalizer.js.map +0 -1
- package/lib/client/side-chat-controller.d.ts.map +0 -1
- package/lib/client/side-chat-controller.js.map +0 -1
- package/lib/client.js.map +0 -1
- package/lib/host/archived-fork-service.d.ts.map +0 -1
- package/lib/host/archived-fork-service.js.map +0 -1
- package/lib/host/index.d.ts.map +0 -1
- package/lib/host/index.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/remote.d.ts.map +0 -1
- package/lib/remote.js.map +0 -1
- package/lib/shared/archived-wire.d.ts.map +0 -1
- package/lib/shared/archived-wire.js.map +0 -1
- package/lib/shared/constants.d.ts.map +0 -1
- package/lib/shared/constants.js.map +0 -1
- package/lib/shared/contracts.d.ts.map +0 -1
- package/lib/shared/contracts.js.map +0 -1
- package/lib/shared/error-codes.d.ts.map +0 -1
- package/lib/shared/error-codes.js.map +0 -1
- package/lib/shared/observable.d.ts.map +0 -1
- package/lib/shared/observable.js.map +0 -1
- package/lib/typert.d.ts.map +0 -1
- package/lib/typert.js.map +0 -1
package/README.md
CHANGED
|
@@ -8,10 +8,10 @@ Ask a focused follow-up about selected text without leaving your current DeepSee
|
|
|
8
8
|
|
|
9
9
|
## Install
|
|
10
10
|
|
|
11
|
-
Install DSH rc.
|
|
11
|
+
Install DSH 0.1.2-rc.1 if it is not already available. Refresh only this package's registry metadata before adding it, so pnpm cannot reuse an older `latest` value immediately after a release:
|
|
12
12
|
|
|
13
13
|
```powershell
|
|
14
|
-
npm install --global @deepseek-ai/dsh@0.1.
|
|
14
|
+
npm install --global @deepseek-ai/dsh@0.1.2-rc.1
|
|
15
15
|
pnpm cache delete "@ahggg/dsh-side-chat"
|
|
16
16
|
dsh plugin --profile web add @ahggg/dsh-side-chat@latest
|
|
17
17
|
```
|
|
@@ -27,7 +27,7 @@ Open the URL printed by DSH. The plugin loads automatically in the Web client.
|
|
|
27
27
|
|
|
28
28
|
### Local linked development
|
|
29
29
|
|
|
30
|
-
When `dsh plugin --profile web list` shows the plugin coming from a `link:` workspace, DSH loads the
|
|
30
|
+
When `dsh plugin --profile web list` shows the plugin coming from a `link:` workspace, DSH loads the committed `lib/client.js`, not `src/`. Rebuild after switching branches or changing client source, then restart the `dsh web` process:
|
|
31
31
|
|
|
32
32
|
```powershell
|
|
33
33
|
pnpm install --frozen-lockfile
|
package/README.zh-CN.md
CHANGED
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
|
|
9
9
|
## 安装
|
|
10
10
|
|
|
11
|
-
如果尚未安装 DSH rc.
|
|
11
|
+
如果尚未安装 DSH 0.1.2-rc.1,先安装它。添加插件前只刷新这个包的 registry metadata,避免刚发布新版本时 pnpm 仍复用旧的 `latest`:
|
|
12
12
|
|
|
13
13
|
```powershell
|
|
14
|
-
npm install --global @deepseek-ai/dsh@0.1.
|
|
14
|
+
npm install --global @deepseek-ai/dsh@0.1.2-rc.1
|
|
15
15
|
pnpm cache delete "@ahggg/dsh-side-chat"
|
|
16
16
|
dsh plugin --profile web add @ahggg/dsh-side-chat@latest
|
|
17
17
|
```
|
|
@@ -27,7 +27,7 @@ dsh web --port 3080
|
|
|
27
27
|
|
|
28
28
|
### 本地链接调试
|
|
29
29
|
|
|
30
|
-
当 `dsh plugin --profile web list` 显示插件来自 `link:` 工作区时,DSH
|
|
30
|
+
当 `dsh plugin --profile web list` 显示插件来自 `link:` 工作区时,DSH 加载的是已提交的 `lib/client.js`,而不是 `src/`。切换分支或修改客户端源码后,需要重新构建并重启 `dsh web` 进程:
|
|
31
31
|
|
|
32
32
|
```powershell
|
|
33
33
|
pnpm install --frozen-lockfile
|
package/lib/client/apply.d.ts
CHANGED
package/lib/client/apply.js
CHANGED
package/lib/client/contracts.js
CHANGED
package/lib/client/index.d.ts
CHANGED
|
@@ -8,4 +8,3 @@ export { captureDomConversationSelection, restoreDomConversationSelection, type
|
|
|
8
8
|
export { selectionFitsLimit, summarizeSelection, utf8ByteLength } from './selection/selection-limits.js';
|
|
9
9
|
export { assertSelectionCurrent, finalizeConversationSelection, normalizeSelectedText, SelectionValidationError, type ConversationSelectionInput, } from './selection/selection-normalizer.js';
|
|
10
10
|
export type { ConversationSelection, SelectionFragment, SelectionRect, SideChatModelSelection, SideChatState, } from '../shared/contracts.js';
|
|
11
|
-
//# sourceMappingURL=index.d.ts.map
|
package/lib/client/index.js
CHANGED
|
@@ -6,4 +6,3 @@ export { SelectionActions } from './selection/SelectionActions.js';
|
|
|
6
6
|
export { captureDomConversationSelection, restoreDomConversationSelection, } from './selection/selection-controller.js';
|
|
7
7
|
export { selectionFitsLimit, summarizeSelection, utf8ByteLength } from './selection/selection-limits.js';
|
|
8
8
|
export { assertSelectionCurrent, finalizeConversationSelection, normalizeSelectedText, SelectionValidationError, } from './selection/selection-normalizer.js';
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -70,4 +70,3 @@ export function SelectionQuote({ selections, messages, onRemove, }) {
|
|
|
70
70
|
setExpanded(value => !value);
|
|
71
71
|
}, children: [_jsxs("svg", { className: "dsh-side-chat-quote-icon", viewBox: "0 0 24 24", "aria-hidden": "true", children: [_jsx("path", { d: "M21 15a4 4 0 0 1-4 4H7l-4 4V7a4 4 0 0 1 4-4h10a4 4 0 0 1 4 4Z" }), _jsx("path", { d: "M8 8h8M8 12h5" })] }), _jsx("strong", { children: messages.selectionAttachments(selections.length) })] }), onRemove !== undefined && (_jsx("button", { type: "button", className: "dsh-side-chat-quote-remove", "aria-label": messages.removeSelection, onClick: onRemove, children: "\u00D7" }))] }), _jsx("div", { ref: detailsRef, className: "dsh-side-chat-quote-details", role: "tooltip", children: selections.map((selection, index) => (_jsxs("div", { className: "dsh-side-chat-quote-detail", children: [_jsx("div", { className: "dsh-side-chat-quote-details-header", children: _jsxs("strong", { children: [String(index + 1), ". ", messages.selectionPreviewLabel, ":"] }) }), _jsx("pre", { children: selection.text }), selection.comment !== undefined && (_jsxs("div", { className: "dsh-side-chat-quote-comment", children: [_jsxs("strong", { children: [messages.selectionCommentLabel, ":"] }), _jsx("pre", { children: selection.comment })] }))] }, `${String(index)}-${selection.text}`))) })] }));
|
|
72
72
|
}
|
|
73
|
-
//# sourceMappingURL=SelectionQuote.js.map
|
|
@@ -3,4 +3,3 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
export function SendIcon() {
|
|
4
4
|
return (_jsx("svg", { viewBox: "0 0 16 16", width: "16", height: "16", "aria-hidden": "true", children: _jsx("path", { d: "M8.3125 0.980183C8.66767 1.0531 8.97902 1.20418 9.2627 1.43233C9.48724 1.61297 9.73029 1.85793 9.97949 2.10714L14.707 6.83468L13.293 8.24874L9 3.95577V15.0417H7V3.95577L2.70703 8.24874L1.29297 6.83468L6.02051 2.10714C6.26971 1.85793 6.51277 1.61297 6.7373 1.43233C6.97662 1.23986 7.28445 1.04402 7.6875 0.980183C7.8973 0.947006 8.1031 0.95516 8.3125 0.980183Z", fill: "currentColor" }) }));
|
|
5
5
|
}
|
|
6
|
-
//# sourceMappingURL=SendIcon.js.map
|
|
@@ -3,4 +3,3 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
export function SideChatErrorState({ error, messages, onRetry, }) {
|
|
4
4
|
return (_jsxs("section", { className: "dsh-side-chat-error", role: "alert", children: [_jsx("strong", { children: error.code === 'side_chat_destroy_failed' ? messages.closeError : messages.genericError }), _jsx("p", { children: error.message }), error.recoverable && _jsx("button", { type: "button", onClick: onRetry, children: messages.retry })] }));
|
|
5
5
|
}
|
|
6
|
-
//# sourceMappingURL=SideChatErrorState.js.map
|
|
@@ -5,4 +5,3 @@ function AddToConversationIcon() {
|
|
|
5
5
|
export function SideChatHeader({ phase, messages, addToConversationDisabled = false, onAddToConversation, onFocusParent, onClose, }) {
|
|
6
6
|
return (_jsxs("header", { className: "dsh-side-chat-header", children: [_jsx("button", { type: "button", className: "dsh-side-chat-heading", onClick: onFocusParent, children: _jsx("strong", { children: messages.title }) }), _jsxs("div", { className: "dsh-side-chat-header-actions", children: [onAddToConversation !== undefined && (_jsxs("button", { type: "button", className: "dsh-side-chat-add-to-conversation", disabled: addToConversationDisabled, onClick: onAddToConversation, children: [_jsx(AddToConversationIcon, {}), _jsx("span", { children: messages.addToConversation })] })), _jsx("button", { type: "button", className: "dsh-side-chat-close", "aria-label": messages.close, disabled: phase === 'closing', onClick: onClose, children: "\u00D7" })] })] }));
|
|
7
7
|
}
|
|
8
|
-
//# sourceMappingURL=SideChatHeader.js.map
|
|
@@ -14,4 +14,3 @@ export interface SideChatModelSelectProps {
|
|
|
14
14
|
}
|
|
15
15
|
/** Side Chat projection of DSH Web's native composer model selector. */
|
|
16
16
|
export declare function SideChatModelSelect({ directory, selection, locked, validateInitialSelection, locale, onInitialize, onSelect, }: SideChatModelSelectProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
-
//# sourceMappingURL=SideChatModelSelect.d.ts.map
|
|
@@ -244,4 +244,3 @@ export function SideChatModelSelect({ directory, selection, locked, validateInit
|
|
|
244
244
|
return (_jsxs("button", { ref: itemRef(), type: "button", role: "menuitemradio", "aria-checked": selected, className: `dsh-side-chat-model-option${selected ? ' dsh-side-chat-model-selected' : ''}`, disabled: selecting, onClick: () => { chooseEffort(level.effort); }, children: [_jsxs("span", { className: "dsh-side-chat-model-option-copy", children: [_jsx("span", { className: "dsh-side-chat-model-name", children: level.label }), level.description !== undefined && (_jsx("span", { className: "dsh-side-chat-model-description", children: level.description }))] }), _jsx("span", { className: "dsh-side-chat-model-check", children: selected ? _jsx(IconCheckOutline16, {}) : null })] }, level.key));
|
|
245
245
|
}))] })), toast !== null && (_jsx(Toast, { text: toast.text, icon: _jsx(IconWarningOutline16, {}), anchor: rootRef.current?.closest('[data-composer-card]') ?? null, onDone: () => { setToast(null); } }, toast.seq))] }));
|
|
246
246
|
}
|
|
247
|
-
//# sourceMappingURL=SideChatModelSelect.js.map
|
|
@@ -16,4 +16,3 @@ export interface SideChatPanelProps {
|
|
|
16
16
|
readonly onRemoveSelection?: () => void;
|
|
17
17
|
}
|
|
18
18
|
export declare function SideChatPanel({ state, locale, embeddedConversation, modelControl, onDraftChange, onFirstSend, onClose, onRetry, onFocusParent, onAddToConversation, addToConversationDisabled, onRemoveSelection, }: SideChatPanelProps): import("react/jsx-runtime").JSX.Element;
|
|
19
|
-
//# sourceMappingURL=SideChatPanel.d.ts.map
|
|
@@ -32,4 +32,3 @@ export function SideChatPanel({ state, locale = 'en', embeddedConversation, mode
|
|
|
32
32
|
}
|
|
33
33
|
} }), _jsxs("div", { className: "dsh-side-chat-draft-actions", children: [modelControl, _jsx("button", { type: "submit", className: "dsh-side-chat-send-button", "aria-label": messages.send, disabled: submitting || state.draft.trim().length === 0, children: _jsx(SendIcon, {}) })] })] })), _jsxs("footer", { className: "dsh-side-chat-footer", children: [_jsx("span", { children: messages.temporary }), _jsx("span", { children: messages.referenceOnly }), _jsx("span", { children: messages.cannotReopen }), _jsx("span", { children: messages.sharedWorkspace })] }), _jsx("div", { className: "dsh-side-chat-announcer", "aria-live": "polite", children: state.phase === 'running' ? 'Side Chat running' : `Side Chat ${state.phase}` })] }));
|
|
34
34
|
}
|
|
35
|
-
//# sourceMappingURL=SideChatPanel.js.map
|
|
@@ -3,4 +3,3 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
export function StopIcon() {
|
|
4
4
|
return (_jsx("svg", { viewBox: "0 0 16 16", width: "16", height: "16", "aria-hidden": "true", children: _jsx("rect", { x: "3", y: "3", width: "10", height: "10", rx: "3", fill: "currentColor" }) }));
|
|
5
5
|
}
|
|
6
|
-
//# sourceMappingURL=StopIcon.js.map
|
|
@@ -26,4 +26,3 @@ export declare function annotatedUserMessageRenderer(Original: UserNodeRenderer)
|
|
|
26
26
|
/** Mount the composer capsule and a thin wrapper around DSH's user renderers. */
|
|
27
27
|
export declare function mountParentConversationAnnotations(ctx: Rc6ClientContext, removeAnnotations: () => void): () => void;
|
|
28
28
|
export {};
|
|
29
|
-
//# sourceMappingURL=ParentConversationAnnotations.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { createElement } from 'react';
|
|
2
|
+
import { createElement, useLayoutEffect, useRef } from 'react';
|
|
3
3
|
import { SIDE_CHAT_MESSAGES } from '../panel/messages.js';
|
|
4
4
|
import { SelectionQuote } from '../panel/SelectionQuote.js';
|
|
5
5
|
import { conversationAnnotations, parseAnnotatedConversationPrompt, } from './add-to-conversation.js';
|
|
@@ -7,12 +7,36 @@ import { parseReferencedConversationPrompt, } from './referenced-conversation.js
|
|
|
7
7
|
function currentLocale() {
|
|
8
8
|
return navigator.language.toLowerCase().startsWith('zh') ? 'zh-CN' : 'en';
|
|
9
9
|
}
|
|
10
|
+
const ANNOTATION_CHIP_WIDTH_PROPERTY = '--dsh-side-chat-parent-annotation-width';
|
|
10
11
|
/** The interactive annotation capsule occupying the reserved first composer row. */
|
|
11
12
|
export function ParentComposerAnnotations({ input, onRemove, locale = currentLocale(), }) {
|
|
12
13
|
const annotations = conversationAnnotations(input);
|
|
14
|
+
const dockRef = useRef(null);
|
|
15
|
+
useLayoutEffect(() => {
|
|
16
|
+
const dock = dockRef.current;
|
|
17
|
+
const seat = dock?.closest('[data-composer-seat]');
|
|
18
|
+
const chip = dock?.querySelector('.dsh-side-chat-quote-chip');
|
|
19
|
+
if (seat === undefined || chip === undefined || seat === null || chip === null)
|
|
20
|
+
return;
|
|
21
|
+
// The durable host reference stays in Lexical's document flow. Match its
|
|
22
|
+
// occupied width to this visible overlay so the caret starts at the edge
|
|
23
|
+
// users see instead of after the longer internal serialization label.
|
|
24
|
+
const syncWidth = () => {
|
|
25
|
+
const width = chip.getBoundingClientRect().width;
|
|
26
|
+
if (width > 0)
|
|
27
|
+
seat.style.setProperty(ANNOTATION_CHIP_WIDTH_PROPERTY, `${String(width)}px`);
|
|
28
|
+
};
|
|
29
|
+
syncWidth();
|
|
30
|
+
const observer = typeof ResizeObserver === 'undefined' ? undefined : new ResizeObserver(syncWidth);
|
|
31
|
+
observer?.observe(chip);
|
|
32
|
+
return () => {
|
|
33
|
+
observer?.disconnect();
|
|
34
|
+
seat.style.removeProperty(ANNOTATION_CHIP_WIDTH_PROPERTY);
|
|
35
|
+
};
|
|
36
|
+
}, [annotations.length, locale]);
|
|
13
37
|
if (annotations.length === 0)
|
|
14
38
|
return null;
|
|
15
|
-
return (_jsx("div", { className: "dsh-side-chat-parent-annotation-dock", children: _jsx(SelectionQuote, { selections: annotations, messages: SIDE_CHAT_MESSAGES[locale], onRemove: onRemove }) }));
|
|
39
|
+
return (_jsx("div", { ref: dockRef, className: "dsh-side-chat-parent-annotation-dock", children: _jsx(SelectionQuote, { selections: annotations, messages: SIDE_CHAT_MESSAGES[locale], onRemove: onRemove }) }));
|
|
16
40
|
}
|
|
17
41
|
function contentText(content) {
|
|
18
42
|
return content.map((block) => {
|
|
@@ -135,4 +159,3 @@ export function mountParentConversationAnnotations(ctx, removeAnnotations) {
|
|
|
135
159
|
removeDock();
|
|
136
160
|
};
|
|
137
161
|
}
|
|
138
|
-
//# sourceMappingURL=ParentConversationAnnotations.js.map
|
|
@@ -48,4 +48,3 @@ export interface AnnotatedConversationPrompt {
|
|
|
48
48
|
export declare function parseAnnotatedConversationPrompt(text: string): AnnotatedConversationPrompt | undefined;
|
|
49
49
|
/** Add the selected quote to the first child prompt. */
|
|
50
50
|
export declare function buildSideChatPrompt(selection: ConversationSelection | undefined, question: string): readonly SideChatPromptPart[];
|
|
51
|
-
//# sourceMappingURL=add-to-conversation.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { draftWithoutOccurrence, LEGACY_REFERENCE_PLACEHOLDER, newlyInsertedOccurrence, occurrenceMatchesDraft, occurrenceRange, referenceDisplayText, } from './composer-reference.js';
|
|
1
|
+
import { draftWithoutOccurrence, LEGACY_REFERENCE_PLACEHOLDER, newlyInsertedOccurrence, occurrenceEditSpan, occurrenceMatchesDraft, occurrenceRange, referenceDisplayText, } from './composer-reference.js';
|
|
2
2
|
const SELECTION_REFERENCE_SOURCE = 'dsh-side-chat-selection';
|
|
3
3
|
export const SELECTION_REFERENCE_LABEL = '__dsh_side_chat_annotations__';
|
|
4
4
|
function escapeXmlText(value) {
|
|
@@ -163,8 +163,23 @@ function draftWithoutSelectionOccurrences(snapshot) {
|
|
|
163
163
|
/** Remove every unsent plugin annotation while preserving the user's draft. */
|
|
164
164
|
export function removeConversationAnnotations(input) {
|
|
165
165
|
const snapshot = input.state.getSnapshot();
|
|
166
|
-
|
|
166
|
+
const occurrences = selectionOccurrences(snapshot);
|
|
167
|
+
if (occurrences.length === 0)
|
|
167
168
|
return false;
|
|
169
|
+
if (input.referenceMode === 'lexical' && input.replaceText !== undefined) {
|
|
170
|
+
for (const occurrenceId of occurrences.map(occurrence => occurrence.occurrenceId).reverse()) {
|
|
171
|
+
const current = input.state.getSnapshot();
|
|
172
|
+
const occurrence = current.occurrences.find(candidate => candidate.occurrenceId === occurrenceId);
|
|
173
|
+
if (occurrence === undefined)
|
|
174
|
+
continue;
|
|
175
|
+
const span = occurrenceEditSpan(input, current, occurrence, {
|
|
176
|
+
consumeFollowingSeparator: true,
|
|
177
|
+
});
|
|
178
|
+
if (span === undefined || !input.replaceText('', span))
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
return selectionOccurrences(input.state.getSnapshot()).length === 0;
|
|
182
|
+
}
|
|
168
183
|
input.setDraft(draftWithoutSelectionOccurrences(snapshot));
|
|
169
184
|
return true;
|
|
170
185
|
}
|
|
@@ -184,7 +199,7 @@ export const selectionReferenceSource = {
|
|
|
184
199
|
},
|
|
185
200
|
},
|
|
186
201
|
};
|
|
187
|
-
function
|
|
202
|
+
function writeTextConversationAnnotations(input, before, annotations) {
|
|
188
203
|
const draft = draftWithoutSelectionOccurrences(before);
|
|
189
204
|
const insertionState = input.state.getSnapshot();
|
|
190
205
|
if (insertionState.draftRev !== before.draftRev || insertionState.draft !== before.draft)
|
|
@@ -269,6 +284,85 @@ function writeConversationAnnotations(input, before, annotations) {
|
|
|
269
284
|
&& retained.offset === 0
|
|
270
285
|
&& occurrenceMatchesDraft(normalized, retained, SELECTION_REFERENCE_LABEL);
|
|
271
286
|
}
|
|
287
|
+
function writeLexicalConversationAnnotations(input, before, annotations) {
|
|
288
|
+
if (input.replaceText === undefined)
|
|
289
|
+
return false;
|
|
290
|
+
const existing = selectionOccurrences(before);
|
|
291
|
+
if (existing.length > 1)
|
|
292
|
+
return false;
|
|
293
|
+
const previous = existing[0];
|
|
294
|
+
if (previous !== undefined && previous.length === undefined)
|
|
295
|
+
return false;
|
|
296
|
+
let insertionState = before;
|
|
297
|
+
let preparedGap = false;
|
|
298
|
+
if (previous === undefined) {
|
|
299
|
+
// A gap inserted before the chip is unambiguously plugin-owned. DSH's
|
|
300
|
+
// automatic gap cannot otherwise be distinguished from a user's leading
|
|
301
|
+
// space when the reference is later removed.
|
|
302
|
+
if (!input.replaceText(' ', { start: 0, end: 0, draftRev: before.draftRev }))
|
|
303
|
+
return false;
|
|
304
|
+
insertionState = input.state.getSnapshot();
|
|
305
|
+
if (insertionState.draft !== ` ${before.draft}`)
|
|
306
|
+
return false;
|
|
307
|
+
preparedGap = true;
|
|
308
|
+
}
|
|
309
|
+
const span = previous === undefined
|
|
310
|
+
? { start: 0, end: 0, draftRev: insertionState.draftRev }
|
|
311
|
+
: occurrenceEditSpan(input, insertionState, previous);
|
|
312
|
+
if (span === undefined)
|
|
313
|
+
return false;
|
|
314
|
+
const ref = encodeSelectionReference(annotations);
|
|
315
|
+
const clipboardText = annotations.map(annotation => annotation.text).join('\n\n');
|
|
316
|
+
const inserted = input.insertReference({
|
|
317
|
+
source: SELECTION_REFERENCE_SOURCE,
|
|
318
|
+
ref,
|
|
319
|
+
label: SELECTION_REFERENCE_LABEL,
|
|
320
|
+
clipboardText,
|
|
321
|
+
}, span);
|
|
322
|
+
if (!inserted) {
|
|
323
|
+
if (preparedGap) {
|
|
324
|
+
const current = input.state.getSnapshot();
|
|
325
|
+
if (current.draft === ` ${before.draft}`) {
|
|
326
|
+
input.replaceText('', { start: 0, end: 1, draftRev: current.draftRev });
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
return false;
|
|
330
|
+
}
|
|
331
|
+
const afterInsert = input.state.getSnapshot();
|
|
332
|
+
const occurrence = newlyInsertedOccurrence(insertionState, afterInsert, SELECTION_REFERENCE_SOURCE, ref);
|
|
333
|
+
const previousEnd = previous === undefined ? 0 : previous.offset + (previous.length ?? 0);
|
|
334
|
+
const previousTail = previous === undefined
|
|
335
|
+
? insertionState.draft
|
|
336
|
+
: insertionState.draft.slice(previousEnd);
|
|
337
|
+
const automaticGap = previousTail.startsWith(' ') ? '' : ' ';
|
|
338
|
+
const expectedDraft = previous === undefined
|
|
339
|
+
? `${clipboardText}${insertionState.draft}`
|
|
340
|
+
: insertionState.draft.slice(0, previous.offset) + clipboardText + automaticGap + previousTail;
|
|
341
|
+
const valid = occurrence !== undefined
|
|
342
|
+
&& selectionOccurrences(afterInsert).length === 1
|
|
343
|
+
&& occurrence.offset === (previous?.offset ?? 0)
|
|
344
|
+
&& occurrence.label === SELECTION_REFERENCE_LABEL
|
|
345
|
+
&& occurrence.clipboardText === clipboardText
|
|
346
|
+
&& occurrenceMatchesDraft(afterInsert, occurrence, SELECTION_REFERENCE_LABEL)
|
|
347
|
+
&& afterInsert.draft === expectedDraft;
|
|
348
|
+
if (valid)
|
|
349
|
+
return true;
|
|
350
|
+
// Best-effort rollback for a first insertion. Replacing an existing chip is
|
|
351
|
+
// atomic and should never reach this path on a conforming DSH input facade.
|
|
352
|
+
if (previous === undefined && occurrence !== undefined) {
|
|
353
|
+
const rollback = occurrenceEditSpan(input, afterInsert, occurrence, {
|
|
354
|
+
consumeFollowingSeparator: true,
|
|
355
|
+
});
|
|
356
|
+
if (rollback !== undefined)
|
|
357
|
+
input.replaceText('', rollback);
|
|
358
|
+
}
|
|
359
|
+
return false;
|
|
360
|
+
}
|
|
361
|
+
function writeConversationAnnotations(input, before, annotations) {
|
|
362
|
+
return input.referenceMode === 'lexical'
|
|
363
|
+
? writeLexicalConversationAnnotations(input, before, annotations)
|
|
364
|
+
: writeTextConversationAnnotations(input, before, annotations);
|
|
365
|
+
}
|
|
272
366
|
/** Add one passage to the parent composer's aggregated annotation occurrence. */
|
|
273
367
|
export function addSelectionToConversation(input, selection, comment) {
|
|
274
368
|
const before = input.state.getSnapshot();
|
|
@@ -282,10 +376,8 @@ export function removeConversationAnnotation(input, annotationIndex) {
|
|
|
282
376
|
if (!Number.isSafeInteger(annotationIndex) || annotations[annotationIndex] === undefined)
|
|
283
377
|
return false;
|
|
284
378
|
annotations.splice(annotationIndex, 1);
|
|
285
|
-
if (annotations.length === 0)
|
|
286
|
-
input
|
|
287
|
-
return selectionOccurrences(input.state.getSnapshot()).length === 0;
|
|
288
|
-
}
|
|
379
|
+
if (annotations.length === 0)
|
|
380
|
+
return removeConversationAnnotations(input);
|
|
289
381
|
return writeConversationAnnotations(input, before, annotations);
|
|
290
382
|
}
|
|
291
383
|
/** Replace the optional comment on one unsent selected-passage annotation. */
|
|
@@ -525,4 +617,3 @@ export function buildSideChatPrompt(selection, question) {
|
|
|
525
617
|
].join('\n'),
|
|
526
618
|
}];
|
|
527
619
|
}
|
|
528
|
-
//# sourceMappingURL=add-to-conversation.js.map
|
|
@@ -5,35 +5,41 @@ export interface ParentComposerOccurrence {
|
|
|
5
5
|
readonly source: string;
|
|
6
6
|
readonly ref: string;
|
|
7
7
|
readonly offset: number;
|
|
8
|
-
/**
|
|
8
|
+
/** Occupied projection length (display text through 0.1.1, clipboard text in 0.1.2). */
|
|
9
9
|
readonly length?: number;
|
|
10
10
|
/** Insert-time display label, present in current DSH input snapshots. */
|
|
11
11
|
readonly label?: string;
|
|
12
12
|
/** Draft-persistence projection cached by current DSH input snapshots. */
|
|
13
13
|
readonly clipboardText?: string;
|
|
14
|
+
readonly appearance?: 'session' | 'file' | 'folder';
|
|
14
15
|
}
|
|
15
16
|
export interface ParentComposerInputSnapshot {
|
|
16
17
|
readonly draft: string;
|
|
17
18
|
readonly draftRev: number;
|
|
18
19
|
readonly occurrences: readonly ParentComposerOccurrence[];
|
|
19
20
|
}
|
|
21
|
+
export interface ParentComposerSpan {
|
|
22
|
+
readonly start: number;
|
|
23
|
+
readonly end: number;
|
|
24
|
+
readonly draftRev: number;
|
|
25
|
+
}
|
|
20
26
|
export interface ParentComposerInput {
|
|
21
27
|
readonly state: {
|
|
22
28
|
getSnapshot(): ParentComposerInputSnapshot;
|
|
23
29
|
subscribe?(listener: () => void): () => void;
|
|
24
30
|
};
|
|
31
|
+
/** DSH 0.1.2's Lexical editor projects each reference as one mutation coordinate. */
|
|
32
|
+
readonly referenceMode?: 'text' | 'lexical';
|
|
25
33
|
setDraft(text: string): void;
|
|
34
|
+
/** Atomic plain-text replacement supplied by Side Chat's scoped input-event adapter. */
|
|
35
|
+
replaceText?(text: string, span: ParentComposerSpan): boolean;
|
|
26
36
|
insertReference(reference: {
|
|
27
37
|
readonly source: string;
|
|
28
38
|
readonly ref: string;
|
|
29
39
|
readonly label: string;
|
|
30
40
|
readonly appearance?: 'session' | 'file' | 'folder';
|
|
31
41
|
readonly clipboardText: string;
|
|
32
|
-
}, span:
|
|
33
|
-
readonly start: number;
|
|
34
|
-
readonly end: number;
|
|
35
|
-
readonly draftRev: number;
|
|
36
|
-
}): boolean;
|
|
42
|
+
}, span: ParentComposerSpan): boolean;
|
|
37
43
|
}
|
|
38
44
|
export interface ParentConversationService {
|
|
39
45
|
readonly input: {
|
|
@@ -63,10 +69,13 @@ export declare function referenceDisplayText(label: string): string;
|
|
|
63
69
|
*/
|
|
64
70
|
export declare function occurrenceRange(snapshot: ParentComposerInputSnapshot, occurrence: ParentComposerOccurrence, expectedLabel: string): OccurrenceRange | undefined;
|
|
65
71
|
export declare function occurrenceMatchesDraft(snapshot: ParentComposerInputSnapshot, occurrence: ParentComposerOccurrence, expectedLabel: string): boolean;
|
|
72
|
+
/** Convert one published occurrence range to the host input machine's mutation coordinates. */
|
|
73
|
+
export declare function occurrenceEditSpan(input: ParentComposerInput, snapshot: ParentComposerInputSnapshot, occurrence: ParentComposerOccurrence, options?: {
|
|
74
|
+
readonly consumeFollowingSeparator?: boolean;
|
|
75
|
+
}): ParentComposerSpan | undefined;
|
|
66
76
|
/** Find the exact occurrence minted by one synchronous insertReference call. */
|
|
67
77
|
export declare function newlyInsertedOccurrence(before: ParentComposerInputSnapshot, after: ParentComposerInputSnapshot, source: string, ref: string): ParentComposerOccurrence | undefined;
|
|
68
78
|
/** Remove one occurrence's display range and, optionally, its separating ASCII gap. */
|
|
69
79
|
export declare function draftWithoutOccurrence(snapshot: ParentComposerInputSnapshot, occurrence: ParentComposerOccurrence, expectedLabel: string, options?: {
|
|
70
80
|
readonly consumeAdjacentSpace?: boolean;
|
|
71
81
|
}): string | undefined;
|
|
72
|
-
//# sourceMappingURL=composer-reference.d.ts.map
|
|
@@ -30,7 +30,40 @@ export function occurrenceMatchesDraft(snapshot, occurrence, expectedLabel) {
|
|
|
30
30
|
if (range === undefined)
|
|
31
31
|
return false;
|
|
32
32
|
const text = snapshot.draft.slice(range.start, range.end);
|
|
33
|
-
|
|
33
|
+
if (text === LEGACY_REFERENCE_PLACEHOLDER || text === referenceDisplayText(expectedLabel))
|
|
34
|
+
return true;
|
|
35
|
+
return occurrence.label === expectedLabel
|
|
36
|
+
&& occurrence.clipboardText !== undefined
|
|
37
|
+
&& text === occurrence.clipboardText;
|
|
38
|
+
}
|
|
39
|
+
/** Convert one published occurrence range to the host input machine's mutation coordinates. */
|
|
40
|
+
export function occurrenceEditSpan(input, snapshot, occurrence, options = {}) {
|
|
41
|
+
const range = occurrenceRange(snapshot, occurrence, occurrence.label ?? '');
|
|
42
|
+
if (range === undefined)
|
|
43
|
+
return;
|
|
44
|
+
let start = range.start;
|
|
45
|
+
let end = range.end;
|
|
46
|
+
if (input.referenceMode === 'lexical') {
|
|
47
|
+
if (occurrence.length === undefined)
|
|
48
|
+
return;
|
|
49
|
+
start = occurrence.offset;
|
|
50
|
+
for (const candidate of [...snapshot.occurrences].sort((left, right) => left.offset - right.offset)) {
|
|
51
|
+
if (candidate.occurrenceId === occurrence.occurrenceId)
|
|
52
|
+
break;
|
|
53
|
+
if (candidate.offset > occurrence.offset || candidate.length === undefined)
|
|
54
|
+
return;
|
|
55
|
+
start -= candidate.length - 1;
|
|
56
|
+
}
|
|
57
|
+
end = start + 1;
|
|
58
|
+
}
|
|
59
|
+
if (options.consumeFollowingSeparator === true) {
|
|
60
|
+
const tail = snapshot.draft.slice(range.end);
|
|
61
|
+
if (tail.startsWith('\n\n'))
|
|
62
|
+
end += 2;
|
|
63
|
+
else if (tail.startsWith('\n') || tail.startsWith(' '))
|
|
64
|
+
end += 1;
|
|
65
|
+
}
|
|
66
|
+
return { start, end, draftRev: snapshot.draftRev };
|
|
34
67
|
}
|
|
35
68
|
/** Find the exact occurrence minted by one synchronous insertReference call. */
|
|
36
69
|
export function newlyInsertedOccurrence(before, after, source, ref) {
|
|
@@ -54,4 +87,3 @@ export function draftWithoutOccurrence(snapshot, occurrence, expectedLabel, opti
|
|
|
54
87
|
}
|
|
55
88
|
return snapshot.draft.slice(0, start) + snapshot.draft.slice(end);
|
|
56
89
|
}
|
|
57
|
-
//# sourceMappingURL=composer-reference.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ConversationNode } from '@deepseek-ai/dsh-client-
|
|
1
|
+
import type { ConversationNode } from '@deepseek-ai/dsh-client-ui-conversation/client';
|
|
2
2
|
import type { SessionId } from '../../shared/contracts.js';
|
|
3
3
|
import type { ParentComposerInput, SelectionReferenceSource } from './composer-reference.js';
|
|
4
4
|
export declare const SIDE_CHAT_CONVERSATION_REFERENCE_SOURCE = "dsh-side-chat-conversation";
|
|
@@ -32,4 +32,3 @@ export declare function parseReferencedConversationPrompt(text: string): ParsedR
|
|
|
32
32
|
export declare function addReferencedSideChatToConversation(input: ParentComposerInput, reference: ReferencedSideChatConversation): boolean;
|
|
33
33
|
/** Reference codec used by the native composer chip and submit pipeline. */
|
|
34
34
|
export declare const sideChatConversationReferenceSource: SelectionReferenceSource;
|
|
35
|
-
//# sourceMappingURL=referenced-conversation.d.ts.map
|