@klarkxy/dsh-session-manager 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client.inner.cjs.map +1 -1
- package/lib/index.js +840 -55
- package/lib/index.js.map +1 -1
- package/package.json +3 -3
package/lib/client.inner.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.inner.cjs","names":["useRef","useState","useCallback","useMemo","Button","useRef","useState","useId","useMemo","rankByName","observeStickyMenuGroups","createPortal","MenuSurface","IconChevronRightOutlineRegular","Input","IconCloseFillRegular","IconCheckOutlineRegular","MenuGroup","isValidElement","cloneElement","useSyncExternalStore","Modal","Button","useRef","useSyncExternalStore","useState","useRef","useCallback","Menu","IconFolderCloseRegular","IconPlusOutlineRegular","IconNewChatOutlineRegular","Modal","Button","store","useState","useRef","useCallback","Menu","Tooltip","Pill","IconRefreshOutlineRegular","IconChevronDownOutlineRegular","createElement","useRef","useMemo","IconChevronDownOutlineRegular","useCallback","useSyncExternalStore","useState","useRef","Button","IconChevronDownOutlineRegular","useSyncExternalStore","useRef","useState","Button","IconCloseFillRegular","useRef","useCallback","useState","useSyncExternalStore","useId","SegmentedTabs","Input","Switch","IconChevronDownOutlineRegular","useState","FileTypeIcon","useRef","Button","useState","useSyncExternalStore","useRef","Tooltip","Button","Modal","useSyncExternalStore","useState","useRef","Tooltip","Button","Modal","useState","useRef","writeClipboard","Tooltip","Button","IconCheckOutlineRegular","IconCopyOutlineRegular","Fragment","FileTypeIcon","fileExtension","fileSizeText","JsonBlock","input","useSyncExternalStore","MenuItemButton"],"sources":["../src/ui-copy.ts","../src/contracts.ts","../src/context-menu.ts","../../dsh-plugin-kit/src/official-ui.ts","../../dsh-model-route/src/route.ts","../../dsh-model-route/src/catalog.ts","../../dsh-model-route/src/catalog-ui.tsx","../../dsh-model-route/src/menu.ts","../../dsh-model-route/src/ui.tsx","../src/styles.ts","../src/free-panel.tsx","../src/temporary-picker.tsx","../src/temporary-workspace.ts","../src/session-actions.ts","../src/welcome-continuation.ts","../src/presence-model.ts","../src/auto-continue-option.tsx","../../dsh-plugin-kit/src/contracts.ts","../../dsh-plugin-kit/src/client-utils.ts","../../dsh-model-route/src/model-picker.ts","../../dsh-plugin-kit/src/model-picker.tsx","../../dsh-plugin-kit/src/model-settings-client.ts","../../dsh-plugin-kit/src/auxiliary-model-client.tsx","../src/presence-panel.tsx","../src/settings-panel.tsx","../src/message-editor.tsx","../src/edit-icon.tsx","../src/user-actions.tsx","../src/edit-host.ts","../src/edit-actions.tsx","../src/user-node.tsx","../src/retry-contracts.ts","../src/retry-host.ts","../src/client.tsx"],"sourcesContent":["/** Failure identity stored by the UI. The sentence is derived from the active locale. */\n\nexport type CopyLocale = 'zh' | 'en'\n\nexport function copyLocale(active: string | undefined): CopyLocale {\n return active?.toLowerCase().startsWith('zh') ? 'zh' : 'en'\n}\n\nexport interface OperationFailure {\n readonly code: string\n readonly reason?: string\n}\n\nconst reasons = {\n zh: {\n modified: '后续操作可能涉及修改,暂时不能重试。',\n unknown: '无法确认这个操作的结果。',\n pending: '这条消息还在等待处理。',\n stale: '这个聊天已经更新,请再试一次。',\n running: '这个聊天仍在运行。请等待当前工作结束后再试。',\n cleanup: '清理没有完成。',\n unsupported: '当前版本不能完成这个操作。',\n retryPending: '重发尚未完成。再次发送会继续同一次操作,不会新建另一份聊天。',\n retryUncertain: '上次创建聊天的结果无法确认,已停止再次创建。请先检查会话列表中是否已有新聊天。',\n },\n en: {\n modified: 'Later operations may have made changes. Retry is unavailable.',\n unknown: \"This action's result could not be confirmed.\",\n pending: 'This message is still pending.',\n stale: 'This chat has changed. Try again.',\n running: 'This chat is still running. Wait for the current work to finish, then try again.',\n cleanup: 'Cleanup did not finish.',\n unsupported: 'This runtime cannot complete that action.',\n retryPending: 'Resend is incomplete. Send again to continue the same operation without creating another chat.',\n retryUncertain: 'The previous chat creation could not be confirmed. Another chat will not be created; check the session list for an existing new chat.',\n },\n} as const\n\nexport type FailureReason = keyof typeof reasons.zh\n\nconst text = {\n zh: {\n tempWorkspace: '临时工作区',\n createFailed: '无法创建临时工作区',\n retryList: '重试',\n deleteChat: '删除聊天',\n deleting: '正在删除',\n deleteFree: '将删除这个聊天及其拥有的文件。',\n deleteOrdinary: '将删除这个聊天。项目文件会保留。',\n cancel: '取消',\n close: '关闭',\n retry: '重试',\n edit: '编辑并重发',\n send: '发送',\n editTitle: '编辑并重发',\n editBranchWarning: '对话将从这条消息继续,之前的版本会移入归档。已执行的文件、命令和外部修改不会撤销,模型可能再次执行相关操作。',\n editConfirm: '确认重发',\n editAddAttachment: '添加附件',\n editRemoveAttachment: '删除附件',\n editImage: '图片',\n editPreviewFailed: '预览不可用',\n draft: '消息文本',\n continueDefault: '继续',\n welcomeBack: '欢迎回来',\n recapSummary: '在聊什么',\n recapProgress: '目前进展',\n recapNextStep: '建议下一步',\n cacheNotice: '离开时间较久,模型的提示缓存可能已失效,下一次发送会重新处理完整上下文。可以压缩上下文,或在新会话中继续;也可以忽略提示直接发送。',\n compactNow: '压缩上下文',\n compacting: '正在压缩',\n compactCommandSent: '已调用宿主压缩命令,结果请查看对话中的压缩记录。',\n continueNew: '在新会话中继续',\n creatingContinuation: '正在创建新会话',\n continueNewHint: '在来源会话的工作区新建会话,将摘要和原会话 ID 填入草稿,不自动发送。',\n compactNothing: '没有值得压缩的内容。',\n settingsTitle: '会话管理',\n composerGroupTitle: '输入框建议',\n composerGroupHint: '输入框为空时显示的下一句建议',\n modeFixed: '固定文本',\n modeAuto: '模型生成',\n composerUsageHint: '按 Tab 填入建议,点击建议直接发送。',\n ghostModelLabel: '生成模型',\n continueSourceLabel: '内容来源',\n continueTextLabel: '固定文本内容',\n continueTextPlaceholder: '留空使用默认「继续」',\n returnGroupTitle: '回到会话时',\n returnGroupHint: '长时间离开后显示摘要或建议压缩',\n awayMinutesLabel: '离开超过',\n recapEnabledLabel: '显示会话摘要',\n recapEnabledHint: '在对话中回顾上次进展。',\n compactEnabledLabel: '建议压缩上下文',\n compactEnabledHint: '长时间离开后,建议先压缩上下文。',\n recapModelLabel: '摘要模型',\n judgeModelLabel: '判断模型',\n judgeModelHint: '判断回复是否提前结束,并写出继续消息。',\n handoffGroupTitle: '会话交接',\n handoffGroupHint: '智能体读取其他会话时生成的交接摘要',\n handoffModelLabel: '摘要模型',\n handoffModelHint: '智能体请求会话交接摘要时使用。',\n autoContinue: '自动继续',\n autoContinueOff: '关闭',\n autoContinueCautious: '谨慎',\n autoContinueBold: '奔放',\n autoContinueTooltip: '回复提前结束时自动发送继续。谨慎:有明确依据才继续;奔放:没完成就继续,低风险的选择按推荐方案走。会话开始后锁定。',\n autoContinueLocked: '请在会话开始前选择自动继续',\n autoContinueStale: '状态已在别处更改,已刷新',\n autoContinueFailed: '切换失败',\n autoContinueGroup: '自动继续',\n autoContinueGroupHint: '回复提前结束时自动发送继续',\n autoContinueModeHint: '开启方式(关闭/谨慎/奔放)在创建会话时按会话选择。',\n autoContinueMaxLabel: '续跑次数上限',\n autoContinueMaxHint: '你每发一条消息之后,最多自动继续的次数(1–10)。',\n autoContinueMaxInvalid: '请填写 1–10 的整数。',\n minutesUnit: '分钟',\n agentActionsGroup: '代理操作',\n agentActionsGroupHint: '允许 agent 自主操作会话',\n allowSelfForkLabel: '允许自我 fork',\n allowSelfForkHint: '允许 agent 自行 fork 当前会话,创建独立分支。',\n allowSendMessageLabel: '允许发送消息',\n allowSendMessageHint: '允许 agent 向其他未归档会话发送消息;空闲会话会被唤醒,运行中的会话会排队接收。',\n modelFollowOption: '默认辅助模型',\n settingsSaving: '正在保存',\n settingsSaved: '已保存',\n settingsLoading: '正在加载',\n settingsUnavailable: '当前宿主不支持在线修改配置',\n minutesInvalid: '请填写大于等于 1 的整数分钟。',\n },\n en: {\n tempWorkspace: 'Temporary Workspace',\n createFailed: 'Could not create the temporary workspace',\n retryList: 'Retry',\n deleteChat: 'Delete chat',\n deleting: 'Deleting',\n deleteFree: 'This deletes this chat and its owned files.',\n deleteOrdinary: 'This deletes this chat. Project files remain.',\n cancel: 'Cancel',\n close: 'Close',\n retry: 'Retry',\n edit: 'Edit and resend',\n send: 'Send',\n editTitle: 'Edit and resend',\n editBranchWarning: 'The conversation continues from this message; the previous version moves to the archive. File, command, and external changes already made are not undone — the model may perform those actions again.',\n editConfirm: 'Confirm resend',\n editAddAttachment: 'Add attachments',\n editRemoveAttachment: 'Remove attachment',\n editImage: 'Image',\n editPreviewFailed: 'Preview unavailable',\n draft: 'Message text',\n continueDefault: 'Continue',\n welcomeBack: 'Welcome back',\n recapSummary: 'What you were discussing',\n recapProgress: 'Where things stand',\n recapNextStep: 'Suggested next step',\n cacheNotice: 'The model prompt cache may have expired, so the next message reprocesses the full context. Compact the context, continue in a new session, or ignore this notice and send normally.',\n compactNow: 'Compact context',\n compacting: 'Compacting',\n compactCommandSent: 'Host compaction command invoked. See the compaction entry in the conversation for its result.',\n continueNew: 'Continue in a new session',\n creatingContinuation: 'Creating new session',\n continueNewHint: \"Create a session in the source session's workspace and fill its draft with the recap and source session ID, without sending.\",\n compactNothing: 'There is nothing useful to compact.',\n settingsTitle: 'Session Management',\n composerGroupTitle: 'Composer suggestion',\n composerGroupHint: 'The suggested next message shown in an empty composer',\n modeFixed: 'Fixed text',\n modeAuto: 'Model-generated',\n composerUsageHint: 'Press Tab to fill the suggestion, or click it to send.',\n ghostModelLabel: 'Generation model',\n continueSourceLabel: 'Source',\n continueTextLabel: 'Fixed text',\n continueTextPlaceholder: 'Empty uses the default \"Continue\"',\n returnGroupTitle: 'When you return',\n returnGroupHint: 'Show a recap or suggest compaction after time away',\n awayMinutesLabel: 'Away for more than',\n recapEnabledLabel: 'Show session recap',\n recapEnabledHint: 'Review your previous progress in the conversation.',\n compactEnabledLabel: 'Suggest context compaction',\n compactEnabledHint: 'Suggest compacting the context after a long time away.',\n recapModelLabel: 'Recap model',\n judgeModelLabel: 'Judge model',\n judgeModelHint: 'Decides whether a reply stopped early and writes the follow-up.',\n handoffGroupTitle: 'Session handoff',\n handoffGroupHint: 'Handoff summaries an agent generates when reading another session',\n handoffModelLabel: 'Summary model',\n handoffModelHint: 'Used when an agent asks for a session handoff summary.',\n autoContinue: 'Auto-continue',\n autoContinueOff: 'Off',\n autoContinueCautious: 'Cautious',\n autoContinueBold: 'Bold',\n autoContinueTooltip: 'Sends a follow-up when a reply stops early. Cautious: continues only on clear evidence. Bold: continues unless done, taking the recommended option on low-risk choices. Locked once the session starts.',\n autoContinueLocked: 'Choose Auto-continue before the session starts',\n autoContinueStale: 'State changed elsewhere; refreshed',\n autoContinueFailed: 'Could not change Auto-continue',\n autoContinueGroup: 'Auto-continue',\n autoContinueGroupHint: 'Send a follow-up when a reply stops early',\n autoContinueModeHint: 'The mode (Off / Cautious / Bold) is chosen per session when creating it.',\n autoContinueMaxLabel: 'Maximum continuations',\n autoContinueMaxHint: 'How many times it may continue automatically after each message you send (1–10).',\n autoContinueMaxInvalid: 'Enter a whole number from 1 to 10.',\n minutesUnit: 'minutes',\n agentActionsGroup: 'Agent actions',\n agentActionsGroupHint: 'Let the agent act on sessions on its own',\n allowSelfForkLabel: 'Allow self-fork',\n allowSelfForkHint: 'Let the agent fork the current session into an independent branch.',\n allowSendMessageLabel: 'Allow sending messages',\n allowSendMessageHint: 'Let the agent message other unarchived sessions; idle sessions are woken, running sessions queue the message.',\n modelFollowOption: 'Default auxiliary model',\n settingsSaving: 'Saving',\n settingsSaved: 'Saved',\n settingsLoading: 'Loading',\n settingsUnavailable: 'This runtime cannot edit the plugin configuration',\n minutesInvalid: 'Enter a whole number of minutes of at least 1.',\n },\n} as const\n\nexport type UiTextKey = keyof typeof text.zh\n\nexport function uiText(locale: CopyLocale, key: UiTextKey): string {\n return text[locale][key]\n}\n\nexport function failureReason(failure: OperationFailure): FailureReason {\n if (failure.code === 'session/retry-pending') return 'retryPending'\n if (failure.code === 'session/retry-uncertain') return 'retryUncertain'\n if (failure.code === 'session/lifecycle-unavailable' || failure.code === 'session/retry-media-unavailable'\n || failure.code === 'session-manager/unavailable') return 'unsupported'\n if (failure.code === 'session-manager/busy') return 'running'\n if (\n failure.code === 'session/retry-revision'\n || failure.code === 'session/branch-moved'\n || failure.code === 'session/retry-input'\n || failure.code === 'session/retry-conflict'\n ) return 'stale'\n if (failure.code === 'session/delete-pending') return 'cleanup'\n if (failure.code === 'session/agent-busy' && failure.reason === 'free-session-work-active') return 'running'\n if (failure.reason === 'modified' || failure.reason === 'pending' || failure.reason === 'running' || failure.reason === 'stale') {\n return failure.reason\n }\n if (failure.reason === 'stop-failed' || failure.reason === 'not-quiet') return 'running'\n if (failure.reason === 'not-human-prompt' || failure.reason === 'missing-evidence') return 'unknown'\n return 'unknown'\n}\n\nexport function failureText(locale: CopyLocale, failure: OperationFailure): string {\n return reasons[locale][failureReason(failure)]\n}\n\nexport function deleteBody(locale: CopyLocale, classification: 'free' | 'ordinary'): string {\n return classification === 'free' ? text[locale].deleteFree : text[locale].deleteOrdinary\n}\n\n/** Idle duration sentence on the welcome-back card. */\nexport function idleText(locale: CopyLocale, minutes: number): string {\n return locale === 'zh' ? `距离上次响应已约 ${minutes} 分钟。` : `About ${minutes} minutes have passed since the last response.`\n}\n\n/** Compaction outcome line; a null token count means the host did not report one. */\nexport function compactedText(locale: CopyLocale, tokens: number | null): string {\n if (locale === 'zh') return tokens === null ? '上下文已压缩。' : `上下文已压缩,约 ${tokens} tokens 的历史被折叠。`\n return tokens === null ? 'Context compacted.' : `Context compacted; about ${tokens} tokens of history were folded.`\n}\n","/** Shared names and bounds for cross-session discovery. */\n\nexport const PLUGIN_NAME = '@klarkxy/dsh-session-manager'\n/** Temporary-workspace row inside the New Session workspace picker (host list slot). */\nexport const TEMP_WORKSPACE_ITEM_ID = '@klarkxy/dsh-session-manager.temp-workspace'\nexport const TEMP_WORKSPACE_CHANNEL = '/dsh-session-manager'\nexport const TEMP_WORKSPACE_FLOW_SLOT = 'session-manager.workspace.directoryFlow'\nexport const USER_ACTIONS_SLOT = 'conversation.chat.user-actions'\nexport const USER_ACTIONS_ID = '@klarkxy/dsh-session-manager.user-actions'\nexport const DELETE_DIALOG_ID = '@klarkxy/dsh-session-manager.delete-chat'\n\nexport const LIST_TOOL = 'list_sessions'\nexport const SEARCH_TOOL = 'search_sessions'\nexport const READ_TOOL = 'read_session'\nexport const FORK_TOOL = 'fork_session'\nexport const SEND_TOOL = 'send_session_message'\n/**\n * Durable message-source kind shared with the host's adjacent-agent delivery\n * (dsh-subagent/continuation-messages): `form: 'relay'` plus the sender's\n * session id. Agent tools must never stamp `kind: 'user'` — the session\n * prompt endpoint's user-rpc source is the only path that may claim it.\n */\nexport const AGENT_MESSAGE_KIND = 'agent-message'\n\n/** Endpoints on the shared TEMP_WORKSPACE_CHANNEL beyond temporary-directory allocation. */\nexport const WELCOME_BACK_PREPARE_ENDPOINT = 'welcomeback.prepare'\nexport const WELCOME_BACK_COMPACT_ENDPOINT = 'welcomeback.compact'\nexport const CONTINUE_SUGGEST_ENDPOINT = 'continue.suggest'\nexport const EDIT_PREPARE_ENDPOINT = 'edit.prepare'\nexport const EDIT_FILE_ENDPOINT = 'edit.file'\nexport const CONFIG_READ_ENDPOINT = 'config.read'\nexport const CONFIG_WRITE_ENDPOINT = 'config.write'\nexport const AUTO_CONTINUE_STATUS_ENDPOINT = 'autocontinue.status'\nexport const AUTO_CONTINUE_UPDATE_ENDPOINT = 'autocontinue.update'\n/** This plugin's rows inside the shared Session Management settings list. */\nexport const SESSION_SETTINGS_ITEMS = [\n { id: 'session-manager.composer', order: 60 },\n { id: 'session-manager.auto-continue', order: 62 },\n { id: 'session-manager.return', order: 64 },\n { id: 'session-manager.handoff', order: 66 },\n { id: 'session-manager.agent-actions', order: 68 },\n] as const\n\n/**\n * Stable feature ids stamped on `callLlmText` requests: each generated call is\n * attributed to its own per-session × feature context. The ghost bucket is\n * never shared with the judge — see buildAuxiliaryUserText in the kit.\n */\nexport const FEATURE_RECAP = 'session-manager.recap'\nexport const FEATURE_GHOST = 'session-manager.ghost'\nexport const FEATURE_JUDGE = 'session-manager.judge'\nexport const FEATURE_HANDOFF = 'session-manager.handoff'\n\n/** Card entry id in the chat flow; the recap renders at the latest completed turn's tail. */\nexport const WELCOME_BACK_CARD_ID = '@klarkxy/dsh-session-manager.welcome-back'\nexport const TURN_TAIL_SLOT = 'conversation.chat.turnTail'\nexport const CONTINUE_GHOST_ID = '@klarkxy/dsh-session-manager.continue-ghost'\nexport const CONTINUE_GHOST_SLOT = 'conversation.input.overlay'\n\nexport const DEFAULT_RECAP_MINUTES = 15\nexport const DEFAULT_COMPACT_MINUTES = 60\n/** Idle thresholds accept one week at most; 0 disables the feature. */\nexport const MAX_IDLE_MINUTES = 10_080\nexport const MAX_CONTINUE_TEXT_CHARS = 200\n/** Cap every model-written recap section shown in the UI. */\nexport const MAX_RECAP_SECTION_CHARS = 600\nexport type ContinueMode = 'fixed' | 'auto'\nexport const CONTINUE_MODES: readonly ContinueMode[] = ['fixed', 'auto']\n/** Per-session automatic continuation stance; 'off' never sends one. */\nexport type AutoContinueMode = 'off' | 'cautious' | 'bold'\nexport const AUTO_CONTINUE_MODES: readonly AutoContinueMode[] = ['off', 'cautious', 'bold']\nexport const DEFAULT_AUTO_CONTINUE_MAX = 3\nexport const MIN_AUTO_CONTINUE_MAX = 1\nexport const MAX_AUTO_CONTINUE_MAX = 10\n\n/** The per-session auto-continue row as the hero option sees it. */\nexport interface AutoContinueStatus {\n readonly sessionId: string\n /** 'executor' for subagent threads: they never carry their own option. */\n readonly role: 'coordinator' | 'executor'\n /** The locked mode; 'off' when the session has no record yet. */\n readonly mode: AutoContinueMode\n /** Automatic continuations allowed after each human message. */\n readonly max: number\n /** The session record's revision; 0 when the session has no record yet. */\n readonly revision: number\n /** No edit is allowed once the first turn starts, or while the session is cold. */\n readonly locked: boolean\n}\n\n/** Model-written welcome-back recap; an empty section means not established. */\nexport interface RecapPayload {\n readonly summary: string\n readonly progress: string\n readonly nextStep: string\n}\n\nexport interface EditPrepareRequest {\n readonly sessionId: string\n readonly promptSeq: number\n}\n\nexport type EditContent = { readonly type: 'text'; readonly text: string }\n | { readonly type: 'image'; readonly attachmentId: string }\n | { readonly type: 'file'; readonly attachmentId: string; readonly name: string; readonly bytes: number }\n\nexport interface EditPrepareValue {\n readonly sessionId: string\n readonly promptSeq: number\n readonly text: string\n /** Original order; images are read through the source Session's authorized endpoint. */\n readonly content?: readonly EditContent[]\n /** The host recorded later file changes after this prompt. */\n readonly modified: boolean\n}\n\nexport interface WelcomeBackPrepareRequest {\n readonly sessionId: string\n /**\n * The lastResponseAt the client already answered for this session. The host\n * skips the recap model call when the mark is unchanged, so a dismissed\n * card costs one cheap observation instead of a model call.\n */\n readonly knownLastResponseAt?: number\n}\n\nexport type WelcomeBackPrepareValue =\n | { readonly show: false }\n | {\n readonly show: true\n readonly sessionId: string\n readonly lastResponseAt: number\n readonly idleMinutes: number\n /** Null when the recap model was unavailable or failed; a compact suggestion still shows. */\n readonly recap: RecapPayload | null\n readonly compactSuggested: boolean\n readonly compactAvailable: boolean\n /** Host-resolved compaction threshold in minutes; 0 means the suggestion is disabled. */\n readonly compactMinutes: number\n }\n\nexport interface WelcomeBackCompactRequest {\n readonly sessionId: string\n readonly requestId: string\n}\n\nexport type WelcomeBackCompactValue =\n | { readonly compacted: true; readonly shadowedTokens: number | null }\n | { readonly compacted: false; readonly reason: 'busy' | 'unavailable' | 'nothing' }\n\nexport interface ContinueSuggestRequest {\n readonly sessionId: string\n /**\n * Last event sequence the client already cached a suggestion for. When it\n * still matches the active branch, the host returns the stored line and\n * skips another model call.\n */\n readonly knownSeq?: number\n}\n\nexport interface ContinueSuggestValue {\n /** Null means there is no continuation to show. */\n readonly text: string | null\n /** Active-branch sequence this text belongs to; absent while a turn is still open. */\n readonly seq?: number\n /** True while the latest turn has not ended, so the composer keeps its own placeholder. */\n readonly pending?: true\n /** Empty fixed text uses the localized default once a turn has ended. */\n readonly fallback?: true\n}\n\n/** The user-facing presence settings view served to the bundle config page. */\nexport interface ConfigView {\n readonly recapMinutes: number\n readonly compactMinutes: number\n readonly continueText: string\n readonly continueMode: ContinueMode\n /** Plugin-owned welcome-back recap model; null follows the default auxiliary model. */\n readonly model: { readonly provider: string; readonly model: string; readonly reasoningEffort?: string } | null\n /** Plugin-owned ghost model; null follows the default auxiliary model. */\n readonly ghostModel: { readonly provider: string; readonly model: string; readonly reasoningEffort?: string } | null\n /** Plugin-owned auto-continue judge model; null follows the default auxiliary model. */\n readonly judgeModel: { readonly provider: string; readonly model: string; readonly reasoningEffort?: string } | null\n /** Plugin-owned read_session handoff model; null follows the default auxiliary model. */\n readonly handoffModel: { readonly provider: string; readonly model: string; readonly reasoningEffort?: string } | null\n /** Initial auto-continue mode for sessions created later. */\n readonly autoContinueMode: AutoContinueMode\n /** Automatic continuations allowed after each human message in an auto-continue session. */\n readonly autoContinueMax: number\n /** Whether the agent may fork its own session without per-call approval. */\n readonly allowSelfFork: boolean\n /** Whether the agent may message other unarchived sessions without per-call approval. */\n readonly allowSendMessage: boolean\n}\n\n/** Sparse settings patch from the bundle config page; every key optional. */\nexport interface ConfigPatch {\n readonly recapMinutes?: number\n readonly compactMinutes?: number\n readonly continueText?: string\n readonly continueMode?: ContinueMode\n /** Null resumes following the default auxiliary model. */\n readonly model?: { readonly provider: string; readonly model: string; readonly reasoningEffort?: string } | null\n /** Null resumes following the default auxiliary model for the ghost. */\n readonly ghostModel?: { readonly provider: string; readonly model: string; readonly reasoningEffort?: string } | null\n /** Null resumes following the default auxiliary model for the auto-continue judge. */\n readonly judgeModel?: { readonly provider: string; readonly model: string; readonly reasoningEffort?: string } | null\n /** Null resumes following the default auxiliary model for read_session handoff summaries. */\n readonly handoffModel?: { readonly provider: string; readonly model: string; readonly reasoningEffort?: string } | null\n readonly autoContinueMode?: AutoContinueMode\n readonly autoContinueMax?: number\n readonly allowSelfFork?: boolean\n readonly allowSendMessage?: boolean\n}\n\nexport interface ConfigWriteRequest {\n readonly patch: ConfigPatch\n}\n\nexport const DEFAULT_PAGE_CHARS = 4_000\nexport const MIN_PAGE_CHARS = 200\nexport const MAX_PAGE_CHARS = 16_000\nexport const DEFAULT_LIST_LIMIT = 20\nexport const MAX_LIST_LIMIT = 100\nexport const DEFAULT_SEARCH_LIMIT = 20\nexport const MAX_SEARCH_LIMIT = 50\nexport const TOOL_SUMMARY_CHARS = 160\n\n/** Conversation reading pages by turn count, never by output size. */\nexport const DEFAULT_TURN_LIMIT = 5\nexport const MAX_TURN_LIMIT = 20\n/** Deterministic preview caps in Unicode code points; full text stays in details mode. */\nexport const PREVIEW_REQUEST_CHARS = 256\nexport const PREVIEW_CONTEXT_CHARS = 128\nexport const PREVIEW_RESPONSE_CHARS = 512\n\nexport interface Config {\n /** Maximum serialized UTF-8 bytes of one read_session details/handoff page, including item metadata. Conversation turn previews do not use this budget. */\n pageChars?: number\n /** Maximum sessions returned by one list_sessions page. */\n listLimit?: number\n /** Maximum sessions returned by one search_sessions page. */\n searchLimit?: number\n /** Idle minutes since the last response before the welcome-back recap card may appear; 0 disables it. */\n recapMinutes?: number\n /** Idle minutes since the last response before the card also suggests context compaction; 0 disables it. */\n compactMinutes?: number\n /** Fixed ghost continuation text; empty falls back to the localized default (\"继续\"/\"Continue\"). */\n continueText?: string\n /** fixed: send continueText; auto: generate the ghost once after the previous turn ends and cache it in the session. */\n continueMode?: ContinueMode\n /** Initial auto-continue mode for sessions created later. */\n autoContinueMode?: AutoContinueMode\n /** Automatic continuations allowed after each human message in an auto-continue session. */\n autoContinueMax?: number\n /** Register the fork_session tool: one-call forks of the calling session, approved once by the toggle. */\n allowSelfFork?: boolean\n /** Register the send_session_message tool: agent-attributed messages to other unarchived sessions, approved once by the toggle. */\n allowSendMessage?: boolean\n}\n\nexport interface ResolvedConfig {\n readonly pageChars: number\n readonly listLimit: number\n readonly searchLimit: number\n readonly recapMinutes: number\n readonly compactMinutes: number\n readonly continueText: string\n readonly continueMode: ContinueMode\n readonly autoContinueMode: AutoContinueMode\n readonly autoContinueMax: number\n readonly allowSelfFork: boolean\n readonly allowSendMessage: boolean\n}\n\nexport function resolveConfig(config: Config = {}): ResolvedConfig {\n return {\n pageChars: boundInteger(config.pageChars, DEFAULT_PAGE_CHARS, MIN_PAGE_CHARS, MAX_PAGE_CHARS, 'pageChars'),\n listLimit: boundInteger(config.listLimit, DEFAULT_LIST_LIMIT, 1, MAX_LIST_LIMIT, 'listLimit'),\n searchLimit: boundInteger(config.searchLimit, DEFAULT_SEARCH_LIMIT, 1, MAX_SEARCH_LIMIT, 'searchLimit'),\n recapMinutes: boundInteger(config.recapMinutes, DEFAULT_RECAP_MINUTES, 0, MAX_IDLE_MINUTES, 'recapMinutes'),\n compactMinutes: boundInteger(config.compactMinutes, DEFAULT_COMPACT_MINUTES, 0, MAX_IDLE_MINUTES, 'compactMinutes'),\n continueText: boundText(config.continueText, MAX_CONTINUE_TEXT_CHARS, 'continueText'),\n continueMode: boundMode(config.continueMode, 'continueMode'),\n autoContinueMode: boundAutoContinueMode(config.autoContinueMode, 'autoContinueMode'),\n autoContinueMax: boundInteger(config.autoContinueMax, DEFAULT_AUTO_CONTINUE_MAX, MIN_AUTO_CONTINUE_MAX, MAX_AUTO_CONTINUE_MAX, 'autoContinueMax'),\n allowSelfFork: boundFlag(config.allowSelfFork, 'allowSelfFork'),\n allowSendMessage: boundFlag(config.allowSendMessage, 'allowSendMessage'),\n }\n}\n\nfunction boundFlag(value: boolean | undefined, name: string): boolean {\n const resolved = value ?? false\n if (typeof resolved !== 'boolean') {\n throw new TypeError(`${PLUGIN_NAME}: ${name} must be a boolean`)\n }\n return resolved\n}\n\nfunction boundInteger(value: number | undefined, fallback: number, min: number, max: number, name: string): number {\n const resolved = value ?? fallback\n if (!Number.isInteger(resolved) || resolved < min || resolved > max) {\n throw new TypeError(`${PLUGIN_NAME}: ${name} must be an integer from ${min} to ${max}`)\n }\n return resolved\n}\n\nfunction boundText(value: string | undefined, maxChars: number, name: string): string {\n const resolved = value?.trim() ?? ''\n if (Array.from(resolved).length > maxChars) {\n throw new TypeError(`${PLUGIN_NAME}: ${name} must be at most ${maxChars} characters`)\n }\n return resolved\n}\n\nfunction boundMode(value: ContinueMode | undefined, name: string): ContinueMode {\n const resolved = value ?? 'fixed'\n if (!CONTINUE_MODES.includes(resolved)) {\n throw new TypeError(`${PLUGIN_NAME}: ${name} must be one of ${CONTINUE_MODES.join(', ')}`)\n }\n return resolved\n}\n\nfunction boundAutoContinueMode(value: AutoContinueMode | undefined, name: string): AutoContinueMode {\n const resolved = value ?? 'off'\n if (!AUTO_CONTINUE_MODES.includes(resolved)) {\n throw new TypeError(`${PLUGIN_NAME}: ${name} must be one of ${AUTO_CONTINUE_MODES.join(', ')}`)\n }\n return resolved\n}\n","/**\n * Relay sidebar right-clicks to the host's own session actions menu.\n *\n * dsh-client-ui-workspace SessionNodeItem renders a keyed treeitem, with a\n * trailing rowActions span. Its first button is the Menu anchor; subsequent\n * buttons are contributed row actions. The span stops click propagation, so\n * clicking the anchor opens the menu without opening the session. Menu portals\n * outside the tree and the row carries a *_menuOpen class while it is open.\n * Blank rows, search results, and AnimatedRows exit clones have no keyed menu\n * anchor and are left alone. CSS-module hash prefixes vary between host builds.\n */\nconst ROW_SELECTOR = '[role=\"treeitem\"][data-row-key^=\"session:\"]'\nconst ACTIONS_SELECTOR = 'span[class*=\"_rowActions\"]'\n\n/** Resolve a live session row in the sidebar tree. */\nexport function findSessionRow(target: Element): HTMLElement | null {\n if (typeof target.closest !== 'function') return null\n const row = target.closest<HTMLElement>(ROW_SELECTOR)\n if (row === null || row.closest('[role=\"tree\"]') === null || row.closest('[inert]') !== null) return null\n return row\n}\n\n/** Forward a context-menu gesture only when the host provides a menu anchor. */\nexport function forwardContextMenu(event: Event): boolean {\n if (event.defaultPrevented) return false\n const target = event.target\n if (target === null || typeof (target as Element).closest !== 'function') return false\n const element = target as Element\n const row = findSessionRow(element)\n if (row === null) return false\n const actions = row.querySelector(ACTIONS_SELECTOR)\n const trigger = actions?.querySelector<HTMLButtonElement>('button')\n if (trigger == null || trigger.disabled) return false\n // Other row actions (pin/archive/etc.) must never fire on right-click.\n if (element.closest(ACTIONS_SELECTOR) !== null && !trigger.contains(element)) return false\n event.preventDefault()\n // The host anchor toggles. Repeated context-menu gestures should keep it open.\n if (!Array.from(row.classList).some(name => name.endsWith('_menuOpen'))) {\n trigger.focus({ preventScroll: true })\n trigger.click()\n }\n return true\n}\n\n/** Capture-phase relay; disposing the client removes the listener. */\nexport function installContextMenuForwarding(doc: Document): () => void {\n const listener = (event: Event) => { forwardContextMenu(event) }\n doc.addEventListener('contextmenu', listener, true)\n return () => { doc.removeEventListener('contextmenu', listener, true) }\n}\n","/**\n * Shared contract that keeps every plugin's browser-side UI on the official\n * DeepSeek Harness Web design language.\n *\n * Two rules produce that language, and both are load-bearing here:\n *\n * 1. Colour, radius, elevation and focus come from the host theme's real\n * `--dsw-*` tokens, written under their own names. Plugins never invent a\n * token, never alias the official ones behind a private palette (a private\n * alias is just a second, diverging theme), and never carries a literal\n * fallback — the host publishes light and dark, and a literal would pin one\n * of them. The only non-colour custom properties used are the host's own\n * content-font axis and frame clearance.\n *\n * 2. Anything the host already ships is used, not reimplemented. Controls come\n * from `@deepseek-ai/dsh-client-ui-primitives` (`Button`, `Input`,\n * `Checkbox`, `Switch`, `Tag`, `Pill`, `SegmentedControl`, `Menu`, `Modal`,\n * `Tooltip`, `Toast`, `DisclosureRow`, `StateDot`, `PathLabel`, the settings\n * form suite). This module only styles what primitives do not cover: page\n * scaffolding, field layout, banners, empty states and scroll regions.\n *\n * The metrics below are transcribed from the primitives' own CSS modules so a\n * feature panel lines up pixel-for-pixel with a native one: the 14/22 body and\n * 13/20 compact type tiers, the 0.5px hairline scale, and the elevation family\n * that draws a surface's edge in its shadow (`border: 0`) instead of a border.\n */\n\n/**\n * Every `--dsw-*` token this repo is allowed to reference, grouped by role.\n *\n * Plugins may only colour through this list. It is exported so the guard test\n * can fail a build when a stylesheet reaches for anything else — the failure\n * mode this prevents is silent: an unknown token resolves to nothing, so a\n * border disappears or a label inherits the wrong colour with no error anywhere.\n */\nexport const OFFICIAL_THEME_TOKENS = {\n /** Surfaces, from the page up to the topmost nested card. */\n surface: [\n '--dsw-alias-bg-base',\n '--dsw-alias-bg-layer-1',\n '--dsw-alias-bg-layer-2',\n '--dsw-alias-bg-layer-3',\n '--dsw-alias-bg-layer-4',\n '--dsw-alias-bg-module-platform',\n '--dsw-alias-bg-overlay',\n ],\n /** Hairlines. l1 is near-invisible on a menu surface, so menus use l2+. */\n border: ['--dsw-alias-border-l1', '--dsw-alias-border-l2', '--dsw-alias-border-l3', '--dsw-alias-border-l4'],\n /** Text. `caption` is menu shortcut text, `dimmed` is placeholder text. */\n label: [\n '--dsw-alias-label-primary',\n '--dsw-alias-label-secondary',\n '--dsw-alias-label-tertiary',\n '--dsw-alias-label-caption',\n '--dsw-alias-label-dimmed',\n '--dsw-alias-label-error',\n '--dsw-alias-label-primary-foreground',\n ],\n /** Interactive fills. The `-danger` hover belongs to destructive rows. */\n interactive: [\n '--dsw-alias-interactive-bg-hover',\n '--dsw-alias-interactive-bg-active',\n '--dsw-alias-interactive-bg-hover-danger',\n ],\n /** Accent and status. `business` is the focus ring's default colour. */\n accent: [\n '--dsw-alias-brand-primary',\n '--dsw-alias-button-primary-fill',\n '--dsw-alias-button-primary-hover',\n '--dsw-alias-button-tool-bar-fill',\n '--dsw-alias-button-tool-bar-hover',\n '--dsw-alias-button-ghost-active-fill',\n '--dsw-alias-button-ghost-active-border',\n ],\n state: [\n '--dsw-alias-state-business-primary',\n '--dsw-alias-state-success-primary',\n '--dsw-alias-state-warn-primary',\n '--dsw-alias-state-error-primary',\n '--dsw-alias-state-idle-primary',\n ],\n /** Corner scale: sm 8, md 12, lg the large card, panel the modal. */\n radius: ['--dsw-radius-sm', '--dsw-radius-md', '--dsw-radius-lg', '--dsw-radius-panel'],\n /** An elevated surface draws its edge in the shadow, so it keeps border: 0. */\n elevation: [\n '--dsw-elevation-soft',\n '--dsw-elevation-stroke',\n '--dsw-elevation-stroke-color',\n '--dsw-elevation-panel',\n '--dsw-elevation-prominent',\n ],\n /** Floats, masks and scrollbars. */\n overlay: [\n '--dsw-menu-surface-fill',\n '--dsw-menu-backdrop-filter',\n '--dsw-mask-blur',\n '--dsw-alias-bg-mask-1',\n '--dsw-alias-menu-icon',\n '--dsw-alias-scrollbar-bg-l2',\n '--dsw-alias-scrollbar-hover-l2',\n '--dsw-shadow-lv3',\n ],\n /** Motion, focus and type axis, published by the host rather than by a component. */\n system: [\n '--dsw-focus-ring-width',\n '--dsw-focus-ring-color',\n '--dsw-font-markdown-code-font-family',\n '--ds-transition-duration',\n '--ds-ease-in-out',\n '--ds-font-family-code',\n '--dsh-scrollbar-thumb',\n '--dsh-scrollbar-thumb-hover',\n '--dsh-content-font-size-secondary',\n '--dsh-content-font-delta',\n '--dsh-frame-top-clearance',\n // Published by the conversation.input.model seat for narrow composer rows.\n '--dsh-composer-model-icon-display',\n '--dsh-composer-model-text-display',\n ],\n} as const\n\n/** Every official token name, flat. Used by the token guard test. */\nexport const OFFICIAL_THEME_TOKEN_NAMES: readonly string[] = Object.values(OFFICIAL_THEME_TOKENS).flat()\n\n/** The elevation steps a surface can be raised by, softest first. */\nexport type OfficialElevation = 'soft' | 'stroke' | 'panel' | 'prominent'\n\n/**\n * The host's focus ring shorthand, verbatim. Writing this per control is how\n * rings drift apart; a stylesheet that draws its own focus style should use\n * {@link officialFocus} instead. The colour fallback is the host's own default.\n */\nexport const OFFICIAL_FOCUS_RING =\n 'var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary))'\n\n/**\n * A complete `outline` declaration at the official geometry. `offset` defaults\n * to the 2px the native controls use; the host's inline field rules sit at 1px\n * and a segmented tab pulls the ring inside itself at -2px.\n */\nexport function officialFocus(offset = '2px'): string {\n return `outline: ${OFFICIAL_FOCUS_RING}; outline-offset: ${offset}`\n}\n\n/**\n * An elevated surface. The host draws a raised surface's edge inside its\n * shadow rather than as a border, so a card sets `border: 0` and takes the edge\n * from the elevation — which is also why its border stays off the alias-border\n * set that a flat, non-elevated rule would use.\n */\nexport function officialElevation(level: OfficialElevation): string {\n return `border: 0; box-shadow: var(--dsw-elevation-${level})`\n}\n\n/**\n * An elevated surface whose edge should read as a specific hairline. Rebinding\n * the stroke colour is how a menu card picks l1 while a panel picks l3, without\n * the two growing apart by hand.\n */\nexport function officialStrokedElevation(level: OfficialElevation, color: string): string {\n return `--dsw-elevation-stroke-color: ${color}; ${officialElevation(level)}`\n}\n\n/**\n * The shared stylesheet for a plugin UI, scoped under that plugin's root class.\n *\n * Scoping is what keeps this safe to always-bundle into every client: the rules\n * can only match inside the plugin's own subtree, so two plugins can both mount\n * `dsh-ui-card` without either styling the other's markup.\n *\n * Each recipe matches the root element *and* its descendants, because the\n * commonest arrangement is one element that is both — a surface that carries\n * the root class and `dsh-ui-card`, or a portaled dialog that is the root and\n * the `dsh-ui-surface`. A descendant-only scope would silently leave those\n * unstyled, with no error anywhere.\n *\n * A caveat worth knowing: `Modal` and `Menu` portal to `document.body`, so their\n * content leaves the plugin's subtree entirely. A portaled surface therefore\n * needs its own root class on an element inside the portal.\n *\n * Only patterns that primitives do not provide live here. If a control appears\n * below that `Button`/`Input`/`Switch`/`Tag`/`Menu` already covers, that is a\n * bug in this file: use the primitive and delete the recipe.\n */\nexport function officialUiCss(roots: string | readonly string[]): string {\n // One plugin often mounts several unrelated surfaces (a settings seat, a chat\n // card, a header menu), so the caller names every root. The rules below are\n // nested under a single selector list and use `&`, which the browser expands\n // per root — so one stylesheet covers all of them without duplicating itself.\n const scope = (typeof roots === 'string' ? [roots] : roots).map(root => `.${root}`).join(', ')\n const sheet = `\n/* Official DSH Web UI contract. Generated by @klarkxy/dsh-plugin-kit/official-ui.\n * Do not hand-edit the copy inside a plugin: change this module so every plugin\n * moves together. Scope: ${scope} */\n/* The scope rule below stays open for the whole sheet: every rule after it\n * nests with the parent selector, so one stylesheet can cover several unrelated\n * roots without leaking into a neighbouring plugin. Its closing brace is last. */\n${scope} {\n color: var(--dsw-alias-label-primary);\n font-family: inherit;\n font-size: 14px;\n line-height: 22px;\n min-width: 0;\n\n& *, & *::before, & *::after { box-sizing: border-box; }\n& h1, & h2, & h3, & h4, & p, & figure { margin: 0; }\n/* Keyboard focus only: pointer input keeps the native resting appearance. The\n * ring needs no radius of its own — the outline already follows the control's\n * own border-radius, and overriding it here would flatten every control. */\n& :focus-visible { ${officialFocus()}; }\n& [hidden] { display: none !important; }\n\n/* --- Type tiers. The same 14/22 and 13/20 steps the primitives use. --- */\n& .dsh-ui-title { font-size: 16px; line-height: 24px; font-weight: 500; color: var(--dsw-alias-label-primary); }\n& .dsh-ui-heading { font-size: 14px; line-height: 22px; font-weight: 500; color: var(--dsw-alias-label-primary); }\n& .dsh-ui-compact { font-size: 13px; line-height: 20px; color: var(--dsw-alias-label-primary); }\n& .dsh-ui-meta { font-size: 12px; line-height: 18px; color: var(--dsw-alias-label-secondary); }\n& .dsh-ui-hint { font-size: 12px; line-height: 18px; color: var(--dsw-alias-label-tertiary); }\n& .dsh-ui-error { font-size: 12px; line-height: 18px; color: var(--dsw-alias-state-error-primary); }\n& .dsh-ui-warn { color: var(--dsw-alias-state-warn-primary); }\n& .dsh-ui-success { color: var(--dsw-alias-state-success-primary); }\n& .dsh-ui-muted { color: var(--dsw-alias-label-tertiary); }\n& .dsh-ui-truncate { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n& .dsh-ui-wrap { min-width: 0; overflow-wrap: anywhere; }\n\n/* --- Layout scaffolding. --- */\n& .dsh-ui-stack { display: flex; flex-direction: column; gap: 12px; }\n& .dsh-ui-stack-lg { display: flex; flex-direction: column; gap: 20px; }\n/* Plugin detail pages share one reading column. These are layout recipes;\n * controls keep their own primitive styles. Form spacing follows the host's\n * settings-form/fields.module.css and SettingsForm.module.css. */\n& .dsh-ui-page { display: flex; flex-direction: column; gap: 16px; width: 100%; max-width: 760px; min-width: 0; }\n& .dsh-ui-form { display: flex; flex-direction: column; gap: 0; min-width: 0; }\n&.dsh-ui-form > .dsh-ui-field, & .dsh-ui-form > .dsh-ui-field { padding: 12px 0; }\n& .dsh-ui-form-footer { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding-top: 16px; min-width: 0; }\n& .dsh-ui-fields-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 20px; min-width: 0; margin: 0; padding: 0; border: 0; }\n@media (max-width: 560px) {\n & .dsh-ui-fields-grid { grid-template-columns: minmax(0, 1fr); }\n}\n& .dsh-ui-row { display: flex; align-items: center; gap: 8px; min-width: 0; }\n& .dsh-ui-row-wrap { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }\n& .dsh-ui-spacer { flex: 1; min-width: 0; }\n/* A 0.5px l2 rule is the host's section divider; reserve the same rhythm. */\n& .dsh-ui-divider { height: 0.5px; background: var(--dsw-alias-border-l2); }\n& .dsh-ui-section { display: flex; flex-direction: column; gap: 12px; padding-top: 16px; border-top: 0.5px solid var(--dsw-alias-border-l2); }\n\n/* --- Card: a raised surface whose edge lives in the shadow. --- */\n& .dsh-ui-card {\n ${officialElevation('stroke')}\n display: flex;\n flex-direction: column;\n gap: 12px;\n padding: 16px;\n border-radius: var(--dsw-radius-lg);\n background: var(--dsw-alias-bg-layer-1);\n color: var(--dsw-alias-label-primary);\n min-width: 0;\n}\n& .dsh-ui-card--flat { border: 0.5px solid var(--dsw-alias-border-l3); box-shadow: none; }\n& .dsh-ui-card--nested { background: var(--dsw-alias-bg-layer-2); }\n& .dsh-ui-card--plain { background: none; }\n\n/* --- Field: label, control, help, error. The control itself is an\n * official primitive, so this only owns the vertical rhythm. --- */\n& .dsh-ui-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }\n& .dsh-ui-field + .dsh-ui-field { border-top: 0.5px solid var(--dsw-alias-border-l2); padding-top: 12px; }\n/* Grid fields share a row, so the stacked-field divider must not win later in\n * the cascade. Reset it here, after the field recipe. */\n& .dsh-ui-fields-grid > .dsh-ui-field { padding: 0; border: 0; }\n& .dsh-ui-label { display: flex; align-items: center; gap: 6px; font-size: 13px; line-height: 20px; font-weight: 500; color: var(--dsw-alias-label-primary); }\n& .dsh-ui-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }\n& .dsh-ui-help { font-size: 12px; line-height: 1.6; color: var(--dsw-alias-label-secondary); }\n& .dsh-ui-help p { margin: 0; }\n& .dsh-ui-help p + p { margin-top: 8px; }\n& .dsh-ui-required { color: var(--dsw-alias-state-error-primary); }\n& .dsh-ui-control { width: 100%; min-width: 0; }\n/* An invalid control is marked on the control, not only in the message. */\n& .dsh-ui-control[aria-invalid='true'] { border-color: var(--dsw-alias-state-error-primary); }\n& .dsh-ui-readonly { display: flex; flex-direction: column; gap: 4px; min-width: 0; }\n& .dsh-ui-readonly > dt { font-size: 12px; line-height: 18px; color: var(--dsw-alias-label-tertiary); }\n& .dsh-ui-readonly > dd { margin: 0; font-size: 13px; line-height: 20px; overflow-wrap: anywhere; }\n\n/* --- Buttons row. A no-op container: it exists so actions line up on the\n * trailing edge the way every native panel does. --- */\n& .dsh-ui-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 4px; }\n& .dsh-ui-actions-end { justify-content: flex-end; }\n\n/* --- Banners. A banner is a left-rail notice, the shape used for warnings,\n * deprecations and blocking instructions. --- */\n& .dsh-ui-banner {\n display: flex;\n flex-direction: column;\n gap: 8px;\n padding: 10px 14px;\n border: 0.5px solid var(--dsw-alias-border-l3);\n border-left: 3px solid var(--dsw-alias-state-warn-primary);\n border-radius: var(--dsw-radius-md);\n background: var(--dsw-alias-bg-layer-1);\n font-size: 13px;\n line-height: 20px;\n color: var(--dsw-alias-label-secondary);\n}\n& .dsh-ui-banner-title { font-weight: 500; color: var(--dsw-alias-state-warn-primary); }\n& .dsh-ui-banner--info { border-left-color: var(--dsw-alias-state-business-primary); }\n& .dsh-ui-banner--danger { border-left-color: var(--dsw-alias-state-error-primary); }\n& .dsh-ui-banner--success { border-left-color: var(--dsw-alias-state-success-primary); }\n& .dsh-ui-banner p { margin: 0; }\n\n/* --- Inline notice: a transient confirmation with no chrome of its own. --- */\n& .dsh-ui-notice { display: flex; align-items: center; gap: 6px; font-size: 12px; line-height: 18px; color: var(--dsw-alias-state-success-primary); }\n& .dsh-ui-notice--error { color: var(--dsw-alias-state-error-primary); }\n\n/* --- Empty and loading states. Both sit in a dashed well so an empty panel\n * reads as \"nothing here yet\" rather than as a broken layout. --- */\n& .dsh-ui-empty {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n gap: 6px;\n padding: 20px 16px;\n border: 0.5px dashed var(--dsw-alias-border-l3);\n border-radius: var(--dsw-radius-md);\n font-size: 13px;\n line-height: 20px;\n color: var(--dsw-alias-label-secondary);\n}\n& .dsh-ui-loading { display: flex; align-items: center; gap: 8px; padding: 20px 0; font-size: 13px; line-height: 20px; color: var(--dsw-alias-label-secondary); }\n\n/* --- Selectable list. A row is a button-sized target with a hover fill and\n * a selected fill; the name carries the weight, the description does not. --- */\n& .dsh-ui-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; min-width: 0; }\n& .dsh-ui-list-scroll { max-height: min(66vh, 760px); overflow-y: auto; overflow-x: hidden; }\n& .dsh-ui-list-row { border-radius: var(--dsw-radius-md); }\n& .dsh-ui-list-row:hover { background: var(--dsw-alias-interactive-bg-hover); }\n& .dsh-ui-list-row[aria-selected='true'], & .dsh-ui-list-row[data-selected] { background: var(--dsw-alias-interactive-bg-active); }\n& .dsh-ui-list-item {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n gap: 4px;\n width: 100%;\n min-width: 0;\n padding: 10px 12px;\n border: 0;\n border-radius: var(--dsw-radius-md);\n background: none;\n font: inherit;\n color: inherit;\n text-align: start;\n cursor: pointer;\n}\n& .dsh-ui-list-item:disabled { cursor: default; }\n& .dsh-ui-list-item:disabled:hover { background: none; }\n& .dsh-ui-list-name { font-size: 14px; line-height: 22px; font-weight: 500; color: var(--dsw-alias-label-primary); overflow-wrap: anywhere; }\n& .dsh-ui-list-desc { font-size: 12px; line-height: 18px; color: var(--dsw-alias-label-tertiary); }\n\n/* --- Code and structured output. Wraps rather than scrolls, because a\n * feature panel is read rather than scanned. --- */\n& .dsh-ui-code {\n padding: 10px 12px;\n border: 0.5px solid var(--dsw-alias-border-l3);\n border-radius: var(--dsw-radius-md);\n background: var(--dsw-alias-bg-layer-1);\n font-family: var(--ds-font-family-code);\n font-size: 12px;\n line-height: 20px;\n color: var(--dsw-alias-label-secondary);\n overflow-wrap: anywhere;\n white-space: pre-wrap;\n}\n& .dsh-ui-scroll { max-height: 60vh; overflow: auto; overscroll-behavior: contain; }\n\n/* --- A toggle row: label on the left, switch on the trailing edge. This is\n * layout only; the switch itself is the official primitive. --- */\n& .dsh-ui-toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-width: 0; padding: 12px 0; }\n& .dsh-ui-toggle-row + .dsh-ui-toggle-row { border-top: 0.5px solid var(--dsw-alias-border-l2); }\n& .dsh-ui-toggle-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }\n& .dsh-ui-toggle-label { font-size: 14px; line-height: 22px; font-weight: 500; color: var(--dsw-alias-label-primary); }\n\n/* --- Floating surface: a panel anchored to a trigger. This is the material\n * a menu card is made of — the translucent fill plus its backdrop blur, with\n * the edge riding inside the prominent elevation. A plugin that hand-rolls this\n * is how tokens like --dsw-specific-menu get invented; use this instead. --- */\n& .dsh-ui-surface {\n --dsw-elevation-stroke-color: var(--dsw-alias-border-l1);\n --dsh-scrollbar-thumb: var(--dsw-alias-scrollbar-bg-l2);\n --dsh-scrollbar-thumb-hover: var(--dsw-alias-scrollbar-hover-l2);\n position: relative;\n display: flex;\n flex-direction: column;\n border: 0;\n border-radius: var(--dsw-radius-lg);\n background: var(--dsw-menu-surface-fill);\n backdrop-filter: var(--dsw-menu-backdrop-filter);\n box-shadow: var(--dsw-elevation-prominent);\n color: var(--dsw-alias-label-primary);\n font-size: 13px;\n line-height: 20px;\n min-width: 0;\n}\n& .dsh-ui-surface-body { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px 14px; overflow-y: auto; }\n& .dsh-ui-surface-head { display: flex; align-items: center; gap: 8px; min-width: 0; }\n& .dsh-ui-surface-title { font-size: 14px; line-height: 22px; font-weight: 500; color: var(--dsw-alias-label-primary); }\n\n/* --- Native select. The primitives ship no select, so a plugin that offers a\n * closed list of choices keeps the platform control and matches the official\n * settings field geometry exactly (34px, 0.5px l4, radius-md, layer-3). A\n * SegmentedControl is the primitive to reach for when the choices are few\n * enough to show at once. --- */\n& .dsh-ui-select {\n box-sizing: border-box;\n width: 100%;\n min-width: 0;\n height: 34px;\n padding: 0 12px;\n border: 0.5px solid var(--dsw-alias-border-l4);\n border-radius: var(--dsw-radius-md);\n background: var(--dsw-alias-bg-layer-3);\n font: inherit;\n font-size: 13px;\n line-height: 1.5;\n color: var(--dsw-alias-label-primary);\n cursor: pointer;\n}\n& .dsh-ui-select:focus-visible { outline: none; border-color: var(--dsw-alias-state-business-primary); }\n& .dsh-ui-select:disabled { color: var(--dsw-alias-label-tertiary); cursor: default; }\n& .dsh-ui-select[aria-invalid='true'] { border-color: var(--dsw-alias-state-error-primary); }\n\n/* --- Native textarea. The primitives ship no textarea either, so a settings\n * prompt keeps the platform element and the same field shell as the select:\n * 0.5px l4, radius-md, layer-3, 13/1.5 type. It grows vertically instead of\n * locking to the select's 34px row. --- */\n& .dsh-ui-textarea {\n box-sizing: border-box;\n width: 100%;\n min-width: 0;\n resize: vertical;\n padding: 8px 12px;\n border: 0.5px solid var(--dsw-alias-border-l4);\n border-radius: var(--dsw-radius-md);\n background: var(--dsw-alias-bg-layer-3);\n font: inherit;\n font-size: 13px;\n line-height: 1.5;\n color: var(--dsw-alias-label-primary);\n}\n& .dsh-ui-textarea:focus-visible { outline: none; border-color: var(--dsw-alias-state-business-primary); }\n& .dsh-ui-textarea:disabled { color: var(--dsw-alias-label-tertiary); cursor: default; }\n& .dsh-ui-textarea::placeholder { color: var(--dsw-alias-label-dimmed); }\n& .dsh-ui-textarea[aria-invalid='true'] { border-color: var(--dsw-alias-state-error-primary); }\n\n/* Long panels scroll inside themselves instead of growing the host page. */\n& .dsh-ui-panel { display: flex; flex-direction: column; gap: 16px; min-width: 0; }\n& .dsh-ui-panel-wide { max-width: 100%; }\n\n@media (prefers-reduced-motion: reduce) {\n & *, & *::before, & *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }\n}\n}\n`\n // Widen every recipe from \"a descendant of the root\" to \"the root, or one of\n // its descendants\". Written as a transform rather than by hand so no recipe\n // can be added later with only the descendant form. The pattern is narrow on\n // purpose: a leading `&` followed by one recipe class and no combinator, so\n // sibling and child rules such as `.dsh-ui-field + .dsh-ui-field` keep their\n // own meaning and are left alone.\n return sheet.replace(/^& (\\.dsh-ui-[a-z0-9-]+)(?=\\s*\\{)/gm, (_match, className: string) =>\n `&${className}, & ${className}`)\n}\n","/**\n * Shared model-route value contract.\n *\n * A feature plugin stores its model override as a ModelRoute on its own\n * settings page. Empty provider/model means \"follow the host default model\".\n * Pure and browser-safe: no cordis, no React, no schema library.\n */\n\n/** A concrete provider model a feature call should use. */\nexport interface ModelRoute {\n provider: string\n model: string\n reasoningEffort?: string\n}\n\n/** Empty route: no explicit model, the feature follows the host default. */\nexport function defaultModelRoute(): ModelRoute {\n return { provider: '', model: '' }\n}\n\n/** Structural check: both id fields are strings (either may be empty). */\nexport function isModelRouteValue(value: unknown): value is ModelRoute {\n if (!value || typeof value !== 'object' || Array.isArray(value)) return false\n const row = value as Record<string, unknown>\n return typeof row.provider === 'string' && typeof row.model === 'string'\n}\n\nconst MAX_ID_CHARS = 250\nconst MAX_EFFORT_CHARS = 80\n\nfunction asText(value: unknown): string | undefined {\n return typeof value === 'string' && value.trim() ? value.trim() : undefined\n}\n\n/**\n * Coerce a stored value into a ModelRoute. Anything malformed collapses to the\n * empty route, matching the per-plugin normalizers this contract replaces.\n */\nexport function normalizeModelRoute(value: unknown): ModelRoute {\n if (!value || typeof value !== 'object' || Array.isArray(value)) return defaultModelRoute()\n const row = value as Record<string, unknown>\n const provider = asText(row.provider) ?? ''\n const model = asText(row.model) ?? ''\n const effort = asText(row.reasoningEffort)\n if (!provider || !model || provider.length > MAX_ID_CHARS || model.length > MAX_ID_CHARS) return defaultModelRoute()\n return effort && effort.length <= MAX_EFFORT_CHARS ? { provider, model, reasoningEffort: effort } : { provider, model }\n}\n\n/** The override to actually call with: undefined when the route is empty. */\nexport function modelRouteOverride(route: ModelRoute | undefined): ModelRoute | undefined {\n const provider = route?.provider?.trim()\n const model = route?.model?.trim()\n if (!provider || !model) return undefined\n const effort = route?.reasoningEffort?.trim()\n return effort ? { provider, model, reasoningEffort: effort } : { provider, model }\n}\n\nconst KEY_SEPARATOR = '\\u001f'\n\n/** Stable key for one route, safe to use as a select-option value. */\nexport function modelRouteKey(provider: string, model: string): string {\n return provider && model ? `${provider}${KEY_SEPARATOR}${model}` : ''\n}\n\n/** Inverse of modelRouteKey; undefined for malformed keys. */\nexport function parseModelRouteKey(value: string): { provider: string; model: string } | undefined {\n const index = value.indexOf(KEY_SEPARATOR)\n if (index <= 0) return undefined\n const provider = value.slice(0, index)\n const model = value.slice(index + KEY_SEPARATOR.length)\n if (!provider || !model) return undefined\n return { provider, model }\n}\n\n/** True when both routes name the same target; two empty routes are equal. */\nexport function sameModelRoute(a: ModelRoute | undefined, b: ModelRoute | undefined): boolean {\n const left = modelRouteOverride(a)\n const right = modelRouteOverride(b)\n if (!left || !right) return !left === !right\n return left.provider === right.provider && left.model === right.model\n && (left.reasoningEffort ?? '') === (right.reasoningEffort ?? '')\n}\n","/**\n * Host model-catalog parsing shared by plugin settings UIs and model hubs.\n * Pure and browser-safe: no React, no host imports. The catalog envelope is\n * structural so hosts may add fields without breaking consumers.\n */\nimport { modelRouteKey, type ModelRoute } from './route.ts'\n\n/** One selectable model. `efforts` are the advertised reasoning efforts. */\nexport interface ModelMenuChoice {\n readonly provider: string\n readonly model: string\n readonly label: string\n /**\n * Provider display name from the catalog group. Optional: synthetic entries\n * (a saved route missing from the catalog) have no group, so consumers must\n * fall back to `provider`. Search matches it alongside the provider id.\n */\n readonly providerLabel?: string\n readonly efforts: ReadonlyArray<{ id: string; name: string }>\n}\n\n/** Both services are required: Cordis checks the nested namespace separately. */\nexport const MODEL_CATALOG_INJECT = ['remote', 'remote.session'] as const\n\nexport interface ModelCatalogFailure {\n readonly id: string\n readonly name: string\n readonly message: string\n}\n\n/** The catalog face this helper needs; stays structural so hosts may add more. */\nexport interface ModelCatalogClient {\n readonly remote?: {\n readonly session?: { readonly modelCatalog?: () => Promise<unknown> }\n }\n}\n\nfunction asRecord(value: unknown): Record<string, unknown> | undefined {\n return value && typeof value === 'object' && !Array.isArray(value) ? value as Record<string, unknown> : undefined\n}\n\nfunction asText(value: unknown): string | undefined {\n return typeof value === 'string' && value.trim() ? value.trim() : undefined\n}\n\n/** A useful diagnostic even when a transport rejects with a plain object. */\nexport function modelCatalogErrorMessage(value: unknown): string {\n if (value instanceof Error && value.message) return value.message\n const row = asRecord(value)\n return asText(row?.message) ?? asText(value) ?? 'Unable to load the model catalog.'\n}\n\n/**\n * Validate and unwrap a successful catalog without discarding provider failures\n * or newer host metadata. Names and metadata remain optional for older hosts.\n * A broken response is never presented as a successfully loaded empty menu.\n */\nexport function checkedModelCatalog(value: unknown): unknown {\n const envelope = asRecord(value)\n if (envelope?.ok === false) throw new Error(modelCatalogErrorMessage(envelope.error ?? envelope))\n const root = envelope?.ok === true ? asRecord(envelope.value) : envelope\n const malformed = (field: string): never => { throw new Error(`Invalid model catalog: ${field}.`) }\n if (!root || !Array.isArray(root.groups)) return malformed('groups must be an array')\n for (const value of root.groups) {\n const group = asRecord(value)\n if (!group || !asText(group.id) || !Array.isArray(group.models)) return malformed('each group needs an id and models array')\n for (const value of group.models) {\n const model = asRecord(value)\n if (!model || !asText(model.id)) return malformed('each model needs an id')\n if (model.reasoning !== undefined) {\n const reasoning = asRecord(model.reasoning)\n if (!reasoning || !Array.isArray(reasoning.efforts) || reasoning.efforts.some(value => !parseEffort(value))) {\n return malformed('reasoning efforts must be an array of identified efforts')\n }\n }\n }\n }\n if (root.failures !== undefined && (!Array.isArray(root.failures) || root.failures.some(value => {\n const failure = asRecord(value)\n return !failure || !asText(failure.id) || typeof failure.name !== 'string' || typeof failure.message !== 'string'\n }))) return malformed('failures must be an array of provider failures')\n return root\n}\n\n/** Read through the injected session namespace; absence and rejection are errors. */\nexport async function readModelCatalog(client: ModelCatalogClient): Promise<unknown> {\n const session = client.remote?.session\n if (typeof session?.modelCatalog !== 'function') {\n throw new Error('Model catalog unavailable: inject both remote and remote.session.')\n }\n return checkedModelCatalog(await session.modelCatalog())\n}\n\n/** Provider failures are partial results, not a transport failure. */\nexport function modelCatalogFailures(value: unknown): readonly ModelCatalogFailure[] {\n // Rendering can precede the checked load boundary (for example hub owner\n // snapshots). Invalid or absent data must not crash the whole settings page.\n try {\n const root = checkedModelCatalog(value) as { failures?: readonly ModelCatalogFailure[] }\n return root.failures ?? []\n } catch { return [] }\n}\n\n/** Text adapter for existing model-hub status messages. */\nexport function catalogFailures(value: unknown): string[] {\n return modelCatalogFailures(value).map(failure => `${failure.name || failure.id}: ${failure.message}`)\n}\n\nfunction parseEffort(value: unknown): { id: string; name: string } | undefined {\n const row = asRecord(value)\n const id = row ? asText(row.id) : undefined\n if (!id) return undefined\n return { id, name: row ? asText(row.name) ?? id : id }\n}\n\n/** Parse the host session catalog into flat choices, keeping a saved route selectable. */\nexport function parseModelMenuChoices(value: unknown, bound?: ModelRoute): ModelMenuChoice[] {\n const envelope = asRecord(value)\n // Host remote calls resolve to a result envelope ({ ok, value }); older hosts\n // and unit tests hand over the bare catalog. Accept both.\n const root = (envelope && envelope.ok === true ? asRecord(envelope.value) : undefined) ?? envelope ?? {}\n const groups = Array.isArray(root.groups) ? root.groups : []\n const choices: ModelMenuChoice[] = []\n for (const group of groups) {\n const groupRow = asRecord(group)\n const provider = groupRow ? asText(groupRow.id) : undefined\n if (!provider || !groupRow || !Array.isArray(groupRow.models)) continue\n const providerName = asText(groupRow.name) ?? provider\n for (const entry of groupRow.models) {\n const modelRow = asRecord(entry)\n const model = modelRow ? asText(modelRow.id) : undefined\n if (!model || !modelRow) continue\n const name = asText(modelRow.name) ?? model\n const reasoning = asRecord(modelRow.reasoning)\n const efforts = reasoning && Array.isArray(reasoning.efforts)\n ? reasoning.efforts.flatMap(effort => { const parsed = parseEffort(effort); return parsed ? [parsed] : [] })\n : []\n choices.push({ provider, model, label: `${providerName} / ${name}`, providerLabel: providerName, efforts })\n }\n }\n if (bound?.provider && bound.model && !choices.some(item => item.provider === bound.provider && item.model === bound.model)) {\n choices.push({ provider: bound.provider, model: bound.model, label: `${bound.provider} / ${bound.model}`, efforts: [] })\n }\n return choices\n}\n\n/** Reasoning-effort options for one choice; the saved value stays selectable. */\nexport function modelMenuEffortOptions(\n choice: ModelMenuChoice | undefined,\n current?: string,\n): Array<{ id: string; name: string }> {\n const listed = (choice?.efforts ?? []).map(item => ({ ...item }))\n if (current && !listed.some(item => item.id === current)) listed.push({ id: current, name: current })\n return listed\n}\n\n/** Flat set of known routes for DetectModelFieldsOptions.knownModel. */\nexport function knownModelFromChoices(choices: readonly ModelMenuChoice[]): (route: ModelRoute) => boolean {\n const known = new Set(choices.map(choice => modelRouteKey(choice.provider, choice.model)))\n return route => known.has(modelRouteKey(route.provider, route.model))\n}\n","import { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { Button } from '@deepseek-ai/dsh-client-ui-primitives'\nimport {\n checkedModelCatalog, modelCatalogErrorMessage, modelCatalogFailures, parseModelMenuChoices,\n type ModelCatalogFailure, type ModelMenuChoice,\n} from './catalog.ts'\n\nexport interface UseModelCatalogOptions {\n /** Used only on mount; subsequent changes come from load(). */\n readonly initialCatalog?: unknown\n /** Disables initial, focus, subscription, and manual refreshes. */\n readonly enabled?: boolean\n readonly subscribe?: (onChange: () => void) => (() => void) | undefined\n}\n\nexport interface ModelCatalogState {\n readonly catalog: unknown\n readonly choices: ModelMenuChoice[]\n readonly loading: boolean\n readonly error: string\n readonly failures: readonly ModelCatalogFailure[]\n readonly refresh: () => Promise<void>\n}\n\ntype Snapshot = Pick<ModelCatalogState, 'catalog' | 'loading' | 'error'>\n\n/**\n * Latest refresh wins, including retries while a previous request is pending.\n * Keep load stable (for example with useCallback); changing it invalidates the\n * previous source and fetches again, so switching clients cannot publish stale data.\n */\nexport function useModelCatalog(load: () => Promise<unknown>, options: UseModelCatalogOptions = {}): ModelCatalogState {\n const enabled = options.enabled !== false\n const enabledRef = useRef(enabled)\n enabledRef.current = enabled\n const live = useRef(false)\n const source = useRef(load)\n const revision = useRef(0)\n const [state, setState] = useState<Snapshot>(() => {\n try {\n return { catalog: options.initialCatalog === undefined ? undefined : checkedModelCatalog(options.initialCatalog), loading: enabled, error: '' }\n } catch (error) {\n return { catalog: undefined, loading: enabled, error: modelCatalogErrorMessage(error) }\n }\n })\n const refresh = useCallback(async (): Promise<void> => {\n if (!live.current || !enabledRef.current) return\n const request = ++revision.current\n setState(previous => ({ ...previous, loading: true, error: '' }))\n try {\n const catalog = checkedModelCatalog(await load())\n if (live.current && request === revision.current) setState({ catalog, loading: false, error: '' })\n } catch (error) {\n if (live.current && request === revision.current) {\n setState(previous => ({ ...previous, loading: false, error: modelCatalogErrorMessage(error) }))\n }\n }\n }, [load, enabled])\n\n useEffect(() => {\n live.current = true\n if (source.current !== load) {\n source.current = load\n // Last-good retention belongs to one source; a new client must not\n // inherit another client's models if its initial request fails.\n setState({ catalog: undefined, loading: enabled, error: '' })\n }\n if (enabled) void refresh()\n else setState(previous => ({ ...previous, loading: false }))\n return () => { live.current = false; ++revision.current }\n }, [enabled, refresh])\n\n useEffect(() => {\n if (!enabled) return\n const reload = (): void => { void refresh() }\n // No polling: the host owns catalog production, and focus is a cheap\n // recovery path for missed ordinary notifications or changed credentials.\n if (typeof window !== 'undefined') window.addEventListener('focus', reload)\n let unsubscribe: (() => void) | undefined\n try { unsubscribe = options.subscribe?.(reload) } catch (error) {\n setState(previous => ({ ...previous, error: modelCatalogErrorMessage(error) }))\n }\n return () => {\n if (typeof window !== 'undefined') window.removeEventListener('focus', reload)\n unsubscribe?.()\n }\n }, [enabled, refresh, options.subscribe])\n\n const choices = useMemo(() => parseModelMenuChoices(state.catalog), [state.catalog])\n const failures = useMemo(() => state.catalog === undefined ? [] : modelCatalogFailures(state.catalog), [state.catalog])\n return { ...state, choices, failures, refresh }\n}\n\nexport interface ModelCatalogStatusProps {\n readonly state: Pick<ModelCatalogState, 'loading' | 'error' | 'failures' | 'refresh'>\n readonly locale?: string\n}\n\n/**\n * Also accepts a mapped state from a caller that owns broader async orchestration.\n *\n * The dsh-ui-* classes carry the styling and resolve through the consuming\n * plugin's own officialUiCss scope (every consumer mounts its root class, so\n * e.g. `.dsh-model-hub .dsh-ui-loading` paints this); dsh-model-catalog-status\n * stays as a structural hook for tests and layout, never a colour source.\n */\nexport function ModelCatalogStatus({ state, locale }: ModelCatalogStatusProps) {\n const zh = locale?.toLowerCase().startsWith('zh') === true\n const copy = zh\n ? { loading: '正在加载模型…', error: '模型列表加载失败', partial: '部分提供商的模型未能加载', retry: '重试' }\n : { loading: 'Loading models…', error: 'Unable to load models', partial: 'Some providers could not load their models', retry: 'Retry' }\n if (!state.loading && !state.error && state.failures.length === 0) return null\n return <div className=\"dsh-model-catalog-status dsh-ui-stack\" lang={zh ? 'zh' : 'en'}>\n {state.loading ? <p role=\"status\" className=\"dsh-ui-loading\">{copy.loading}</p> : null}\n {state.error ? <p role=\"alert\" className=\"dsh-ui-error dsh-ui-wrap\">{copy.error}: {state.error}</p> : null}\n {state.failures.length > 0 ? <div role=\"status\" className=\"dsh-ui-meta\">\n <p>{copy.partial}</p>\n <ul className=\"dsh-ui-list\">{state.failures.map((failure, index) => <li key={`${failure.id}:${index}`}>{failure.name || failure.id}: {failure.message}</li>)}</ul>\n </div> : null}\n {state.error || state.failures.length > 0\n ? <div className=\"dsh-ui-actions\"><Button type=\"button\" size=\"sm\" disabled={state.loading} onClick={() => { void state.refresh() }}>{copy.retry}</Button></div>\n : null}\n </div>\n}\n","/**\n * Pure menu helpers over parsed catalog choices: provider grouping, display\n * names and search filtering. Pure and browser-safe like the rest of the core\n * entry — no React, no host imports. The popover component lives in `./ui.tsx`.\n */\nimport type { ModelMenuChoice } from './catalog.ts'\n\n/** Localize standard effort ids only when the provider has not supplied a display name. */\nexport function modelMenuEffortLabel(effort: { id: string; name: string }, locale?: string): string {\n if (effort.name !== effort.id) return effort.name\n const labels: Record<string, readonly [string, string]> = {\n off: ['关闭', 'Off'], none: ['无', 'None'], minimal: ['最低', 'Minimal'], low: ['低', 'Low'],\n medium: ['中', 'Medium'], high: ['高', 'High'], xhigh: ['极高', 'Extra high'],\n max: ['最高', 'Maximum'], ultra: ['超高', 'Ultra'],\n }\n return labels[effort.id]?.[locale?.toLowerCase().startsWith('zh') ? 0 : 1] ?? effort.name\n}\n\n/** One provider group in the menu, in catalog order, after applying the search query. */\nexport interface ModelMenuGroup {\n readonly provider: string\n /** Provider display name, from the catalog group or split from the \"Provider / Model\" label. */\n readonly name: string\n readonly items: readonly ModelMenuChoice[]\n}\n\n/** The short model label shown inside a provider group. */\nexport function modelMenuShortName(choice: ModelMenuChoice): string {\n const sep = choice.label.indexOf(' / ')\n return sep > 0 ? choice.label.slice(sep + 3) : choice.model\n}\n\n/** Group catalog choices by provider and filter them by a case-insensitive query. */\nexport function groupModelMenuChoices(choices: readonly ModelMenuChoice[], query: string): ModelMenuGroup[] {\n const needle = query.trim().toLowerCase()\n const matched = needle\n ? choices.filter(choice => choice.label.toLowerCase().includes(needle)\n || choice.model.toLowerCase().includes(needle)\n || choice.provider.toLowerCase().includes(needle)\n // The provider display name is a separate search channel: a catalog may\n // name a provider differently from its id, and callers search by name.\n || (choice.providerLabel?.toLowerCase().includes(needle) ?? false))\n : choices\n const groups: Array<{ provider: string; name: string; items: ModelMenuChoice[] }> = []\n for (const choice of matched) {\n const sep = choice.label.indexOf(' / ')\n const name = choice.providerLabel ?? (sep > 0 ? choice.label.slice(0, sep) : choice.provider)\n const last = groups.at(-1)\n if (last && last.provider === choice.provider) last.items.push(choice)\n else groups.push({ provider: choice.provider, name, items: [choice] })\n }\n return groups\n}\n","/**\n * ModelMenu: the standard editor of one model-route field — the visible half\n * of the x-model-route contract. A feature plugin's settings page renders it\n * for its own marked field; the model hub renders one per detected field.\n *\n * It is a plugin-side copy of the host's composer model picker\n * (dsh-client-ui-model-selection's ModelSelect), rebuilt from the official\n * primitives and the published bundle's behavior: one card that opens on the\n * root pane (Model / Effort cells), drills into the provider-grouped,\n * searchable model list or the effort list, and Escapes back before closing.\n * Sticky group headings, subsequence ranking, highlight walking and focus\n * hand-back all match the host. SYNC POINT: when the host's ModelSelect or\n * ModelSelect.module.css changes, this copy must be re-transcribed; styles\n * below may only reference allowlisted theme tokens (the --dsw-* set plus the\n * host's --ds-* motion tokens), never literal colors.\n *\n * It statically imports the primitives, so only browser clients should load\n * this entry; host code and node tests use the core entry (`./index.ts`).\n */\nimport { cloneElement, isValidElement, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type ReactNode } from 'react'\nimport { createPortal } from 'react-dom'\nimport {\n IconCheckOutlineRegular, IconChevronRightOutlineRegular, IconCloseFillRegular, Input, MenuGroup, MenuSurface,\n observeStickyMenuGroups, rankByName,\n} from '@deepseek-ai/dsh-client-ui-primitives'\nexport { useModelCatalog, ModelCatalogStatus } from './catalog-ui.tsx'\nexport type { UseModelCatalogOptions, ModelCatalogState, ModelCatalogStatusProps } from './catalog-ui.tsx'\nimport type { ModelMenuChoice } from './catalog.ts'\nimport { groupModelMenuChoices, modelMenuEffortLabel, modelMenuShortName } from './menu.ts'\n\n/** Extra rows rendered above the model groups (e.g. a plugin's \"follow\"/\"off\" modes). */\nexport interface ModelMenuLeadingItem {\n readonly id: string\n readonly label: ReactNode\n readonly selected?: boolean\n}\n\nexport interface ModelMenuProps {\n /** Active host locale, supplied by the owning plugin's live locale subscription. */\n readonly locale?: string\n readonly open: boolean\n readonly onOpenChange: (open: boolean) => void\n /** Trigger rendered in place; the menu anchors to it and returns focus to it. */\n readonly anchor: ReactNode\n readonly choices: readonly ModelMenuChoice[]\n readonly selected?: { readonly provider: string; readonly model: string }\n readonly onPick: (route: { provider: string; model: string }) => void\n readonly leading?: readonly ModelMenuLeadingItem[]\n readonly onPickLeading?: (id: string) => void\n /** Effort pane rows; the root Effort cell is hidden while this is empty. */\n readonly efforts?: ReadonlyArray<{ id: string; name: string }>\n readonly selectedEffort?: string\n readonly onPickEffort?: (effort: string | undefined) => void\n /** Root-cell labels and the values shown trailing them. */\n readonly modelLabel?: string\n readonly modelValue?: string\n readonly effortLabel?: string\n readonly effortValue?: string\n readonly defaultEffortLabel?: string\n readonly searchPlaceholder?: string\n readonly emptyLabel?: string\n readonly clearSearchLabel?: string\n /** Pane the menu opens on; default 'root'. 'model' opens the searchable model list directly. */\n readonly initialPane?: 'root' | 'model'\n /** Show the model search row even when the catalog has four or fewer choices. */\n readonly alwaysShowSearch?: boolean\n /**\n * Render the declared reasoning efforts as a discrete slider inside the model\n * pane. Additive: the effort list and the root Effort cell stay for the\n * default (false) mode, and only the caller-supplied effort rows are shown.\n */\n readonly reasoningSlider?: boolean\n /**\n * Optional banner rendered at the top of the menu card, above the search and\n * list — e.g. a directory status/error row. Pure library-local React content,\n * not a cross-factory data contract.\n */\n readonly menuHeader?: ReactNode\n /** Disable every action after opening; by default a true value also closes\n * the menu (closeOnDisable). */\n readonly disabled?: boolean\n /**\n * Submission in progress. Keeps the menu open (unlike `disabled`) and still\n * allows opening/closing and typing in search, but disables selection rows\n * and blocks repeated model/leading/effort/slider submissions.\n */\n readonly busy?: boolean\n /**\n * Close the card after a model pick. Default true (drill menus dismiss).\n * The composer picker sets false so a selection does not unmount the open\n * list — search and scroll belong to that card.\n */\n readonly closeOnPick?: boolean\n /**\n * Close the open card when `disabled` rises. Default true — a hard lock\n * dismisses. Keep-open callers (the composer picker) set false: an owner's\n * save-state \"disabled\" pulse gates actions without unmounting the open\n * list, and Escape/outside presses still dismiss while disabled.\n */\n readonly closeOnDisable?: boolean\n readonly className?: string\n /** Extra class on the portaled menu card, which renders under document.body. */\n readonly listClassName?: string\n}\n\ntype Pane = 'root' | 'model' | 'effort'\n\n/** Unplaced portal card: hidden but laid out at a fixed origin so measurements are real. */\nconst MEASURE_STYLE: CSSProperties = { visibility: 'hidden', left: 0, top: 0 }\n\nexport function ModelMenu(props: ModelMenuProps) {\n const language = props.locale?.toLowerCase().startsWith('zh') ? 'zh' : 'en'\n const copy = language === 'zh'\n ? { model: '模型', effort: '思考强度', default: '默认', search: '搜索模型…', empty: '没有匹配的模型', clear: '清除搜索' }\n : { model: 'Model', effort: 'Reasoning', default: 'Default', search: 'Search models…', empty: 'No matching models', clear: 'Clear search' }\n const {\n open, onOpenChange, anchor, choices, selected, onPick,\n leading = [], onPickLeading, efforts = [], selectedEffort, onPickEffort,\n modelLabel = copy.model, modelValue = '—', effortLabel = copy.effort, effortValue, defaultEffortLabel = copy.default,\n searchPlaceholder = copy.search, emptyLabel = copy.empty, clearSearchLabel = copy.clear,\n initialPane = 'root', alwaysShowSearch = false, reasoningSlider = false,\n menuHeader, disabled = false, busy = false, closeOnPick = true, closeOnDisable = true,\n className, listClassName,\n } = props\n const rootRef = useRef<HTMLSpanElement | null>(null)\n const openRef = useRef(open)\n openRef.current = open\n const pendingOpenRef = useRef(false)\n const pendingRestoreFocus = useRef(false)\n const [requestedOpen, setRequestedOpen] = useState(false)\n const menuRef = useRef<HTMLDivElement | null>(null)\n const groupsRef = useRef<HTMLDivElement | null>(null)\n const searchRef = useRef<HTMLInputElement | null>(null)\n const itemRefs = useRef<Array<HTMLButtonElement | null>>([])\n const paneFocus = useRef<Pane | 'drill' | null>(null)\n const [pane, setPane] = useState<Pane>('root')\n const [query, setQuery] = useState('')\n const [highlightedIndex, setHighlightedIndex] = useState<number | null>(null)\n /* Keyboard arrows only. Mouse focus and a rebuilt choices array must not scroll. */\n const [keyNav, setKeyNav] = useState(0)\n const [menuPos, setMenuPos] = useState<CSSProperties | null>(null)\n const id = useId()\n const showSearch = alwaysShowSearch || choices.length > 4\n const effortRows = useMemo(() => [{ id: '', name: defaultEffortLabel }, ...efforts.map(effort => ({ ...effort, name: modelMenuEffortLabel(effort, language) }))], [defaultEffortLabel, efforts, language])\n /* The official ranks each provider group by a case-insensitive ordered\n * subsequence (prefix hits first, then alignment score, then catalog order);\n * groups left empty by the query drop out. */\n const filteredGroups = useMemo(() => groupModelMenuChoices(choices, '').map(group => ({\n ...group,\n items: rankByName(group.items.map(choice => ({\n choice,\n name: modelMenuShortName(choice),\n // The match surface deliberately carries the provider id, provider display\n // name, model id and the full \"Provider / Model\" label — never only the\n // possibly-truncated short model name — so provider and model-id searches\n // resolve while the rendered name stays short.\n label: [choice.provider, choice.providerLabel, choice.model, choice.label].filter(Boolean).join(' '),\n })), showSearch ? query.trim() : ''),\n })).filter(group => group.items.length > 0), [choices, query, showSearch])\n const visibleModels = useMemo(() => filteredGroups.flatMap(group => group.items.map(item => item.choice)), [filteredGroups])\n const currentVisibleIndex = visibleModels.findIndex(choice => choice.provider === selected?.provider && choice.model === selected.model)\n const activeModelIndex = Math.min(highlightedIndex ?? Math.max(0, currentVisibleIndex), visibleModels.length - 1)\n const changeOpen = (next: boolean): void => {\n if (openRef.current === next) return\n openRef.current = next\n onOpenChange(next)\n }\n const requestOpen = (): void => {\n if (open || pendingOpenRef.current) return\n pendingOpenRef.current = true\n pendingRestoreFocus.current = false\n setRequestedOpen(true)\n }\n const close = (restoreFocus = false): void => {\n const active = document.activeElement\n pendingRestoreFocus.current = restoreFocus && (active === document.body\n || rootRef.current?.contains(active) === true || menuRef.current?.contains(active) === true)\n changeOpen(false)\n }\n const drill = (next: Pane): void => {\n setQuery('')\n setHighlightedIndex(null)\n paneFocus.current = 'drill'\n setPane(next)\n }\n /** Leave a drilled pane for the entry pane, handing the keyboard back to it.\n * A root entry refocuses the cell that opened the pane; a search-first\n * (model) entry refocuses that pane's own intent. */\n const back = (from: Pane): void => {\n paneFocus.current = initialPane === 'root' ? from : 'drill'\n setPane(initialPane)\n }\n const moveFocus = (offset: number): void => {\n const items = itemRefs.current.filter((item): item is HTMLButtonElement => item !== null && !item.disabled)\n if (!items.length) return\n const active = items.findIndex(item => item === document.activeElement)\n items[active === -1 ? (offset > 0 ? 0 : items.length - 1) : (active + offset + items.length) % items.length]?.focus()\n }\n\n // A selection can synchronously disable its trigger while the owner writes.\n // Retry on the owner's next render, once the native button can take focus.\n useLayoutEffect(() => {\n if (open || !pendingRestoreFocus.current) return\n const active = document.activeElement\n if (active !== document.body && !rootRef.current?.contains(active)) {\n pendingRestoreFocus.current = false\n return\n }\n const trigger = rootRef.current?.querySelector('button')\n if (!trigger || trigger.disabled) return\n trigger.focus()\n if (document.activeElement === trigger) pendingRestoreFocus.current = false\n })\n useEffect(() => {\n if (open || !pendingRestoreFocus.current) return\n const cancelOutside = (event: Event): void => {\n if (event.target instanceof Node && !rootRef.current?.contains(event.target)) pendingRestoreFocus.current = false\n }\n document.addEventListener('focusin', cancelOutside)\n document.addEventListener('pointerdown', cancelOutside)\n return () => {\n document.removeEventListener('focusin', cancelOutside)\n document.removeEventListener('pointerdown', cancelOutside)\n }\n })\n\n useEffect(() => {\n if (!requestedOpen) return\n pendingOpenRef.current = false\n setRequestedOpen(false)\n // The caller's trigger handler may also update the controlled open prop.\n // Check the committed state before supplying the missing open callback.\n if (!open) changeOpen(true)\n }, [requestedOpen, open])\n\n useEffect(() => {\n if (!open) return\n // A consumer may open directly at the model pane (a search-first picker).\n // The root cells stay reachable with Escape; the default stays 'root' and\n // leaves the trigger's keyboard focus intent untouched.\n setPane(initialPane)\n if (initialPane === 'model') paneFocus.current = 'drill'\n setQuery('')\n setHighlightedIndex(null)\n }, [open, initialPane])\n // A consumer that becomes busy/locked after opening must not leave actions\n // available. With closeOnDisable a true value also closes the card (the\n // trigger owns the disabled look); without it the open card stays mounted\n // and only dismissal stays available.\n useEffect(() => {\n if (disabled && open && closeOnDisable) changeOpen(false)\n }, [disabled, open, closeOnDisable])\n useEffect(() => {\n if (!open) return\n const closeOutside = (event: MouseEvent): void => {\n const target = event.target as Node\n if (rootRef.current?.contains(target) || menuRef.current?.contains(target)) return\n changeOpen(false)\n }\n /* The span's React onKeyDown already sees Escape from inside the menu —\n * portal rows bubble through the React tree. What it cannot see is focus\n * that is no longer in the tree at all: a disabled rise ejects the\n * focused row's focus to document.body, and Escape there never reaches\n * the span. This listener keeps dismissal reachable for that focus; the\n * openRef check means it never double-acts after the in-tree handler. */\n const escapeOutside = (event: KeyboardEvent): void => {\n if (event.key !== 'Escape' || event.defaultPrevented || event.isComposing) return\n if (!openRef.current) return\n event.preventDefault()\n if (pane !== initialPane) back(pane)\n else close(true)\n }\n document.addEventListener('mousedown', closeOutside)\n document.addEventListener('keydown', escapeOutside)\n return () => {\n document.removeEventListener('mousedown', closeOutside)\n document.removeEventListener('keydown', escapeOutside)\n }\n }, [open, onOpenChange, pane, initialPane])\n /* Focus intent after a pane change: the model pane takes the search field when\n * it has one, every other drill takes the checked row, and going back takes\n * the cell that opened the pane. */\n useEffect(() => {\n const intent = paneFocus.current\n // MenuSurface forwards the measurement visibility:hidden style. Browsers\n // refuse focus there, so keep intent until placement has made it visible.\n if (!open || menuPos === null || intent === null) return\n // Reopening resets a previously drilled pane in a separate commit. Entry\n // and return intent belong to the root cells, never the outgoing rows.\n if (intent !== 'drill' && pane !== 'root') return\n paneFocus.current = null\n if (intent === 'drill') {\n if (pane === 'model' && showSearch) { searchRef.current?.focus(); return }\n (menuRef.current?.querySelector<HTMLButtonElement>('[role=\"menuitemradio\"][aria-checked=\"true\"]:not([disabled])')\n ?? itemRefs.current.find(item => item !== null && !item.disabled))?.focus()\n return\n }\n itemRefs.current[intent === 'effort' ? 1 : 0]?.focus()\n }, [open, pane, showSearch, menuPos])\n useEffect(() => {\n const viewport = groupsRef.current\n if (viewport === null) return\n return observeStickyMenuGroups(viewport)\n }, [open, pane, filteredGroups])\n /* Scroll when the model pane opens, or when a keyboard arrow moves the\n * highlight. `visibleModels` is a new array whenever a directory snapshot\n * replaces `current` and the caller rebuilds equivalent choices — depending\n * on that array jumped scrollTop. Search may replace the rows; a model\n * click must not. */\n const modelPaneOpen = open && pane === 'model'\n const scrollSignal = !modelPaneOpen ? 'closed' : keyNav === 0 ? 'open' : `key:${keyNav}`\n const scrollSignalRef = useRef<string | null>(null)\n useLayoutEffect(() => {\n if (!modelPaneOpen || activeModelIndex < 0) {\n if (!modelPaneOpen) scrollSignalRef.current = null\n return\n }\n if (scrollSignalRef.current === scrollSignal) return\n scrollSignalRef.current = scrollSignal\n itemRefs.current[leading.length + activeModelIndex]?.scrollIntoView({ block: 'nearest' })\n }, [modelPaneOpen, scrollSignal, activeModelIndex, leading.length])\n /* The card hangs above the trigger, right-aligned, inside 12px viewport\n * margins — the official placement formula, re-run on scroll and resize. */\n useLayoutEffect(() => {\n if (!open) { setMenuPos(null); return }\n const place = (): void => {\n const rect = rootRef.current?.getBoundingClientRect()\n if (!rect) return\n const margin = 12, lw = menuRef.current?.offsetWidth ?? 0, lh = menuRef.current?.offsetHeight ?? 0\n let x = rect.right - lw, y = rect.top - 8 - lh\n if (lw > 0) x = Math.min(Math.max(x, margin), window.innerWidth - lw - margin)\n if (lh > 0) y = Math.min(Math.max(y, margin), window.innerHeight - lh - margin)\n setMenuPos(prev => (prev && prev.left === x && prev.top === y ? prev : { left: x, top: y }))\n }\n place()\n window.addEventListener('scroll', place, true)\n window.addEventListener('resize', place)\n return () => {\n window.removeEventListener('scroll', place, true)\n window.removeEventListener('resize', place)\n }\n }, [open, pane, choices, query])\n\n function onKeyDown(event: React.KeyboardEvent): void {\n if (event.defaultPrevented || event.nativeEvent.isComposing) return\n // Escape dismisses even while actions are disabled — a save lock gates\n // selection, not closing. A drilled pane backs out to the entry pane\n // first; the entry pane closes outright.\n if (event.key === 'Escape' && open) {\n event.preventDefault()\n if (pane !== initialPane) back(pane)\n else close(true)\n return\n }\n if (disabled) return\n if (!open && ['Enter', ' ', 'ArrowDown', 'ArrowUp'].includes(event.key)) {\n const button = event.target instanceof Element ? event.target.closest('button') : null\n if (!(button instanceof HTMLButtonElement) || button.disabled || !rootRef.current?.contains(button)) return\n // Prevent the native Enter/Space click from opening a second time.\n event.preventDefault()\n paneFocus.current = 'model'\n requestOpen()\n return\n }\n if (!open) return\n if (pane === 'model' && showSearch && (event.key === 'ArrowDown' || event.key === 'ArrowUp')) {\n event.preventDefault()\n if (visibleModels.length > 0) {\n setHighlightedIndex((activeModelIndex + (event.key === 'ArrowDown' ? 1 : -1) + visibleModels.length) % visibleModels.length)\n setKeyNav(n => n + 1)\n searchRef.current?.focus()\n }\n return\n }\n if (pane === 'model' && showSearch && event.target instanceof HTMLInputElement && (event.key === 'Enter' || (event.key === 'Tab' && !event.shiftKey))) {\n if (event.key === 'Tab' && visibleModels.length === 0) return\n event.preventDefault()\n const highlighted = visibleModels[activeModelIndex]\n // A submission in progress must not be repeated by Enter/Tab.\n if (highlighted && !busy) { onPick({ provider: highlighted.provider, model: highlighted.model }); if (closeOnPick) close(true) }\n return\n }\n if (event.key === 'Tab') {\n if (event.shiftKey) {\n event.preventDefault()\n if (pane !== initialPane) back(pane)\n else close(true)\n return\n }\n const focused = document.activeElement\n const rows = itemRefs.current.filter((item): item is HTMLButtonElement => item !== null)\n if (focused instanceof HTMLButtonElement && rows.includes(focused)) {\n event.preventDefault()\n focused.click()\n return\n }\n if (pane === 'model' && showSearch) {\n event.preventDefault()\n setHighlightedIndex(null)\n searchRef.current?.focus()\n }\n return\n }\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault()\n moveFocus(event.key === 'ArrowDown' ? 1 : -1)\n }\n }\n\n function onBlur(event: React.FocusEvent): void {\n const related = event.relatedTarget\n // A target already detached from the document (the menu re-rendering the\n // focused row) is inside for this purpose — never a dismissal.\n if (related instanceof Node\n && (rootRef.current?.contains(related) || menuRef.current?.contains(related)\n || !related.isConnected)) return\n // Keep-open mode never closes on a blur that has no connected next focus:\n // disabling the picked row, or a blur whose target raced a re-render, is\n // not the user dismissing the card. Outside presses, Escape, and focus\n // landing in a real outside node still close.\n if (!closeOnPick && !(related instanceof Node)) return\n // Disabling the focused row while a selection is in flight blurs it with\n // no next target. That is not a dismissal — closing here unmounts the card.\n if (busy && related == null) return\n if (open) changeOpen(false)\n }\n\n itemRefs.current = []\n let itemIndex = 0\n let modelIndex = 0\n const itemRef = () => {\n const at = itemIndex++\n return (node: HTMLButtonElement | null): void => { itemRefs.current[at] = node }\n }\n\n const menu = open && typeof document !== 'undefined'\n ? createPortal(\n <MenuSurface\n ref={menuRef}\n id={`${id}-menu`}\n className={`dsh-model-menu-menu${listClassName ? ` ${listClassName}` : ''}`}\n style={menuPos ?? MEASURE_STYLE}\n role={pane === 'model' ? 'group' : 'menu'}\n aria-label={modelLabel}\n lang={language}\n >\n {menuHeader ? <div className=\"dsh-model-menu-header\">{menuHeader}</div> : null}\n {pane === 'root' ? <>\n <button ref={itemRef()} type=\"button\" role=\"menuitem\" className=\"dsh-model-menu-cell\" disabled={disabled} onClick={() => drill('model')}>\n <span className=\"dsh-model-menu-cellLabel\">{modelLabel}</span>\n <span className=\"dsh-model-menu-cellValue\">{modelValue}</span>\n <IconChevronRightOutlineRegular className=\"dsh-model-menu-cellChevron\" />\n </button>\n {efforts.length > 0 && !reasoningSlider ? <button ref={itemRef()} type=\"button\" role=\"menuitem\" className=\"dsh-model-menu-cell\" disabled={disabled} onClick={() => drill('effort')}>\n <span className=\"dsh-model-menu-cellLabel\">{effortLabel}</span>\n <span className=\"dsh-model-menu-cellValue\">{effortValue ?? effortRows.find(row => row.id === (selectedEffort ?? ''))?.name ?? defaultEffortLabel}</span>\n <IconChevronRightOutlineRegular className=\"dsh-model-menu-cellChevron\" />\n </button> : null}\n </> : null}\n {pane === 'model' ? <>\n {showSearch ? <div className=\"dsh-model-menu-searchRow\">\n <Input\n ref={searchRef}\n disabled={disabled}\n className={`dsh-model-menu-search${query !== '' ? ' dsh-model-menu-searchWithQuery' : ''}`}\n type=\"text\"\n role=\"searchbox\"\n aria-label={searchPlaceholder}\n aria-controls={`${id}-models`}\n aria-activedescendant={activeModelIndex < 0 ? undefined : `${id}-model-${activeModelIndex}`}\n placeholder={searchPlaceholder}\n value={query}\n onChange={event => { setQuery(event.target.value); setHighlightedIndex(0) }}\n />\n {query !== '' ? <button type=\"button\" className=\"dsh-model-menu-searchClear\" aria-label={clearSearchLabel} disabled={disabled}\n onClick={() => { setQuery(''); setHighlightedIndex(null); searchRef.current?.focus() }}>\n <IconCloseFillRegular />\n </button> : null}\n </div> : null}\n <div ref={groupsRef} id={`${id}-models`} className=\"dsh-model-menu-groups scrollable\" role=\"menu\" aria-label={modelLabel}\n hidden={filteredGroups.length === 0}>\n {leading.length > 0 ? <div className=\"dsh-model-menu-leading\">\n {leading.map(item => (\n <button key={item.id} ref={itemRef()} type=\"button\" role=\"menuitemradio\" aria-checked={item.selected === true} disabled={disabled || busy}\n className={`dsh-model-menu-option${item.selected === true ? ' dsh-model-menu-selected' : ''}`}\n onClick={() => { if (disabled || busy) return; onPickLeading?.(item.id); if (closeOnPick) close(true) }}>\n <span className=\"dsh-model-menu-optionCopy\"><span className=\"dsh-model-menu-modelName\">{item.label}</span></span>\n <span className=\"dsh-model-menu-check\">{item.selected === true ? <IconCheckOutlineRegular /> : null}</span>\n </button>\n ))}\n </div> : null}\n {filteredGroups.map(group => (\n <MenuGroup key={group.provider} label={group.name}>\n {group.items.map(item => {\n const index = modelIndex++\n const choice = item.choice\n const checked = selected?.provider === choice.provider && selected.model === choice.model\n return <button\n key={`${choice.provider}/${choice.model}`}\n ref={itemRef()}\n type=\"button\"\n role=\"menuitemradio\"\n aria-checked={checked}\n id={`${id}-model-${index}`}\n tabIndex={showSearch ? -1 : 0}\n disabled={disabled || busy}\n onFocus={() => setHighlightedIndex(index)}\n data-highlighted={index === activeModelIndex ? '' : undefined}\n className={`dsh-model-menu-option dsh-model-menu-modelOption${checked ? ' dsh-model-menu-selected' : ''}${index === activeModelIndex ? ' dsh-model-menu-optionActive' : ''}`}\n onMouseMove={index === activeModelIndex ? undefined : () => {\n if (showSearch) setHighlightedIndex(index)\n else itemRefs.current[leading.length + index]?.focus()\n }}\n title={choice.label}\n onClick={() => { if (disabled || busy) return; onPick({ provider: choice.provider, model: choice.model }); if (closeOnPick) close(true) }}\n >\n <span className=\"dsh-model-menu-optionCopy\"><span className=\"dsh-model-menu-modelName\">{modelMenuShortName(choice)}</span></span>\n <span className=\"dsh-model-menu-check\">{checked ? <IconCheckOutlineRegular /> : null}</span>\n </button>\n })}\n </MenuGroup>\n ))}\n </div>\n {reasoningSlider && efforts.length > 0 && filteredGroups.length > 0\n ? <EffortSlider label={effortLabel} rows={effortRows} selected={selectedEffort ?? ''} disabled={disabled} busy={busy}\n onPick={value => onPickEffort?.(value)} />\n : null}\n {filteredGroups.length === 0 ? <div className=\"dsh-model-menu-empty\" role=\"status\">{emptyLabel}</div> : null}\n </> : null}\n {pane === 'effort' ? <>\n {effortRows.map(row => {\n const checked = (selectedEffort ?? '') === row.id\n return <button key={row.id || '__default'} ref={itemRef()} type=\"button\" role=\"menuitemradio\" aria-checked={checked} disabled={disabled || busy}\n className={`dsh-model-menu-option${checked ? ' dsh-model-menu-selected' : ''}`}\n onClick={() => { if (disabled || busy) return; onPickEffort?.(row.id || undefined); if (closeOnPick) close(true) }}>\n <span className=\"dsh-model-menu-optionCopy\"><span className=\"dsh-model-menu-modelName\">{row.name}</span></span>\n <span className=\"dsh-model-menu-check\">{checked ? <IconCheckOutlineRegular /> : null}</span>\n </button>\n })}\n </> : null}\n </MenuSurface>,\n document.body,\n )\n : null\n const trigger = isValidElement<Record<string, unknown>>(anchor)\n ? cloneElement(anchor, { 'aria-haspopup': 'menu', 'aria-expanded': open, 'aria-controls': open ? `${id}-menu` : undefined, 'aria-disabled': disabled || undefined })\n : anchor\n return <span ref={rootRef} className={`dsh-model-menu-root${className ? ` ${className}` : ''}`} onKeyDown={onKeyDown} onBlur={onBlur}\n onClick={event => {\n if (disabled || event.defaultPrevented) return\n const button = event.target instanceof Element ? event.target.closest('button') : null\n if (!(button instanceof HTMLButtonElement) || button.disabled || !rootRef.current?.contains(button)) return\n requestOpen()\n }}\n onMouseDown={event => { if (event.target instanceof Element && menuRef.current?.contains(event.target) && event.target.closest('button') !== null) event.preventDefault() }}>\n {trigger}{menu}\n </span>\n}\n\n/**\n * Discrete reasoning-effort slider shown under the model list in enhanced mode.\n *\n * A native range input (`step=1`) over exactly the rows the caller supplies —\n * the default row plus each effort the selected model advertises — so it can\n * never invent a level. It previews locally while dragging or arrowing and\n * commits only when the gesture ends (pointer up, key up, or blur), so a drag\n * does not write on every step. The menu stays open, so adjusting the effort\n * never loses the model selection or the search query.\n *\n * The input itself stays the entire interaction and accessibility surface —\n * keyboard, ARIA, disabled and the native step snapping all come from it —\n * while the track, gradient fill and thumb below are decorative layers painted\n * from the `--_p` percentage the preview position sets on the rail. Value\n * changes only update that custom property, so the CSS transitions animate\n * between levels without remounting nodes or restarting an animation.\n */\nfunction EffortSlider(props: {\n readonly label: string\n readonly rows: ReadonlyArray<{ id: string; name: string }>\n readonly selected: string\n readonly disabled?: boolean\n readonly busy?: boolean\n readonly onPick: (effort: string | undefined) => void\n}) {\n const { label, rows, selected, disabled = false, busy = false, onPick } = props\n const active = Math.max(0, rows.findIndex(row => row.id === selected))\n const [position, setPosition] = useState(active)\n const positionRef = useRef(position)\n // A committed selection from the owner resets the preview.\n useEffect(() => { positionRef.current = active; setPosition(active) }, [active])\n const preview = (next: number): void => {\n positionRef.current = next\n setPosition(next)\n }\n // Commit once per gesture: pointer up, key up, or leaving the control. A\n // submission already in flight must not be repeated.\n const commit = (): void => {\n if (disabled || busy) return\n const row = rows[positionRef.current]\n if (row !== undefined) onPick(row.id === '' ? undefined : row.id)\n }\n const max = Math.max(0, rows.length - 1)\n const percent = max > 0 ? Math.round((position / max) * 100) : 0\n return <div className=\"dsh-model-menu-sliderGroup\" role=\"group\" aria-label={label}>\n <div className=\"dsh-model-menu-sliderHead\">\n <span className=\"dsh-model-menu-sliderTitle\">{label}</span>\n <span className=\"dsh-model-menu-sliderValue\">{rows[position]?.name}</span>\n </div>\n <div className=\"dsh-model-menu-sliderRail\" style={{ '--_p': percent } as CSSProperties}>\n <input\n type=\"range\"\n className=\"dsh-model-menu-sliderInput\"\n min={0}\n max={max}\n step={1}\n value={position}\n disabled={disabled}\n aria-label={label}\n aria-disabled={disabled || busy || undefined}\n aria-valuetext={rows[position]?.name}\n onChange={event => {\n // Read the event target, not currentTarget: a synthetic change event may\n // carry a detached `{ value }` target, while a real range event targets\n // the input itself. Both must preview the same position.\n const value = Number((event.target as HTMLInputElement).value)\n if (Number.isFinite(value)) preview(value)\n }}\n onPointerUp={commit}\n onKeyUp={commit}\n onBlur={commit}\n />\n <span className=\"dsh-model-menu-sliderTrack\" aria-hidden=\"true\">\n <span className=\"dsh-model-menu-sliderFill\"><span className=\"dsh-model-menu-sliderFillBar\" /></span>\n <span className=\"dsh-model-menu-sliderNodes\">\n {rows.map((row, index) => (\n <span key={row.id || '__default'} data-covered={index <= position ? '' : undefined}\n className=\"dsh-model-menu-sliderNode\" style={{ '--_n': max > 0 ? Math.round((index / max) * 100) : 0 } as CSSProperties} />\n ))}\n </span>\n </span>\n <span className=\"dsh-model-menu-sliderThumb\" aria-hidden=\"true\" />\n </div>\n </div>\n}\n\n/**\n * ModelMenu styles, transcribed from the official ModelSelect.module.css (the\n * published dsh-client-ui-model-selection bundle): card capped at\n * min(360px, 100vh - 96px), 34px option cells at 13/18 with 5px 7px padding,\n * 34px root cells at 13/20, a borderless 12px search row with a clear button,\n * sticky group headings (MenuGroup's own CSS), and the l1-stroke prominent\n * elevation at portal z-index 1100. The trigger mirrors the composer's 28px\n * model pill, chevron rotating open. MenuSurface paints fill and backdrop.\n * Only allowlisted --dsw- and --ds- theme tokens may appear here — a literal\n * color is a bug.\n */\nexport const modelMenuCss = `\n.dsh-model-menu-root { min-width: 0; position: relative; display: inline-flex; }\n.dsh-model-menu-trigger {\n border-radius: var(--dsw-radius-sm);\n min-width: 0;\n max-width: min(360px, 45cqw);\n height: 28px;\n color: var(--dsw-alias-label-secondary);\n cursor: pointer;\n background: none;\n border: none;\n outline: none;\n align-items: center;\n gap: 4px;\n padding: 0 4px 0 8px;\n font-size: 13px;\n font-weight: 400;\n line-height: 20px;\n display: flex;\n}\n.dsh-model-menu-trigger:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover); }\n.dsh-model-menu-trigger:focus-visible:not([data-selection-focus]) { box-shadow: 0 0 0 var(--dsw-focus-ring-width) var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary)); }\n.dsh-model-menu-trigger:disabled { color: var(--dsw-alias-label-dimmed); cursor: default; }\n.dsh-model-menu-triggerLabel { text-overflow: ellipsis; white-space: nowrap; min-width: 0; overflow: hidden; }\n.dsh-model-menu-triggerEffort { text-overflow: ellipsis; white-space: nowrap; min-width: 0; color: var(--dsw-alias-label-caption); flex-shrink: 1000; overflow: hidden; }\n.dsh-model-menu-chevron { color: var(--dsw-alias-label-caption); flex: none; transition: transform var(--ds-transition-duration) var(--ds-ease-in-out); }\n.dsh-model-menu-chevronOpen { transform: rotate(180deg); }\n/* Portal overlay: the host publishes no z-index token, so the card keeps the\n * native menu layer's 1100 verbatim. */\n.dsh-model-menu-menu {\n z-index: 1100;\n --dsw-elevation-stroke-color: var(--dsw-alias-border-l1);\n width: max-content;\n min-width: min(240px, 100vw - 32px);\n max-width: min(420px, 100vw - 32px);\n max-height: min(360px, 100vh - 96px);\n box-shadow: var(--dsw-elevation-prominent);\n color: var(--dsw-alias-label-primary);\n --dsh-scrollbar-thumb: var(--dsw-alias-scrollbar-bg-l2);\n --dsh-scrollbar-thumb-hover: var(--dsw-alias-scrollbar-hover-l2);\n border: 0;\n flex-direction: column;\n padding: 4px;\n display: flex;\n position: fixed;\n overflow: hidden;\n}\n.dsh-model-menu-status, .dsh-model-menu-empty { color: var(--dsw-alias-label-tertiary); padding: 8px; font-size: 12px; line-height: 18px; }\n.dsh-model-menu-header { flex: none; padding: 2px 2px 4px; }\n.dsh-model-menu-searchRow { flex-shrink: 0; margin: 2px 0 3px; position: relative; }\n.dsh-model-menu-searchRow .dsh-model-menu-search { border-radius: var(--dsw-radius-md); background: none; border: 0 solid transparent; height: auto; padding: 5px 7px; display: flex; }\n.dsh-model-menu-searchRow .dsh-model-menu-search:focus-within { border-color: transparent; }\n.dsh-model-menu-searchWithQuery { padding-right: 34px; }\n.dsh-model-menu-searchRow .dsh-model-menu-search input { padding: 0; font-size: 12px; line-height: normal; }\n.dsh-model-menu-searchRow .dsh-model-menu-search input::placeholder { color: var(--dsw-alias-label-caption); }\n/* The clear button is a circle by geometry (border-radius: 50%), a shape the\n * radius token scale does not describe. */\n.dsh-model-menu-searchClear {\n width: 24px;\n height: 24px;\n color: var(--dsw-alias-label-secondary);\n cursor: pointer;\n background: none;\n border: none;\n border-radius: 50%;\n justify-content: center;\n align-items: center;\n padding: 0;\n display: inline-flex;\n position: absolute;\n top: 50%;\n right: 4px;\n transform: translateY(-50%);\n}\n.dsh-model-menu-searchClear:hover, .dsh-model-menu-searchClear:focus-visible { background: var(--dsw-alias-interactive-bg-hover); outline: none; }\n.dsh-model-menu-groups { min-height: 0; overflow-y: auto; }\n.dsh-model-menu-leading { border-bottom: 0.5px solid var(--dsw-alias-border-l2); margin-bottom: 3px; padding-bottom: 3px; }\n.dsh-model-menu-option {\n box-sizing: border-box;\n border-radius: var(--dsw-radius-md);\n width: auto;\n min-width: 100%;\n min-height: 34px;\n color: inherit;\n text-align: left;\n cursor: pointer;\n background: none;\n border: none;\n outline: none;\n align-items: center;\n gap: 6px;\n padding: 5px 7px;\n display: flex;\n}\n.dsh-model-menu-option:not(.dsh-model-menu-modelOption):hover:not(:disabled),\n.dsh-model-menu-option:focus-visible,\n.dsh-model-menu-optionActive:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover); }\n.dsh-model-menu-modelOption:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover); }\n.dsh-model-menu-selected { background: none; }\n.dsh-model-menu-option:disabled { color: var(--dsw-alias-label-dimmed); cursor: default; }\n.dsh-model-menu-optionCopy { flex-direction: column; flex: 1; min-width: 0; display: flex; }\n.dsh-model-menu-modelName { color: inherit; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 400; line-height: 18px; overflow: hidden; }\n.dsh-model-menu-check { color: var(--dsw-alias-label-primary); flex: 0 0 14px; place-items: center; display: grid; }\n.dsh-model-menu-check svg { width: 14px; height: 14px; }\n.dsh-model-menu-cell {\n box-sizing: border-box;\n border-radius: var(--dsw-radius-md);\n width: auto;\n min-width: 100%;\n height: 34px;\n color: var(--dsw-alias-label-primary);\n cursor: pointer;\n text-align: left;\n background: none;\n border: none;\n outline: none;\n align-items: center;\n gap: 6px;\n padding: 0 8px;\n font-size: 13px;\n line-height: 20px;\n display: flex;\n}\n.dsh-model-menu-cell:hover, .dsh-model-menu-cell:focus-visible { background: var(--dsw-alias-interactive-bg-hover); }\n.dsh-model-menu-cellLabel { white-space: nowrap; flex: none; }\n.dsh-model-menu-cellValue { text-overflow: ellipsis; white-space: nowrap; text-align: right; min-width: 0; color: var(--dsw-alias-label-tertiary); flex: auto; overflow: hidden; }\n.dsh-model-menu-cellChevron { width: 12px; height: 12px; color: var(--dsw-alias-menu-icon); flex: none; }\n/* Discrete reasoning-effort slider under the model list (enhanced mode).\n * The painted control is layered over a fully functional native range input:\n * the input stays on top, transparent, and owns pointer/keyboard/ARIA, while\n * the decorative track, fill and thumb render beneath it at pointer-events:\n * none. Position lives in one custom property (--_p, 0–100) on the rail, so\n * the only animated work a level change triggers is a clip-path/left\n * transition — no keyframes, no element churn. */\n.dsh-model-menu-sliderGroup { border-top: 0.5px solid var(--dsw-alias-border-l2); flex: none; margin-top: 4px; padding: 6px 8px 8px; }\n.dsh-model-menu-sliderHead { align-items: baseline; justify-content: space-between; gap: 8px; margin: 0 2px 4px; display: flex; }\n.dsh-model-menu-sliderTitle { color: var(--dsw-alias-label-tertiary); font-size: 12px; line-height: 18px; }\n.dsh-model-menu-sliderValue { color: var(--dsw-alias-label-primary); font-size: 13px; font-weight: 600; line-height: 20px; transition: color var(--ds-transition-duration) var(--ds-ease-in-out); }\n.dsh-model-menu-sliderRail { position: relative; direction: ltr; height: 38px; margin-top: 2px; }\n.dsh-model-menu-sliderRail:has(:disabled) { opacity: 0.45; }\n.dsh-model-menu-sliderInput {\n appearance: none;\n -webkit-appearance: none;\n box-sizing: border-box;\n border: 0;\n cursor: pointer;\n direction: ltr;\n opacity: 0;\n margin: 0;\n padding: 0;\n width: 100%;\n height: 100%;\n position: absolute;\n inset: 0;\n z-index: 1;\n touch-action: pan-y;\n}\n.dsh-model-menu-sliderInput:disabled { cursor: default; }\n/* The transparent input must keep the painted thumb's geometry: an\n * appearance:none webkit thumb defaults to 16px, which would shift the\n * end-point positions 7px off the decorative 30px disc and misplace the\n * native drag hit target. Track gets the full rail height so the whole band\n * maps to values identically. */\n.dsh-model-menu-sliderInput::-webkit-slider-runnable-track { width: 100%; height: 100%; }\n.dsh-model-menu-sliderInput::-webkit-slider-thumb { appearance: none; -webkit-appearance: none; width: 30px; height: 30px; margin: 0; }\n.dsh-model-menu-sliderInput::-moz-range-track { width: 100%; height: 100%; }\n.dsh-model-menu-sliderInput::-moz-range-thumb { width: 30px; height: 30px; margin: 0; border: 0; }\n.dsh-model-menu-sliderTrack {\n pointer-events: none;\n border-radius: 999px;\n width: 100%;\n height: 26px;\n background: var(--dsw-alias-interactive-bg-hover);\n box-shadow: inset 0 0 0 0.5px var(--dsw-alias-border-l2);\n position: absolute;\n inset-inline: 0;\n top: 50%;\n transform: translateY(-50%);\n /* No overflow:hidden — it would clip the fill's drop-shadow glow; the bar's\n * own clip-path already supplies the rounded reveal shape. */\n}\n/* The accent ramp paints the full track width once and is revealed by an\n * animated clip-path, so raising the effort unwraps more of the spectrum\n * instead of squashing the same gradient into a narrower bar. The glow lives\n * on the un-clipped parent: a filter on the clipped element itself would be\n * clipped away with it. */\n.dsh-model-menu-sliderFill {\n display: block;\n height: 100%;\n filter: drop-shadow(0 0 5px var(--dsw-alias-state-business-primary));\n transition: filter var(--ds-transition-duration) var(--ds-ease-in-out);\n}\n.dsh-model-menu-sliderInput:hover:not(:disabled) ~ .dsh-model-menu-sliderTrack .dsh-model-menu-sliderFill,\n.dsh-model-menu-sliderInput:active:not(:disabled) ~ .dsh-model-menu-sliderTrack .dsh-model-menu-sliderFill {\n filter: drop-shadow(0 0 9px var(--dsw-alias-state-business-primary));\n}\n/* The fill stops at the thumb's center, not at the track edge — at a 30px\n * thumb the end stops sit 15px in from each side, matching the node dots. */\n.dsh-model-menu-sliderFillBar {\n display: block;\n height: 100%;\n background: linear-gradient(90deg,\n var(--dsw-alias-state-business-primary),\n var(--dsw-alias-state-success-primary),\n var(--dsw-alias-state-warn-primary),\n var(--dsw-alias-state-error-primary));\n clip-path: inset(0 calc(100% - 15px - (100% - 30px) * var(--_p, 0) / 100) 0 0 round 999px);\n transition: clip-path var(--ds-transition-duration) var(--ds-ease-in-out);\n}\n/* Stop dots: one per declared row (default + every advertised effort), evenly\n * spread across the band between the two thumb-center extremes (inset 15px,\n * i.e. half the 30px thumb). --_n is 0-100 along that band. A covered dot\n * reads as a pale pin through the gradient; an uncovered one stays a neutral\n * notch on the empty track. */\n.dsh-model-menu-sliderNodes {\n pointer-events: none;\n display: block;\n position: absolute;\n inset-inline: 15px;\n inset-block: 0;\n}\n.dsh-model-menu-sliderNode {\n pointer-events: none;\n box-sizing: border-box;\n width: 4px;\n height: 4px;\n border-radius: 50%;\n background: color-mix(in srgb, var(--dsw-alias-label-secondary) 35%, transparent);\n position: absolute;\n left: calc(var(--_n, 0) * 1%);\n top: 50%;\n transform: translate(-50%, -50%);\n transition: background-color var(--ds-transition-duration) var(--ds-ease-in-out),\n transform var(--ds-transition-duration) var(--ds-ease-in-out);\n}\n.dsh-model-menu-sliderNode[data-covered] { background: color-mix(in srgb, var(--dsw-alias-label-primary) 60%, transparent); }\n.dsh-model-menu-sliderThumb {\n pointer-events: none;\n box-sizing: border-box;\n border-radius: 50%;\n width: 30px;\n height: 30px;\n background: var(--dsw-alias-button-primary-fill);\n border: 0.5px solid var(--dsw-alias-border-l4);\n box-shadow: 0 0 0 3px var(--dsw-alias-interactive-bg-hover), var(--dsw-elevation-soft);\n position: absolute;\n left: calc((100% - 30px) * var(--_p, 0) / 100);\n top: 50%;\n transform: translateY(-50%) scale(0.92);\n transition: left var(--ds-transition-duration) var(--ds-ease-in-out),\n transform var(--ds-transition-duration) var(--ds-ease-in-out),\n box-shadow var(--ds-transition-duration) var(--ds-ease-in-out);\n}\n.dsh-model-menu-sliderInput:hover:not(:disabled) ~ .dsh-model-menu-sliderThumb { transform: translateY(-50%) scale(1); }\n.dsh-model-menu-sliderInput:active:not(:disabled) ~ .dsh-model-menu-sliderThumb {\n transform: translateY(-50%) scale(1.1);\n box-shadow: 0 0 0 4px var(--dsw-alias-interactive-bg-hover), 0 0 12px var(--dsw-alias-state-business-primary);\n}\n.dsh-model-menu-sliderInput:focus-visible ~ .dsh-model-menu-sliderThumb {\n box-shadow: 0 0 0 3px var(--dsw-alias-interactive-bg-hover),\n 0 0 0 calc(3px + var(--dsw-focus-ring-width)) var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary));\n}\n@media (prefers-reduced-motion: reduce) {\n .dsh-model-menu-sliderFill, .dsh-model-menu-sliderFillBar, .dsh-model-menu-sliderThumb,\n .dsh-model-menu-sliderNode, .dsh-model-menu-sliderValue { transition: none; }\n}\n`\n","import { officialUiCss } from '@klarkxy/dsh-plugin-kit/official-ui'\nimport { modelMenuCss } from '@klarkxy/dsh-model-route/ui'\n\nexport const FREE_CHAT_ROOT = 'dsh-free-chat'\n\n/** Host tokens and official scaffolding. Only the edit draft, the inline action row,\n * and the alert line survive the panel removal; the modals reuse the root class. */\nexport const freeChatCss = `${officialUiCss(FREE_CHAT_ROOT)}\n${modelMenuCss}\n.${FREE_CHAT_ROOT} .dsh-free-draft {\n width: 100%;\n min-height: 8em;\n}\n.${FREE_CHAT_ROOT} .dsh-free-actions {\n display: inline-flex;\n align-items: center;\n gap: 8px;\n min-width: 0;\n}\n.${FREE_CHAT_ROOT} .dsh-free-alert { margin: 0; }\n.${FREE_CHAT_ROOT} .dsh-free-warning {\n margin: 0 0 12px;\n color: var(--dsw-alias-label-secondary);\n}\n.${FREE_CHAT_ROOT}.dsm-user-row {\n display: flex;\n flex-direction: column;\n align-items: flex-end;\n gap: 6px;\n}\n.${FREE_CHAT_ROOT} .dsm-user-stack {\n display: flex;\n flex-direction: column;\n align-items: flex-end;\n gap: 8px;\n min-width: 0;\n max-width: 82%;\n}\n.${FREE_CHAT_ROOT} .dsm-user-bubble {\n max-width: 100%;\n padding: 10px 16px;\n border-radius: var(--dsw-radius-md);\n background: var(--dsw-alias-bg-layer-3);\n color: var(--dsw-alias-label-primary);\n font-size: 14px;\n line-height: 22px;\n white-space: pre-wrap;\n word-break: break-word;\n}\n.${FREE_CHAT_ROOT} .dsm-user-chrome {\n display: flex;\n align-items: center;\n gap: 8px;\n min-height: 28px;\n color: var(--dsw-alias-label-tertiary);\n}\n.${FREE_CHAT_ROOT} .dsm-user-time {\n font-size: 13px;\n white-space: nowrap;\n}\n.${FREE_CHAT_ROOT} .dsm-icon-action {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n padding: 6px;\n border: none;\n border-radius: var(--dsw-radius-sm);\n background: transparent;\n color: var(--dsw-alias-label-tertiary);\n cursor: pointer;\n}\n.${FREE_CHAT_ROOT} .dsm-icon-action:hover:not(:disabled) {\n background: var(--dsw-alias-interactive-bg-hover);\n color: var(--dsw-alias-label-secondary);\n}\n.${FREE_CHAT_ROOT} .dsm-icon-action svg { width: 15px; height: 15px; }\n.${FREE_CHAT_ROOT} .dsm-user-attachments {\n display: flex;\n flex-wrap: wrap;\n justify-content: flex-end;\n max-width: 100%;\n gap: 8px;\n}\n.${FREE_CHAT_ROOT} .dsm-file-card {\n display: inline-flex;\n flex: 0 0 240px;\n align-items: center;\n gap: 10px;\n box-sizing: border-box;\n width: 240px;\n min-height: 64px;\n padding: 8px 12px;\n border: 0.5px solid var(--dsw-alias-border-l2);\n border-radius: var(--dsw-radius-md);\n background: var(--dsw-alias-bg-layer-3);\n}\n.${FREE_CHAT_ROOT} .dsm-file-icon { flex: none; width: 28px; height: 28px; }\n.${FREE_CHAT_ROOT} .dsm-file-content {\n display: flex;\n flex: 1;\n flex-direction: column;\n min-width: 0;\n}\n.${FREE_CHAT_ROOT} .dsm-file-name {\n overflow: hidden;\n color: var(--dsw-alias-label-primary);\n font-size: 14px;\n font-weight: 500;\n line-height: 22px;\n white-space: nowrap;\n text-overflow: ellipsis;\n}\n.${FREE_CHAT_ROOT} .dsm-file-meta {\n overflow: hidden;\n color: var(--dsw-alias-label-tertiary);\n font-size: 12px;\n line-height: 15px;\n white-space: nowrap;\n text-overflow: ellipsis;\n}\n.${FREE_CHAT_ROOT} .dsm-reference-summary {\n color: var(--dsw-alias-label-tertiary);\n font-size: 13px;\n line-height: 18px;\n}\n/* General-section item: a named details group mirroring the host's native\n * item rows (16px vertical padding, a 0.5px l2 rule the shell drops on the\n * last item, 24px label-control gutter). The body mounts on first expand and\n * stays mounted while collapsed, so a fold never drops an unsaved draft. */\n.${FREE_CHAT_ROOT}.dsm-item {\n padding: 0;\n border-bottom: 0.5px solid var(--dsw-alias-border-l2);\n}\n.${FREE_CHAT_ROOT} .dsm-item-summary {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 24px;\n padding: 16px 0;\n list-style: none;\n cursor: pointer;\n}\n.${FREE_CHAT_ROOT} .dsm-item-summary::-webkit-details-marker { display: none; }\n.${FREE_CHAT_ROOT} .dsm-item-summary > span:first-child { min-width: 0; }\n.${FREE_CHAT_ROOT} .dsm-item-title {\n display: block;\n font-size: 14px;\n line-height: 20px;\n color: var(--dsw-alias-label-primary);\n}\n.${FREE_CHAT_ROOT} .dsm-item-desc {\n display: block;\n margin-top: 4px;\n font-size: 12px;\n line-height: 18px;\n color: var(--dsw-alias-label-secondary);\n}\n.${FREE_CHAT_ROOT} .dsm-item-chevron {\n width: 14px;\n height: 14px;\n color: var(--dsw-alias-label-secondary);\n transition: transform 0.15s ease;\n}\n.${FREE_CHAT_ROOT}.dsm-item[open] > .dsm-item-summary .dsm-item-chevron { transform: rotate(180deg); }\n.${FREE_CHAT_ROOT} .dsm-item-body { padding: 0 0 16px; }\n/* Settings row bodies: each collapsible row edits its own keys and saves on\n * change, so the body is one flat reading surface — a feature block per\n * switch/section, dependent controls indented underneath. */\n.${FREE_CHAT_ROOT} .dsm-settings {\n display: flex;\n flex-direction: column;\n gap: 12px;\n min-width: 0;\n}\n.${FREE_CHAT_ROOT} .dsm-feature {\n display: flex;\n flex-direction: column;\n gap: 8px;\n min-width: 0;\n}\n.${FREE_CHAT_ROOT} .dsm-feature + .dsm-feature {\n margin-top: 4px;\n padding-top: 4px;\n border-top: 0.5px solid var(--dsw-alias-border-l2);\n}\n.${FREE_CHAT_ROOT} .dsm-feature > .dsh-ui-toggle-row { padding: 8px 0; }\n.${FREE_CHAT_ROOT} .dsm-feature-options {\n display: flex;\n flex-direction: column;\n gap: 8px;\n padding: 0 0 8px 24px;\n}\n.${FREE_CHAT_ROOT} .dsm-feature-options[data-disabled='true'] .dsh-ui-label,\n.${FREE_CHAT_ROOT} .dsm-feature-options[data-disabled='true'] .dsh-ui-meta {\n color: var(--dsw-alias-label-tertiary);\n}\n/* A feature's model picker: label on the left, the menu trigger on the right;\n * narrow widths wrap the trigger under the label. */\n.${FREE_CHAT_ROOT} .dsm-model-field {\n display: flex;\n flex-direction: column;\n gap: 4px;\n min-width: 0;\n}\n.${FREE_CHAT_ROOT} .dsm-model-choice .dsh-model-menu-trigger:disabled {\n color: var(--dsw-alias-label-tertiary);\n cursor: not-allowed;\n}\n.${FREE_CHAT_ROOT} .dsm-model-choice {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: space-between;\n gap: 4px 16px;\n}\n.${FREE_CHAT_ROOT} .dsm-model-choice > .dsh-ui-label {\n flex: 1 1 120px;\n min-width: 120px;\n}\n.${FREE_CHAT_ROOT} .dsm-model-choice .dsh-model-menu-root {\n flex: 1 1 200px;\n min-width: min(200px, 100%);\n max-width: 280px;\n}\n.${FREE_CHAT_ROOT} .dsm-model-choice .dsh-model-menu-trigger {\n display: flex;\n justify-content: space-between;\n width: 100%;\n height: 32px;\n padding: 0 10px;\n border: 0.5px solid var(--dsw-alias-border-l4);\n border-radius: var(--dsw-radius-md);\n background: var(--dsw-alias-bg-layer-3);\n color: var(--dsw-alias-label-primary);\n}\n.${FREE_CHAT_ROOT} .dsm-model-choice .dsh-model-menu-triggerLabel {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n text-align: left;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.${FREE_CHAT_ROOT} .dsm-minutes-control {\n display: flex;\n align-items: center;\n gap: 8px;\n}\n.${FREE_CHAT_ROOT} .dsm-minutes { width: 88px; }\n.${FREE_CHAT_ROOT} .dsm-text-input { max-width: 320px; }\n/* Welcome-back card: one flat full-width row at the latest turn's tail in the\n * chat flow — a single bordered surface with the recap laid out inline, no\n * nested box. */\n.${FREE_CHAT_ROOT}.dsh-welcome-card {\n box-sizing: border-box;\n width: 100%;\n margin: 8px 0 0;\n padding: 8px 12px;\n border: 0.5px solid var(--dsw-alias-border-l4);\n border-radius: var(--dsw-radius-md);\n background: var(--dsw-alias-bg-layer-3);\n}\n.${FREE_CHAT_ROOT} .dsh-welcome-card-head {\n display: flex;\n align-items: baseline;\n gap: 8px;\n margin: 0 0 4px;\n}\n.${FREE_CHAT_ROOT} .dsh-welcome-card-title { font-weight: 600; }\n.${FREE_CHAT_ROOT} .dsh-welcome-card-idle {\n flex: 1;\n min-width: 0;\n color: var(--dsw-alias-label-secondary);\n font-size: 12px;\n}\n.${FREE_CHAT_ROOT} .dsh-welcome-card-close {\n align-self: flex-start;\n margin-left: auto;\n}\n.${FREE_CHAT_ROOT} .dsh-welcome-card-actions {\n display: flex;\n justify-content: flex-start;\n flex-wrap: wrap;\n gap: 8px;\n margin: 8px 0 0;\n}\n.${FREE_CHAT_ROOT} .dsh-welcome-recap {\n margin: 0;\n padding: 0;\n border: none;\n}\n.${FREE_CHAT_ROOT} .dsh-welcome-recap dt {\n margin: 6px 0 0;\n font-size: 12px;\n color: var(--dsw-alias-label-tertiary);\n}\n.${FREE_CHAT_ROOT} .dsh-welcome-recap dt:first-child { margin-top: 0; }\n.${FREE_CHAT_ROOT} .dsh-welcome-recap dd {\n margin: 0;\n white-space: pre-wrap;\n word-break: break-word;\n}\n.${FREE_CHAT_ROOT} .dsh-welcome-cache {\n margin: 6px 0 0;\n color: var(--dsw-alias-label-secondary);\n}\n.${FREE_CHAT_ROOT} .dsh-welcome-done { margin: 6px 0 0; }\n\n/* Hero-row Auto-continue chip: icon + mode label, tinted while a mode is on. */\n.${FREE_CHAT_ROOT}.smac-option {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n}\n.${FREE_CHAT_ROOT} .smac-chip {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n height: 28px;\n padding: 0 10px;\n border-radius: 999px;\n font-size: 13px;\n line-height: 20px;\n border: 1px solid var(--dsw-alias-border-l3);\n background: transparent;\n color: var(--dsw-alias-label-secondary);\n cursor: pointer;\n}\n.${FREE_CHAT_ROOT} .smac-chip svg { width: 16px; height: 16px; }\n.${FREE_CHAT_ROOT} .smac-chip .smac-chevron { width: 12px; height: 12px; }\n.${FREE_CHAT_ROOT} .smac-chip:hover:not(:disabled) {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n.${FREE_CHAT_ROOT} .smac-chip.smac-chip-on {\n background: var(--dsw-alias-button-primary-fill);\n border-color: var(--dsw-alias-button-primary-fill);\n color: var(--dsw-alias-label-primary-foreground);\n}\n.${FREE_CHAT_ROOT} .smac-chip.smac-chip-on:hover:not(:disabled) {\n background: var(--dsw-alias-button-primary-hover);\n border-color: var(--dsw-alias-button-primary-hover);\n}\n.${FREE_CHAT_ROOT} .smac-chip:disabled {\n opacity: 0.5;\n cursor: default;\n}\n.${FREE_CHAT_ROOT} .smac-note {\n font-size: 12px;\n line-height: 18px;\n color: var(--dsw-alias-label-tertiary);\n}\n\n.${FREE_CHAT_ROOT} .dsm-user-original { display: contents; }\n.${FREE_CHAT_ROOT} .dsm-user-original[hidden] { display: none; }\n.${FREE_CHAT_ROOT} .dsm-message-edit { width: min(100%, 720px); align-self: flex-end; }\n.${FREE_CHAT_ROOT} .dsm-message-editor { width: 100%; box-sizing: border-box; padding: 14px; border-radius: 18px; background: var(--dsw-alias-bg-layer-3); }\n.${FREE_CHAT_ROOT} .dsm-message-editor .dsh-free-draft { width: 100%; min-height: 80px; max-height: 360px; resize: vertical; border: none; background: transparent; box-shadow: none; padding: 4px; box-sizing: border-box; }\n.${FREE_CHAT_ROOT} .dsm-edit-footer { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }\n.${FREE_CHAT_ROOT} .dsm-edit-spacer { flex: 1; }\n.${FREE_CHAT_ROOT} .dsm-edit-attachments { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }\n.${FREE_CHAT_ROOT} .dsm-edit-attachment { display: flex; align-items: center; gap: 6px; border: 1px solid var(--dsw-alias-border-l2); border-radius: 10px; padding: 6px; max-width: 100%; }\n.${FREE_CHAT_ROOT} .dsm-edit-attachment img { width: 72px; height: 60px; object-fit: contain; border-radius: 6px; }\n.${FREE_CHAT_ROOT} .dsm-edit-attachment > span { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.${FREE_CHAT_ROOT} .dsm-edit-attachment > svg { width: 24px; height: 24px; }\n.${FREE_CHAT_ROOT} .dsm-edit-image { position: relative; padding: 0; border: none; }\n.${FREE_CHAT_ROOT} .dsm-edit-image img { width: auto; height: auto; max-width: 220px; max-height: 140px; object-fit: contain; border-radius: 10px; }\n.${FREE_CHAT_ROOT} .dsm-edit-image > button { position: absolute; top: 4px; right: 4px; border-radius: 50%; background: var(--dsw-alias-bg-layer-3); width: 24px; height: 24px; padding: 0; }\n`\n","import { useEffect, useRef, useSyncExternalStore } from 'react'\nimport { Button, Modal } from '@deepseek-ai/dsh-client-ui-primitives'\nimport type { FreeChatModel } from './session-actions.ts'\nimport { FREE_CHAT_ROOT } from './styles.ts'\nimport { deleteBody, failureText, uiText, type CopyLocale } from './ui-copy.ts'\n\n/** Create failures used to surface inside the standalone panel. The panel is gone,\n * so they get a small overlay instead; closing it dismisses the stored notice. */\nexport function CreateNoticeDialog(props: { model: FreeChatModel; locale: CopyLocale }): React.ReactElement | null {\n const snapshot = useSyncExternalStore(props.model.subscribe, props.model.getSnapshot, props.model.getSnapshot)\n const notice = snapshot.notice\n if (notice === undefined) return null\n const copy = (key: Parameters<typeof uiText>[1]) => uiText(props.locale, key)\n return (\n <Modal\n open\n className={FREE_CHAT_ROOT}\n title={copy('createFailed')}\n closeLabel={copy('close')}\n onClose={() => { props.model.dismissNotice() }}\n footer={(\n <Button variant=\"primary\" data-modal-autofocus onClick={() => { props.model.dismissNotice() }}>\n {copy('close')}\n </Button>\n )}\n >\n <p className=\"dsh-ui-error dsh-free-alert\" role=\"alert\">{failureText(props.locale, notice)}</p>\n </Modal>\n )\n}\n\nexport function DeleteChatDialog(props: { model: FreeChatModel; locale: CopyLocale }): React.ReactElement | null {\n const snapshot = useSyncExternalStore(props.model.subscribe, props.model.getSnapshot, props.model.getSnapshot)\n const request = snapshot.deleteRequest\n const confirmRef = useRef<HTMLButtonElement>(null)\n useEffect(() => {\n if (request?.failure) confirmRef.current?.focus()\n }, [request?.failure])\n if (request === undefined) return null\n const copy = (key: Parameters<typeof uiText>[1]) => uiText(props.locale, key)\n const label = request.busy ? copy('deleting') : request.failure ? copy('retryList') : copy('deleteChat')\n return (\n <Modal\n open\n className={FREE_CHAT_ROOT}\n title={copy('deleteChat')}\n closeLabel={copy('close')}\n description={deleteBody(props.locale, request.classification)}\n onClose={() => { props.model.cancelDelete() }}\n footer={(\n <>\n <Button variant=\"ghost\" data-modal-autofocus disabled={request.busy} onClick={() => { props.model.cancelDelete() }}>{copy('cancel')}</Button>\n <Button\n ref={confirmRef}\n variant=\"primary\"\n disabled={request.busy}\n onClick={() => { void props.model.confirmDelete() }}\n >\n {label}\n </Button>\n </>\n )}\n >\n <p>{request.title}</p>\n {request.failure ? <p className=\"dsh-ui-error dsh-free-alert\" role=\"alert\">{failureText(props.locale, request.failure)}</p> : null}\n </Modal>\n )\n}\n","import { useCallback, useEffect, useRef, useState, useSyncExternalStore, type ReactNode, type RefObject } from 'react'\nimport { Button, IconFolderCloseRegular, IconNewChatOutlineRegular, IconPlusOutlineRegular, Menu, Modal } from '@deepseek-ai/dsh-client-ui-primitives'\nimport type { StoredEntry } from '@deepseek-ai/dsh-client-ui-slots'\nimport type { DirectoryFlowOwnerProps, WorkspacePickerProps } from '@deepseek-ai/dsh-client-ui-workspace/client'\nimport { TEMP_WORKSPACE_FLOW_SLOT } from './contracts.ts'\nimport { FREE_CHAT_ROOT } from './styles.ts'\nimport { copyLocale, uiText, type CopyLocale } from './ui-copy.ts'\nimport type { TemporaryWorkspaceModel } from './temporary-workspace.ts'\n\nconst PICKER_SLOT = 'conversation.hero.workspace'\nconst DIRECTORY_SLOT = 'conversation.hero.workspace.directoryFlow'\n\n/** Public registry faces used by the version-bounded directory-flow compatibility adapter. */\nexport interface PickerRegistry {\n inject(key: string, callback: () => (() => void) | void): () => void\n register(options: Record<string, unknown>, component: unknown): () => void\n entriesOfSlot(key: string): readonly StoredEntry[]\n spec(key: string): { kind: string; scope: string } | undefined\n subscribe(key: string, listener: () => void): () => void\n onEntryError?(listener: (key: string, entry: StoredEntry, error: unknown) => void): () => void\n}\n\n/** Keep the host's native/web picker implementation and its injected capabilities.\n * Standard rc.2 offers no exported directory-flow factory. Only its simple root\n * registration can be mirrored; more complex future registrations restore the host picker.\n * Original entries and their ownership ledger are never changed.\n */\nexport function installTemporaryWorkspacePicker(slots: PickerRegistry, model: TemporaryWorkspaceModel,\n createWorkspace: (path: string) => Promise<{ workspaceId: string }>, locale?: {\n getSnapshot(): { active: string }; subscribe(listener: () => void): () => void\n }): () => void {\n if (typeof slots.entriesOfSlot !== 'function' || typeof slots.spec !== 'function' || typeof slots.subscribe !== 'function') {\n model.reportFailure(copyLocale(locale?.getSnapshot().active) === 'zh'\n ? '当前版本无法扩展工作区菜单,已保留原菜单。' : 'Could not extend the workspace menu. The original menu has been preserved.')\n return () => {}\n }\n return slots.inject(PICKER_SLOT, () => {\n let mirror: StoredEntry | undefined, stopMirror = () => {}, restored = false\n const failureMessage = () => copyLocale(locale?.getSnapshot().active) === 'zh'\n ? '当前版本无法扩展工作区菜单,已保留原菜单。' : 'Could not extend the workspace menu. The original menu has been preserved.'\n const renderPicker = (props: PickerProps) => <TemporaryWorkspacePicker {...props} model={model} createWorkspace={createWorkspace} locale={locale}\n getDirectoryFlow={() => mirror} subscribeFlow={listener => slots.subscribe(DIRECTORY_SLOT, listener)} />\n const stopPicker = slots.register({ name: PICKER_SLOT, priority: -10, locale: 'workspace',\n children: { [TEMP_WORKSPACE_FLOW_SLOT]: { kind: 'single', scope: 'root' } },\n }, renderPicker)\n const stopErrors = slots.onEntryError?.((key, entry) => {\n if (restored || (key !== TEMP_WORKSPACE_FLOW_SLOT && !(key === PICKER_SLOT && entry.component === renderPicker))) return\n restored = true; stopMirror(); mirror = undefined; stopPicker()\n model.reportFailure(failureMessage())\n }) ?? (() => {})\n const sync = () => {\n if (restored) return\n const next = slots.entriesOfSlot(DIRECTORY_SLOT)[0]\n if (next === mirror) return\n stopMirror(); stopMirror = () => {}; mirror = undefined\n if (next === undefined) return\n const spec = slots.spec(DIRECTORY_SLOT)\n if (spec?.kind !== 'single' || spec.scope !== 'root' || typeof next.component !== 'function'\n || next.children !== undefined || next.store !== undefined || next.locale !== undefined || next.select !== undefined) {\n restored = true; stopPicker()\n model.reportFailure(failureMessage())\n return\n }\n try {\n stopMirror = slots.register({ name: TEMP_WORKSPACE_FLOW_SLOT, ...next.inject ? { inject: next.inject } : {} }, next.component)\n mirror = next\n } catch (error) {\n restored = true; stopPicker()\n model.reportFailure(error instanceof Error ? error.message : 'Could not extend the workspace picker')\n }\n }\n const stopSource = slots.subscribe(DIRECTORY_SLOT, sync)\n sync()\n return () => { restored = true; stopErrors(); stopSource(); stopMirror(); stopPicker() }\n })\n}\n\n/** Standard conversation hero owner share; some published type graphs omit its merge. */\ntype PickerProps = Pick<WorkspacePickerProps, 'useWorkspaces'> & {\n open: boolean\n anchorRef?: RefObject<HTMLElement | null>\n selectedId?: string\n onPick(workspaceId: string): void\n onClose(): void\n t(key: string): string\n renderSlot(key: typeof TEMP_WORKSPACE_FLOW_SLOT, owner: DirectoryFlowOwnerProps): ReactNode\n}\n\nfunction TemporaryWorkspacePicker(props: PickerProps & {\n model: TemporaryWorkspaceModel; createWorkspace(path: string): Promise<{ workspaceId: string }>\n getDirectoryFlow(): StoredEntry | undefined; subscribeFlow(listener: () => void): () => void\n locale?: { getSnapshot(): { active: string }; subscribe(listener: () => void): () => void }\n}) {\n const workspaces = props.useWorkspaces(snapshot => snapshot)\n const state = useSyncExternalStore(props.model.subscribe, props.model.getSnapshot, props.model.getSnapshot)\n const source = useSyncExternalStore(props.subscribeFlow, props.getDirectoryFlow, props.getDirectoryFlow)\n const available = source !== undefined\n const locale = copyLocale(useSyncExternalStore(listener => props.locale?.subscribe(listener) ?? (() => {}),\n () => props.locale?.getSnapshot().active ?? 'en', () => 'en'))\n const [flowOpen, setFlowOpen] = useState(false), [adopting, setAdopting] = useState(false)\n const [failure, setFailure] = useState<string>()\n const epoch = useRef(0)\n useEffect(() => () => { epoch.current++ }, [])\n useEffect(() => { epoch.current++; setFlowOpen(false); setAdopting(false) }, [source])\n const busy = flowOpen || adopting || state.creating\n const getAnchorRect = useCallback(() => props.anchorRef?.current?.getBoundingClientRect() ?? null, [props.anchorRef])\n const openDirectory = () => { props.onClose(); setFailure(undefined); setFlowOpen(true) }\n return <>\n <Menu open={props.open} anchor={null} portal getAnchorRect={getAnchorRect} selectedId={props.selectedId}\n onClose={props.onClose} items={workspaces.items.map(workspace => ({ id: workspace.workspaceId,\n // The standard registry's first-use title is language-neutral; all user titles stay verbatim.\n label: workspace.title === 'default-workspace' ? props.t('workspace.defaultName') : workspace.title,\n icon: <IconFolderCloseRegular size={16} />, disabled: busy }))}\n footer={[\n ...available ? [{ id: '::add-workspace', label: props.t('menu.addWorkspace'), icon: <IconPlusOutlineRegular size={16} />, disabled: busy }] : [],\n { id: '::temporary-workspace', label: uiText(locale, 'tempWorkspace'), icon: <IconNewChatOutlineRegular size={16} />, disabled: busy },\n ]}\n onSelect={id => {\n if (id === '::add-workspace') openDirectory()\n else if (id === '::temporary-workspace') { props.onClose(); void props.model.create() }\n else props.onPick(id as never)\n }} />\n {/* The picker renders straight into the host's conversation.hero.workspace\n * slot with no plugin-rooted ancestor, so the loading line carries the root\n * class itself for the dsh-ui-loading recipe to reach it. */}\n {props.open && workspaces.phase === 'pending' && <span role=\"status\" className={`${FREE_CHAT_ROOT} dsh-ui-loading`}>{props.t('picker.loading')}</span>}\n {props.renderSlot(TEMP_WORKSPACE_FLOW_SLOT, {\n open: flowOpen, busy: adopting,\n onCancel: () => { epoch.current++; setFlowOpen(false); setAdopting(false) },\n onError: message => { epoch.current++; setFlowOpen(false); setAdopting(false); setFailure(message) },\n onPicked: path => {\n if (adopting) return\n const ticket = ++epoch.current\n setAdopting(true)\n void props.createWorkspace(path).then(workspace => {\n if (ticket !== epoch.current) return\n setFlowOpen(false); props.onPick(workspace.workspaceId as never)\n }, error => {\n if (ticket !== epoch.current) return\n setFlowOpen(false); setFailure(error instanceof Error ? error.message : String(error))\n }).finally(() => { if (ticket === epoch.current) setAdopting(false) })\n },\n })}\n <Modal open={failure !== undefined} className={FREE_CHAT_ROOT} title={props.t('folderError.title')} closeLabel={props.t('close')}\n onClose={() => setFailure(undefined)} footer={<>\n <Button variant=\"outline\" onClick={() => setFailure(undefined)}>{props.t('cancel')}</Button>\n <Button variant=\"primary\" disabled={!available} onClick={openDirectory}>{props.t('folderError.retry')}</Button>\n </>}><p role=\"alert\">{failure}</p></Modal>\n </>\n}\n\nexport function TemporaryWorkspaceNotice({ model, locale }: { model: TemporaryWorkspaceModel; locale: CopyLocale }) {\n const state = useSyncExternalStore(model.subscribe, model.getSnapshot, model.getSnapshot)\n return <Modal open={state.failure !== undefined} className={FREE_CHAT_ROOT} title={uiText(locale, 'createFailed')}\n closeLabel={uiText(locale, 'close')} onClose={model.dismissFailure} footer={<>\n <Button variant=\"outline\" onClick={model.dismissFailure}>{uiText(locale, 'close')}</Button>\n <Button variant=\"primary\" disabled={state.creating} onClick={() => { void model.create() }}>{uiText(locale, 'retry')}</Button>\n </>}><p role=\"alert\">{state.failure}</p></Modal>\n}\n","import { TEMP_WORKSPACE_CHANNEL } from './contracts.ts'\n\nexport interface TemporaryWorkspaceHost {\n beginNavigation(): AbortSignal\n allocate(requestId: string, signal: AbortSignal): Promise<{ requestId: string; path: string }>\n createWorkspace(path: string): Promise<{ workspaceId: string }>\n renameWorkspace(workspaceId: string, title: string): Promise<unknown>\n openWorkspace(workspaceId: string, beforeOpen: () => void): Promise<void>\n}\n\nexport interface TemporaryWorkspaceSnapshot {\n readonly creating: boolean\n readonly failure?: string\n}\n\nexport function createTemporaryWorkspaceModel(host: TemporaryWorkspaceHost, ids = () => crypto.randomUUID(), label = () => 'Temporary Workspace') {\n const lifetime = new AbortController(), listeners = new Set<() => void>()\n let snapshot: TemporaryWorkspaceSnapshot = { creating: false }\n let pending: { requestId: string; title: string; path?: string; workspaceId?: string; named?: boolean } | undefined\n const publish = (next: TemporaryWorkspaceSnapshot) => {\n if (lifetime.signal.aborted) return\n snapshot = next\n for (const listener of listeners) listener()\n }\n return {\n getSnapshot: () => snapshot,\n subscribe(listener: () => void) { listeners.add(listener); return () => { listeners.delete(listener) } },\n dismissFailure() { publish({ creating: snapshot.creating }) },\n reportFailure(failure: string) { publish({ ...snapshot, failure }) },\n async create() {\n if (snapshot.creating || lifetime.signal.aborted) return\n // Capture before allocation/adoption so late completion cannot steal a newer navigation.\n const signal = AbortSignal.any([host.beginNavigation(), lifetime.signal])\n const action = pending ??= { requestId: ids(), title: label() }\n let opening = false\n publish({ creating: true })\n try {\n signal.throwIfAborted()\n if (action.path === undefined) {\n const allocated = await host.allocate(action.requestId, signal)\n if (allocated.requestId !== action.requestId || !allocated.path) throw new Error('Invalid temporary workspace response')\n action.path = allocated.path\n }\n signal.throwIfAborted()\n if (action.workspaceId === undefined) action.workspaceId = (await host.createWorkspace(action.path)).workspaceId\n signal.throwIfAborted()\n if (!action.named) {\n await host.renameWorkspace(action.workspaceId, `${action.title} ${action.requestId.slice(0, 8)}`)\n action.named = true\n }\n signal.throwIfAborted()\n opening = true\n await host.openWorkspace(action.workspaceId, () => lifetime.signal.throwIfAborted())\n // openWorkspace starts its own fenced navigation, invalidating our earlier signal.\n if (!lifetime.signal.aborted) pending = undefined\n } catch (error) {\n if (!lifetime.signal.aborted && (opening ? !(error instanceof Error && error.name === 'AbortError') : !signal.aborted)) {\n publish({ creating: false, failure: error instanceof Error ? error.message : 'Could not create the temporary workspace' })\n }\n } finally {\n publish({ ...snapshot, creating: false })\n }\n },\n cancel() { lifetime.abort(); listeners.clear() },\n }\n}\n\nexport type TemporaryWorkspaceModel = ReturnType<typeof createTemporaryWorkspaceModel>\n\nexport function bindTemporaryWorkspaceHost(ctx: {\n layout: { beginNavigation(): AbortSignal }\n connection: { rpc: { call(channel: string, endpoint: string, payload: unknown, signal?: AbortSignal): Promise<unknown> } }\n workspaces: { create(input: { path: string }): Promise<{ workspaceId: string }>; rename(workspaceId: string, title: string): Promise<unknown> }\n uiWorkspace: { openWorkspace(workspaceId: string, beforeOpen?: () => void): Promise<void> }\n}): TemporaryWorkspaceHost {\n return {\n beginNavigation: () => ctx.layout.beginNavigation(),\n async allocate(requestId, signal) {\n const raw = await ctx.connection.rpc.call(TEMP_WORKSPACE_CHANNEL, 'temporary.allocate', { requestId }, signal)\n const response = raw as { ok?: boolean; value?: { requestId: string; path: string }; error?: { message?: string } }\n if (response?.ok !== true || typeof response.value?.path !== 'string' || typeof response.value.requestId !== 'string') {\n throw new Error(response?.error?.message ?? 'Could not allocate the temporary workspace')\n }\n return response.value\n },\n createWorkspace: path => ctx.workspaces.create({ path }),\n renameWorkspace: (workspaceId, title) => ctx.workspaces.rename(workspaceId, title),\n openWorkspace: (workspaceId, beforeOpen) => ctx.uiWorkspace.openWorkspace(workspaceId, beforeOpen),\n }\n}\n","/**\n * Narrow client faces the host owner still has to publish.\n * Call these only when the live service actually has the method.\n * Do not call the session remote directly: manager.create still drops `kind`,\n * and delete/retry have to update the catalog and the open selection.\n */\nimport type { OperationFailure } from './ui-copy.ts'\nimport type { SessionListSnapshot } from './free-list.ts'\nimport type { PromptContent } from './edit-host.ts'\n\nexport interface SessionCapabilities {\n readonly retry: boolean\n /** Whether retry accepts explicit confirmation of later modifications. */\n readonly retryModified: boolean\n readonly retryContent?: boolean\n readonly freeSession: boolean\n readonly deleteSession: boolean\n}\n\nexport const UNSUPPORTED_CAPABILITIES: SessionCapabilities = {\n retry: false,\n retryModified: false,\n freeSession: false,\n deleteSession: false,\n}\n\n/**\n * `inputRevision` is an opaque token from preview.\n * An eligible preview without it is not a supported retry.\n */\nexport interface RetryPreview {\n readonly branchRevision: number\n readonly inputRevision: string\n readonly eligible: boolean\n readonly reason?: string\n}\n\n/** Base request shape of the host's retry API; an edit adds `text` or `content`. */\nexport interface DirectRetryRequest {\n readonly sessionId: string\n readonly messageId: string\n readonly expectedRevision: number\n readonly expectedInputRevision: string\n readonly requestId: string\n /** Explicit user confirmation keeps later file and external changes intact. */\n readonly allowModified?: boolean\n}\n\n/** Edit sends plain text only. The host keeps attachments. */\nexport interface EditRetryRequest extends DirectRetryRequest {\n readonly text?: string\n readonly content?: readonly PromptContent[]\n}\n\nexport interface DeleteOutcome {\n readonly phase: 'deleted' | 'cleanup-pending'\n}\n\nexport interface ObservableList {\n getSnapshot(): SessionListSnapshot\n subscribe(listener: () => void): () => void\n}\n\nexport interface SessionHost {\n readonly list: ObservableList\n capabilities?: () => Promise<unknown> | unknown\n create?: (opts: { kind: 'free' }) => Promise<unknown>\n previewRetry?: (request: { sessionId: string; messageId: string }) => Promise<unknown>\n retry?: (request: DirectRetryRequest | EditRetryRequest) => Promise<unknown>\n openSession?: (sessionId: string) => void\n deleteSession?: (sessionId: string, requestId: string) => Promise<unknown>\n}\n\ninterface RemoteFailure {\n readonly code?: string\n readonly message?: string\n readonly details?: { readonly reason?: string }\n}\n\ninterface RemoteResult {\n readonly ok: boolean\n readonly value?: unknown\n readonly error?: RemoteFailure\n}\n\nexport function isRecoverable(failure: OperationFailure): boolean {\n return failure.code === 'transport' || failure.code === 'session/delete-pending'\n || failure.code === 'session/retry-pending' || failure.code === 'session/retry-uncertain'\n}\n\nexport function isStaleRetryFailure(failure: OperationFailure | undefined): boolean {\n return failure?.code === 'session/retry-revision'\n || failure?.code === 'session/branch-moved'\n || failure?.code === 'session/retry-input'\n || failure?.code === 'session/retry-conflict'\n}\n\nexport function readFailure(error: unknown): OperationFailure {\n if (isFailure(error)) return { code: error.code, ...error.reason === undefined ? {} : { reason: error.reason } }\n if (typeof error === 'object' && error !== null) {\n const record = error as { code?: unknown; reason?: unknown; message?: unknown; rpcError?: RemoteFailure }\n const rpc = record.rpcError\n if (typeof rpc?.code === 'string') {\n return { code: rpc.code, ...reasonOf(rpc) === undefined ? {} : { reason: reasonOf(rpc) } }\n }\n if (typeof record.code === 'string') {\n const reason = typeof record.reason === 'string' ? record.reason : undefined\n return { code: record.code, ...reason === undefined ? {} : { reason } }\n }\n }\n return { code: 'transport', reason: 'unknown' }\n}\n\nfunction isFailure(error: unknown): error is OperationFailure {\n return typeof error === 'object' && error !== null && 'code' in error && typeof (error as { code: unknown }).code === 'string'\n && (error as { name?: string }).name === 'HostOperationError'\n}\n\nexport class HostOperationError extends Error implements OperationFailure {\n override readonly name = 'HostOperationError'\n readonly reason?: string\n constructor(readonly code: string, reason?: string) {\n super(code)\n if (reason !== undefined) this.reason = reason\n }\n}\n\nfunction reasonOf(error: RemoteFailure | undefined): string | undefined {\n return typeof error?.details?.reason === 'string' ? error.details.reason : undefined\n}\n\nfunction isRemoteResult(value: unknown): value is RemoteResult {\n if (typeof value !== 'object' || value === null || !('ok' in value)) return false\n const ok = (value as { ok: unknown }).ok\n return typeof ok === 'boolean' && ('value' in value || 'error' in value)\n}\n\nexport async function unwrap(value: unknown): Promise<unknown> {\n const resolved = await value\n if (!isRemoteResult(resolved)) return resolved\n if (!resolved.ok) {\n throw new HostOperationError(resolved.error?.code ?? 'transport', reasonOf(resolved.error))\n }\n return resolved.value\n}\n\nexport async function readCapabilities(host: SessionHost): Promise<SessionCapabilities> {\n if (typeof host.capabilities !== 'function') return UNSUPPORTED_CAPABILITIES\n try {\n const value = await unwrap(host.capabilities())\n if (typeof value !== 'object' || value === null) return UNSUPPORTED_CAPABILITIES\n const record = value as Partial<SessionCapabilities>\n return {\n retry: record.retry === true,\n retryModified: record.retryModified === true,\n ...record.retryContent === true ? { retryContent: true } : {},\n freeSession: record.freeSession === true,\n deleteSession: record.deleteSession === true,\n }\n } catch {\n return UNSUPPORTED_CAPABILITIES\n }\n}\n\nexport function controlsFor(capabilities: SessionCapabilities, ready: boolean, host: SessionHost): {\n create: boolean\n delete: boolean\n retry: boolean\n} {\n return {\n create: ready && capabilities.freeSession && typeof host.create === 'function',\n delete: ready && capabilities.deleteSession && typeof host.deleteSession === 'function',\n retry: ready && capabilities.retry && typeof host.previewRetry === 'function' && typeof host.retry === 'function',\n }\n}\n\nfunction sessionIdOf(value: unknown): string {\n if (typeof value === 'string' && value !== '') return value\n if (typeof value === 'object' && value !== null && typeof (value as { sessionId?: unknown }).sessionId === 'string') {\n return (value as { sessionId: string }).sessionId\n }\n throw new HostOperationError('session/lifecycle-unavailable')\n}\n\n/** Pass only `{ kind: 'free' }`. A cwd or workspace is rejected by free create, and must not be invented. */\nexport async function createFreeSession(host: SessionHost): Promise<string> {\n if (typeof host.create !== 'function') throw new HostOperationError('session/lifecycle-unavailable')\n return sessionIdOf(await unwrap(host.create({ kind: 'free' })))\n}\n\nexport async function deleteOwnedSession(host: SessionHost, sessionId: string, requestId: string): Promise<DeleteOutcome> {\n if (typeof host.deleteSession !== 'function') throw new HostOperationError('session/lifecycle-unavailable')\n const value = await unwrap(host.deleteSession(sessionId, requestId))\n if (typeof value !== 'object' || value === null) throw new HostOperationError('session/delete-pending', 'missing-outcome')\n const phase = (value as { phase?: unknown }).phase\n if (phase !== 'deleted' && phase !== 'cleanup-pending') {\n throw new HostOperationError('session/delete-pending', 'missing-outcome')\n }\n return { phase }\n}\n\n/** Build the body for one edited prompt; the host keeps the original attachments when only text changes. */\nexport function editRetryRequest(input: {\n sessionId: string\n messageId: string\n expectedRevision: number\n expectedInputRevision: string\n requestId: string\n text: string\n content?: readonly PromptContent[]\n allowModified?: boolean\n}): EditRetryRequest {\n return {\n sessionId: input.sessionId,\n messageId: input.messageId,\n expectedRevision: input.expectedRevision,\n expectedInputRevision: input.expectedInputRevision,\n requestId: input.requestId,\n ...input.content === undefined ? { text: input.text } : { content: input.content },\n ...input.allowModified === true ? { allowModified: true } : {},\n }\n}\n\nexport class SubmissionLedger {\n private active = false\n private unresolved: EditRetryRequest | undefined\n\n get busy(): boolean {\n return this.active\n }\n\n pending(): EditRetryRequest | undefined {\n return this.unresolved\n }\n\n /** Resend the stored body. A non-recoverable result drops it; a lost reply keeps it. */\n async replay(execute: (body: EditRetryRequest) => Promise<unknown>): Promise<void> {\n const body = this.unresolved\n if (body === undefined) return\n if (this.active) throw new HostOperationError('busy', 'running')\n this.active = true\n try {\n await execute(body)\n this.unresolved = undefined\n } catch (error) {\n const failure = readFailure(error)\n if (!isRecoverable(failure) && failure.reason !== 'aborted') this.unresolved = undefined\n throw error instanceof HostOperationError ? error : new HostOperationError(failure.code, failure.reason)\n } finally {\n this.active = false\n }\n }\n\n /** First submission of a body built from the current preview. */\n async submit(body: EditRetryRequest, execute: () => Promise<unknown>): Promise<void> {\n if (this.active || this.unresolved !== undefined) throw new HostOperationError('busy', 'running')\n this.active = true\n try {\n await execute()\n this.unresolved = undefined\n } catch (error) {\n const failure = readFailure(error)\n this.unresolved = isRecoverable(failure) ? body : undefined\n throw error instanceof HostOperationError ? error : new HostOperationError(failure.code, failure.reason)\n } finally {\n this.active = false\n }\n }\n}\n\ninterface Listener {\n (): void\n}\n\nfunction store() {\n const listeners = new Set<Listener>()\n return {\n subscribe(listener: Listener): () => void {\n listeners.add(listener)\n return () => { listeners.delete(listener) }\n },\n emit(): void {\n for (const listener of listeners) listener()\n },\n }\n}\n\nexport interface DeleteRequestState {\n readonly sessionId: string\n readonly title: string\n readonly classification: 'free' | 'ordinary'\n readonly requestId: string\n readonly busy: boolean\n readonly failure?: OperationFailure\n}\n\nexport interface FreeChatSnapshot {\n readonly controls: ReturnType<typeof controlsFor>\n readonly capabilitiesReady: boolean\n readonly creating: boolean\n readonly notice?: OperationFailure\n readonly deleteRequest?: DeleteRequestState\n}\n\nexport interface FreeChatModel {\n subscribe(listener: Listener): () => void\n getSnapshot(): FreeChatSnapshot\n reloadCapabilities(): Promise<void>\n create(): Promise<void>\n dismissNotice(): void\n requestDelete(sessionId: string): void\n cancelDelete(): void\n confirmDelete(): Promise<void>\n cancel(): void\n}\n\nexport function createFreeChatModel(host: SessionHost, ids: () => string = () => crypto.randomUUID()): FreeChatModel {\n const events = store()\n let capabilities = UNSUPPORTED_CAPABILITIES\n let capabilitiesReady = false\n let creating = false\n let notice: OperationFailure | undefined\n let deleteRequest: DeleteRequestState | undefined\n let generation = 0\n let snapshot: FreeChatSnapshot = build()\n\n function build(): FreeChatSnapshot {\n return {\n controls: controlsFor(capabilities, capabilitiesReady, host),\n capabilitiesReady,\n creating,\n ...notice === undefined ? {} : { notice },\n ...deleteRequest === undefined ? {} : { deleteRequest },\n }\n }\n\n function publish(): void {\n snapshot = build()\n events.emit()\n }\n\n return {\n subscribe: events.subscribe,\n getSnapshot: () => snapshot,\n async reloadCapabilities() {\n capabilities = await readCapabilities(host)\n capabilitiesReady = true\n publish()\n },\n async create() {\n if (!controlsFor(capabilities, capabilitiesReady, host).create || creating) return\n const ticket = generation\n creating = true\n notice = undefined\n publish()\n try {\n const id = await createFreeSession(host)\n if (ticket !== generation) return\n if (typeof host.openSession !== 'function') throw new HostOperationError('session/lifecycle-unavailable', 'open-session')\n host.openSession(id)\n } catch (error) {\n if (ticket !== generation) return\n notice = readFailure(error)\n } finally {\n if (ticket === generation) {\n creating = false\n publish()\n }\n }\n },\n dismissNotice() {\n if (notice === undefined) return\n notice = undefined\n publish()\n },\n requestDelete(sessionId) {\n if (!controlsFor(capabilities, capabilitiesReady, host).delete) return\n const row = host.list.getSnapshot().byId[sessionId]\n deleteRequest = {\n sessionId,\n title: row?.displayTitle ?? row?.title ?? sessionId,\n classification: row?.classification === 'free' ? 'free' : 'ordinary',\n requestId: ids(),\n busy: false,\n }\n publish()\n },\n cancelDelete() {\n if (deleteRequest?.busy) return\n deleteRequest = undefined\n publish()\n },\n async confirmDelete() {\n const current = deleteRequest\n if (current === undefined || current.busy) return\n const ticket = generation\n deleteRequest = { ...current, busy: true, failure: undefined }\n publish()\n try {\n const outcome = await deleteOwnedSession(host, current.sessionId, current.requestId)\n if (ticket !== generation) return\n if (outcome.phase !== 'deleted') {\n deleteRequest = {\n ...current,\n busy: false,\n failure: { code: 'session/delete-pending', reason: 'pending' },\n }\n publish()\n return\n }\n // The host clears the open selection itself; there is no panel to jump to.\n deleteRequest = undefined\n } catch (error) {\n if (ticket !== generation) return\n const failure = readFailure(error)\n deleteRequest = { ...current, busy: false, failure }\n }\n if (ticket === generation) publish()\n },\n cancel() {\n generation += 1\n creating = false\n notice = undefined\n deleteRequest = undefined\n publish()\n },\n }\n}\n\nexport interface RetrySnapshot {\n readonly controlsRetry: boolean\n readonly controlsContent?: boolean\n readonly busy: boolean\n readonly editing: boolean\n /** The current preview found later modifications that the user must acknowledge. */\n readonly modified: boolean\n readonly draft: string\n readonly sessionId: string\n readonly messageId: string\n readonly failure?: OperationFailure\n}\n\nexport interface RetryModel {\n subscribe(listener: Listener): () => void\n getSnapshot(): RetrySnapshot\n load(): Promise<void>\n beginEdit(sessionId: string, messageId: string, text: string, signal: AbortSignal): Promise<void>\n setDraft(text: string): void\n cancelEdit(): void\n sendEdit(sessionId: string, messageId: string, signal: AbortSignal, content?: readonly PromptContent[], confirmed?: boolean): Promise<void>\n retire(sessionId: string, messageId: string): void\n cancel(): void\n}\n\nexport function createRetryModel(host: SessionHost, ids: () => string = () => crypto.randomUUID()): RetryModel {\n const events = store()\n const ledger = new SubmissionLedger()\n let capabilities = UNSUPPORTED_CAPABILITIES\n let ready = false\n let busy = false\n let editing = false\n let modified = false\n let editNeedsPreview = false\n let draft = ''\n let failure: OperationFailure | undefined\n let expectedRevision = 0\n let expectedInputRevision = ''\n let ownerSession = ''\n let ownerMessage = ''\n let call = 0\n let snapshot: RetrySnapshot = build()\n\n function build(): RetrySnapshot {\n return {\n controlsRetry: controlsFor(capabilities, ready, host).retry,\n controlsContent: ready && capabilities.retryContent === true,\n busy,\n editing,\n modified,\n draft,\n sessionId: ownerSession,\n messageId: ownerMessage,\n ...failure === undefined ? {} : { failure },\n }\n }\n\n function publish(): void {\n snapshot = build()\n events.emit()\n }\n\n function readPreview(value: unknown): RetryPreview {\n if (typeof value !== 'object' || value === null || typeof (value as { branchRevision?: unknown }).branchRevision !== 'number') {\n throw new HostOperationError('session/lifecycle-unavailable')\n }\n const record = value as { branchRevision: number; eligible?: boolean; reason?: string; inputRevision?: unknown }\n const inputRevision = typeof record.inputRevision === 'string' ? record.inputRevision : ''\n const eligible = record.eligible === true\n if ((eligible || record.reason === 'modified') && inputRevision === '') {\n throw new HostOperationError('session/lifecycle-unavailable', 'input-revision')\n }\n return {\n branchRevision: record.branchRevision,\n inputRevision,\n eligible,\n ...typeof record.reason === 'string' ? { reason: record.reason } : {},\n }\n }\n\n async function preview(sessionId: string, id: string, signal: AbortSignal, ticket: number): Promise<RetryPreview | undefined> {\n if (ticket !== call || signal.aborted) return undefined\n if (typeof host.previewRetry !== 'function') throw new HostOperationError('session/lifecycle-unavailable')\n const value = await unwrap(host.previewRetry({ sessionId, messageId: id }))\n if (ticket !== call || signal.aborted) return undefined\n return readPreview(value)\n }\n\n async function callRetry(body: EditRetryRequest, signal: AbortSignal, ticket: number): Promise<void> {\n if (signal.aborted || ticket !== call) throw new HostOperationError('busy', 'aborted')\n if (typeof host.retry !== 'function') throw new HostOperationError('session/lifecycle-unavailable')\n await unwrap(host.retry(body))\n }\n\n function settle(): void {\n if (!ledger.busy) busy = false\n publish()\n }\n\n async function replaySame(signal: AbortSignal): Promise<void> {\n if (signal.aborted) return\n const pending = ledger.pending()\n const ticket = ++call\n busy = true\n failure = undefined\n publish()\n try {\n await ledger.replay(async body => { await callRetry(body, signal, ticket) })\n if (\n pending !== undefined\n && ticket === call\n && !signal.aborted\n && ownerSession === pending.sessionId\n && ownerMessage === pending.messageId\n ) {\n editing = false\n modified = false\n editNeedsPreview = false\n }\n } catch (error) {\n if (ticket === call && !signal.aborted) failure = readFailure(error)\n } finally {\n settle()\n }\n }\n\n function samePending(sessionId: string, id: string): boolean {\n const pending = ledger.pending()\n return pending !== undefined && pending.sessionId === sessionId && pending.messageId === id\n }\n\n return {\n subscribe: events.subscribe,\n getSnapshot: () => snapshot,\n async load() {\n capabilities = await readCapabilities(host)\n ready = true\n publish()\n },\n async beginEdit(sessionId, id, text, signal) {\n if (busy || !controlsFor(capabilities, ready, host).retry || signal.aborted) return\n if (editing && (ownerSession !== sessionId || ownerMessage !== id)) return\n if (ledger.pending() !== undefined) {\n if (!samePending(sessionId, id)) return\n await replaySame(signal)\n return\n }\n const ticket = ++call\n busy = true\n failure = undefined\n modified = false\n editNeedsPreview = false\n ownerSession = sessionId\n ownerMessage = id\n publish()\n try {\n const seen = await preview(sessionId, id, signal, ticket)\n if (seen === undefined) return\n if (signal.aborted || ticket !== call) return\n expectedRevision = seen.branchRevision\n expectedInputRevision = seen.inputRevision\n if (!seen.eligible && (seen.reason !== 'modified' || !capabilities.retryModified)) {\n failure = { code: 'session/retry-blocked', reason: seen.reason ?? 'unknown' }\n return\n }\n modified = !seen.eligible\n draft = text\n editing = true\n } catch (error) {\n if (ticket === call && !signal.aborted) failure = readFailure(error)\n } finally {\n settle()\n }\n },\n setDraft(text) {\n if (!editing || ownerSession === '' || ownerMessage === '') return\n draft = text\n publish()\n },\n cancelEdit() {\n if (busy) return\n editing = false\n modified = false\n editNeedsPreview = false\n publish()\n },\n async sendEdit(sessionId, id, signal, content, confirmed) {\n if (signal.aborted || busy || !controlsFor(capabilities, ready, host).retry) return\n if (!editing || ownerSession !== sessionId || ownerMessage !== id) return\n if (ledger.pending() !== undefined) {\n if (!samePending(sessionId, id)) return\n await replaySame(signal)\n return\n }\n const ticket = ++call\n busy = true\n const refresh = editNeedsPreview || isStaleRetryFailure(failure)\n failure = undefined\n const text = draft\n publish()\n try {\n if (signal.aborted || ticket !== call) return\n if (refresh) {\n // Revalidate both tokens after a conflict; ordinary first sends keep\n // the beginEdit preview, and lost replies still replay exactly above.\n editNeedsPreview = true\n const seen = await preview(sessionId, id, signal, ticket)\n if (seen === undefined) return\n expectedRevision = seen.branchRevision\n expectedInputRevision = seen.inputRevision\n if (!seen.eligible && (seen.reason !== 'modified' || !capabilities.retryModified)) {\n failure = { code: 'session/retry-blocked', reason: seen.reason ?? 'unknown' }\n return\n }\n modified = !seen.eligible\n editNeedsPreview = false\n }\n if (content !== undefined && capabilities.retryContent !== true) throw new HostOperationError('session/lifecycle-unavailable')\n const body = editRetryRequest({\n sessionId,\n messageId: id,\n expectedRevision,\n expectedInputRevision,\n requestId: ids(),\n text,\n ...content === undefined ? {} : { content },\n allowModified: confirmed === true,\n })\n await ledger.submit(body, () => callRetry(body, signal, ticket))\n if (ticket === call && !signal.aborted) {\n editing = false\n modified = false\n editNeedsPreview = false\n }\n } catch (error) {\n const nextFailure = readFailure(error)\n if (isStaleRetryFailure(nextFailure)) editNeedsPreview = true\n if (ticket === call && !signal.aborted) failure = nextFailure\n } finally {\n settle()\n }\n },\n retire(sessionId, messageId) {\n if (ownerSession !== sessionId || ownerMessage !== messageId) return\n call += 1\n editing = false\n modified = false\n editNeedsPreview = false\n failure = undefined\n draft = ''\n if (!ledger.busy) busy = false\n publish()\n },\n cancel() {\n call += 1\n editing = false\n modified = false\n editNeedsPreview = false\n failure = undefined\n if (!ledger.busy) busy = false\n publish()\n },\n }\n}\n\nexport function bindHost(ctx: {\n sessions?: {\n list?: ObservableList\n capabilities?: SessionHost['capabilities']\n create?: (opts?: { workspaceId?: string; cwd?: string; sessionId?: string }) => Promise<unknown>\n previewRetry?: SessionHost['previewRetry']\n retry?: SessionHost['retry']\n }\n uiWorkspace?: {\n openSession?: SessionHost['openSession']\n deleteSession?: SessionHost['deleteSession']\n }\n}): SessionHost {\n const sessions = ctx.sessions\n const workspace = ctx.uiWorkspace\n const empty: ObservableList = {\n getSnapshot: () => ({ ids: [], byId: {}, phase: 'ready' }),\n subscribe: () => () => {},\n }\n return {\n list: sessions?.list ?? empty,\n ...typeof sessions?.capabilities === 'function' ? { capabilities: () => sessions.capabilities!() } : {},\n ...typeof sessions?.create === 'function'\n ? { create: (opts: { kind: 'free' }) => (sessions.create as (input: { kind: 'free' }) => Promise<unknown>)(opts) }\n : {},\n ...typeof sessions?.previewRetry === 'function' ? { previewRetry: request => sessions.previewRetry!(request) } : {},\n ...typeof sessions?.retry === 'function' ? { retry: request => sessions.retry!(request) } : {},\n ...typeof workspace?.openSession === 'function' ? { openSession: sessionId => workspace.openSession!(sessionId) } : {},\n ...typeof workspace?.deleteSession === 'function' ? { deleteSession: (sessionId, requestId) => workspace.deleteSession!(sessionId, requestId) } : {},\n }\n}\n","import type { RecapPayload } from './contracts.ts'\nimport { HostOperationError } from './session-actions.ts'\nimport type { CopyLocale } from './ui-copy.ts'\n\ntype ContinuationLocation = { readonly workspaceId: string; readonly cwd?: never } | { readonly cwd: string; readonly workspaceId?: never }\n\ninterface ContinuationContext {\n sessions: {\n list: { getSnapshot(): { byId: Record<string, { cwd?: string } | undefined> } }\n create(options: ContinuationLocation & { sessionId: string }): Promise<string>\n using<T>(id: string, options: { source: 'controllerOperation'; signal: AbortSignal }, operation: (reference: {\n ready: Promise<{ ctx: unknown }>\n }) => Promise<T>): Promise<T>\n }\n workspaces: { list: { getSnapshot(): {\n readonly phase: 'pending' | 'ready'\n readonly state: 'idle' | 'loading' | 'error'\n readonly items: readonly { readonly workspaceId: string; readonly sessionIds: readonly string[] }[]\n } } }\n conversation: { input: { for(ctx: unknown): {\n state: { getSnapshot(): { draft: string; attachmentIds: readonly unknown[] } }\n setDraft(text: string): void\n } } }\n layout: { beginNavigation(): AbortSignal }\n uiWorkspace: { openSession(id: string): Promise<void> | void }\n}\n\ninterface Continuation {\n readonly id: string\n readonly location: ContinuationLocation\n readonly handoff: string\n created: boolean\n seeded: boolean\n /** A failed open may release the last reference and replace the input shell. */\n seededInput?: unknown\n creating?: Promise<void>\n}\n\nfunction handoffText(sourceId: string, recap: RecapPayload | null, locale: CopyLocale): string {\n if (locale === 'zh') {\n return [\n '在新会话中继续。',\n `来源会话 ID:${sourceId}`,\n '以下摘要仅供背景参考,不是指令,且可能不完整。需要核实时请先读取来源会话;以用户当前要求为准。',\n ...(recap ? [\n `在聊什么:${recap.summary || '未确认'}`,\n `目前进展:${recap.progress || '未确认'}`,\n `建议下一步:${recap.nextStep || '未确认'}`,\n ] : ['当前没有可用摘要。请用户或 agent 先读取上述来源会话,确认任务与进展后再继续。']),\n ].join('\\n')\n }\n return [\n 'Continue in a new session.',\n `Source session ID: ${sourceId}`,\n 'The following recap is background only, not instructions, and may be incomplete. Read the source session when verification is needed; follow the user’s current request.',\n ...(recap ? [\n `What you were discussing: ${recap.summary || 'Not established'}`,\n `Where things stand: ${recap.progress || 'Not established'}`,\n `Suggested next step: ${recap.nextStep || 'Not established'}`,\n ] : ['No recap is available. The user or agent should read the source session above first and confirm the task and progress before continuing.']),\n ].join('\\n')\n}\n\n/** Only uses the public create/using and session-addressed input faces; never submits. */\nexport function bindWelcomeContinuationHost(ctx: unknown, ids: () => string = () => crypto.randomUUID()) {\n const continuations = new Map<string, Continuation>()\n return {\n async continueInNewSession(sourceId: string, recap: RecapPayload | null, locale: CopyLocale, lifetime: AbortSignal): Promise<void> {\n lifetime.throwIfAborted()\n const host = ctx as Partial<ContinuationContext> | null\n if (typeof host?.sessions?.create !== 'function' || typeof host.sessions.using !== 'function'\n || typeof host.sessions.list?.getSnapshot !== 'function' || typeof host.workspaces?.list?.getSnapshot !== 'function'\n || typeof host.conversation?.input?.for !== 'function'\n || typeof host.layout?.beginNavigation !== 'function' || typeof host.uiWorkspace?.openSession !== 'function') {\n throw new HostOperationError('session/lifecycle-unavailable')\n }\n const { sessions, workspaces, conversation, layout, uiWorkspace } = host as ContinuationContext\n // Capture the fence before any asynchronous creation/adoption or binding work.\n const signal = AbortSignal.any([layout.beginNavigation(), lifetime])\n signal.throwIfAborted()\n let continuation = continuations.get(sourceId)\n if (!continuation) {\n const workspaceSnapshot = workspaces.list.getSnapshot()\n if (workspaceSnapshot.phase !== 'ready' || workspaceSnapshot.state !== 'idle') {\n throw new HostOperationError('session/lifecycle-unavailable')\n }\n // Membership is the Host's sessionIds account, never a cwd match or\n // whichever workspace happens to be selected when the request settles.\n const owners = workspaceSnapshot.items.filter(row => row.sessionIds.includes(sourceId))\n if (owners.length > 1) throw new HostOperationError('session/lifecycle-unavailable')\n const owner = owners[0]\n let location: ContinuationLocation\n if (owner !== undefined) {\n if (!owner.workspaceId.trim()) throw new HostOperationError('session/lifecycle-unavailable')\n location = { workspaceId: owner.workspaceId }\n } else {\n // A confirmed ungrouped source stays ungrouped in its own directory.\n const cwd = sessions.list.getSnapshot()?.byId?.[sourceId]?.cwd\n if (typeof cwd !== 'string' || !cwd.trim()) throw new HostOperationError('session/lifecycle-unavailable')\n location = { cwd }\n }\n const id = ids()\n if (!id || id === sourceId) throw new HostOperationError('session/lifecycle-unavailable')\n continuation = { id, location, handoff: handoffText(sourceId, recap, locale), created: false, seeded: false }\n continuations.set(sourceId, continuation)\n }\n const target = continuation\n if (!target.created) {\n // Keep the preallocated id even if the Host created it but its reply was lost.\n // Concurrent clicks share creation; each caller still owns its navigation fence.\n target.creating ??= (async () => {\n const created = await sessions.create({ ...target.location, sessionId: target.id })\n if (created !== target.id) throw new HostOperationError('session/lifecycle-unavailable')\n target.created = true\n })().finally(() => { target.creating = undefined })\n await target.creating\n }\n signal.throwIfAborted()\n await sessions.using(target.id, { source: 'controllerOperation', signal }, async reference => {\n const binding = await reference.ready\n signal.throwIfAborted()\n if (!binding?.ctx) throw new HostOperationError('session/lifecycle-unavailable')\n const input = conversation.input.for(binding.ctx)\n if (typeof input?.setDraft !== 'function' || typeof input.state?.getSnapshot !== 'function') {\n throw new HostOperationError('session/lifecycle-unavailable')\n }\n const state = input.state.getSnapshot()\n if (typeof state?.draft !== 'string' || !Array.isArray(state.attachmentIds)) {\n throw new HostOperationError('session/lifecycle-unavailable')\n }\n signal.throwIfAborted()\n if (state.attachmentIds.length || (state.draft !== '' && !(target.seeded && state.draft === target.handoff))) {\n throw new HostOperationError('session/retry-conflict', 'modified')\n }\n if (!target.seeded || target.seededInput !== input) {\n input.setDraft(target.handoff)\n target.seeded = true\n target.seededInput = input\n }\n // openSession owns a fresh navigation; do not test our old fence after it.\n signal.throwIfAborted()\n await uiWorkspace.openSession(target.id)\n })\n // Only failed attempts reuse the target. A later welcome-back activity\n // must create a genuinely new session rather than reopening this child.\n if (continuations.get(sourceId) === target) continuations.delete(sourceId)\n },\n }\n}\n","/**\n * Client models for the continue ghost and the welcome-back card.\n * Business state lives here, not in React state, mirroring session-actions.ts.\n */\nimport {\n CONFIG_READ_ENDPOINT,\n CONFIG_WRITE_ENDPOINT,\n CONTINUE_SUGGEST_ENDPOINT,\n TEMP_WORKSPACE_CHANNEL,\n WELCOME_BACK_COMPACT_ENDPOINT,\n WELCOME_BACK_PREPARE_ENDPOINT,\n type ConfigPatch,\n type ConfigView,\n type RecapPayload,\n type WelcomeBackCompactValue,\n type WelcomeBackPrepareValue,\n} from './contracts.ts'\nimport { HostOperationError, readFailure, unwrap } from './session-actions.ts'\nimport type { CopyLocale, OperationFailure } from './ui-copy.ts'\nimport { bindWelcomeContinuationHost } from './welcome-continuation.ts'\n\nexport interface PresenceRpc {\n call(channel: string, endpoint: string, payload: unknown, signal?: AbortSignal): Promise<unknown>\n}\n\nexport interface PresenceHost {\n readonly rpc?: PresenceRpc\n /** Native commands use the target session's composed capabilities. */\n readonly compactContext?: (sessionId: string, signal: AbortSignal) => Promise<void>\n readonly continueInNewSession?: (sessionId: string, recap: RecapPayload | null, locale: CopyLocale, signal: AbortSignal) => Promise<void>\n}\n\n/** Narrow the plugin client's connection face without redeclaring the Context type. */\nexport function bindPresenceHost(ctx: unknown): PresenceHost {\n const client = ctx as {\n connection?: { rpc?: PresenceRpc }\n sessions?: {\n using?: <T>(id: string, options: { source: 'controllerOperation'; signal: AbortSignal }, operation: (reference: {\n ready: Promise<{ session: { command(line: string): Promise<unknown> } }>\n }) => Promise<T>) => Promise<T>\n }\n }\n return {\n ...bindWelcomeContinuationHost(ctx),\n ...(typeof client.connection?.rpc?.call === 'function' ? { rpc: client.connection.rpc } : {}),\n ...(typeof client.sessions?.using === 'function' ? {\n compactContext: async (sessionId: string, signal: AbortSignal) => {\n await client.sessions!.using!(sessionId, { source: 'controllerOperation', signal }, async reference => {\n const binding = await reference.ready\n signal.throwIfAborted()\n const result = await unwrap(binding.session.command('/compact')) as { matched?: boolean } | undefined\n // matched is command admission, NOT a successful compaction. The\n // native command/done node owns the eventual outcome in the chat.\n if (result?.matched !== true) throw new HostOperationError('session-manager/unavailable')\n })\n },\n } : {}),\n }\n}\n\nfunction requireRpc(host: PresenceHost): PresenceRpc {\n if (typeof host.rpc?.call !== 'function') throw new HostOperationError('session/lifecycle-unavailable')\n return host.rpc\n}\n\nasync function callPresence<T>(host: PresenceHost, endpoint: string, payload: unknown, signal?: AbortSignal): Promise<T> {\n const raw = await unwrap(requireRpc(host).call(TEMP_WORKSPACE_CHANNEL, endpoint, payload, signal))\n return raw as T\n}\n\ninterface Listener {\n (): void\n}\n\nfunction store() {\n const listeners = new Set<Listener>()\n return {\n subscribe(listener: Listener): () => void {\n listeners.add(listener)\n return () => { listeners.delete(listener) }\n },\n emit(): void {\n for (const listener of listeners) listener()\n },\n }\n}\n\n/* ------------------------------------------------------------------ */\n/* Continue ghost */\n/* ------------------------------------------------------------------ */\n\nexport interface ContinueSessionState {\n /** undefined until the first resolve settles; null means show nothing. */\n readonly text?: string | null\n /** Active-branch sequence this text belongs to; absent while a turn is still open. */\n readonly seq?: number\n /** The latest turn is still open, so the shipped placeholder stays. */\n readonly pending?: true\n /** Empty fixed text uses the localized default once a turn has ended. */\n readonly fallback?: true\n}\n\nconst EMPTY_CONTINUE: ContinueSessionState = {}\n\nexport interface ContinueModel {\n subscribe(listener: Listener): () => void\n /** Stable per-session snapshot identity for useSyncExternalStore selectors. */\n getSnapshot(sessionId: string): ContinueSessionState\n /** Resolve the suggestion for the latest ended turn. Safe to call on every mount. */\n load(sessionId: string): void\n /** The previous turn ended: drop the cached line so the next load generates once. */\n invalidate(sessionId: string): void\n /** Drop every cached line and revoke every pending reply on config changes. */\n invalidateAll(): void\n cancel(): void\n}\n\nexport function createContinueModel(host: PresenceHost): ContinueModel {\n const events = store()\n const states = new Map<string, ContinueSessionState>()\n const inflight = new Map<string, AbortController>()\n const lifetime = new AbortController()\n let empty = EMPTY_CONTINUE\n\n function read(sessionId: string): ContinueSessionState {\n return states.get(sessionId) ?? empty\n }\n function write(sessionId: string, next: ContinueSessionState): void {\n if (lifetime.signal.aborted) return\n states.set(sessionId, next)\n events.emit()\n }\n\n return {\n subscribe: events.subscribe,\n getSnapshot: read,\n load(sessionId) {\n if (sessionId === '' || lifetime.signal.aborted || inflight.has(sessionId)) return\n const current = read(sessionId)\n // A settled seq-less line is final (fixed text, fallback, empty model\n // line); a pending answer is not — the host saw an open turn, so an\n // explicit load must be able to re-ask once it has ended. Without this\n // a stranded turn or a missed running edge would pin the ghost forever.\n if (current.text !== undefined && current.seq === undefined && current.pending !== true) return\n const ticket = new AbortController()\n inflight.set(sessionId, ticket)\n const signal = AbortSignal.any([lifetime.signal, ticket.signal])\n void callContinueSuggest(host, sessionId, current.text ? current.seq : undefined, signal)\n .then(value => {\n if (signal.aborted || inflight.get(sessionId) !== ticket) return\n write(sessionId, value)\n })\n .catch(() => {\n // A rejected RPC is not a settled suggestion: the server owner may\n // have cancelled while our signal stayed active. Preserve the\n // snapshot without emitting, so explicit loads can retry and a\n // mounted empty composer does not start an automatic retry loop.\n })\n .finally(() => {\n if (inflight.get(sessionId) === ticket) inflight.delete(sessionId)\n })\n },\n invalidate(sessionId) {\n if (sessionId === '') return\n inflight.get(sessionId)?.abort()\n inflight.delete(sessionId)\n if (!states.has(sessionId)) return\n states.delete(sessionId)\n events.emit()\n },\n invalidateAll() {\n for (const ticket of inflight.values()) ticket.abort()\n inflight.clear()\n states.clear()\n empty = {}\n events.emit()\n },\n cancel() {\n lifetime.abort()\n for (const ticket of inflight.values()) ticket.abort()\n inflight.clear()\n states.clear()\n },\n }\n}\n\nasync function callContinueSuggest(\n host: PresenceHost,\n sessionId: string,\n knownSeq: number | undefined,\n signal: AbortSignal,\n): Promise<ContinueSessionState> {\n const value = await callPresence<{ text?: unknown; seq?: unknown; pending?: unknown; fallback?: unknown }>(host, CONTINUE_SUGGEST_ENDPOINT, {\n sessionId,\n ...knownSeq === undefined ? {} : { knownSeq },\n }, signal)\n const text = typeof value?.text === 'string' && value.text.trim() !== '' ? value.text : null\n const seq = typeof value?.seq === 'number' && Number.isSafeInteger(value.seq) && value.seq >= 0 ? value.seq : undefined\n return {\n text,\n ...seq === undefined ? {} : { seq },\n ...value?.pending === true ? { pending: true as const } : {},\n ...value?.fallback === true ? { fallback: true as const } : {},\n }\n}\n\n/* ------------------------------------------------------------------ */\n/* Bundle settings (config.read / config.write) */\n/* ------------------------------------------------------------------ */\n\nexport interface PresenceConfigSnapshot {\n readonly phase: 'loading' | 'ready' | 'unavailable'\n readonly values?: ConfigView\n readonly saving: boolean\n /** Set briefly after a write is confirmed by a re-read (the write itself may drop with the reloading fiber). */\n readonly saved: boolean\n readonly failure?: OperationFailure\n}\n\nexport interface PresenceConfigModel {\n subscribe(listener: Listener): () => void\n getSnapshot(): PresenceConfigSnapshot\n load(): Promise<void>\n save(patch: ConfigPatch): Promise<void>\n cancel(): void\n}\n\n/**\n * A host that predates the agent-action flags returns a config view without\n * them, and a malformed one may carry a non-boolean. Both normalize to\n * false: an absent or unusable flag must never read as granted. Only a real\n * boolean true keeps the permission on.\n */\nfunction normalizeConfigView(view: ConfigView): ConfigView {\n return {\n ...view,\n allowSelfFork: view.allowSelfFork === true,\n allowSendMessage: view.allowSendMessage === true,\n }\n}\n\nexport function createPresenceConfigModel(host: PresenceHost, delay: (ms: number) => Promise<void> = ms => new Promise(resolve => setTimeout(resolve, ms))): PresenceConfigModel {\n const events = store()\n const lifetime = new AbortController()\n let phase: PresenceConfigSnapshot['phase'] = 'loading'\n let values: ConfigView | undefined\n let saving = false\n let saved = false\n let failure: OperationFailure | undefined\n let snapshot: PresenceConfigSnapshot = build()\n let readGeneration = 0\n /** Several settings rows share this model; collapse concurrent reads into one call. */\n let inflightLoad: Promise<void> | undefined\n\n function build(): PresenceConfigSnapshot {\n return {\n phase,\n ...values === undefined ? {} : { values },\n saving,\n saved,\n ...failure === undefined ? {} : { failure },\n }\n }\n function publish(): void {\n snapshot = build()\n events.emit()\n }\n function sameRoute(\n current: ConfigView['model'] | undefined,\n value: unknown,\n ): boolean {\n const route = value as ConfigView['model'] | undefined\n if (current === null || current === undefined) return route === null || route === undefined\n return route !== null && route !== undefined && current.provider === route.provider && current.model === route.model\n && current.reasoningEffort === route.reasoningEffort\n }\n function same(view: ConfigView | undefined, patch: ConfigPatch): boolean {\n if (view === undefined) return false\n return Object.entries(patch).every(([key, value]) => {\n if (key === 'model' || key === 'ghostModel' || key === 'judgeModel' || key === 'handoffModel') return sameRoute(view[key], value)\n return view[key as keyof ConfigView] === value\n })\n }\n\n async function doLoad() {\n const generation = ++readGeneration\n try {\n const view = await callPresence<ConfigView>(host, CONFIG_READ_ENDPOINT, {}, lifetime.signal)\n if (lifetime.signal.aborted || generation !== readGeneration) return\n values = normalizeConfigView(view)\n phase = 'ready'\n failure = undefined\n } catch (error) {\n if (lifetime.signal.aborted || generation !== readGeneration) return\n phase = 'unavailable'\n failure = readFailure(error)\n }\n publish()\n }\n\n return {\n subscribe: events.subscribe,\n getSnapshot: () => snapshot,\n load() {\n inflightLoad ??= doLoad().finally(() => { inflightLoad = undefined })\n return inflightLoad\n },\n async save(patch) {\n if (saving || lifetime.signal.aborted) return\n saving = true\n ++readGeneration\n saved = false\n failure = undefined\n publish()\n try {\n await callPresence<ConfigView>(host, CONFIG_WRITE_ENDPOINT, { patch }, lifetime.signal)\n } catch {\n // The host fiber reloads with the new config mid-write; confirm by re-reading.\n }\n try {\n for (let attempt = 0; attempt < 10 && !lifetime.signal.aborted; attempt++) {\n await delay(400)\n let view: ConfigView\n try {\n view = normalizeConfigView(await callPresence<ConfigView>(host, CONFIG_READ_ENDPOINT, {}, lifetime.signal))\n } catch (error) {\n // A config edit can temporarily remove the RPC while its Host\n // instance is replaced. One failed read is not a failed save.\n if (lifetime.signal.aborted || attempt === 9) throw error\n continue\n }\n if (same(view, patch)) {\n ++readGeneration\n values = normalizeConfigView(view)\n phase = 'ready'\n saved = true\n saving = false\n publish()\n return\n }\n }\n throw new HostOperationError('transport', 'unknown')\n } catch (error) {\n if (lifetime.signal.aborted) return\n saving = false\n failure = readFailure(error)\n publish()\n }\n },\n cancel() {\n lifetime.abort()\n },\n }\n}\n\n\n/* ------------------------------------------------------------------ */\n/* Welcome-back card */\n/* ------------------------------------------------------------------ */\n\nexport interface WelcomeBackCardState {\n readonly sessionId: string\n readonly idleMinutes: number\n readonly lastResponseAt: number\n readonly recap: RecapPayload | null\n readonly compactSuggested: boolean\n readonly compactAvailable: boolean\n /** Host-resolved threshold so the client can flip the suggestion on live as the idle clock crosses it. */\n readonly compactMinutes: number\n}\n\nexport interface WelcomeBackSnapshot {\n /** Present while this session's card is visible. */\n readonly card?: WelcomeBackCardState\n readonly compactBusy: boolean\n readonly continueBusy?: boolean\n /** Native command accepted; its own chat node reports success or failure. */\n readonly compactCommandSent?: boolean\n /** null = compacted but the host gave no token count. */\n readonly compactedTokens?: number | null\n readonly compactReason?: 'busy' | 'unavailable' | 'nothing'\n readonly failure?: OperationFailure\n}\n\nconst EMPTY_WELCOME_BACK: WelcomeBackSnapshot = { compactBusy: false }\n\nexport interface WelcomeBackModel {\n subscribe(listener: Listener): () => void\n /** Stable per-session snapshot identity for useSyncExternalStore selectors. */\n getSnapshot(sessionId: string): WelcomeBackSnapshot\n /** Ask the host whether this session deserves the card; events call this on return. */\n check(sessionId: string): Promise<void>\n /** Re-evaluate cached cards and dismissed marks after confirmed threshold changes. */\n invalidate(): void\n dismiss(sessionId: string): void\n compact(sessionId: string): Promise<void>\n continueInNewSession(sessionId: string, locale: CopyLocale): Promise<void>\n cancel(): void\n}\n\nexport function createWelcomeBackModel(\n host: PresenceHost,\n ids: () => string = () => crypto.randomUUID(),\n minIntervalMs = 10_000,\n): WelcomeBackModel {\n const events = store()\n const lifetime = new AbortController()\n /** Sessions already answered for one exact lastResponseAt; new activity re-arms the card. */\n const settled = new Map<string, number>()\n const checkedAt = new Map<string, number>()\n const capMarks = (map: Map<string, number>) => {\n while (map.size > 64) map.delete(map.keys().next().value!)\n }\n /** Per-session card plus its live compact operation fields. */\n const states = new Map<string, {\n card: WelcomeBackCardState\n compactBusy: boolean\n continueBusy?: boolean\n continueAbort?: AbortController\n compactCommandSent?: boolean\n compactedTokens: number | null | undefined\n compactReason: WelcomeBackSnapshot['compactReason']\n failure: OperationFailure | undefined\n }>()\n /** Stable snapshot per session, rebuilt only when its fields change. */\n const snapshots = new Map<string, WelcomeBackSnapshot>()\n const inflight = new Map<string, AbortController>()\n\n function read(sessionId: string): WelcomeBackSnapshot {\n return snapshots.get(sessionId) ?? EMPTY_WELCOME_BACK\n }\n function publish(sessionId: string): void {\n const state = states.get(sessionId)\n if (state === undefined) {\n snapshots.delete(sessionId)\n } else {\n snapshots.set(sessionId, {\n card: state.card,\n compactBusy: state.compactBusy,\n continueBusy: state.continueBusy === true,\n compactCommandSent: state.compactCommandSent === true,\n ...state.compactedTokens === undefined ? {} : { compactedTokens: state.compactedTokens },\n ...state.compactReason === undefined ? {} : { compactReason: state.compactReason },\n ...state.failure === undefined ? {} : { failure: state.failure },\n })\n }\n events.emit()\n }\n\n return {\n subscribe: events.subscribe,\n getSnapshot: read,\n async check(sessionId) {\n if (sessionId === '' || lifetime.signal.aborted || states.has(sessionId)) return\n const now = Date.now()\n const last = checkedAt.get(sessionId) ?? 0\n if (now - last < minIntervalMs) return\n if (inflight.has(sessionId)) return\n checkedAt.set(sessionId, now)\n capMarks(checkedAt)\n const ticket = new AbortController()\n inflight.set(sessionId, ticket)\n const signal = AbortSignal.any([lifetime.signal, ticket.signal])\n try {\n const value = await callPresence<WelcomeBackPrepareValue>(host, WELCOME_BACK_PREPARE_ENDPOINT, {\n sessionId,\n ...settled.has(sessionId) ? { knownLastResponseAt: settled.get(sessionId) } : {},\n }, signal)\n if (signal.aborted || inflight.get(sessionId) !== ticket || states.has(sessionId) || value.show !== true) return\n if (value.sessionId !== sessionId) return\n if (settled.get(sessionId) === value.lastResponseAt) return\n states.set(sessionId, {\n card: {\n sessionId,\n idleMinutes: value.idleMinutes,\n lastResponseAt: value.lastResponseAt,\n recap: value.recap,\n compactSuggested: value.compactSuggested,\n compactAvailable: value.compactAvailable,\n compactMinutes: value.compactMinutes,\n },\n compactBusy: false,\n compactedTokens: undefined,\n compactReason: undefined,\n failure: undefined,\n })\n publish(sessionId)\n } catch {\n // A failed or unavailable prepare stays silent: the card is a courtesy, never a blocker.\n } finally {\n if (inflight.get(sessionId) === ticket) inflight.delete(sessionId)\n }\n },\n invalidate() {\n for (const ticket of inflight.values()) ticket.abort()\n inflight.clear()\n checkedAt.clear()\n settled.clear()\n // Explicit operations keep ownership until they settle; configuration\n // refresh must not abort a user's chosen compaction or navigation.\n for (const [sessionId, state] of states) {\n if (state.compactBusy || state.continueBusy) continue\n states.delete(sessionId)\n snapshots.delete(sessionId)\n }\n events.emit()\n },\n dismiss(sessionId) {\n inflight.get(sessionId)?.abort()\n inflight.delete(sessionId)\n const state = states.get(sessionId)\n if (state === undefined) return\n state.continueAbort?.abort()\n settled.set(sessionId, state.card.lastResponseAt)\n capMarks(settled)\n states.delete(sessionId)\n publish(sessionId)\n },\n async compact(sessionId) {\n const state = states.get(sessionId)\n if (state === undefined || state.compactBusy || state.continueBusy || lifetime.signal.aborted) return\n state.compactBusy = true\n state.failure = undefined\n state.compactReason = undefined\n publish(sessionId)\n try {\n if (host.compactContext !== undefined) {\n await host.compactContext(sessionId, lifetime.signal)\n if (lifetime.signal.aborted || states.get(sessionId) !== state) return\n state.compactBusy = false\n state.compactCommandSent = true\n publish(sessionId)\n return\n }\n const value = await callPresence<WelcomeBackCompactValue>(host, WELCOME_BACK_COMPACT_ENDPOINT, {\n sessionId: state.card.sessionId,\n requestId: ids(),\n }, lifetime.signal)\n if (lifetime.signal.aborted || states.get(sessionId) !== state) return\n state.compactBusy = false\n if (value.compacted) state.compactedTokens = value.shadowedTokens\n else state.compactReason = value.reason\n publish(sessionId)\n } catch (error) {\n if (lifetime.signal.aborted || states.get(sessionId) !== state) return\n state.compactBusy = false\n state.failure = readFailure(error)\n publish(sessionId)\n }\n },\n async continueInNewSession(sessionId, locale) {\n const state = states.get(sessionId)\n if (state === undefined || state.compactBusy || state.continueBusy || lifetime.signal.aborted) return\n state.continueBusy = true\n state.continueAbort = new AbortController()\n state.failure = undefined\n publish(sessionId)\n try {\n if (host.continueInNewSession === undefined) throw new HostOperationError('session/lifecycle-unavailable')\n await host.continueInNewSession(sessionId, state.card.recap, locale,\n AbortSignal.any([lifetime.signal, state.continueAbort.signal]))\n if (lifetime.signal.aborted || states.get(sessionId) !== state) return\n settled.set(sessionId, state.card.lastResponseAt)\n capMarks(settled)\n states.delete(sessionId)\n publish(sessionId)\n } catch (error) {\n if (lifetime.signal.aborted || states.get(sessionId) !== state) return\n state.continueBusy = false\n if (!(error instanceof Error && error.name === 'AbortError')) state.failure = readFailure(error)\n publish(sessionId)\n }\n },\n cancel() {\n lifetime.abort()\n inflight.clear()\n states.clear()\n snapshots.clear()\n settled.clear()\n checkedAt.clear()\n },\n }\n}\n","/**\n * The hero-row Auto-continue option: a chip that opens a three-mode menu on a\n * blank session and locks once the session starts. Mirrors the delegation\n * chip's revision discipline: stale reads never roll the chip back, a 'stale'\n * rejection refetches, and 'session-locked' explains itself in the tooltip.\n */\nimport { IconChevronDownOutlineRegular, IconRefreshOutlineRegular, Menu, Pill, Tooltip } from '@deepseek-ai/dsh-client-ui-primitives'\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport {\n AUTO_CONTINUE_STATUS_ENDPOINT,\n AUTO_CONTINUE_UPDATE_ENDPOINT,\n type AutoContinueMode,\n type AutoContinueStatus,\n} from './contracts.ts'\nimport { FREE_CHAT_ROOT } from './styles.ts'\nimport { uiText, type CopyLocale } from './ui-copy.ts'\n\nclass RpcError extends Error {\n readonly code: string\n constructor(code: string, message: string) {\n super(message)\n this.name = 'RpcError'\n this.code = code\n }\n}\n\nasync function rpc<T>(call: (endpoint: string, payload: unknown) => Promise<unknown>, endpoint: string, payload: unknown): Promise<T> {\n const result = await call(endpoint, payload) as { ok: true; value: T } | { ok: false; error?: { code?: string; message?: string } } | undefined\n if (!result || result.ok !== true) {\n const failed = result && 'error' in result ? result.error : undefined\n throw new RpcError(failed?.code ?? 'unknown', failed?.message ?? '')\n }\n return result.value\n}\n\nexport interface AutoContinueSessionSnapshotLike {\n openState?: string\n running?: boolean\n blank?: boolean\n awaitingFirstTurn?: boolean\n pendingSubmissions?: readonly unknown[]\n}\n\nexport interface AutoContinueOptionProps {\n sessionId: string\n call: (endpoint: string, payload: unknown) => Promise<unknown>\n /** Host connection-generation subscription; refetches on reconnect. */\n subscribeGeneration?: (listener: () => void) => (() => void) | undefined\n /** Host per-session selector hook; a cold→open transition triggers a refetch. */\n useSession?: <T>(selector: (snapshot: AutoContinueSessionSnapshotLike) => T) => T\n locale: CopyLocale\n}\n\ntype Notice = '' | 'autoContinueStale' | 'autoContinueFailed' | 'autoContinueLocked'\n\nconst MODES: readonly AutoContinueMode[] = ['off', 'cautious', 'bold']\n\nexport function AutoContinueOption({ sessionId, call, subscribeGeneration, useSession, locale }: AutoContinueOptionProps) {\n const [status, setStatus] = useState<AutoContinueStatus>()\n const [saving, setSaving] = useState(false)\n const [notice, setNotice] = useState<Notice>('')\n const [open, setOpen] = useState(false)\n const generationRef = useRef(0)\n const readSeqRef = useRef(0)\n const openState = useSession?.(snapshot => snapshot.openState)\n const sessionRunning = useSession?.(snapshot => snapshot.running === true)\n const sessionBlank = useSession?.(snapshot => snapshot.blank)\n const submitting = useSession?.(snapshot => snapshot.awaitingFirstTurn === true || (snapshot.pendingSubmissions?.length ?? 0) > 0)\n\n const load = useCallback(async () => {\n const generation = generationRef.current\n const seq = ++readSeqRef.current\n try {\n const next = await rpc<AutoContinueStatus>(call, AUTO_CONTINUE_STATUS_ENDPOINT, { sessionId })\n if (generationRef.current !== generation || seq !== readSeqRef.current) return\n setStatus(prev => prev && prev.sessionId === next.sessionId && next.revision < prev.revision ? prev : next)\n } catch {\n // A failed refetch keeps the last known state; the chip stays put.\n }\n }, [call, sessionId])\n\n useEffect(() => {\n generationRef.current += 1\n readSeqRef.current += 1\n setStatus(undefined)\n setSaving(false)\n setNotice('')\n setOpen(false)\n }, [sessionId])\n\n useEffect(() => { void load() }, [load, openState, sessionRunning, sessionBlank])\n\n useEffect(() => {\n const off = subscribeGeneration?.(() => { void load() })\n const win = typeof window === 'undefined' ? undefined : window\n const onFocus = () => { void load() }\n win?.addEventListener('focus', onFocus)\n return () => { off?.(); win?.removeEventListener('focus', onFocus) }\n }, [load, subscribeGeneration])\n\n useEffect(() => {\n if (!notice) return\n const timer = setTimeout(() => setNotice(''), 4000)\n return () => clearTimeout(timer)\n }, [notice])\n\n const choose = useCallback(async (mode: AutoContinueMode) => {\n if (!status || saving || status.locked || sessionBlank === false || sessionRunning || submitting || mode === status.mode) return\n const generation = generationRef.current\n readSeqRef.current += 1\n setSaving(true)\n setNotice('')\n try {\n const next = await rpc<AutoContinueStatus>(call, AUTO_CONTINUE_UPDATE_ENDPOINT, {\n sessionId, mode, expectedRevision: status.revision,\n })\n if (generationRef.current !== generation) return\n setStatus(next)\n } catch (reason) {\n if (generationRef.current !== generation) return\n if (reason instanceof RpcError && (reason.code === 'stale' || reason.code === 'session-locked')) {\n setNotice(reason.code === 'stale' ? 'autoContinueStale' : 'autoContinueLocked')\n void load()\n } else {\n setNotice('autoContinueFailed')\n }\n } finally {\n if (generationRef.current === generation) setSaving(false)\n }\n }, [call, load, saving, sessionId, status, sessionBlank, sessionRunning, submitting])\n\n if (!status || status.role === 'executor' || sessionBlank === false) return null\n const mode = status.mode\n const locked = status.locked || sessionRunning === true || submitting === true\n const tooltip = locked\n ? uiText(locale, 'autoContinueLocked')\n : notice\n ? uiText(locale, notice)\n : uiText(locale, 'autoContinueTooltip')\n const modeKey = mode === 'cautious' ? 'autoContinueCautious' : mode === 'bold' ? 'autoContinueBold' : 'autoContinueOff'\n const label = `${uiText(locale, 'autoContinue')} · ${uiText(locale, modeKey)}`\n return (\n <span className={`${FREE_CHAT_ROOT} smac-option`}>\n <Menu\n open={open}\n align=\"end\"\n portal\n listClassName={FREE_CHAT_ROOT}\n selectedId={mode}\n items={MODES.map(value => ({\n id: value,\n label: uiText(locale, value === 'off' ? 'autoContinueOff' : value === 'cautious' ? 'autoContinueCautious' : 'autoContinueBold'),\n }))}\n onSelect={id => {\n setOpen(false)\n void choose(id as AutoContinueMode)\n }}\n onClose={() => setOpen(false)}\n anchor={(\n <Tooltip label={tooltip} side=\"bottom\" gap={4}>\n <Pill\n className={`smac-chip${mode !== 'off' ? ' smac-chip-on' : ''}`}\n active={mode !== 'off'}\n aria-haspopup=\"menu\"\n aria-expanded={open}\n aria-label={label}\n disabled={locked || saving}\n onClick={() => setOpen(current => !current)}\n >\n <IconRefreshOutlineRegular />\n <span className=\"smac-chip-label\">{label}</span>\n <IconChevronDownOutlineRegular className=\"smac-chevron\" />\n </Pill>\n </Tooltip>\n )}\n />\n {notice ? <span role=\"status\" className=\"smac-note\">{uiText(locale, notice)}</span> : null}\n </span>\n )\n}\n","import type { ContextFormed } from '@deepseek-ai/dsh-llm'\nimport { modelRouteOverride, type ModelRoute } from '@klarkxy/dsh-model-route'\n\n/**\n * The canonical home is @klarkxy/dsh-model-route; re-exported here so existing\n * plugin-kit consumers keep compiling.\n */\nexport type { ModelRoute }\n\n/** Public, browser-safe contracts. Host implementations stay in their owning packages. */\nexport type ProducerSourceKind = `plugin:${string}`\nexport type ProducerMessageSource = { kind: ProducerSourceKind; plugin: string } & ContextFormed\n\n/**\n * V4 sessions persist the producing extension in `kind`; the retired generic\n * `plugin` wrapper is not admitted. Each feature plugin declares its own kind.\n */\ndeclare module '@deepseek-ai/dsh-llm' {\n interface MessageSourceMap {\n [kind: ProducerSourceKind]: ProducerMessageSource\n }\n}\n\nexport function producerMessageSource(plugin: string): ProducerMessageSource {\n return { kind: `plugin:${plugin}`, plugin }\n}\n\nexport type RpcResult<T = unknown> = { ok: true; value: T } | { ok: false; error: { code: string; message: string } }\nexport const CHAT_EVENTS_SLOT = 'dsh-editor.chat.events'\nexport interface EvidenceRef { sessionId: string; seq: number; kind: 'user' | 'tool' | 'turn' | 'manual'; excerpt?: string }\nexport interface TaskContract {\n id: string\n sessionId: string\n sourceVersion: string\n revision: number\n goal: string\n deliverables: string[]\n inScope: string[]\n outOfScope: string[]\n constraints: string[]\n acceptance: string[]\n assumptions: string[]\n questions: string[]\n evidence: EvidenceRef[]\n readiness: 'pending' | 'clear-request' | 'user-confirmed' | 'disclosed-assumptions' | 'cancelled' | 'stale'\n updatedAt: number\n}\nexport interface TaskCheckpoint {\n id: string\n sessionId: string\n sourceVersion: string\n contractVersion?: number\n fromSeq: number\n toSeq: number\n revision: number\n status: 'running' | 'completed' | 'failed' | 'cancelled'\n items: Array<{ label: string; state: 'pending' | 'verified' | 'failed'; evidence: EvidenceRef[] }>\n constraints: string[]\n nextAction: string\n createdAt: number\n}\nexport type KnowledgeScope = { kind: 'global' } | { kind: 'project'; projectId: string }\nexport type KnowledgeKind = 'preference' | 'project-fact' | 'decision' | 'vocabulary' | 'activity' | 'lesson'\n/** Descriptive context, never an executable instruction or authorization. */\nexport interface ContextKnowledge {\n subject: string\n domain: string\n key: string\n aliases: string[]\n observedAt: number\n /** The user's own time expression, not an inferred completion date. */\n eventTime?: string\n activityStatus?: 'planned' | 'in-progress' | 'blocked' | 'paused' | 'completed' | 'cancelled' | 'unknown'\n}\n/** A scoped method. Observations remain candidates until explicitly accepted. */\nexport interface ProcedureKnowledge {\n origin: 'instruction' | 'observation'\n goal: string\n when: string[]\n steps: string[]\n avoid: string[]\n verify: string[]\n}\nexport interface MemoryRecord {\n id: string\n revision: number\n scope: KnowledgeScope\n kind: KnowledgeKind\n status: 'candidate' | 'active' | 'rejected' | 'superseded' | 'revoked' | 'deleted'\n title: string\n content: string\n tags: string[]\n evidence: EvidenceRef[]\n exceptions: string[]\n source: 'user' | 'memory' | 'dream' | 'self-improvement'\n context?: ContextKnowledge\n procedure?: ProcedureKnowledge\n createdAt: number\n updatedAt: number\n expiresAt?: number\n supersedes?: string[]\n /** Exact record revisions behind a derived candidate; revalidated on adoption. */\n basis?: Array<{ id: string; revision: number }>\n}\nexport type NewMemoryRecord = Omit<MemoryRecord, 'id' | 'revision' | 'createdAt' | 'updatedAt'>\nexport interface MemoryQuery { scope: KnowledgeScope; query?: string; kinds?: KnowledgeKind[]; statuses?: MemoryRecord['status'][]; limit?: number }\nexport interface MemoryMutationOptions { signal?: AbortSignal; isCurrent?: () => boolean }\nexport interface MemoryService {\n list(query: MemoryQuery): Promise<MemoryRecord[]>\n create(record: NewMemoryRecord, options?: MemoryMutationOptions): Promise<MemoryRecord>\n update(id: string, patch: Partial<Pick<MemoryRecord, 'title' | 'content' | 'tags' | 'exceptions' | 'status' | 'expiresAt'>>, expectedRevision: number, options?: MemoryMutationOptions): Promise<MemoryRecord>\n /** Explicit user promotion, persisted atomically on the same record; preserves expiry and evidence. */\n promoteToGlobal(id: string, expectedRevision: number, options?: MemoryMutationOptions): Promise<MemoryRecord>\n remove(id: string, expectedRevision: number, options?: MemoryMutationOptions): Promise<void>\n recall(query: MemoryQuery): Promise<MemoryRecord[]>\n}\n\n/**\n * The session creation metadata the host snapshots when it creates a delegated child\n * thread. Mirrors `CreateAgentOptions.meta` in `@deepseek-ai/dsh-agent`; it is durable\n * session data, so it survives a restart and needs no ancestry walk.\n */\nexport interface SubagentSessionLike {\n readonly header?: {\n readonly parentSession?: unknown\n readonly origin?: unknown\n readonly delegationDepth?: unknown\n readonly isSeeded?: unknown\n readonly classification?: unknown\n }\n}\n\n/**\n * True when `session` is a delegated child thread rather than a human-driven top-level\n * conversation.\n *\n * A message's `source.kind === 'user'` cannot answer this: a lead agent's dispatch prompt\n * is delivered as the child's own user message, so delegated work is indistinguishable\n * from a person typing once you only look at the message. Plugins use this to keep\n * automatic writes and derived model calls on top-level sessions.\n */\nexport function isSubagentSession(session: unknown): boolean {\n const header = (session as SubagentSessionLike | null | undefined)?.header\n if (!header || typeof header !== 'object') return false\n if (header.origin === 'subagent' || Number(header.delegationDepth ?? 0) > 0) return true\n // Native human forks also persist parentSession for history lineage. A fork's\n // seeded header distinguishes it from legacy children whose parent is the\n // only marker. Native rc.2 forks omit depth; patched hosts may persist zero.\n // Explicit delegation and unknown metadata still keep the child guard.\n const humanFork = header.isSeeded === true\n && (header.delegationDepth === undefined || header.delegationDepth === 0)\n && header.origin === undefined\n && (header.classification === undefined || header.classification === 'ordinary' || header.classification === 'free')\n return Boolean(header.parentSession) && !humanFork\n}\n\n/** Project keys come only from the host-validated session directory, never client input. */\nexport function projectIdFromCwd(cwd: string | undefined): string | undefined {\n if (typeof cwd !== 'string') return undefined\n const normalized = cwd.trim().replaceAll('\\\\', '/')\n if (!normalized) return undefined\n return normalized === '/' || /^[A-Za-z]:\\/$/.test(normalized) ? normalized : normalized.replace(/\\/+$/, '')\n}\n\n/**\n * One settings owner's Remote stream. Typert accepts either case in an RPC\n * segment, so the Cordis service key and the wire namespace use the same\n * Pascal segment. The scope's first letter stays uppercase.\n */\nexport interface ModelSettingsChangesIdentity {\n readonly service: string\n readonly namespace: string\n}\n\n/** `@klarkxy/dsh-git-commit` becomes `KlarkxyDshGitCommitModelSettingsChanges`. */\nexport function modelSettingsChangesIdentity(packageName: string): ModelSettingsChangesIdentity {\n const scoped = /^@([^/]+)\\/(.+)$/.exec(packageName)\n const body = scoped ? `${scoped[1]}/${scoped[2]}` : packageName\n const parts = body.split(/[^A-Za-z0-9]+/).filter(Boolean)\n if (!parts.length) throw new Error('Model settings package name has no RPC segment')\n const segment = `${parts.map(part => part.charAt(0).toUpperCase() + part.slice(1)).join('')}ModelSettingsChanges`\n if (!/^[A-Z][A-Za-z0-9]*$/.test(segment)) throw new Error(`Model settings sync name is not an RPC segment: ${segment}`)\n return { service: segment, namespace: segment }\n}\n\n/**\n * Repository extension: a native web provider announces that its local\n * availability changed. Kind is `search` or `fetch`; id is the provider id.\n * Listeners refresh management state and must not treat this as a network probe.\n */\nexport const WEB_PROVIDER_AVAILABILITY_EVENT = 'web/provider-availability-updated' as const\n\n/**\n * Optional display metadata a provider may attach when it registers directly\n * with `ctx.web`. Execution and credentials stay with the provider; this object\n * is display-only and must never carry secret values.\n */\nexport interface DshWebManagementDescriptor {\n readonly id: string\n readonly label: string\n readonly description: string\n readonly defaultBaseURL?: string\n readonly credentialRef?: string\n /** True when the key is shared with another surface. The page must not delete it. */\n readonly credentialShared?: boolean\n /** Optional notice naming the settings surface that owns a shared credential. */\n readonly credentialHint?: string\n readonly billing: 'request' | 'model-and-tools' | 'none' | 'unknown'\n /** Optional provider-supplied billing summary. */\n readonly pricing?: string\n /** Public HTTPS page explaining provider charges. */\n readonly pricingUrl?: string\n /** Public HTTPS page where the user can create an API key. */\n readonly signupUrl?: string\n /** Plugin that owns configuration. Native providers keep their settings there. */\n readonly configurationOwner?: string\n /** Explicit settings link supplied by the provider, never inferred from its id. */\n readonly configurationUrl?: string\n /** Fixed legacy route migrated by a bundle-owned adapter; not used by native plugins. */\n readonly legacyId?: string\n}\n\n/**\n * Host Creator agent-preset id (`agentPresets.composedPreset`).\n * Plugins that gate Creator-only tools or prompt sections compare against this.\n */\nexport const CREATOR_PRESET_ID = 'cordis'\n\n/**\n * Shared \"Session Management\" settings section id. The section is provided by\n * shared infrastructure (see `registerSessionSettingsItem` in `client-utils`),\n * not by any one business plugin: every participant registers only a row into\n * {@link SESSION_SETTINGS_ITEM_SLOT}, so any enabled subset yields the same page.\n */\nexport const SESSION_SETTINGS_SECTION_ID = 'session-manager'\n\n/**\n * Child list slot declared by the shared Session Management page. Neutral\n * naming on purpose: participants never import each other, they only\n * contribute `{id, order}` rows into this slot while the page is alive.\n */\nexport const SESSION_SETTINGS_ITEM_SLOT = 'dsh.session-settings.item'\n\n/**\n * Host-owned nav icon seat: a root-scoped list where each entry's `id` must\n * equal the `settings.section` id it decorates. Owner props are\n * `{size, active}`; icons stay `aria-hidden` so the section label remains the\n * accessible name. Contributors into a shared section may register the same\n * icon `id` with different priorities — the ledger keeps every entry while the\n * host renders one icon per section.\n */\nexport const SETTINGS_SECTION_ICON_SLOT = 'settings.section.icon'\n\n/* Shared auxiliary-model default. Feature plugins may store a global default\n * route that fills the tier between their own saved override and the live\n * session model. The durable state is a root-context singleton (like the\n * shared session-settings page): it exists while any participant retains it\n * and is never owned by a business plugin. See `auxiliary-model.ts`. */\n\n/** Root context service key holding the shared auxiliary-model state. */\nexport const AUXILIARY_MODEL_SERVICE = 'dshAuxiliaryModel'\n\n/** Authenticated host-RPC channel for get/set of the shared default. */\nexport const AUXILIARY_MODEL_CHANNEL = '/dsh-auxiliary-model'\n\n/** Model-settings namespace under which the shared default is published. */\nexport const AUXILIARY_MODEL_NS = '@klarkxy/dsh-plugin-kit/auxiliary-model'\n\n/**\n * Typert identity of the shared change stream. Mounted on the root context\n * with ownerNs filtering, so frames only carry {@link AUXILIARY_MODEL_NS}.\n */\nexport const AUXILIARY_MODEL_CHANGES_IDENTITY = modelSettingsChangesIdentity('@klarkxy/dsh-plugin-kit')\n\n/** The value the shared default persists: `model: null` means follow the live session/host model. */\nexport interface AuxiliaryModelDefaults {\n readonly revision: number\n readonly model: ModelRoute | null\n}\n\n/** Shape of the root singleton; produced and owned by `auxiliary-model.ts`. */\nexport interface AuxiliaryModelShared {\n readonly ready: Promise<void>\n snapshot(): AuxiliaryModelDefaults\n}\n\nfunction sharedAuxiliaryModel(host: unknown): AuxiliaryModelShared | undefined {\n const root = (host as { root?: unknown } | undefined)?.root as { get?(name: string, strict?: boolean): unknown } | undefined\n try {\n const shared = root?.get?.(AUXILIARY_MODEL_SERVICE, false) as AuxiliaryModelShared | undefined\n return shared && typeof shared.snapshot === 'function' ? shared : undefined\n } catch { return undefined }\n}\n\n/**\n * Synchronously read the shared auxiliary default; `undefined` only when no\n * participant retains the singleton or the default is legitimately unset.\n * An initialization or snapshot failure propagates: silently falling back to\n * a different model after a storage error would spend the wrong budget.\n */\nexport function getAuxiliaryModel(host: unknown): ModelRoute | undefined {\n const shared = sharedAuxiliaryModel(host)\n if (!shared) return undefined\n return modelRouteOverride(shared.snapshot().model ?? undefined)\n}\n","import type { Context } from '@deepseek-ai/cordis'\nimport { createElement, useCallback, useEffect, useRef, useSyncExternalStore, type ReactNode } from 'react'\nimport { SESSION_SETTINGS_ITEM_SLOT, SESSION_SETTINGS_SECTION_ID, SETTINGS_SECTION_ICON_SLOT } from './contracts.ts'\n\n/** Fixed pause for failing background reads; manual work is never replayed. */\nexport function createPluginReadGate(now: () => number = Date.now) {\n let pausedUntil = 0\n let epoch = 0\n return {\n canRead: () => now() >= pausedUntil,\n reset: () => { epoch++; pausedUntil = 0 },\n async run<T>(read: () => Promise<T>): Promise<T> {\n const current = epoch\n try {\n const value = await read()\n if (current === epoch) pausedUntil = 0\n return value\n } catch (error) {\n // The native Connection error is an Error with this exact HTTP text.\n // Authentication, application failures, and cancellation stay distinct.\n const message = error instanceof Error ? error.message : ''\n if (current === epoch && (/(?:^|\\s)transport failure for .+: HTTP (?:404|405|503)\\b/.test(message)\n || (error instanceof TypeError && /^(?:Failed to fetch|fetch failed|NetworkError when attempting to fetch resource\\.?)$/i.test(message)))) {\n pausedUntil = now() + 30_000\n }\n throw error\n }\n },\n }\n}\n\nexport interface NativeSurfaceClient {\n sessions: {\n binding?(sessionId: string): { eventSource: { subscribe(listener: () => void): () => void } } | undefined\n }\n uiWorkspace: { current?: { getSnapshot(): { sessionId: string } | undefined; subscribe(listener: () => void): () => void } }\n uiSession: { adapter: { current: { getSnapshot(): { key?: string }; subscribe(listener: () => void): () => void } } }\n locale: { getSnapshot(): { active: string }; subscribe(listener: () => void): () => void }\n connection?: { generation?: { subscribe(listener: () => void): () => void } }\n}\n\n/** The Editor retains its manuscript session separately; native DSH exposes the main-view binding. */\nexport function selectedSessionId(client: Pick<NativeSurfaceClient, 'uiWorkspace' | 'uiSession'>): string {\n const workspace = client.uiWorkspace?.current\n return workspace\n ? workspace.getSnapshot()?.sessionId ?? ''\n : client.uiSession.adapter.current.getSnapshot().key ?? ''\n}\n\n/**\n * Owner props are data the host composed, never a Cordis context: reading an\n * undeclared property off one throws instead of returning undefined, which\n * would crash the slot entry and abdicate its cell for good. Tolerate a\n * throwing read so a mistaken prop degrades to \"not supplied\".\n */\nfunction read(source: unknown, key: string): unknown {\n if (source === null || typeof source !== 'object') return undefined\n try {\n return (source as Record<string, unknown>)[key]\n } catch {\n return undefined\n }\n}\n\nfunction readString(source: unknown, key: string): string | undefined {\n const value = read(source, key)\n return typeof value === 'string' ? value : undefined\n}\n\n/** Owner props win; native settings only supplies close, so resolve its selected session. */\nexport function useNativeSeat(client: NativeSurfaceClient, props?: unknown) {\n const current = useSyncExternalStore(\n useCallback((fn: () => void) => (client.uiWorkspace?.current ?? client.uiSession.adapter.current).subscribe(fn), [client]),\n useCallback(() => selectedSessionId(client), [client]),\n () => '',\n )\n const language = useSyncExternalStore(\n useCallback((fn: () => void) => client.locale.subscribe(fn), [client]),\n useCallback(() => client.locale.getSnapshot().active, [client]),\n () => 'en',\n )\n const sessionId = readString(props, 'sessionId') ?? readString(read(props, 'owner'), 'sessionId') ?? current\n const requestedLocale = read(props, 'locale') ?? read(read(props, 'owner'), 'locale') ?? language\n return { sessionId, locale: (String(requestedLocale).startsWith('zh') ? 'zh' : 'en') as 'zh' | 'en',\n hidden: read(props, 'hidden') === true || read(read(props, 'owner'), 'hidden') === true }\n}\n\n/** Refresh on native log boundaries/reconnect/focus. Read-only settling is bounded to an observed job. */\nexport function useFeatureRefresh(\n client: NativeSurfaceClient, sessionId: string, refresh: () => void,\n working = false, enabled = true,\n): void {\n const refreshRef = useRef(refresh)\n refreshRef.current = refresh\n useEffect(() => {\n if (!enabled) return\n let timer: ReturnType<typeof setTimeout> | undefined\n const queue = () => {\n if (typeof document !== 'undefined' && document.visibilityState === 'hidden') return\n clearTimeout(timer)\n timer = setTimeout(() => refreshRef.current(), 150)\n }\n const source = sessionId ? client.sessions.binding?.(sessionId)?.eventSource : undefined\n const stopEvents = source?.subscribe(queue)\n const stopConnection = client.connection?.generation?.subscribe(queue)\n const visibility = () => { if (document.visibilityState === 'visible') queue() }\n window.addEventListener('focus', queue)\n document.addEventListener('visibilitychange', visibility)\n // Details are collapsed by default; opening an existing panel must get current state.\n document.addEventListener('toggle', queue, true)\n return () => {\n clearTimeout(timer)\n stopEvents?.(); stopConnection?.()\n window.removeEventListener('focus', queue)\n document.removeEventListener('visibilitychange', visibility)\n document.removeEventListener('toggle', queue, true)\n }\n }, [client, sessionId, enabled])\n useEffect(() => {\n if (!enabled || !working) return\n let delay = 250\n const until = Date.now() + 300_000\n let timer: ReturnType<typeof setTimeout>\n const tick = () => {\n if (Date.now() >= until) return\n if (document.visibilityState !== 'hidden') refreshRef.current()\n delay = Math.min(delay * 2, 2000)\n timer = setTimeout(tick, delay)\n }\n timer = setTimeout(tick, delay)\n return () => clearTimeout(timer)\n }, [client, sessionId, working, enabled])\n}\n\n/* Shared \"Session Management\" settings page. The page is root-owned shared\n * infrastructure, not a business plugin: any participant alone yields the same\n * section, and participants never import each other. Synchronization crosses\n * separately bundled copies of this helper through the Cordis root context —\n * `root.get`/`root.provide` is the only rendezvous, so no window global or\n * module singleton is needed and no participant depends on another being enabled.\n */\n\n/** A row contributed into the shared Session Management page. */\nexport interface SessionSettingsItemSpec {\n readonly id: string\n readonly order: number\n}\n\n/* Original line icons for settings-section navigation seats. The official\n * `dsh-client-ui-primitives` icon set covers generic glyphs only; these keep\n * the same conventions (16×16 viewBox, 1px stroke, round caps, currentColor)\n * so the plugin set stays visually consistent with the native nav. Colors\n * never appear here: `currentColor` lets the host style the active state, and\n * `aria-hidden` keeps the section label the single accessible name. */\n\n/** Owner props the host's `settings.section.icon` seat hands to its cell. */\nexport interface SettingsSectionIconProps {\n readonly size?: number\n /** Selection state; the nav styles active icons through color, not geometry. */\n readonly active?: boolean\n}\n\ntype IconChild = readonly [tag: string, attrs: Record<string, string | number>]\n\n/** One `<svg>` with the shared icon chrome; children are plain elements. */\nfunction lineIcon(children: IconChild[]) {\n return function SettingsSectionIcon(props: SettingsSectionIconProps): ReactNode {\n return createElement('svg', {\n 'aria-hidden': 'true',\n width: props.size ?? 16,\n height: props.size ?? 16,\n viewBox: '0 0 16 16',\n fill: 'none',\n stroke: 'currentColor',\n strokeWidth: 1,\n strokeLinecap: 'round',\n strokeLinejoin: 'round',\n }, ...children.map(([tag, attrs], index) => createElement(tag, { key: index, ...attrs })))\n }\n}\n\n/** Chat bubble for the shared Session Management section. */\nexport const IconSessionSettings = lineIcon([\n ['path', { d: 'M8.5 13a5.5 5.5 0 0 0 5.5-5.5A5.5 5.5 0 0 0 8.5 2 5.5 5.5 0 0 0 3 7.5a5.48 5.48 0 0 0 .9 3L2.8 12.6a.5.5 0 0 0 .62.62l2.9-.98a5.48 5.48 0 0 0 2.18.76Z' }],\n])\n\n/** Serif-flavoured letter A for the Font section. */\nexport const IconFontSettings = lineIcon([\n ['path', { d: 'M3.3 12.6 7.9 3.1a.5.5 0 0 1 .9 0l4.6 9.5' }],\n ['path', { d: 'M5.2 9.4h6.3' }],\n ['path', { d: 'M2.4 12.6h2.4' }],\n ['path', { d: 'M11.9 12.6h2.4' }],\n])\n\n/** Keyboard for the Shortcuts section. */\nexport const IconKeyboardSettings = lineIcon([\n ['rect', { x: 1.75, y: 4.75, width: 12.5, height: 7.5, rx: 1.2 }],\n ['path', { d: 'M4.5 7.25h0' }],\n ['path', { d: 'M8 7.25h0' }],\n ['path', { d: 'M11.5 7.25h0' }],\n ['path', { d: 'M5.25 9.75h5.5' }],\n])\n\n/** Linked model nodes for the Model Management section. */\nexport const IconModelNetworkSettings = lineIcon([\n ['line', { x1: 10.6, y1: 5.3, x2: 8.8, y2: 7.1 }],\n ['line', { x1: 7.2, y1: 8.9, x2: 5.4, y2: 10.7 }],\n ['circle', { cx: 12, cy: 4, r: 1.9 }],\n ['circle', { cx: 4, cy: 12, r: 1.9 }],\n ['circle', { cx: 8, cy: 8, r: 1.5 }],\n])\n\n/**\n * Contribute the nav icon of a `settings.section` entry. The `settings\n * .section.icon` seat is declared by the host independently of the section\n * list, so the wait runs in parallel: the icon appears as soon as both seats\n * exist and unloading removes it again, restoring the host's default glyph.\n * The `id` must equal the section id; `order`/`priority` mirror `order` so the\n * icon cell sorts like its section and, for shared sections, several\n * contributors can register the same icon id under different priorities\n * without duplicating nav entries.\n */\nexport function registerSettingsSectionIcon(\n ctx: Context,\n sectionId: string,\n order: number,\n component: (props: SettingsSectionIconProps) => ReactNode,\n): () => void {\n const slots = (ctx as unknown as { slots: SessionSettingsSlots }).slots\n return slots.inject(SETTINGS_SECTION_ICON_SLOT, () =>\n slots.register({ name: SETTINGS_SECTION_ICON_SLOT, id: sectionId, order, priority: order }, component))\n}\n\ninterface SessionSettingsSlots {\n inject(key: string, callback: () => Iterable<(() => void) | void> | (() => void) | void): () => void\n register(spec: Record<string, unknown>, render: unknown): () => void\n}\n\ninterface SessionSettingsRoot {\n get(name: string, strict?: boolean): unknown\n provide(name: string, value: unknown): () => void\n readonly slots?: SessionSettingsSlots\n}\n\n/** Private Cordis rendezvous; every bundled copy of this helper resolves the same root service. */\nconst SESSION_SETTINGS_PAGE_SERVICE = 'dshSessionSettingsPage'\n\ninterface SessionSettingsPage {\n retain(): void\n release(): void\n}\n\n/** The page component renders only its declared child list: items paint their own titles and styles. */\nfunction SessionSettingsPageView(props: { renderSlot: (key: string, owner: Record<string, never>) => ReactNode }): ReactNode {\n return props.renderSlot(SESSION_SETTINGS_ITEM_SLOT, {})\n}\n\n/**\n * Acquire the root-owned page service, creating and providing it on first use.\n * One counter covers participants, the section wait and the provider: the last\n * release removes the wait and then the provider synchronously (Cordis deletes\n * the impl before its async disposer awaits), so a later acquire sees a clean\n * get() miss and can re-establish the page.\n */\nfunction acquireSessionSettingsPage(root: SessionSettingsRoot): SessionSettingsPage {\n const existing = root.get(SESSION_SETTINGS_PAGE_SERVICE, false) as SessionSettingsPage | undefined\n if (existing) return existing\n const slots = root.slots as SessionSettingsSlots\n let users = 0\n let stopPage: (() => void) | undefined\n let unprovide: (() => void) | undefined\n const page: SessionSettingsPage = {\n retain() {\n // The reservation is counted before the throwing install, so a failure\n // lets the caller's release() undo it fully instead of leaking the service.\n users += 1\n if (!stopPage) {\n stopPage = slots.inject('settings.section', () => slots.register(\n {\n name: 'settings.section',\n id: SESSION_SETTINGS_SECTION_ID,\n order: 30,\n label: () => {\n const locale = root.get('locale', false) as { getSnapshot?(): { active?: unknown } } | undefined\n return String(locale?.getSnapshot?.().active ?? '').startsWith('zh') ? '会话管理' : 'Session Management'\n },\n children: { [SESSION_SETTINGS_ITEM_SLOT]: { kind: 'list', scope: 'root' } },\n },\n SessionSettingsPageView,\n ))\n }\n },\n release() {\n if (users <= 0) return\n users -= 1\n if (users > 0) return\n // The last contributor tears the section down; collapsing its children\n // declaration clears the item slot for every other bundle as well.\n stopPage?.()\n stopPage = undefined\n unprovide?.()\n },\n }\n unprovide = root.provide(SESSION_SETTINGS_PAGE_SERVICE, page)\n return page\n}\n\n/**\n * Contribute one row to the shared Session Management settings page.\n *\n * `ctx` is the plugin's own context: the row's slot wait unloads with the\n * plugin, while the page itself is retained on the shared root context for as\n * long as any contributor lives. There is no fallback seat — when every\n * contributor is gone the section disappears with the page. Returns a disposer.\n * Shared root-owned infrastructure (the auxiliary-model card) calls this on\n * `ctx.root` so its row, icon and page share are owned by the root lifetime\n * and released by the returned disposer, not by any plugin fiber.\n */\nexport function registerSessionSettingsItem(\n ctx: Context,\n item: SessionSettingsItemSpec,\n component: (props: never) => ReactNode,\n): () => void {\n const slots = (ctx as unknown as { slots: SessionSettingsSlots }).slots\n const root = ctx.root as unknown as SessionSettingsRoot\n const page = acquireSessionSettingsPage(root)\n let stopItem: (() => void) | undefined\n let stopIcon: (() => void) | undefined\n try {\n page.retain()\n stopItem = slots.inject(SESSION_SETTINGS_ITEM_SLOT, () => slots.register({ name: SESSION_SETTINGS_ITEM_SLOT, ...item }, component))\n // Every contributor also waits on the nav-icon seat, registering the same\n // section icon id under its own priority (its row order). Same-id entries\n // coexist on the ledger while the host renders one icon, so no contributor\n // owns the icon and none depends on another for it; the wait lives with\n // this ctx, so it fires now on fresh loads and retro-fills on HMR.\n stopIcon = slots.inject(SETTINGS_SECTION_ICON_SLOT, () => slots.register(\n { name: SETTINGS_SECTION_ICON_SLOT, id: SESSION_SETTINGS_SECTION_ID, order: item.order, priority: item.order },\n IconSessionSettings,\n ))\n } catch (error) {\n // A synchronous failure (for example a duplicate row id or a failing page\n // install) must not pin the shared page for a contributor that never joined.\n stopIcon?.()\n stopItem?.()\n page.release()\n throw error\n }\n // The disposer may be invoked by both ctx.effect and an explicit caller;\n // releasing twice would unbalance the shared refcount.\n let disposed = false\n return () => {\n if (disposed) return\n disposed = true\n stopIcon?.()\n stopItem?.()\n page.release()\n }\n}\n","/**\n * Shared `klarkxy.model-picker` Factory contract.\n *\n * `@klarkxy/dsh-model-picker` registers one root-scoped Component Factory under\n * this name: a searchable model picker with a reasoning-effort slider, built on\n * the same ModelMenu recipe this package ships. Feature plugins opt in by\n * calling `renderFactorySlot('klarkxy.model-picker', props, options)` inside a\n * slot component; when no definition is registered the renderer resolves the\n * caller's `options.fallback`, so each consumer keeps its own native menu as\n * the fallback and gains the shared picker only while the plugin is installed.\n *\n * This entry is pure types and constants — no React, no host imports — so a\n * consumer can `import type` the declaration and the input/local props without\n * depending on the business plugin at runtime. The `SlotFactoryMap` merge is\n * what makes the `renderFactorySlot`/`registerFactory` calls type-check on\n * both sides; import it for the types only.\n */\nimport type { ModelMenuChoice, ModelCatalogFailure } from './catalog.ts'\nimport type { HostObservable } from '@deepseek-ai/dsh-client-ui-slots'\n\n/** Registered Factory name — the `renderFactorySlot`/`registerFactory` key. */\nexport const MODEL_PICKER_FACTORY = 'klarkxy.model-picker'\n/** The one caller-selectable local position: the trigger rendered in place. */\nexport const MODEL_PICKER_ANCHOR_SLOT = 'anchor'\n\n/** Extra row the picker renders above the model groups (pure data; no React). */\nexport interface ModelPickerLeadingItem {\n readonly id: string\n readonly label: string\n readonly selected?: boolean\n}\n\n/** Status banner data the picker renders inside the menu header, above the groups. */\nexport interface ModelPickerStatus {\n /** Whole-request failure text; renders with a retry action. */\n readonly error?: string | null\n /** Advisory row (e.g. the saved route left the catalog); rendered warn-toned, no retry. */\n readonly warning?: string\n /** Whether the owner is loading or selecting (dims the banner). */\n readonly busy?: boolean\n /** Provider-local failures; still usable groups stay selectable. */\n readonly failures?: readonly ModelCatalogFailure[]\n /** Reload action the banner's retry buttons call. */\n readonly retry?: () => void\n}\n\n/**\n * Occurrence input (`renderFactorySlot` `props`). Everything here is data or\n * callbacks — React content travels through the `anchor` local slot instead.\n */\nexport interface ModelPickerProps {\n /** Active UI language; `'zh*'` selects the built-in Chinese copy. */\n readonly locale?: string\n /** Flat catalog choices (grouped internally by provider). */\n readonly choices: readonly ModelMenuChoice[]\n /** Current selection highlight. */\n readonly selected?: { readonly provider: string; readonly model: string }\n /** Model pick; the picker closes after the callback runs. */\n readonly onPick: (route: { provider: string; model: string }) => void\n /** Extra rows above the model groups (e.g. a \"follow default\" row). */\n readonly leading?: readonly ModelPickerLeadingItem[]\n /** Leading-row pick; `undefined` keeps the menu open. */\n readonly onPickLeading?: (id: string) => void\n /** Declared reasoning-effort rows; the slider is hidden while empty. */\n readonly efforts?: ReadonlyArray<{ id: string; name: string }>\n /** Current effort id; `''`/undefined marks the provider-default row. */\n readonly selectedEffort?: string\n /** Effort pick; the menu stays open. `undefined` = provider default. */\n readonly onPickEffort?: (effort: string | undefined) => void\n /** Disables the trigger and every menu action. */\n readonly disabled?: boolean\n /** Trigger caption; the default anchor falls back to localized \"Select model\". */\n readonly triggerLabel?: string\n /** Current effort caption shown after the trigger label (\"model · high\"). */\n readonly triggerEffortLabel?: string\n /** Extra class on the default trigger button. */\n readonly triggerClassName?: string\n /** Show a spinner instead of the chevron while a selection settles. */\n readonly busy?: boolean\n /** Extra class on the portaled menu card. */\n readonly listClassName?: string\n /** Menu opens on the searchable model pane ('model') or the root cells. */\n readonly initialPane?: 'root' | 'model'\n /** Show the search row even for a small catalog. */\n readonly alwaysShowSearch?: boolean\n /** Show the reasoning-effort slider under the model list (default true here). */\n readonly reasoningSlider?: boolean\n /** Status banner rendered inside the menu header (load failures, retry). */\n readonly status?: ModelPickerStatus\n /** Menu open-state changes; the owner may react (e.g. refresh the catalog). */\n readonly onOpenChange?: (open: boolean) => void\n /** Copy overrides; every key is optional. */\n readonly modelLabel?: string\n readonly modelValue?: string\n readonly effortLabel?: string\n readonly defaultEffortLabel?: string\n readonly searchPlaceholder?: string\n readonly emptyLabel?: string\n readonly clearSearchLabel?: string\n readonly retryLabel?: string\n}\n\n/** Props one `anchor` local component receives (plus the framework kit). */\nexport interface ModelPickerAnchorProps {\n /** Mirror of `aria-expanded`; true while the menu is open. */\n readonly open: boolean\n /** Disabled state passed down by the owner. */\n readonly disabled: boolean\n /** Whether a selection is settling; the default anchor shows a spinner. */\n readonly busy: boolean\n /** Resolved trigger caption. */\n readonly label: string\n /** Resolved effort caption appended to the caption, if any. */\n readonly effortLabel?: string\n /** Extra class on the trigger element. */\n readonly className?: string\n /** Anchored-popup marker the picker stamps on the trigger (always 'menu'). */\n readonly 'aria-haspopup'?: 'menu'\n /** Mirror of `open`, for ARIA-compliant custom anchors. */\n readonly 'aria-expanded'?: boolean\n /** Menu element id while the menu is mounted. */\n readonly 'aria-controls'?: string\n /** Resolved accessible name for the trigger. */\n readonly 'aria-label'?: string\n /** Set when the picker is disabled; custom anchors may read it instead of `disabled`. */\n readonly 'aria-disabled'?: boolean\n}\n\ndeclare module '@deepseek-ai/dsh-client-ui-slots' {\n interface SlotFactoryMap {\n /**\n * Reusable model picker: one searchable provider-grouped model list plus an\n * optional reasoning-effort slider. Consumers call `renderFactorySlot` with\n * `ModelPickerProps`; `options.slots.anchor` may supply a custom trigger\n * component typed `ModelPickerAnchorProps`, and `options.fallback` is the\n * menu rendered while no `klarkxy.model-picker` definition is registered.\n */\n 'klarkxy.model-picker': {\n scope: 'root'\n props: ModelPickerProps\n /** Occurrence inject face: the active-locale observable bound as a hook. */\n inject: { hooks: { activeLocale: HostObservable<{ active: string }> } }\n slots: {\n anchor: {\n scope: 'root'\n props: ModelPickerAnchorProps\n }\n }\n locale: 'model-picker'\n }\n }\n interface LocaleNamespaceMap {\n /** Copy owned by @klarkxy/dsh-model-picker. */\n 'model-picker':\n | 'trigger.fallback' | 'trigger.aria' | 'trigger.ariaEffort'\n | 'menu.model' | 'menu.effort' | 'effort.providerDefault'\n | 'search.placeholder' | 'search.clear' | 'search.empty' | 'empty.models'\n | 'status.loading' | 'error.action' | 'action.retry' | 'warning.unroutable'\n }\n}\n","/**\n * Optional shared model picker (`klarkxy.model-picker` Factory).\n *\n * `@klarkxy/dsh-model-picker`, when installed, registers one root-scoped\n * Component Factory under `MODEL_PICKER_FACTORY`: an enhanced model menu with\n * a searchable provider-grouped list and a reasoning-effort slider, built on\n * the same ModelMenu recipe. Consumers keep their own ModelMenu as the\n * `fallback`; when no definition is registered the renderer resolves that\n * fallback verbatim, so the shared picker is strictly opt-in and every saved\n * value keeps its existing write path.\n *\n * `renderFactorySlot` is a framework-composed prop, never a context: the\n * component a plugin registers into any slot receives it automatically, but\n * the plugin must pass it down to whichever child renders the menu (or to the\n * render callback handed to registerSessionSettingsItem).\n *\n * The Factory manages its own open state; a consumer's `open`/`onOpenChange`\n * pair belongs to the fallback menu only and must not be fed to both.\n */\nimport { useEffect, useMemo, useRef, type ReactNode } from 'react'\nimport { IconChevronDownOutlineRegular } from '@deepseek-ai/dsh-client-ui-primitives'\nimport type { RenderFactorySlot } from '@deepseek-ai/dsh-client-ui-slots'\nimport {\n MODEL_PICKER_FACTORY, MODEL_PICKER_ANCHOR_SLOT,\n type ModelPickerAnchorProps, type ModelPickerProps,\n} from '@klarkxy/dsh-model-route/model-picker'\n\nexport {\n MODEL_PICKER_ANCHOR_SLOT,\n MODEL_PICKER_FACTORY,\n type ModelPickerAnchorProps,\n type ModelPickerLeadingItem,\n type ModelPickerProps,\n type ModelPickerStatus,\n} from '@klarkxy/dsh-model-route/model-picker'\nexport type { RenderFactorySlot } from '@deepseek-ai/dsh-client-ui-slots'\n\n/**\n * The trigger every consumer used to hand its own ModelMenu, rebuilt as the\n * factory's `anchor` local component: identical classes and chevron, the menu\n * state coming from the occurrence's props instead of local open state.\n *\n * `ariaLabel` and `title` are the whole accessible name and tooltip (the\n * caller formats \"field: current route\" itself because the factory's resolved\n * caption may intentionally be a short name). The component identity stays\n * put across label changes — a new function would unmount the trigger, and\n * its cleanup would close a menu that `closeOnPick={false}` is keeping open.\n * The latest label, title, and `onClose` are read from refs.\n */\nexport function useModelMenuAnchor(ariaLabel: string, title?: string, onClose?: () => void): (props: ModelPickerAnchorProps) => ReactNode {\n const closeRef = useRef(onClose)\n const labelRef = useRef(ariaLabel)\n const titleRef = useRef(title)\n closeRef.current = onClose\n labelRef.current = ariaLabel\n titleRef.current = title\n return useMemo(() => {\n const ModelPickerTrigger = (props: ModelPickerAnchorProps): ReactNode => {\n /* A real unmount means the factory occurrence left (definition unloaded\n * or the row closed). `onOpenChange` only tracks user-driven opens, so\n * without this the fallback's shared open state could stay true. */\n useEffect(() => () => closeRef.current?.(), [])\n /* The factory injects its own aria set (aria-controls among them) plus\n * the caller's triggerClassName into the local component's props.\n * Forward exactly those attributes — a blanket {...props} spread would\n * leak framework props (including renderFactorySlot) onto the DOM. The\n * caller's label/title win over any injected aria-label; popup semantics\n * default to the mirror of the fallback trigger and yield to injected\n * values when present. */\n const record = props as unknown as Record<string, unknown>\n const injected: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(record)) {\n if (key.startsWith('aria-')) injected[key] = value\n }\n const extraClass = typeof record.className === 'string' ? ` ${record.className}` : ''\n return (\n <button\n type=\"button\"\n className={`dsh-model-menu-trigger${extraClass}`}\n disabled={props.disabled}\n aria-haspopup=\"menu\"\n aria-expanded={props.open}\n {...injected}\n aria-label={labelRef.current}\n title={titleRef.current}\n >\n <span className=\"dsh-model-menu-triggerLabel\">{props.label}</span>\n {props.effortLabel ? <span className=\"dsh-model-menu-triggerEffort\">{props.effortLabel}</span> : null}\n <IconChevronDownOutlineRegular className={`dsh-model-menu-chevron${props.open ? ' dsh-model-menu-chevronOpen' : ''}`} />\n </button>\n )\n }\n return ModelPickerTrigger\n }, [])\n}\n\n/**\n * Render the shared model picker while it is registered; `options.fallback`\n * whenever it is not (plugin absent, disabled, or unloaded).\n *\n * `options.anchor` is optional: the factory ships a default trigger, so only\n * consumers that need their own chrome (custom aria-label, tooltip, class)\n * pass one built with {@link useModelMenuAnchor}. The returned node is never\n * assumed to be the factory's own output — a defensive `?? fallback` covers a\n * renderer that yields null for an unregistered definition.\n */\nexport function renderModelPicker(\n renderFactorySlot: RenderFactorySlot | undefined,\n props: ModelPickerProps,\n options: {\n readonly anchor?: (props: ModelPickerAnchorProps) => ReactNode\n readonly fallback: ReactNode\n },\n): ReactNode {\n if (typeof renderFactorySlot !== 'function') return options.fallback\n const rendered = renderFactorySlot(MODEL_PICKER_FACTORY, props, {\n ...(options.anchor ? { slots: { [MODEL_PICKER_ANCHOR_SLOT]: options.anchor } } : {}),\n fallback: options.fallback,\n })\n return rendered ?? options.fallback\n}\n","import type { TypertRemoteContribution } from '@deepseek-ai/dsh-typert-protocol'\nimport { modelSettingsChangesIdentity, type ModelSettingsChangesIdentity } from './contracts.ts'\n\nexport type ModelSettingsChangeFrame = { kind: 'ready' } | { kind: 'changed'; ns: string; revision: number }\n\n/** This stream carries invalidations only; ready is never a settings snapshot. */\nexport function parseModelSettingsChangeFrame(value: unknown): ModelSettingsChangeFrame {\n if (!value || typeof value !== 'object' || Array.isArray(value)) throw new Error('Invalid model settings change frame')\n const frame = value as Record<string, unknown>\n if (frame.kind === 'ready' && Object.keys(frame).length === 1) return { kind: 'ready' }\n if (frame.kind === 'changed' && Object.keys(frame).length === 3 && typeof frame.ns === 'string' && frame.ns.length > 0\n && typeof frame.revision === 'number' && Number.isSafeInteger(frame.revision) && frame.revision >= 0) {\n return { kind: 'changed', ns: frame.ns, revision: frame.revision }\n }\n throw new Error('Invalid model settings change frame')\n}\n\n/** One owner's contribution. Each package mounts only its own endpoint. */\nexport function modelSettingsChangesRemote(packageName: string, identity: ModelSettingsChangesIdentity = modelSettingsChangesIdentity(packageName)): TypertRemoteContribution {\n return {\n package: packageName,\n descriptors: [{\n id: `${identity.namespace}/watch`,\n service: identity.service,\n namespace: identity.namespace,\n method: 'watch',\n mode: 'stream' as const,\n invocation: { kind: 'direct' as const },\n parameters: [],\n cancellation: { parameter: 'signal' as const },\n result: { mode: 'strict' as const, typeSymbol: 'ModelSettings.ChangeFrame', create: () => ({ parse: parseModelSettingsChangeFrame }) },\n }],\n }\n}\n\ninterface RemoteMountScope {\n remote: { $mount(contribution: TypertRemoteContribution): Promise<() => Promise<void>> }\n effect(callback: () => () => void | Promise<void>): unknown\n}\ninterface RemoteMountContext {\n inject(dependencies: string[], callback: (scope: unknown) => void): unknown\n}\n\n/** Mount from a synchronous apply. Disposal waits for an in-flight mount and\n * then withdraws it, so the contribution cannot outlive the plugin. */\nexport function mountModelSettingsChanges(ctx: RemoteMountContext, packageName: string): void {\n const contribution = modelSettingsChangesRemote(packageName)\n ctx.inject(['remote'], injected => {\n const scope = injected as RemoteMountScope\n const mounting = scope.remote.$mount(contribution)\n void mounting.catch(() => {})\n scope.effect(() => async () => {\n const unmount = await mounting.catch(() => undefined)\n await unmount?.()\n })\n })\n}\n\ninterface StreamItem {\n generation: number\n value: unknown\n signal: AbortSignal\n accept(): void\n}\ninterface ChangeStream extends AsyncIterable<StreamItem> { dispose(): Promise<void> }\ntype OpenChangeStream = (options: {\n name: string\n open(signal: AbortSignal): AsyncIterable<unknown>\n ended(accepted: boolean): Error\n}) => ChangeStream\nexport interface ModelSettingsSubscriberScope {\n remote: { $stream: OpenChangeStream } & Record<string, { watch?(signal: AbortSignal): AsyncIterable<unknown> } | OpenChangeStream | undefined>\n effect(callback: () => () => void | Promise<void>): unknown\n}\nexport interface ModelSettingsSubscriberContext {\n inject(dependencies: string[], callback: (scope: unknown) => void): unknown\n}\nexport interface ModelSettingsSubscriber {\n subscribe(onChange: () => void, onError?: (message: string) => void): () => void\n}\n\n/** Native RemoteStream owns carrier reconnects; no timers or browser transport.\n * A factory shares one logical stream while at least one subscriber remains. */\nexport function createModelSettingsSubscriber(\n ctx: ModelSettingsSubscriberContext,\n packageName: string,\n identity: ModelSettingsChangesIdentity = modelSettingsChangesIdentity(packageName),\n accept: (ns: string) => boolean = ns => ns === packageName,\n): ModelSettingsSubscriber {\n const endpoint = identity\n const listeners = new Set<{ change: () => void; error?: (message: string) => void }>()\n let injection: { dispose(): void | Promise<void> } | undefined\n let current: { stream: ChangeStream; active: boolean } | undefined\n let lifecycle = 0\n let failureMessage: string | undefined\n const report = (message: string) => {\n failureMessage = message\n for (const listener of [...listeners]) {\n try { listener.error?.(message) } catch { /* Isolate page callbacks. */ }\n }\n }\n const invalidate = () => {\n for (const listener of [...listeners]) {\n if (!listeners.has(listener)) continue\n try { listener.change() } catch (error) {\n try { listener.error?.(error instanceof Error ? error.message : String(error)) } catch { /* Isolate callbacks. */ }\n }\n }\n }\n const start = () => {\n const life = ++lifecycle\n injection = ctx.inject(['remote', `remote.${endpoint.namespace}`], injected => {\n if (life !== lifecycle || !listeners.size) return\n const scope = injected as ModelSettingsSubscriberScope\n const service = scope.remote[endpoint.namespace]\n if (!service || !('watch' in service) || !service.watch) { report('Model settings sync service unavailable'); return }\n const watch = service.watch\n const stream = scope.remote.$stream({\n name: 'Model settings sync',\n open: signal => watch(signal),\n ended: accepted => new Error(`Model settings sync stream ended ${accepted ? 'after' : 'before'} ready; refresh or reopen the page`),\n })\n const session = { stream, active: true }\n current = session\n scope.effect(() => () => {\n session.active = false\n if (current === session) {\n current = undefined\n if (life === lifecycle && listeners.size) report('Model settings sync service unavailable')\n }\n return stream.dispose()\n })\n void (async () => {\n let generation: number | undefined\n let ready = false\n try {\n for await (const item of stream) {\n if (!session.active || life !== lifecycle || !listeners.size) break\n if (item.signal.aborted) continue\n if (generation !== item.generation) { generation = item.generation; ready = false }\n const frame = parseModelSettingsChangeFrame(item.value)\n if (frame.kind === 'ready') {\n ready = true\n failureMessage = undefined\n // Accept the validated invalidation baseline, not fetched data.\n // Every current listener queues its own latest settings read.\n item.accept()\n invalidate()\n } else {\n if (!ready) throw new Error('Model settings sync change arrived before ready')\n if (accept(frame.ns)) invalidate()\n }\n }\n } catch (error) {\n if (session.active && life === lifecycle) report(error instanceof Error ? error.message : String(error))\n } finally {\n if (current === session) current = undefined\n session.active = false\n await stream.dispose().catch(() => {})\n }\n })()\n }) as { dispose(): void | Promise<void> }\n queueMicrotask(() => {\n if (life === lifecycle && listeners.size && !current) report('Model settings sync service unavailable')\n })\n }\n return Object.freeze({ subscribe(onChange: () => void, onError?: (message: string) => void) {\n const listener = { change: onChange, error: onError }\n listeners.add(listener)\n if (!injection) start()\n else if (failureMessage) queueMicrotask(() => {\n if (listeners.has(listener) && failureMessage) {\n try { listener.error?.(failureMessage) } catch { /* Isolate callbacks. */ }\n }\n })\n return () => {\n if (!listeners.delete(listener) || listeners.size) return\n lifecycle++\n if (current) { current.active = false; void current.stream.dispose().catch(() => {}) }\n current = undefined\n failureMessage = undefined\n const previous = injection\n injection = undefined\n try { void Promise.resolve(previous?.dispose()).catch(() => {}) } catch { /* Already unloaded. */ }\n }\n } })\n}\n","/**\n * Shared \"default auxiliary model\" settings card.\n *\n * Any number of feature plugins call `registerAuxiliaryModelSettings(ctx)`\n * from their client half; a single card appears as the `auxiliary-model` row\n * of the shared Session Management settings column for as long as at least\n * one participant lives. The card is root-owned shared infrastructure, not a\n * business plugin: every bundled copy of this helper rendezvouses on the same\n * Cordis root service, so no participant depends on another being enabled, the\n * card is mounted once (duplicate row ids would throw), and the last\n * `release()` removes it. The card also retains the shared page itself, so a\n * lone auxiliary plugin still yields the column — participants never depend\n * on another business plugin providing their settings page.\n *\n * The storage side lives in the shared host service behind the plugin-kit RPC\n * channel: `defaults.get` returns `{revision, model}` and `defaults.set`\n * carries `{model, expectedRevision}` with an empty provider/model clearing\n * the override. Cross-window invalidation rides the existing model-settings\n * change stream — no polling is added anywhere in this file.\n */\nimport type { Context } from '@deepseek-ai/cordis'\nimport { Button, IconChevronDownOutlineRegular } from '@deepseek-ai/dsh-client-ui-primitives'\nimport { useCallback, useEffect, useRef, useState, useSyncExternalStore, type ReactNode } from 'react'\nimport {\n readModelCatalog, modelMenuEffortLabel, modelMenuEffortOptions, parseModelMenuChoices, type ModelRoute,\n} from '@klarkxy/dsh-model-route'\nimport { ModelCatalogStatus, ModelMenu, modelMenuCss, useModelCatalog } from '@klarkxy/dsh-model-route/ui'\nimport { officialUiCss } from './official-ui.ts'\nimport { renderModelPicker, useModelMenuAnchor, type RenderFactorySlot } from './model-picker.tsx'\nimport {\n createModelSettingsSubscriber, modelSettingsChangesRemote, type ModelSettingsSubscriber,\n} from './model-settings-client.ts'\nimport { registerSessionSettingsItem } from './client-utils.ts'\nimport {\n AUXILIARY_MODEL_CHANNEL, AUXILIARY_MODEL_CHANGES_IDENTITY, AUXILIARY_MODEL_NS,\n type AuxiliaryModelDefaults, type RpcResult,\n} from './contracts.ts'\n\nconst AUXILIARY_MODEL_PACKAGE = '@klarkxy/dsh-plugin-kit'\n\n/** The stored row; re-exported so card consumers share the contract shape. */\nexport type AuxiliaryModelSnapshot = AuxiliaryModelDefaults\n\n/* The card is one row of the shared Session Management column: the item slot\n * is a root-scope list declared by the shared page, and row ids must be\n * unique. The row sorts ahead of every business participant. */\nexport const AUXILIARY_MODEL_SEAT_ID = 'auxiliary-model'\nexport const AUXILIARY_MODEL_SEAT_ORDER = 55\n\n/** Private Cordis rendezvous; every bundled copy resolves the same root service. */\nconst AUXILIARY_MODEL_CARD_SERVICE = 'dshAuxiliaryModelSettingsCard'\n\n/** Theme-token-only stylesheet: officialUiCss scope plus the shared ModelMenu recipe. */\nexport const auxiliaryModelCss = `${officialUiCss('ams-root')}${modelMenuCss}\n.ams-root .ams-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }\n`\n\nconst auxiliaryCopy = {\n zh: {\n title: '默认辅助模型',\n help: '各辅助功能(如标题生成、摘要)没有单独指定模型时使用的模型;仅影响声明使用它的功能。',\n model: '辅助模型',\n modelDefault: '跟随会话或宿主默认',\n modelHint: '不选择模型时,各功能按自己的规则决定对话模型。',\n effortDefault: '跟随模型默认',\n loading: '正在读取设置…',\n failed: '无法读取模型设置。',\n stale: '设置已被其他窗口更新,请刷新后重试。',\n saveFailed: '保存失败,原设置未更改。请重试。',\n saved: '已保存。',\n retry: '重试',\n refresh: '刷新设置',\n syncUnavailable: '自动刷新不可用,请手动刷新设置。',\n },\n en: {\n title: 'Default Auxiliary Model',\n help: 'The model used by auxiliary features (such as title generation or summarizing) that do not name their own model; only features that opted in are affected.',\n model: 'Auxiliary model',\n modelDefault: 'Follow session or host default',\n modelHint: 'With no model selected, each feature follows its own rules for the conversation model.',\n effortDefault: 'Follow model default',\n loading: 'Loading settings…',\n failed: 'Could not load model settings.',\n stale: 'Settings were changed elsewhere; refresh and retry.',\n saveFailed: 'Save failed; the previous setting was not changed. Try again.',\n saved: 'Saved.',\n retry: 'Retry',\n refresh: 'Refresh settings',\n syncUnavailable: 'Automatic refresh unavailable; refresh settings manually.',\n },\n} as const\ntype AuxiliaryCopy = (typeof auxiliaryCopy)['zh'] | (typeof auxiliaryCopy)['en']\n\n/** A failed RPC keeps its code so the card can translate known rejections. */\nclass AuxiliaryRpcError extends Error {\n constructor(readonly code: string, message: string) { super(message); this.name = 'AuxiliaryRpcError' }\n}\n\n/** The client services this card reads; the shared service passes ctx.root. */\nexport interface AuxiliaryModelClient {\n connection: {\n rpc: { call(channel: string, endpoint: string, payload: unknown): Promise<unknown> }\n generation?: { subscribe(listener: () => void): () => void }\n }\n remote?: { session?: { modelCatalog?: () => Promise<unknown> } }\n locale?: { getSnapshot(): { active: string }; subscribe(listener: () => void): () => void }\n}\n\n/** Host UI language, following live switches with the host's English fallback. */\nfunction useAuxiliaryLocale(client: AuxiliaryModelClient): 'zh' | 'en' {\n const subscribe = useCallback((listener: () => void) => client.locale?.subscribe(listener) ?? (() => {}), [client])\n const snapshot = useCallback(() => client.locale?.getSnapshot().active ?? 'en', [client])\n return String(useSyncExternalStore(subscribe, snapshot, snapshot)).startsWith('zh') ? 'zh' : 'en'\n}\n\nfunction isAbort(error: unknown): boolean {\n return error instanceof Error && (error.name === 'AbortError' || /abort|cancel/i.test(error.message))\n}\n\n/* A revision mismatch is a lost race, not a broken save: the stored row moved\n * past the one the user edited. The host reports it as auxiliary-model/conflict;\n * the message fallback covers older hosts that surfaced it as internal. */\nfunction isStaleRejection(error: unknown): boolean {\n if (!(error instanceof AuxiliaryRpcError)) return false\n return error.code === 'stale' || error.code === 'auxiliary-model/conflict'\n || /changed|revision|reload|stale|conflict/i.test(error.message)\n}\n\nasync function callAuxiliaryRpc<T>(\n client: AuxiliaryModelClient, endpoint: string, payload: unknown = {},\n): Promise<T> {\n const result = await client.connection.rpc.call(AUXILIARY_MODEL_CHANNEL, endpoint, payload) as RpcResult<T> | undefined\n if (!result || result.ok !== true) {\n const error = result && 'error' in result ? result.error : undefined\n throw new AuxiliaryRpcError(error?.code ?? 'unknown', error?.message ?? `RPC ${endpoint} failed`)\n }\n return result.value\n}\n\n/**\n * The shared card. All state comes from the shared host service over the\n * plugin-kit RPC channel; the card only renders the stored row.\n */\nexport function AuxiliaryModelCard({ client, subscribe, renderFactorySlot }: {\n client: AuxiliaryModelClient\n /** Settings-change invalidation; injected for tests without a live stream. */\n subscribe?: (change: () => void, error?: (message: string) => void) => () => void\n /** Framework-composed factory renderer; absent under direct test renders. */\n renderFactorySlot?: RenderFactorySlot\n}): ReactNode {\n const language = useAuxiliaryLocale(client)\n const text: AuxiliaryCopy = auxiliaryCopy[language]\n const [settings, setSettings] = useState<AuxiliaryModelSnapshot>()\n const loadCatalog = useCallback(() => readModelCatalog(client), [client])\n const subscribeCatalog = useCallback(\n (change: () => void) => client.connection.generation?.subscribe(change), [client])\n const catalogState = useModelCatalog(loadCatalog, { subscribe: subscribeCatalog })\n const { refresh: refreshCatalog } = catalogState\n const choices = parseModelMenuChoices(catalogState.catalog, settings?.model ?? undefined)\n const [menuOpen, setMenuOpen] = useState(false)\n const [error, setError] = useState<'' | 'failed' | 'stale' | 'saveFailed'>('')\n const [note, setNote] = useState(false)\n const [busy, setBusy] = useState(false)\n const [syncError, setSyncError] = useState('')\n const operation = useRef({ epoch: 0, active: false, reading: false, writing: false, pending: false })\n const refreshRef = useRef<() => void>(() => {})\n\n const refresh = () => {\n const state = operation.current\n if (!state.active) return\n if (state.reading || state.writing) { state.pending = true; return }\n state.pending = false; state.reading = true; setBusy(true)\n const epoch = state.epoch\n void callAuxiliaryRpc<AuxiliaryModelSnapshot>(client, 'defaults.get').then(next => {\n if (state.active && state.epoch === epoch && !state.pending) {\n setSettings(next); setError('')\n }\n }).catch(reason => {\n if (state.active && state.epoch === epoch && !state.pending && !isAbort(reason)) setError('failed')\n }).finally(() => {\n if (!state.active || state.epoch !== epoch) return\n state.reading = false; setBusy(false)\n if (state.pending) refreshRef.current()\n })\n }\n refreshRef.current = refresh\n useEffect(() => {\n const state = operation.current\n state.epoch++; state.active = true; state.reading = false; state.writing = false; state.pending = false\n setBusy(false); setSettings(undefined); setError(''); setNote(false)\n refreshRef.current()\n return () => { state.active = false; state.epoch++ }\n }, [client])\n // Cross-window invalidation rides the shared model-settings change stream.\n useEffect(() => {\n setSyncError('')\n let live = true\n let stop: (() => void) | undefined\n try {\n stop = subscribe?.(() => {\n if (live) { setSyncError(''); refreshCatalog(); refreshRef.current() }\n }, message => { if (live) setSyncError(message) })\n } catch {\n // A subscriber that cannot even attach degrades to manual refresh.\n if (live) setSyncError('Model settings sync service unavailable')\n }\n return () => { live = false; try { stop?.() } catch { /* detach is best-effort */ } }\n }, [subscribe, refreshCatalog])\n\n const save = useCallback((model: ModelRoute | null) => {\n const state = operation.current\n if (!settings || !state.active || state.writing || state.reading) return\n state.writing = true\n const epoch = state.epoch\n setBusy(true); setNote(false); setError('')\n void callAuxiliaryRpc<AuxiliaryModelSnapshot>(client, 'defaults.set', {\n model: model ?? { provider: '', model: '' },\n expectedRevision: settings.revision,\n }).then(next => {\n if (state.active && state.epoch === epoch) { setSettings(next); setNote(true); refreshCatalog() }\n }).catch(reason => {\n if (state.active && state.epoch === epoch) {\n setError(isStaleRejection(reason) ? 'stale' : 'saveFailed')\n }\n }).finally(() => {\n if (!state.active || state.epoch !== epoch) return\n state.writing = false; setBusy(false)\n if (state.pending) refreshRef.current()\n })\n }, [client, settings, refreshCatalog])\n\n const locked = busy\n const current = settings?.model ?? { provider: '', model: '' }\n const follow = !current.provider || !current.model\n const selected = follow ? undefined : choices.find(item => item.provider === current.provider && item.model === current.model)\n const efforts = follow ? [] : modelMenuEffortOptions(selected, current.reasoningEffort)\n const currentLabel = follow ? text.modelDefault : selected?.label ?? `${current.provider} / ${current.model}`\n const selectedEffort = efforts.find(item => item.id === (current.reasoningEffort || ''))\n const effortName = selectedEffort ? modelMenuEffortLabel(selectedEffort, language) : undefined\n // The shared picker's anchor mirrors the trigger the fallback menu renders.\n const anchor = useModelMenuAnchor(`${text.model}: ${settings ? currentLabel : ''}`, undefined,\n () => setMenuOpen(false))\n if (!settings) {\n return <section className=\"ams-root dsh-ui-card\" data-testid=\"auxiliary-model-settings\">\n <span className=\"dsh-ui-heading\">{text.title}</span>\n <p className=\"dsh-ui-help\">{text.help}</p>\n {error\n ? <p role=\"alert\" className=\"dsh-ui-error\">{text[error]}</p>\n : <p role=\"status\" className=\"dsh-ui-hint\">{text.loading}</p>}\n {syncError && <p role=\"status\" className=\"dsh-ui-hint\">{text.syncUnavailable}</p>}\n <div className=\"dsh-ui-actions\">\n <Button variant=\"ghost\" size=\"sm\" disabled={locked} onClick={() => refreshRef.current()}>{text.retry}</Button>\n </div>\n </section>\n }\n\n\n return <section className=\"ams-root dsh-ui-card\" data-testid=\"auxiliary-model-settings\">\n <span className=\"dsh-ui-heading\">{text.title}</span>\n <p className=\"dsh-ui-help\">{text.help}</p>\n <div className=\"dsh-ui-field\">\n <span className=\"dsh-ui-label\">{text.model}</span>\n <ModelCatalogStatus state={catalogState} locale={language} />\n {renderModelPicker(renderFactorySlot, {\n locale: language,\n disabled: locked,\n busy: locked,\n onOpenChange: next => setMenuOpen(next && !locked),\n listClassName: 'ams-root ams-menu-portal',\n choices,\n selected: follow ? undefined : { provider: current.provider, model: current.model },\n onPick: picked => save({ provider: picked.provider, model: picked.model }),\n leading: [{ id: 'default', label: text.modelDefault, selected: follow }],\n onPickLeading: () => save(null),\n efforts,\n selectedEffort: current.reasoningEffort || '',\n onPickEffort: effort => save(follow\n ? null\n : { provider: current.provider, model: current.model, ...(effort ? { reasoningEffort: effort } : {}) }),\n triggerLabel: currentLabel,\n triggerEffortLabel: !follow && efforts.length ? (effortName ?? text.effortDefault) : undefined,\n modelLabel: text.model,\n modelValue: currentLabel,\n defaultEffortLabel: text.effortDefault,\n }, {\n anchor,\n fallback: <ModelMenu\n locale={language}\n open={menuOpen && !locked}\n onOpenChange={next => setMenuOpen(next && !locked)}\n listClassName=\"ams-root ams-menu-portal\"\n anchor={<button type=\"button\" className=\"dsh-model-menu-trigger\" disabled={locked}\n aria-label={`${text.model}: ${currentLabel}`}>\n <span className=\"dsh-model-menu-triggerLabel\">{currentLabel}</span>\n {!follow && efforts.length ? <span className=\"dsh-model-menu-triggerEffort\">{effortName ?? text.effortDefault}</span> : null}\n <IconChevronDownOutlineRegular className={`dsh-model-menu-chevron${menuOpen && !locked ? ' dsh-model-menu-chevronOpen' : ''}`} />\n </button>}\n choices={choices}\n selected={follow ? undefined : { provider: current.provider, model: current.model }}\n onPick={picked => save({ provider: picked.provider, model: picked.model })}\n leading={[{ id: 'default', label: text.modelDefault, selected: follow }]}\n onPickLeading={() => save(null)}\n efforts={efforts}\n selectedEffort={current.reasoningEffort || ''}\n onPickEffort={effort => save(follow\n ? null\n : { provider: current.provider, model: current.model, ...(effort ? { reasoningEffort: effort } : {}) })}\n modelLabel={text.model}\n modelValue={currentLabel}\n defaultEffortLabel={text.effortDefault}\n />,\n })}\n <span className=\"dsh-ui-hint\">{text.modelHint}</span>\n </div>\n <div className=\"ams-row\">\n {syncError && <p role=\"status\" className=\"dsh-ui-hint\">{text.syncUnavailable}</p>}\n {error && <p role=\"alert\" className=\"dsh-ui-error\">{text[error]}</p>}\n {note && <p role=\"status\" className=\"dsh-ui-notice\">{text.saved}</p>}\n {error || syncError ? (\n <Button variant=\"ghost\" size=\"sm\" disabled={locked} onClick={() => refreshRef.current()}>{text.refresh}</Button>\n ) : null}\n </div>\n </section>\n}\n\ninterface AuxiliaryRoot {\n get(name: string, strict?: boolean): unknown\n provide(name: string, value: unknown): () => void\n inject(deps: string[], callback: (scope: unknown) => void): AuxiliaryFiber\n}\ninterface AuxiliaryFiber {\n dispose(): void | Promise<void>\n}\ninterface AuxiliaryRemoteMountScope {\n remote: { $mount(contribution: unknown): Promise<unknown> }\n effect(cb: () => () => void | Promise<void>): unknown\n}\n\n/* The client-side stream descriptor mount, serialized through one root\n * coordinator. Its tail carries mounts and unmounts in strict order: a new\n * mount cannot start while a previous fiber's unmount is in flight, and a\n * lease that closes before its continuation runs never mounts at all. The\n * coordinator leaves the store only when the queue is drained and no lease\n * is active — a fast teardown→re-acquire chains onto the same tail instead\n * of hitting \"already registered\" or overlapping a second mount. */\ninterface AuxiliaryWatchLease {\n fiber: AuxiliaryFiber | undefined\n closed: boolean\n done(): void\n}\ninterface AuxiliaryWatchCoordinator {\n tail: Promise<void>\n active: number\n mount(): AuxiliaryWatchLease\n}\nconst AUXILIARY_MODEL_WATCH_COORDINATOR = 'dshAuxiliaryModelWatchCoordinator'\n\nfunction acquireWatchCoordinator(root: AuxiliaryRoot): AuxiliaryWatchCoordinator {\n const existing = root.get(AUXILIARY_MODEL_WATCH_COORDINATOR, false) as AuxiliaryWatchCoordinator | undefined\n if (existing) return existing\n let unprovide: (() => void) | undefined\n const coordinator: AuxiliaryWatchCoordinator = {\n tail: Promise.resolve(),\n active: 0,\n mount() {\n coordinator.active += 1\n const previousTail = coordinator.tail\n const lease: AuxiliaryWatchLease = {\n closed: false,\n done() {\n if (lease.closed) return\n lease.closed = true\n coordinator.active -= 1\n const owned = lease.fiber\n lease.fiber = undefined\n // The unmount joins the tail every later mount waits on.\n coordinator.tail = coordinator.tail\n .then(() => Promise.resolve(owned?.dispose()).catch(() => {}))\n // Unprovide only once the queue is really drained: a newer lease\n // already queued on this coordinator must keep it alive.\n void coordinator.tail.then(() => {\n if (coordinator.active > 0) return\n try {\n if (root.get(AUXILIARY_MODEL_WATCH_COORDINATOR, false) === coordinator) {\n void Promise.resolve(unprovide?.()).catch(() => {})\n }\n } catch { /* Root already unloading. */ }\n })\n },\n fiber: undefined,\n }\n void previousTail.then(() => {\n // A release that beat the mount ends here: nothing mounted, nothing\n // to unmount, and the tail already moved on.\n if (lease.closed) return\n // mountModelSettingsChanges performs this exact inject/$mount pair;\n // it is repeated here only because that helper returns void and the\n // fiber must be captured for symmetric teardown.\n try {\n lease.fiber = root.inject(['remote'], injected => {\n const scope = injected as AuxiliaryRemoteMountScope\n const mounting = scope.remote.$mount(\n modelSettingsChangesRemote(AUXILIARY_MODEL_PACKAGE, AUXILIARY_MODEL_CHANGES_IDENTITY),\n ) as Promise<(() => Promise<void>) | undefined>\n void mounting.catch(() => {})\n scope.effect(() => async () => {\n const unmount = await mounting.catch(() => undefined)\n await unmount?.()\n })\n })\n } catch { /* remote unavailable: the card degrades to manual refresh */ }\n })\n return lease\n },\n }\n unprovide = root.provide(AUXILIARY_MODEL_WATCH_COORDINATOR, coordinator)\n return coordinator\n}\n\ninterface AuxiliaryCardService {\n retain(): void\n release(): void\n}\n\n/**\n * Acquire the root-owned card service, creating it on first use. One counter\n * covers participants, the seat wait and the change-stream mount: the last\n * release removes the wait, then the watch contribution, then the provider\n * itself synchronously (Cordis deletes the impl before its async disposer\n * awaits), so a later acquire sees a clean get() miss and can re-establish.\n */\nfunction acquireAuxiliaryModelCard(root: AuxiliaryRoot, ctx: Context): AuxiliaryCardService {\n const existing = root.get(AUXILIARY_MODEL_CARD_SERVICE, false) as AuxiliaryCardService | undefined\n if (existing) return existing\n let users = 0\n let styleElement: HTMLStyleElement | undefined\n let stopItem: (() => void) | undefined\n let unprovide: (() => void) | undefined\n // The client-side stream descriptor hangs off the shared root context —\n // never a plugin fiber — so the first participant's unload cannot take the\n // card's change stream down. The coordinator still unmounts it, in tail\n // order, on the last release.\n const watchLease = acquireWatchCoordinator(root).mount()\n const subscriber: ModelSettingsSubscriber = createModelSettingsSubscriber(\n ctx.root as unknown as Parameters<typeof createModelSettingsSubscriber>[0],\n AUXILIARY_MODEL_PACKAGE,\n AUXILIARY_MODEL_CHANGES_IDENTITY,\n ns => ns === AUXILIARY_MODEL_NS,\n )\n const render = (props: { renderFactorySlot?: RenderFactorySlot }) => <AuxiliaryModelCard\n client={root as unknown as AuxiliaryModelClient}\n subscribe={subscriber.subscribe}\n renderFactorySlot={props.renderFactorySlot} />\n const service: AuxiliaryCardService = {\n retain() {\n // The reservation is counted before the throwing installs, so a failure\n // lets the caller's release() undo it fully instead of leaking the service.\n users += 1\n if (styleElement === undefined && typeof document !== 'undefined') {\n styleElement = document.createElement('style')\n styleElement.setAttribute('data-plugin', 'dsh-auxiliary-model-shared')\n styleElement.textContent = auxiliaryModelCss\n document.head.appendChild(styleElement)\n }\n /* The card is a participant of the shared column too: the root-owned\n * call contributes its row AND retains the page and nav icon, which is\n * what guarantees a lone auxiliary plugin still creates the Session\n * Management section — no business plugin has to provide it. The waits\n * sit on the root context, so they live exactly as long as the card. */\n if (!stopItem) {\n stopItem = registerSessionSettingsItem(ctx.root, {\n id: AUXILIARY_MODEL_SEAT_ID,\n order: AUXILIARY_MODEL_SEAT_ORDER,\n }, render)\n }\n },\n release() {\n if (users <= 0) return\n users -= 1\n if (users > 0) return\n stopItem?.()\n stopItem = undefined\n styleElement?.remove()\n styleElement = undefined\n watchLease.done()\n // The store entry leaves synchronously, like the shared page service:\n // the next acquire must not see a stale \"already registered\" marker.\n try { void Promise.resolve(unprovide?.()).catch(() => {}) } catch { /* Root already unloading. */ }\n unprovide = undefined\n },\n }\n unprovide = root.provide(AUXILIARY_MODEL_CARD_SERVICE, service)\n return service\n}\n\n/**\n * Show the shared \"default auxiliary model\" card while the calling plugin is\n * enabled.\n *\n * `ctx` is the plugin's own client context: the card itself is retained on the\n * shared root context for as long as any participant lives, so an arbitrary\n * subset of enabled plugins yields the same single card. The mount's slot wait\n * and the change-stream contribution are owned by the root service — the first\n * participant's unload cannot take the card down. Returns a disposer; it may\n * be invoked by both ctx.effect and an explicit caller and releases at most\n * once, so a double call cannot unbalance the shared refcount.\n */\nexport function registerAuxiliaryModelSettings(ctx: Context): () => void {\n const root = ctx.root as unknown as AuxiliaryRoot\n const service = acquireAuxiliaryModelCard(root, ctx)\n try {\n service.retain()\n } catch (error) {\n // A synchronous failure (for example a duplicate row id) must not pin the\n // shared card for a participant that never joined.\n service.release()\n throw error\n }\n let disposed = false\n return () => {\n if (disposed) return\n disposed = true\n service.release()\n }\n}\n","import { useEffect, useRef, useState, useSyncExternalStore } from 'react'\nimport { Button, IconCloseFillRegular } from '@deepseek-ai/dsh-client-ui-primitives'\nimport type { ContinueModel, WelcomeBackModel } from './presence-model.ts'\nimport { FREE_CHAT_ROOT } from './styles.ts'\nimport { compactedText, failureText, idleText, uiText, type CopyLocale } from './ui-copy.ts'\n\n/** Narrow slot standard props the components rely on; the host keeps the real types. */\nexport interface GhostInputState {\n readonly draft: string\n readonly phase: string\n readonly attachmentIds: readonly unknown[]\n}\n\nexport interface GhostSessionState {\n readonly blank: boolean\n}\n\nexport interface GhostStatusState {\n readonly running?: boolean\n}\n\nexport interface GhostSlotProps {\n readonly sessionId?: string\n readonly useInput?: <T>(selector: (state: GhostInputState) => T) => T\n readonly useSession?: <T>(selector: (state: GhostSessionState) => T) => T\n readonly useSessionStatus?: <T>(selector: (state: ReadonlyMap<string, GhostStatusState>) => T) => T\n readonly inputActions?: {\n setDraft(text: string): void\n }\n}\n\n/**\n * Grey inline-completion for an empty composer, IDE style: the shipped\n * placeholder's own text becomes the continuation (native look, zero\n * positioning), and Tab fills it into the draft for a normal send.\n * The rendered element is a hidden anchor; all work happens in effects.\n */\nexport function ContinueGhost(props: GhostSlotProps & {\n model: ContinueModel\n locale: CopyLocale\n}): React.ReactElement | null {\n const sessionId = props.sessionId ?? ''\n const draft = props.useInput?.(state => state.draft) ?? ''\n const phase = props.useInput?.(state => state.phase) ?? 'plain'\n // The host placeholder shows exactly when the draft and attachment rail are\n // both empty; the ghost replaces its text under the same condition.\n const bare = (props.useInput?.(state => state.attachmentIds.length) ?? 0) === 0\n const blank = props.useSession?.(state => state.blank) ?? true\n const running = props.useSessionStatus?.(state => state.get(sessionId)?.running === true) ?? false\n const snapshot = useSyncExternalStore(\n props.model.subscribe,\n () => props.model.getSnapshot(sessionId),\n () => props.model.getSnapshot(sessionId),\n )\n // An unresolved or still-open turn keeps the shipped placeholder. Empty fixed\n // text becomes the localized default; an empty model line shows nothing.\n const shown = running || snapshot.pending === true || snapshot.text === undefined\n ? ''\n : (snapshot.text ?? (snapshot.fallback === true ? uiText(props.locale, 'continueDefault') : ''))\n const idle = sessionId !== '' && !blank && bare && draft === '' && phase === 'plain' && !running\n const active = shown !== '' && idle\n const text = shown\n const latest = useRef({ active, text })\n useEffect(() => {\n latest.current = { active, text }\n }, [active, text])\n\n const wasRunning = useRef(false)\n useEffect(() => {\n const finished = wasRunning.current && !running\n wasRunning.current = running\n // A falling edge is the previous turn ending. Drop the cached line so the\n // next idle composer asks once for the new cut.\n if (finished && sessionId !== '') props.model.invalidate(sessionId)\n if (idle && !running) props.model.load(sessionId)\n }, [props.model, idle, running, sessionId])\n // Config invalidation can happen while this same idle composer stays\n // mounted. Its empty snapshot must start a fresh load too.\n useEffect(() => {\n if (idle && !running && snapshot.text === undefined) props.model.load(sessionId)\n }, [props.model, idle, running, sessionId, snapshot])\n\n // Replace the shipped placeholder's text while the composer is empty. Class\n // hashes change per host build, so the DOM contract is the stable data\n // attributes [data-composer-card] / [data-composer-placeholder]; the editor's\n // own [data-placeholder] attribute keeps the original text for restore.\n const anchorRef = useRef<HTMLSpanElement>(null)\n useEffect(() => {\n if (!active) return\n const anchor = anchorRef.current\n const card = anchor?.closest('[data-composer-card]') ?? document.querySelector('[data-composer-card]')\n if (!card) return\n const write = () => {\n const placeholder = card.querySelector('[data-composer-placeholder]')\n if (placeholder !== null && placeholder.textContent !== latest.current.text) {\n placeholder.textContent = latest.current.text\n }\n }\n write()\n const observer = new MutationObserver(write)\n observer.observe(card, { subtree: true, childList: true, characterData: true })\n return () => {\n observer.disconnect()\n const placeholder = card.querySelector('[data-composer-placeholder]')\n const original = card.querySelector('[data-composer-input]')?.getAttribute('data-placeholder')\n // Only undo our own write; a genuinely different placeholder stays.\n if (placeholder !== null && typeof original === 'string' && placeholder.textContent === latest.current.text) {\n placeholder.textContent = original\n }\n }\n }, [active, text])\n\n useEffect(() => {\n const onKey = (event: KeyboardEvent) => {\n if (event.key !== 'Tab' || event.shiftKey || event.ctrlKey || event.metaKey || event.altKey) return\n if (event.isComposing || event.keyCode === 229) return\n const current = latest.current\n if (!current.active) return\n // Only this composer's editor. Dialogs and every other field keep Tab.\n // The anchor normally sits in the card. A single page-level card is the\n // fallback when the slot mounts beside it; several cards and no match\n // means leave the key alone.\n const target = event.target\n if (!(target instanceof HTMLElement)) return\n if (target.closest('[role=\"dialog\"]') !== null) return\n const anchored = anchorRef.current?.closest('[data-composer-card]')\n const fromTarget = target.closest('[data-composer-card]')\n const only = document.querySelectorAll('[data-composer-card]')\n const card = anchored ?? (fromTarget !== null && only.length === 1 ? fromTarget : null) ?? (only.length === 1 ? only[0] : null)\n const composer = card?.querySelector('[data-composer-input]') ?? null\n if (composer === null || (target !== composer && !composer.contains(target))) return\n event.preventDefault()\n event.stopPropagation()\n props.inputActions?.setDraft(current.text)\n }\n document.addEventListener('keydown', onKey, true)\n return () => document.removeEventListener('keydown', onKey, true)\n }, [props.inputActions])\n\n return <span ref={anchorRef} hidden data-sm-ghost-anchor=\"\" />\n}\n\n/**\n * Narrow TurnLocation face the card needs from the conversation.chat.turnTail\n * owner props; the host keeps the real type.\n */\nexport interface WelcomeBackTurn {\n readonly turn: number\n readonly start?: { readonly time: number }\n readonly end?: { readonly time: number }\n}\n\n/** Narrow ChatSnapshot face used to find the latest loaded turn. */\nexport interface WelcomeBackChatState {\n readonly timeline: { readonly turnOrder: readonly number[] }\n}\n\n/**\n * The merged return card inside the chat flow: model recap past the recap\n * threshold, compaction offer past the compact one. It renders at the latest\n * completed turn's tail instead of opening a modal, so it suggests rather\n * than intercepts a send.\n */\nexport function WelcomeBackCard(props: {\n sessionId?: string\n turn?: WelcomeBackTurn\n useChat?: <T>(selector: (state: WelcomeBackChatState) => T) => T\n useInput?: <T>(selector: (state: GhostInputState) => T) => T\n model: WelcomeBackModel\n locale: CopyLocale\n}): React.ReactElement | null {\n const sessionId = props.sessionId ?? ''\n const snapshot = useSyncExternalStore(\n props.model.subscribe,\n () => props.model.getSnapshot(sessionId),\n () => props.model.getSnapshot(sessionId),\n )\n const lastTurn = props.useChat?.(state => state.timeline.turnOrder[state.timeline.turnOrder.length - 1])\n const inputPhase = props.useInput?.(state => state.phase)\n const card = snapshot.card\n // Live idle clock: the prepared value is a fixed snapshot, so the card\n // recomputes the minutes against lastResponseAt every half minute and the\n // compaction offer can cross its threshold while the card is visible.\n const [liveMinutes, setLiveMinutes] = useState(() => card === undefined ? 0 : Math.max(0, Math.floor((Date.now() - card.lastResponseAt) / 60_000)))\n useEffect(() => {\n if (card === undefined) return\n const tick = () => setLiveMinutes(Math.max(0, Math.floor((Date.now() - card.lastResponseAt) / 60_000)))\n tick()\n const timer = setInterval(tick, 30_000)\n return () => clearInterval(timer)\n }, [card])\n // Sending closes the card: once the composer leaves the plain phase the\n // user has continued, and dismiss() records the activity mark so a fresh\n // response re-arms the card without another model call.\n const phaseRef = useRef(inputPhase)\n useEffect(() => {\n const previous = phaseRef.current\n phaseRef.current = inputPhase\n if (inputPhase === undefined || previous === inputPhase) return\n if (previous === 'plain' && sessionId !== '') props.model.dismiss(sessionId)\n }, [inputPhase, sessionId, props.model])\n if (sessionId === '' || card === undefined) return null\n // The slot dispatches once per completed turn; only the latest one's tail\n // hosts the card, so it reads as the bottom of the conversation chain.\n if (props.turn === undefined || lastTurn === undefined || props.turn.turn !== lastTurn) return null\n // A response newer than the prepared mark makes the recap stale: the user\n // already continued, so the card never reappears at the new turn's tail.\n const respondedAt = props.turn.end?.time ?? props.turn.start?.time\n if (respondedAt !== undefined && card.lastResponseAt < respondedAt) return null\n const copy = (key: Parameters<typeof uiText>[1]) => uiText(props.locale, key)\n const recap = card.recap\n const settled = snapshot.compactedTokens !== undefined || snapshot.compactReason === 'nothing'\n const liveCompactSuggested = card.compactSuggested || (card.compactMinutes > 0 && liveMinutes >= card.compactMinutes)\n // Root-level capability probes cannot see preset-isolated commands. Always\n // offer the explicit action; the native target-session command fails closed.\n const offerCompact = liveCompactSuggested && !settled\n const actionBusy = snapshot.compactBusy || snapshot.continueBusy === true\n return (\n <div className={`${FREE_CHAT_ROOT} dsh-welcome-card`}>\n <div className=\"dsh-welcome-card-head\">\n <span className=\"dsh-welcome-card-title\">{copy('welcomeBack')}</span>\n <span className=\"dsh-welcome-card-idle\">{idleText(props.locale, liveMinutes)}</span>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n className=\"dsh-welcome-card-close\"\n aria-label={copy('close')}\n icon={<IconCloseFillRegular />}\n onClick={() => { props.model.dismiss(sessionId) }}\n />\n </div>\n {recap !== null ? (\n <dl className=\"dsh-welcome-recap\">\n <dt>{copy('recapSummary')}</dt>\n <dd>{recap.summary}</dd>\n {recap.progress !== '' ? <dt>{copy('recapProgress')}</dt> : null}\n {recap.progress !== '' ? <dd>{recap.progress}</dd> : null}\n {recap.nextStep !== '' ? <dt>{copy('recapNextStep')}</dt> : null}\n {recap.nextStep !== '' ? <dd>{recap.nextStep}</dd> : null}\n </dl>\n ) : null}\n {liveCompactSuggested ? <p className=\"dsh-welcome-cache\">{copy('cacheNotice')}</p> : null}\n {liveCompactSuggested ? (\n <div className=\"dsh-welcome-card-actions\">\n {offerCompact ? (\n <Button\n type=\"button\"\n variant=\"outline\"\n disabled={actionBusy}\n onClick={() => { void props.model.compact(sessionId) }}\n >\n {snapshot.compactBusy ? copy('compacting') : copy('compactNow')}\n </Button>\n ) : null}\n <Button\n type=\"button\"\n variant=\"outline\"\n disabled={actionBusy}\n title={copy('continueNewHint')}\n onClick={() => { void props.model.continueInNewSession(sessionId, props.locale) }}\n >\n {snapshot.continueBusy ? copy('creatingContinuation') : copy('continueNew')}\n </Button>\n </div>\n ) : null}\n {snapshot.compactCommandSent ? (\n <p className=\"dsh-welcome-done\" role=\"status\">{copy('compactCommandSent')}</p>\n ) : null}\n {snapshot.compactedTokens !== undefined ? (\n <p className=\"dsh-welcome-done\" role=\"status\">{compactedText(props.locale, snapshot.compactedTokens)}</p>\n ) : null}\n {snapshot.compactReason === 'nothing' ? <p className=\"dsh-welcome-done\" role=\"status\">{copy('compactNothing')}</p> : null}\n {snapshot.compactReason === 'busy' || snapshot.compactReason === 'unavailable' ? (\n <p className=\"dsh-ui-error dsh-free-alert\" role=\"alert\">\n {failureText(props.locale, { code: snapshot.compactReason === 'busy' ? 'session-manager/busy' : 'session-manager/unavailable' })}\n </p>\n ) : null}\n {snapshot.failure ? <p className=\"dsh-ui-error dsh-free-alert\" role=\"alert\">{failureText(props.locale, snapshot.failure)}</p> : null}\n </div>\n )\n}\n","import { useCallback, useEffect, useId, useRef, useState, useSyncExternalStore } from 'react'\nimport { Input, SegmentedTabs, Switch, IconChevronDownOutlineRegular } from '@deepseek-ai/dsh-client-ui-primitives'\nimport { modelRouteKey, parseModelMenuChoices } from '@klarkxy/dsh-model-route'\nimport { ModelMenu, ModelCatalogStatus, useModelCatalog } from '@klarkxy/dsh-model-route/ui'\nimport { renderModelPicker, useModelMenuAnchor, type RenderFactorySlot } from '@klarkxy/dsh-plugin-kit/model-picker'\nimport { DEFAULT_COMPACT_MINUTES, DEFAULT_RECAP_MINUTES, type ConfigPatch, type ConfigView } from './contracts.ts'\nimport type { PresenceConfigModel, PresenceConfigSnapshot } from './presence-model.ts'\nimport { FREE_CHAT_ROOT } from './styles.ts'\nimport { failureText, uiText, type CopyLocale, type UiTextKey } from './ui-copy.ts'\n\n/** Enabled thresholds are whole minutes of at least 1. 0 stays the stored \"off\" value and is not a valid enabled draft. */\nfunction minutesOf(text: string): number | undefined {\n if (!/^[1-9]\\d*$/.test(text.trim())) return undefined\n const value = Number.parseInt(text.trim(), 10)\n return Number.isSafeInteger(value) && value >= 1 ? value : undefined\n}\n\n/** Automatic continuations per human message: a whole number from 1 to 10. */\nfunction autoMaxOf(text: string): number | undefined {\n if (!/^\\d+$/.test(text.trim())) return undefined\n const value = Number.parseInt(text.trim(), 10)\n return Number.isSafeInteger(value) && value >= 1 && value <= 10 ? value : undefined\n}\n\nconst missingCatalog = async (): Promise<unknown> => { throw new Error('Model catalog service unavailable') }\n\ninterface RowProps {\n model: PresenceConfigModel\n locale: CopyLocale\n}\n\nfunction copy(locale: CopyLocale, key: UiTextKey): string {\n return uiText(locale, key)\n}\n\n/**\n * Sparse save-on-change writer shared by every row. Each patch holds only the\n * keys that changed, so an untouched model selector can never overwrite a\n * stored route's reasoningEffort. The single-flight model drops a second save\n * while one is in flight, so edits queue as one merged patch and flush when\n * the current save settles.\n */\ninterface PatchWriter {\n send(patch: ConfigPatch, row: symbol): void\n /** The row that issued the latest write; only that row shows the save status. */\n lastRow: symbol | undefined\n}\n\n// One queue per config model, shared by every row: a per-row queue would leave\n// a patch stranded when another row's save holds the single-flight slot.\nconst writers = new WeakMap<PresenceConfigModel, PatchWriter>()\n\nfunction writerFor(model: PresenceConfigModel): PatchWriter {\n let writer = writers.get(model)\n if (writer !== undefined) return writer\n let queue: ConfigPatch | undefined\n const flush = () => {\n if (queue === undefined || model.getSnapshot().saving) return\n const patch = queue\n queue = undefined\n void model.save(patch).finally(flush)\n }\n writer = {\n lastRow: undefined,\n send(patch, row) {\n writer!.lastRow = row\n queue = { ...queue, ...patch }\n flush()\n },\n }\n writers.set(model, writer)\n return writer\n}\n\nfunction useConfigPatch(model: PresenceConfigModel): { send: (patch: ConfigPatch) => void; owns: () => boolean } {\n const row = useRef(Symbol('row')).current\n const writer = writerFor(model)\n const send = useCallback((patch: ConfigPatch) => writer.send(patch, row), [writer, row])\n return { send, owns: () => writer.lastRow === row }\n}\n\n/**\n * One controlled text/number input bound to a stored string. The draft follows\n * external writes only while untouched — a focused, edited draft is never\n * wiped by a settings reload. The commit runs on blur and Enter: valid input\n * normalizes and saves when it differs; invalid input keeps the draft and its\n * inline error and is never written.\n */\nfunction useTextSetting<T>(props: {\n stored: string\n parse: (draft: string) => { readonly value: T; readonly draft: string } | undefined\n send: (value: T) => void\n}): {\n draft: string\n invalid: boolean\n inputProps: {\n value: string\n onChange: (event: { target: { value: string } }) => void\n onBlur: () => void\n onKeyDown: (event: { key: string }) => void\n }\n} {\n const [draft, setDraft] = useState(props.stored)\n const seen = useRef(props.stored)\n const touched = useRef(false)\n useEffect(() => {\n if (props.stored === seen.current) return\n seen.current = props.stored\n // Follow the stored value while untouched, or once it caught up with the\n // draft (our own save confirmed); an edited, unsaved draft stays put.\n setDraft(current => {\n if (touched.current && current !== props.stored) return current\n touched.current = false\n return props.stored\n })\n }, [props.stored])\n const commit = useCallback(() => {\n const parsed = props.parse(draft)\n if (parsed === undefined) return\n setDraft(parsed.draft)\n // Normalizing may fold the draft back to the stored value (\"015\" -> 15);\n // only a real change writes.\n if (parsed.draft === seen.current) {\n touched.current = false\n return\n }\n props.send(parsed.value)\n }, [draft, props.parse, props.send])\n return {\n draft,\n invalid: props.parse(draft) === undefined,\n inputProps: {\n value: draft,\n onChange: event => {\n touched.current = true\n setDraft(event.target.value)\n },\n onBlur: commit,\n onKeyDown: event => { if (event.key === 'Enter') commit() },\n },\n }\n}\n\n/** Per-row write status: one line under the controls, only while it has something to say. */\nfunction SaveStatus(props: { snapshot: PresenceConfigSnapshot; locale: CopyLocale; owns: () => boolean }): React.ReactElement | null {\n const { snapshot, locale } = props\n if (!props.owns()) return null\n if (snapshot.saving) return <p className=\"dsh-ui-notice\" role=\"status\">{copy(locale, 'settingsSaving')}</p>\n if (snapshot.failure) return <p className=\"dsh-ui-notice dsh-ui-notice--error\" role=\"alert\">{failureText(locale, snapshot.failure)}</p>\n if (snapshot.saved) return <p className=\"dsh-ui-notice\" role=\"status\">{copy(locale, 'settingsSaved')}</p>\n return null\n}\n\n/** Shared loading/unavailable body: every row reads the same config snapshot. */\nfunction useRowGate(props: RowProps): { snapshot: PresenceConfigSnapshot; values?: ConfigView; gate?: React.ReactElement } {\n const snapshot = useSyncExternalStore(props.model.subscribe, props.model.getSnapshot, props.model.getSnapshot)\n useEffect(() => {\n if (snapshot.phase === 'loading') void props.model.load()\n }, [props.model, snapshot.phase])\n if (snapshot.phase === 'loading') {\n return { snapshot, gate: <p className=\"dsh-ui-loading\">{copy(props.locale, 'settingsLoading')}</p> }\n }\n if (snapshot.phase === 'unavailable' || snapshot.values === undefined) {\n return {\n snapshot,\n gate: (\n <p className=\"dsh-ui-error\" role=\"alert\">\n {snapshot.failure ? failureText(props.locale, snapshot.failure) : copy(props.locale, 'settingsUnavailable')}\n </p>\n ),\n }\n }\n return { snapshot, values: snapshot.values }\n}\n\n/** 输入框建议 / Composer suggestion row. */\nexport function ComposerSettings(props: RowProps & CatalogProps): React.ReactElement {\n const { snapshot, values, gate } = useRowGate(props)\n const { send, owns } = useConfigPatch(props.model)\n const tabsId = useId()\n const field = useTextSetting<string>({\n stored: values?.continueText ?? '',\n parse: draft => ({ value: draft.trim(), draft: draft.trim() }),\n send: useCallback(value => send({ continueText: value }), [send]),\n })\n if (gate !== undefined || values === undefined) return gate ?? <></>\n const fixedPanelId = `${tabsId}-fixed-panel`\n const autoPanelId = `${tabsId}-auto-panel`\n return (\n <div className=\"dsm-settings\">\n <div className=\"dsm-feature\">\n <div className=\"dsh-ui-field\">\n <span className=\"dsh-ui-label\">{copy(props.locale, 'continueSourceLabel')}</span>\n <SegmentedTabs<'fixed' | 'auto'>\n label={copy(props.locale, 'continueSourceLabel')}\n items={[\n { id: `${tabsId}-fixed`, panelId: fixedPanelId, value: 'fixed', label: copy(props.locale, 'modeFixed') },\n { id: `${tabsId}-auto`, panelId: autoPanelId, value: 'auto', label: copy(props.locale, 'modeAuto') },\n ]}\n value={values.continueMode}\n onChange={value => { if (value !== values.continueMode) send({ continueMode: value }) }}\n />\n </div>\n <div\n role=\"tabpanel\"\n id={fixedPanelId}\n aria-labelledby={`${tabsId}-fixed`}\n hidden={values.continueMode !== 'fixed'}\n >\n {values.continueMode === 'fixed' ? (\n <label className=\"dsh-ui-field\">\n <span className=\"dsh-ui-label\">{copy(props.locale, 'continueTextLabel')}</span>\n <Input\n className=\"dsm-text-input\"\n placeholder={copy(props.locale, 'continueTextPlaceholder')}\n {...field.inputProps}\n />\n </label>\n ) : null}\n </div>\n <div\n role=\"tabpanel\"\n id={autoPanelId}\n aria-labelledby={`${tabsId}-auto`}\n hidden={values.continueMode !== 'auto'}\n >\n {values.continueMode === 'auto'\n ? <ModelField {...props} field=\"ghostModel\" labelKey=\"ghostModelLabel\" route={values.ghostModel} send={send} />\n : null}\n </div>\n <p className=\"dsh-ui-hint\">{copy(props.locale, 'composerUsageHint')}</p>\n <SaveStatus snapshot={snapshot} locale={props.locale} owns={owns} />\n </div>\n </div>\n )\n}\n\n/** 自动继续 / Auto-continue row. */\nexport function AutoContinueSettings(props: RowProps & CatalogProps): React.ReactElement {\n const { snapshot, values, gate } = useRowGate(props)\n const { send, owns } = useConfigPatch(props.model)\n const errorId = useId()\n const field = useTextSetting<number>({\n stored: String(values?.autoContinueMax ?? ''),\n parse: draft => {\n const value = autoMaxOf(draft)\n return value === undefined ? undefined : { value, draft: String(value) }\n },\n send: useCallback(value => send({ autoContinueMax: value }), [send]),\n })\n if (gate !== undefined || values === undefined) return gate ?? <></>\n return (\n <div className=\"dsm-settings\">\n <div className=\"dsm-feature\">\n <label className=\"dsh-ui-field\">\n <span className=\"dsh-ui-label\">{copy(props.locale, 'autoContinueMaxLabel')}</span>\n <Input\n className=\"dsm-minutes\"\n inputMode=\"numeric\"\n aria-invalid={field.invalid || undefined}\n aria-describedby={field.invalid ? `${errorId}-max-error` : undefined}\n {...field.inputProps}\n />\n </label>\n <p className=\"dsh-ui-hint\">{copy(props.locale, 'autoContinueMaxHint')}</p>\n {field.invalid ? <p id={`${errorId}-max-error`} className=\"dsh-ui-error\" role=\"alert\">{copy(props.locale, 'autoContinueMaxInvalid')}</p> : null}\n <ModelField {...props} field=\"judgeModel\" labelKey=\"judgeModelLabel\" route={values.judgeModel} send={send} />\n <p className=\"dsh-ui-hint\">{copy(props.locale, 'judgeModelHint')}</p>\n <p className=\"dsh-ui-hint\">{copy(props.locale, 'autoContinueModeHint')}</p>\n <SaveStatus snapshot={snapshot} locale={props.locale} owns={owns} />\n </div>\n </div>\n )\n}\n\n/** One return-feature block: a switch row and its gated \"away for N minutes\" input. */\nfunction ThresholdBlock(props: RowProps & {\n field: 'recapMinutes' | 'compactMinutes'\n titleKey: 'recapEnabledLabel' | 'compactEnabledLabel'\n hintKey: 'recapEnabledHint' | 'compactEnabledHint'\n minutes: number | undefined\n fallback: number\n send: (patch: ConfigPatch) => void\n /** Extra options that belong to this feature, gated with its switch. */\n extra?: (enabled: boolean) => React.ReactNode\n}): React.ReactElement {\n const enabled = (props.minutes ?? 0) > 0\n const errorId = useId()\n const input = useTextSetting<number>({\n stored: String(enabled ? props.minutes : props.fallback),\n parse: draft => {\n const value = minutesOf(draft)\n return value === undefined ? undefined : { value, draft: String(value) }\n },\n send: useCallback(value => props.send({ [props.field]: value }), [props.send, props.field]),\n })\n const toggle = (next: boolean) => {\n if (next === enabled) return\n if (!next) {\n props.send({ [props.field]: 0 })\n return\n }\n // Enabling saves the shown draft when it is valid, else the feature's default.\n props.send({ [props.field]: minutesOf(input.draft) ?? props.fallback })\n }\n return (\n <div className=\"dsm-feature\">\n <div className=\"dsh-ui-toggle-row\">\n <span className=\"dsh-ui-toggle-text\">\n <span className=\"dsh-ui-toggle-label\">{copy(props.locale, props.titleKey)}</span>\n <span className=\"dsh-ui-hint\">{copy(props.locale, props.hintKey)}</span>\n </span>\n <Switch\n label={copy(props.locale, props.titleKey)}\n checked={enabled}\n onChange={toggle}\n />\n </div>\n <div className=\"dsm-feature-options\" data-disabled={enabled ? undefined : 'true'}>\n <label className=\"dsh-ui-field\">\n <span className=\"dsm-minutes-control\">\n <span className=\"dsh-ui-label\">{copy(props.locale, 'awayMinutesLabel')}</span>\n <Input\n className=\"dsm-minutes\"\n inputMode=\"numeric\"\n disabled={!enabled}\n aria-label={`${copy(props.locale, 'awayMinutesLabel')} ${copy(props.locale, 'minutesUnit')}`}\n aria-invalid={enabled && input.invalid ? true : undefined}\n aria-describedby={enabled && input.invalid ? `${errorId}-minutes-error` : undefined}\n {...input.inputProps}\n />\n <span className=\"dsh-ui-meta\">{copy(props.locale, 'minutesUnit')}</span>\n </span>\n </label>\n {enabled && input.invalid ? <p id={`${errorId}-minutes-error`} className=\"dsh-ui-error\" role=\"alert\">{copy(props.locale, 'minutesInvalid')}</p> : null}\n {props.extra?.(enabled)}\n </div>\n </div>\n )\n}\n\n/** 回到会话时 / When you return row. */\nexport function ReturnSettings(props: RowProps & CatalogProps): React.ReactElement {\n const { snapshot, values, gate } = useRowGate(props)\n const { send, owns } = useConfigPatch(props.model)\n if (gate !== undefined || values === undefined) return gate ?? <></>\n return (\n <div className=\"dsm-settings\">\n <ThresholdBlock\n {...props}\n field=\"recapMinutes\"\n titleKey=\"recapEnabledLabel\"\n hintKey=\"recapEnabledHint\"\n minutes={values.recapMinutes}\n fallback={DEFAULT_RECAP_MINUTES}\n send={send}\n extra={enabled => (\n <ModelField {...props} field=\"model\" labelKey=\"recapModelLabel\" route={values.model} send={send} disabled={!enabled} />\n )}\n />\n <ThresholdBlock\n {...props}\n field=\"compactMinutes\"\n titleKey=\"compactEnabledLabel\"\n hintKey=\"compactEnabledHint\"\n minutes={values.compactMinutes}\n fallback={DEFAULT_COMPACT_MINUTES}\n send={send}\n />\n <SaveStatus snapshot={snapshot} locale={props.locale} owns={owns} />\n </div>\n )\n}\n\ntype ModelField = 'model' | 'ghostModel' | 'judgeModel' | 'handoffModel'\n\n/** Catalog wiring for the rows that carry a model picker. */\ninterface CatalogProps {\n modelCatalog?: () => Promise<unknown>\n subscribeCatalog?: (onChange: () => void) => (() => void) | undefined\n /** Framework-composed factory renderer; absent under direct test renders. */\n renderFactorySlot?: RenderFactorySlot\n}\n\n/**\n * One feature's model picker. The catalog loads with the row (first expand);\n * a stored route missing from the catalog stays selectable so a refresh or a\n * partial outage never hides the current choice.\n */\nfunction ModelField(props: RowProps & CatalogProps & {\n field: ModelField\n labelKey: UiTextKey\n route: { readonly provider: string; readonly model: string; readonly reasoningEffort?: string } | null\n send: (patch: ConfigPatch) => void\n disabled?: boolean\n}): React.ReactElement {\n const catalog = useModelCatalog(props.modelCatalog ?? missingCatalog, { subscribe: props.subscribeCatalog })\n const [open, setOpen] = useState(false)\n const label = copy(props.locale, props.labelKey)\n const selected = props.route === null ? undefined : { provider: props.route.provider, model: props.route.model }\n const choices = parseModelMenuChoices(catalog.catalog)\n if (selected && !choices.some(choice => choice.provider === selected.provider && choice.model === selected.model)) {\n choices.push({ provider: selected.provider, model: selected.model, label: `${selected.provider} / ${selected.model}`, efforts: [] })\n }\n const key = selected === undefined ? '' : modelRouteKey(selected.provider, selected.model)\n const value = choices.find(choice => modelRouteKey(choice.provider, choice.model) === key)?.label\n ?? copy(props.locale, 'modelFollowOption')\n const anchor = useModelMenuAnchor(`${label}: ${value}`, undefined, () => setOpen(false))\n const pick = (route: { provider: string; model: string }) => {\n // Re-picking the same route writes nothing: an unchanged selection\n // must not strip a stored route's reasoningEffort.\n if (selected && route.provider === selected.provider && route.model === selected.model) return\n props.send({ [props.field]: { provider: route.provider, model: route.model } })\n }\n return (\n <div className=\"dsm-model-field\">\n <div className=\"dsm-model-choice\">\n <span className=\"dsh-ui-label\">{label}</span>\n {renderModelPicker(props.renderFactorySlot, {\n locale: props.locale,\n disabled: props.disabled,\n onOpenChange: next => setOpen(next && !props.disabled),\n listClassName: FREE_CHAT_ROOT,\n choices,\n selected,\n onPick: pick,\n leading: [{ id: 'follow', label: copy(props.locale, 'modelFollowOption'), selected: selected === undefined }],\n onPickLeading: () => { if (props.route !== null) props.send({ [props.field]: null }) },\n triggerLabel: value,\n modelValue: value,\n }, {\n anchor,\n fallback: <ModelMenu\n locale={props.locale}\n open={open && !props.disabled}\n onOpenChange={next => setOpen(next && !props.disabled)}\n listClassName={FREE_CHAT_ROOT}\n anchor={<button type=\"button\" className=\"dsh-model-menu-trigger\" disabled={props.disabled} aria-label={`${label}: ${value}`} aria-haspopup=\"menu\" aria-expanded={open}>\n <span className=\"dsh-model-menu-triggerLabel\">{value}</span>\n <IconChevronDownOutlineRegular className={`dsh-model-menu-chevron${open ? ' dsh-model-menu-chevronOpen' : ''}`} />\n </button>}\n choices={choices}\n selected={selected}\n onPick={pick}\n leading={[{ id: 'follow', label: copy(props.locale, 'modelFollowOption'), selected: selected === undefined }]}\n onPickLeading={() => { if (props.route !== null) props.send({ [props.field]: null }) }}\n modelValue={value}\n />,\n })}\n </div>\n <ModelCatalogStatus state={catalog} locale={props.locale} />\n </div>\n )\n}\n\n/** 会话交接 / Session handoff row: the model behind read_session handoff summaries. */\nexport function HandoffSettings(props: RowProps & CatalogProps): React.ReactElement {\n const { snapshot, values, gate } = useRowGate(props)\n const { send, owns } = useConfigPatch(props.model)\n if (gate !== undefined || values === undefined) return gate ?? <></>\n return (\n <div className=\"dsm-settings\">\n <div className=\"dsm-feature\">\n <ModelField {...props} field=\"handoffModel\" labelKey=\"handoffModelLabel\" route={values.handoffModel} send={send} />\n <p className=\"dsh-ui-hint\">{copy(props.locale, 'handoffModelHint')}</p>\n <SaveStatus snapshot={snapshot} locale={props.locale} owns={owns} />\n </div>\n </div>\n )\n}\n\n/**\n * 代理操作 / Agent actions row.\n *\n * Two independent switches: each one saves only its own field, so toggling\n * one never rewrites the other. Both default to off, and the agent decides\n * on its own once a switch is on — there is no per-call approval here.\n *\n * The switches share one sparse writer: the config model accepts a single\n * write at a time, so a second click while a save is in flight must queue\n * rather than be dropped. The shared writer merges the pending patches and\n * flushes them once the current save settles.\n */\nexport function AgentActionsSettings(props: RowProps): React.ReactElement {\n const { snapshot, values, gate } = useRowGate(props)\n const { send, owns } = useConfigPatch(props.model)\n if (gate !== undefined || values === undefined) return gate ?? <></>\n return (\n <div className=\"dsm-settings\">\n <div className=\"dsm-feature\">\n <div className=\"dsh-ui-toggle-row\">\n <span className=\"dsh-ui-toggle-text\">\n <span className=\"dsh-ui-toggle-label\">{copy(props.locale, 'allowSelfForkLabel')}</span>\n <span className=\"dsh-ui-hint\">{copy(props.locale, 'allowSelfForkHint')}</span>\n </span>\n <Switch\n label={copy(props.locale, 'allowSelfForkLabel')}\n checked={values.allowSelfFork === true}\n onChange={next => { send({ allowSelfFork: next }) }}\n />\n </div>\n </div>\n <div className=\"dsm-feature\">\n <div className=\"dsh-ui-toggle-row\">\n <span className=\"dsh-ui-toggle-text\">\n <span className=\"dsh-ui-toggle-label\">{copy(props.locale, 'allowSendMessageLabel')}</span>\n <span className=\"dsh-ui-hint\">{copy(props.locale, 'allowSendMessageHint')}</span>\n </span>\n <Switch\n label={copy(props.locale, 'allowSendMessageLabel')}\n checked={values.allowSendMessage === true}\n onChange={next => { send({ allowSendMessage: next }) }}\n />\n </div>\n </div>\n <SaveStatus snapshot={snapshot} locale={props.locale} owns={owns} />\n </div>\n )\n}\n\n/**\n * One collapsible row in the shared Session Management section: a named\n * details group. The body mounts on the first expand only — opening the page\n * must not fire every feature's config and model reads — and stays mounted\n * afterwards so collapsing never drops an in-progress text draft.\n */\nexport function SessionSettingsDetails(props: {\n testId: string\n titleKey: UiTextKey\n descKey: UiTextKey\n locale: CopyLocale\n children?: React.ReactNode\n}): React.ReactElement {\n const [visited, setVisited] = useState(false)\n return (\n <details\n className={`${FREE_CHAT_ROOT} dsm-item`}\n data-testid={props.testId}\n onToggle={event => { if ((event.currentTarget as HTMLDetailsElement).open) setVisited(true) }}\n >\n <summary className=\"dsm-item-summary\">\n <span>\n <span className=\"dsm-item-title\">{copy(props.locale, props.titleKey)}</span>\n <span className=\"dsm-item-desc\">{copy(props.locale, props.descKey)}</span>\n </span>\n <IconChevronDownOutlineRegular className=\"dsm-item-chevron\" aria-hidden=\"true\" />\n </summary>\n {visited ? <div className=\"dsm-item-body\">{props.children}</div> : null}\n </details>\n )\n}\n","import { useEffect, useRef, useState } from 'react'\nimport { Button, FileTypeIcon } from '@deepseek-ai/dsh-client-ui-primitives'\nimport { unwrap } from './session-actions.ts'\nimport type { DraftAttachment, EditHost } from './edit-host.ts'\nimport { uiText, type CopyLocale } from './ui-copy.ts'\n\nfunction AttachmentPreview(props: { item: DraftAttachment; sessionId: string; host: EditHost; locale: CopyLocale }): React.ReactElement {\n const [src, setSrc] = useState<string>()\n const [failed, setFailed] = useState(false)\n const item = props.item\n const name = item.type === 'upload' ? item.file.name : item.type === 'file' ? item.name : uiText(props.locale, 'editImage')\n useEffect(() => {\n let active = true\n let url: string | undefined\n setSrc(undefined)\n setFailed(false)\n if (item.type === 'upload' && item.file.type.startsWith('image/')) {\n url = URL.createObjectURL(item.file)\n setSrc(url)\n } else if (item.type === 'image' && props.host.attachment) {\n void unwrap(props.host.attachment({ sessionId: props.sessionId, attachmentId: item.attachmentId })).then(value => {\n const image = value as { data?: string; attachment?: { mediaType?: string } }\n if (active && image.data && image.attachment?.mediaType?.startsWith('image/')) setSrc(`data:${image.attachment.mediaType};base64,${image.data}`)\n else if (active) setFailed(true)\n }).catch(() => { if (active) setFailed(true) })\n }\n return () => { active = false; if (url) URL.revokeObjectURL(url) }\n }, [item, props.host, props.sessionId])\n return <>\n {src ? <img src={src} alt={name} /> : <FileTypeIcon path={name} />}\n {item.type === 'file' || (item.type === 'upload' && !item.file.type.startsWith('image/')) ? <span title={name}>{name}</span> : null}\n {failed ? <span role=\"status\">{uiText(props.locale, 'editPreviewFailed')}</span> : null}\n </>\n}\n\n/** Lives in the original bubble; drafts and attachments remain local until Send. */\nexport function MessageEditor(props: {\n text: string; setText: (text: string) => void; attachments?: readonly DraftAttachment[]\n setAttachments?: (attachments: DraftAttachment[]) => void\n sessionId: string; host?: EditHost; locale: CopyLocale; busy: boolean; locked?: boolean\n error?: string; onCancel: () => void; onSend: () => void\n}): React.ReactElement {\n const textarea = useRef<HTMLTextAreaElement>(null)\n const copy = (key: Parameters<typeof uiText>[1]) => uiText(props.locale, key)\n const attachments = props.attachments ?? []\n const disabled = props.busy || props.locked === true\n useEffect(() => {\n textarea.current?.focus()\n textarea.current?.setSelectionRange(props.text.length, props.text.length)\n }, [])\n useEffect(() => {\n const element = textarea.current\n if (!element) return\n element.style.height = 'auto'\n element.style.height = `${Math.max(80, Math.min(element.scrollHeight, 360))}px`\n }, [props.text])\n const add = (files: File[]) => {\n if (!disabled && files.length > 0) props.setAttachments?.([...attachments, ...files.map(file => ({ type: 'upload' as const, file }))])\n }\n return <div className=\"dsm-message-edit\" role=\"group\" aria-label={copy('editTitle')}\n onDragOver={event => { if (!disabled && props.setAttachments && event.dataTransfer.types.includes('Files')) event.preventDefault() }}\n onDrop={event => { if (props.setAttachments && event.dataTransfer.files.length) { event.preventDefault(); add(Array.from(event.dataTransfer.files)) } }}>\n {attachments.length ? <div className=\"dsm-edit-attachments\">{attachments.map((item, index) => (\n <div className={`dsm-edit-attachment ${item.type === 'image' || (item.type === 'upload' && item.file.type.startsWith('image/')) ? 'dsm-edit-image' : ''}`} key={item.type === 'upload' ? `${index}:${item.file.name}` : `${index}:${item.attachmentId}`}>\n <AttachmentPreview item={item} sessionId={props.sessionId} host={props.host ?? {}} locale={props.locale} />\n {props.setAttachments ? <Button size=\"sm\" variant=\"ghost\" disabled={disabled} aria-label={`${copy('editRemoveAttachment')} ${index + 1}`}\n onClick={() => { props.setAttachments?.(attachments.filter((_, position) => position !== index)) }}>×</Button> : null}\n </div>\n ))}</div> : null}\n <div className=\"dsm-message-editor\">\n <textarea ref={textarea} className=\"dsh-ui-textarea dsh-free-draft\" aria-label={copy('draft')}\n value={props.text} disabled={disabled} onChange={event => { props.setText(event.target.value) }}\n onPaste={event => {\n const files = Array.from(event.clipboardData.files)\n if (files.length && props.setAttachments) { event.preventDefault(); add(files) }\n }} onKeyDown={event => { if (event.key === 'Escape' && !props.busy) { event.stopPropagation(); props.onCancel() } }} />\n {props.error ? <p className=\"dsh-ui-error\" role=\"alert\">{props.error}</p> : null}\n <div className=\"dsm-edit-footer\">\n <span className=\"dsm-edit-spacer\" />\n <Button variant=\"ghost\" disabled={props.busy} onClick={props.onCancel}>{copy('cancel')}</Button>\n <Button variant=\"primary\" disabled={props.busy || (!props.text.trim() && !attachments.length)} onClick={props.onSend}>{copy('send')}</Button>\n </div>\n </div>\n </div>\n}\n","/** The stock edit primitive includes a box; message editing uses a standalone pencil. */\nexport function EditMessageIcon(): React.ReactElement {\n return (\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" aria-hidden=\"true\">\n <path d=\"m10.5 2.5 3 3M2 14l1-4L10.5 2.5a2.12 2.12 0 0 1 3 3L6 13l-4 1Z\" stroke=\"currentColor\" strokeWidth=\"1\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </svg>\n )\n}\n","import { useEffect, useRef, useState, useSyncExternalStore } from 'react'\nimport { Button, Modal, Tooltip } from '@deepseek-ai/dsh-client-ui-primitives'\nimport { MessageEditor } from './message-editor.tsx'\nimport { EditMessageIcon } from './edit-icon.tsx'\nimport type { RetryModel } from './session-actions.ts'\nimport { FREE_CHAT_ROOT } from './styles.ts'\nimport { failureText, uiText, type CopyLocale } from './ui-copy.ts'\n\nexport function UserMessageActions(props: {\n messageId: string\n text: string\n sessionId: string\n locale: CopyLocale\n model: RetryModel\n hideEdit?: boolean\n}): React.ReactElement | null {\n const [confirming, setConfirming] = useState(false)\n const snapshot = useSyncExternalStore(props.model.subscribe, props.model.getSnapshot, props.model.getSnapshot)\n const signal = useRef<AbortController>(new AbortController())\n useEffect(() => {\n const controller = new AbortController()\n signal.current = controller\n return () => {\n controller.abort()\n props.model.retire(props.sessionId, props.messageId)\n }\n }, [props.model, props.sessionId, props.messageId])\n if (props.sessionId === '' || !snapshot.controlsRetry) return null\n const mine = snapshot.sessionId === props.sessionId && snapshot.messageId === props.messageId\n const copy = (key: Parameters<typeof uiText>[1]) => uiText(props.locale, key)\n const failure = mine ? snapshot.failure : undefined\n const editing = mine && snapshot.editing\n const draft = mine ? snapshot.draft : props.text\n return (\n <span className={`${FREE_CHAT_ROOT} dsh-free-actions`}>\n {!props.hideEdit ? <Tooltip label={copy('edit')} side=\"bottom\">\n <Button\n size=\"sm\"\n className=\"dsm-icon-action\"\n variant=\"ghost\"\n aria-label={copy('edit')}\n disabled={snapshot.busy || (snapshot.editing && !mine)}\n onClick={() => { void props.model.beginEdit(props.sessionId, props.messageId, props.text, signal.current.signal) }}\n >\n <EditMessageIcon />\n </Button>\n </Tooltip> : null}\n {failure && !editing ? <span className=\"dsh-ui-error dsh-free-alert\" role=\"alert\">{failureText(props.locale, failure)}</span> : null}\n {editing && !props.hideEdit ? <MessageEditor text={draft} setText={value => { props.model.setDraft(value) }}\n sessionId={props.sessionId} locale={props.locale} busy={snapshot.busy}\n error={failure ? failureText(props.locale, failure) : undefined}\n onCancel={() => { props.model.cancelEdit() }}\n onSend={() => { setConfirming(true) }} /> : null}\n <Modal open={confirming && editing} className={FREE_CHAT_ROOT} title={copy('editTitle')} closeLabel={copy('close')}\n onClose={() => { setConfirming(false) }} footer={<>\n <Button variant=\"ghost\" data-modal-autofocus onClick={() => { setConfirming(false) }}>{copy('cancel')}</Button>\n <Button variant=\"primary\" onClick={() => { setConfirming(false); void props.model.sendEdit(props.sessionId, props.messageId, signal.current.signal, undefined, true) }}>{copy('editConfirm')}</Button>\n </>}><p>{copy('editBranchWarning')}</p></Modal>\n </span>\n )\n}\n","import { EDIT_FILE_ENDPOINT, EDIT_PREPARE_ENDPOINT, TEMP_WORKSPACE_CHANNEL, type EditContent, type EditPrepareValue } from './contracts.ts'\nimport type { PresenceRpc } from './presence-model.ts'\nimport { HostOperationError, unwrap } from './session-actions.ts'\n\nexport type PromptContent = { readonly type: 'text'; readonly text: string }\n | { readonly type: 'image'; readonly data: string; readonly mediaType: string; readonly name?: string }\n | { readonly type: 'file'; readonly receiptId: string }\n\nexport type DraftAttachment = Exclude<EditContent, { type: 'text' }>\n | { readonly type: 'upload'; readonly file: File }\n\nexport interface EditHost {\n uploadFile?: (sessionId: string, file: File, signal: AbortSignal) => Promise<unknown>\n stageFile?: (request: { sessionId: string; promptSeq: number; attachmentId: string }, signal: AbortSignal) => Promise<unknown>\n prepare?: (request: { sessionId: string; promptSeq: number }, signal: AbortSignal) => Promise<unknown>\n attachment?: (request: { sessionId: string; attachmentId: string }) => Promise<unknown>\n}\n\ninterface EditClient {\n connection?: { rpc?: PresenceRpc }\n remote?: { session?: { attachment?: EditHost['attachment'] } }\n}\n\nexport function bindEditHost(client: EditClient): EditHost {\n const rpc = client.connection?.rpc\n const remote = client.remote?.session\n return {\n ...typeof rpc?.call === 'function' ? {\n prepare: (request, signal) => rpc.call(TEMP_WORKSPACE_CHANNEL, EDIT_PREPARE_ENDPOINT, request, signal),\n stageFile: (request, signal) => rpc.call(TEMP_WORKSPACE_CHANNEL, EDIT_FILE_ENDPOINT, request, signal),\n } : {},\n uploadFile: async (sessionId, file, signal) => {\n const query = new URLSearchParams({ sessionId, name: file.name })\n const response = await fetch(`/api/session/uploadFileBinary?${query}`, {\n method: 'POST', credentials: 'same-origin', headers: { 'content-type': 'application/octet-stream' }, body: file, signal,\n })\n if (!response.ok) throw new HostOperationError('session/attachment-invalid')\n return response.json()\n },\n ...typeof remote?.attachment === 'function' ? { attachment: request => remote.attachment!(request) } : {},\n }\n}\n\nfunction readPreview(value: unknown): EditPrepareValue {\n if (typeof value !== 'object' || value === null) throw new HostOperationError('session-manager/unavailable')\n const record = value as {\n sessionId?: unknown\n promptSeq?: unknown\n text?: unknown\n content?: unknown\n modified?: unknown\n }\n if (typeof record.sessionId !== 'string'\n || typeof record.promptSeq !== 'number'\n || typeof record.text !== 'string' || typeof record.modified !== 'boolean') {\n throw new HostOperationError('session-manager/unavailable')\n }\n const content = record.content\n if (content !== undefined && (!Array.isArray(content) || !content.every(isEditContent))) {\n throw new HostOperationError('session-manager/unavailable')\n }\n return {\n sessionId: record.sessionId,\n promptSeq: record.promptSeq,\n text: record.text,\n ...content === undefined ? {} : { content: content as EditContent[] },\n modified: record.modified,\n }\n}\n\nfunction isEditContent(value: unknown): value is EditContent {\n if (typeof value !== 'object' || value === null) return false\n const part = value as { type?: unknown; text?: unknown; attachmentId?: unknown; name?: unknown; bytes?: unknown }\n return part.type === 'text' ? typeof part.text === 'string'\n : (part.type === 'image' || (part.type === 'file' && typeof part.name === 'string' && typeof part.bytes === 'number'))\n && typeof part.attachmentId === 'string' && part.attachmentId !== ''\n}\n\ntype PendingContent = PromptContent | Exclude<DraftAttachment, { type: 'image' }>\n\n/** Build the exact body for the edited prompt; images are read from the source Session. */\nasync function buildContent(host: EditHost, preview: EditPrepareValue, text: string, signal: AbortSignal, attachments?: readonly DraftAttachment[]): Promise<PendingContent[]> {\n const content: PendingContent[] = []\n let wroteText = false\n const parts = attachments === undefined ? preview.content ?? [{ type: 'text' as const, text: preview.text }]\n : [{ type: 'text' as const, text }, ...attachments]\n for (const part of parts) {\n signal.throwIfAborted()\n if (part.type === 'text') {\n if (text === preview.text) content.push(part)\n else if (!wroteText) content.push({ type: 'text', text })\n wroteText = true\n continue\n }\n if (part.type === 'file') { content.push(part); continue }\n if (part.type === 'upload') {\n if (['image/png', 'image/jpeg', 'image/webp', 'image/gif'].includes(part.file.type)) {\n const data = await new Promise<string>((resolve, reject) => {\n const reader = new FileReader()\n reader.onload = () => { resolve(String(reader.result).split(',')[1]!) }\n reader.onerror = () => { reject(reader.error) }\n reader.readAsDataURL(part.file)\n })\n signal.throwIfAborted()\n content.push({ type: 'image', data, mediaType: part.file.type, name: part.file.name })\n } else content.push(part)\n continue\n }\n if (!host.attachment) throw new HostOperationError('session/lifecycle-unavailable')\n // Read against the source session, whose history authorizes this exact image.\n // Complete every read before staging, so a missing image cannot leave a half-staged body.\n const value = await unwrap(host.attachment({ sessionId: preview.sessionId, attachmentId: part.attachmentId }))\n const image = value as { attachment?: { attachmentId?: unknown; mediaType?: unknown; name?: unknown }; data?: unknown } | null\n if (image?.attachment?.attachmentId !== part.attachmentId || typeof image.data !== 'string' || image.data === ''\n || typeof image.attachment.mediaType !== 'string' || !image.attachment.mediaType.startsWith('image/')) {\n throw new HostOperationError('session/attachment-invalid')\n }\n content.push({\n type: 'image', data: image.data, mediaType: image.attachment.mediaType,\n ...typeof image.attachment.name === 'string' ? { name: image.attachment.name } : {},\n })\n }\n if (!wroteText && text !== '') content.push({ type: 'text', text })\n signal.throwIfAborted()\n return content\n}\n\nexport interface EditSubmission {\n readonly requestId: string\n /** Freeze bytes and receipts after confirmation so retries never reuse an id for a changed body. */\n prepared?: PendingContent[]\n content?: PromptContent[]\n receipts?: Map<number, string>\n}\n\n/** Prepare the exact edit body for the existing Session; the host sends it on submit. */\nexport async function prepareEditContent(\n host: EditHost, preview: EditPrepareValue, text: string, submission: EditSubmission,\n signal: AbortSignal, attachments?: readonly DraftAttachment[],\n): Promise<readonly PromptContent[]> {\n submission.prepared ??= await buildContent(host, preview, text, signal, attachments)\n await stageContent(host, preview, submission, preview.sessionId, signal)\n return submission.content!\n}\n\nasync function stageContent(host: EditHost, preview: EditPrepareValue, submission: EditSubmission, sessionId: string, signal: AbortSignal): Promise<void> {\n const prepared = submission.prepared!\n if (submission.content !== undefined) return\n const content: PromptContent[] = []\n const receipts = submission.receipts ??= new Map()\n for (const [index, part] of prepared.entries()) {\n signal.throwIfAborted()\n if (part.type !== 'upload' && !(part.type === 'file' && 'attachmentId' in part)) { content.push(part); continue }\n let receiptId = receipts.get(index)\n if (receiptId === undefined) {\n const result = part.type === 'upload'\n ? host.uploadFile?.(sessionId, part.file, signal)\n : host.stageFile?.({ sessionId: preview.sessionId, promptSeq: preview.promptSeq, attachmentId: part.attachmentId }, signal)\n if (!result) throw new HostOperationError('session/lifecycle-unavailable')\n const value = await unwrap(result) as { receiptId?: unknown }\n if (typeof value?.receiptId !== 'string' || value.receiptId === '') throw new HostOperationError('session/attachment-invalid')\n receiptId = value.receiptId\n receipts.set(index, receiptId)\n }\n content.push({ type: 'file', receiptId })\n }\n submission.content = content\n}\n\n/** Read the exact human prompt that the editor edits. */\nexport async function previewEdit(\n host: EditHost,\n sessionId: string,\n promptSeq: number,\n signal: AbortSignal,\n): Promise<EditPrepareValue> {\n if (typeof host.prepare !== 'function') throw new HostOperationError('session/lifecycle-unavailable')\n return readPreview(await unwrap(host.prepare({ sessionId, promptSeq }, signal)))\n}\n","import { useEffect, useRef, useState, useSyncExternalStore, type ReactNode } from 'react'\nimport { Button, Modal, Tooltip } from '@deepseek-ai/dsh-client-ui-primitives'\nimport { MessageEditor } from './message-editor.tsx'\nimport { EditMessageIcon } from './edit-icon.tsx'\nimport { HostOperationError, isStaleRetryFailure, readFailure, type RetryModel } from './session-actions.ts'\nimport { prepareEditContent, previewEdit, type DraftAttachment, type EditHost, type EditSubmission } from './edit-host.ts'\nimport type { EditPrepareValue } from './contracts.ts'\nimport { FREE_CHAT_ROOT } from './styles.ts'\nimport { failureText, uiText, type CopyLocale, type OperationFailure } from './ui-copy.ts'\n\n/** Edit one human prompt in its own Session; the host switches branches when the edit is sent. */\nexport function EditActions(props: {\n promptSeq?: number; sessionId?: string; messageId?: string; locale: CopyLocale\n host: EditHost; nativeRetry: RetryModel\n useSessionAccess?: (sessionId: string, action: string) => boolean\n ids?: () => string\n render?: (actions: ReactNode, editor: ReactNode) => React.ReactElement\n}): React.ReactElement | null {\n const sessionId = props.sessionId ?? ''\n const native = useSyncExternalStore(props.nativeRetry.subscribe, props.nativeRetry.getSnapshot, props.nativeRetry.getSnapshot)\n const [confirming, setConfirming] = useState(false)\n const [busy, setBusy] = useState(false)\n const [editing, setEditing] = useState(false)\n const [draft, setDraft] = useState('')\n const [attachments, setAttachments] = useState<DraftAttachment[]>([])\n const [mediaChanged, setMediaChanged] = useState(false)\n const [locked, setLocked] = useState(false)\n const [failure, setFailure] = useState<OperationFailure>()\n const preview = useRef<EditPrepareValue>()\n const submission = useRef<EditSubmission>()\n const signal = useRef(new AbortController())\n useEffect(() => {\n const controller = new AbortController()\n signal.current = controller\n return () => { controller.abort() }\n }, [sessionId, props.promptSeq])\n const allowed = props.useSessionAccess?.(sessionId, 'session/prompt') ?? true\n const copy = (key: Parameters<typeof uiText>[1]) => uiText(props.locale, key)\n const mine = native.sessionId === sessionId && native.messageId === props.messageId\n useEffect(() => {\n if (editing && !busy && native.controlsRetry && !mine) setEditing(false)\n }, [editing, busy, native.controlsRetry, mine])\n // Host capability is global and false while loading; it must not hide a new session's edit entry.\n if (!allowed || !sessionId || props.promptSeq === undefined || !props.host.prepare) return props.render?.(null, null) ?? null\n\n const run = async (action: 'edit' | 'send') => {\n if (busy || signal.current.signal.aborted) return\n setBusy(true)\n setFailure(undefined)\n try {\n if (!native.controlsRetry || !props.messageId) throw new HostOperationError('session/lifecycle-unavailable')\n if (action === 'edit') {\n const value = await previewEdit(props.host, sessionId, props.promptSeq!, signal.current.signal)\n await props.nativeRetry.beginEdit(sessionId, props.messageId, value.text, signal.current.signal)\n const state = props.nativeRetry.getSnapshot()\n if (!state.editing) { setFailure(state.failure); return }\n preview.current = value\n submission.current = { requestId: (props.ids ?? (() => crypto.randomUUID()))() }\n setDraft(value.text)\n setAttachments((value.content ?? []).filter((part): part is Exclude<NonNullable<EditPrepareValue['content']>[number], { type: 'text' }> => part.type !== 'text'))\n setMediaChanged(false)\n setLocked(false)\n setEditing(true)\n return\n }\n if (!preview.current || !submission.current) return\n if (mediaChanged && native.controlsContent !== true) throw new HostOperationError('session/retry-media-unavailable')\n setLocked(true)\n const content = mediaChanged ? await prepareEditContent(props.host, preview.current, draft, submission.current, signal.current.signal, attachments) : undefined\n props.nativeRetry.setDraft(draft)\n await props.nativeRetry.sendEdit(sessionId, props.messageId, signal.current.signal, content, true)\n const state = props.nativeRetry.getSnapshot()\n setFailure(state.failure)\n if (!state.editing) setEditing(false)\n else if (isStaleRetryFailure(state.failure)) setLocked(false)\n } catch (error) {\n if (!signal.current.signal.aborted) setFailure(readFailure(error))\n } finally {\n if (!signal.current.signal.aborted) setBusy(false)\n }\n }\n const cancel = () => {\n if (busy) return\n props.nativeRetry.cancelEdit()\n setEditing(false)\n setFailure(undefined)\n }\n const invalidatePrepared = () => {\n if (submission.current) submission.current = { requestId: submission.current.requestId }\n }\n const actions = <span className={`${FREE_CHAT_ROOT} dsh-free-actions`}>\n <Tooltip label={copy('edit')} side=\"bottom\">\n <Button className=\"dsm-icon-action\" size=\"sm\" variant=\"ghost\" aria-label={copy('edit')}\n disabled={busy || native.busy || (native.editing && !mine)} onClick={() => { void run('edit') }}><EditMessageIcon /></Button>\n </Tooltip>\n {failure && !editing ? <span className=\"dsh-ui-error dsh-free-alert\" role=\"alert\">{failureText(props.locale, failure)}</span> : null}\n </span>\n const editor = editing ? <MessageEditor text={draft} setText={text => { invalidatePrepared(); setDraft(text) }} attachments={attachments}\n setAttachments={native.controlsContent ? items => { invalidatePrepared(); setAttachments(items); setMediaChanged(true) } : undefined} sessionId={sessionId} host={props.host}\n locale={props.locale} busy={busy} locked={locked} onCancel={cancel} onSend={() => { setConfirming(true) }}\n error={failure ? failureText(props.locale, failure) : undefined} /> : null\n const content = props.render ? props.render(actions, editor) : <>{actions}{editor}</>\n return <>{content}<Modal open={confirming && editing} className={FREE_CHAT_ROOT} title={copy('editTitle')}\n closeLabel={copy('close')} onClose={() => { setConfirming(false) }} footer={<>\n <Button variant=\"ghost\" data-modal-autofocus onClick={() => { setConfirming(false) }}>{copy('cancel')}</Button>\n <Button variant=\"primary\" onClick={() => { setConfirming(false); void run('send') }}>{copy('editConfirm')}</Button>\n </>}><p>{copy('editBranchWarning')}</p></Modal></>\n}\n","import { Fragment, useEffect, useRef, useState, type ReactNode } from 'react'\nimport {\n Button,\n IconCheckOutlineRegular,\n IconCopyOutlineRegular,\n fileExtension,\n FileTypeIcon,\n fileSizeText,\n JsonBlock,\n Tooltip,\n writeClipboard,\n} from '@deepseek-ai/dsh-client-ui-primitives'\nimport { EditActions } from './edit-actions.tsx'\nimport type { EditHost } from './edit-host.ts'\nimport type { RetryModel } from './session-actions.ts'\nimport { UserMessageActions } from './user-actions.tsx'\nimport { FREE_CHAT_ROOT } from './styles.ts'\nimport type { CopyLocale } from './ui-copy.ts'\n\ninterface ContentBlock {\n type?: string\n text?: string\n attachment?: unknown\n}\n\ninterface PresentedImage {\n readonly type: 'image'\n readonly image: { readonly attachment: unknown }\n}\n\ninterface PresentedFile {\n readonly type: 'file'\n readonly file: {\n readonly attachmentId: string\n readonly name: string\n readonly bytes: number\n }\n}\n\ninterface UserNodeData {\n readonly seq: number\n readonly time: number\n readonly content: readonly ContentBlock[]\n readonly referenceLabels?: readonly string[]\n readonly skillNames?: readonly string[]\n}\n\ninterface UserNode {\n readonly id: string\n readonly data: UserNodeData\n}\n\ninterface UserContentInput {\n readonly content: {\n readonly text: string\n readonly attachments: readonly (PresentedImage | PresentedFile)[]\n readonly extraBlocks: readonly ContentBlock[]\n readonly referenceLabels?: readonly string[]\n }\n readonly loadImage?: unknown\n readonly facts: { readonly sessionLabels?: readonly string[]; readonly skillNames?: readonly string[] }\n readonly interactive: boolean\n}\n\ninterface UserNodeProps {\n readonly node: UserNode\n readonly sessionId?: string\n readonly locale: CopyLocale\n readonly host: EditHost\n readonly nativeRetry: RetryModel\n readonly useSessionAccess?: (sessionId: string, action: string) => boolean\n /** Current hosts own the complete content stack, including images and reference chips. */\n readonly renderFactorySlot?: (name: 'conversation.chat.user.content', input: UserContentInput) => ReactNode\n readonly loadImage?: unknown\n /** Older hosts expose only the image renderer. */\n readonly renderMessageImages?: (input: {\n readonly images: readonly { readonly attachment: unknown }[]\n readonly align: 'end'\n readonly compact: boolean\n }) => ReactNode\n readonly t: (key: string, params?: Record<string, unknown>) => string\n readonly ids?: () => string\n}\n\nfunction contentParts(content: readonly ContentBlock[]): {\n text: string\n attachments: (PresentedImage | PresentedFile)[]\n rest: ContentBlock[]\n} {\n const texts: string[] = []\n const attachments: (PresentedImage | PresentedFile)[] = []\n const rest: ContentBlock[] = []\n for (const block of content) {\n if (block.type === 'text' && typeof block.text === 'string') texts.push(block.text)\n else if (block.type === 'image' && block.attachment !== undefined) {\n attachments.push({ type: 'image', image: { attachment: block.attachment } })\n } else if (block.type === 'file' && block.attachment !== undefined) {\n attachments.push({ type: 'file', file: block.attachment as PresentedFile['file'] })\n } else rest.push(block)\n }\n return { text: texts.join(''), attachments, rest }\n}\n\nfunction pad2(value: number): string {\n return String(value).padStart(2, '0')\n}\n\nfunction messageClock(time: number, t: UserNodeProps['t']): string {\n const date = new Date(time)\n const now = new Date()\n const clock = `${pad2(date.getHours())}:${pad2(date.getMinutes())}`\n if (date.getFullYear() === now.getFullYear() && date.getMonth() === now.getMonth() && date.getDate() === now.getDate()) return clock\n const params = { y: date.getFullYear(), m: date.getMonth() + 1, d: date.getDate() }\n const day = date.getFullYear() === now.getFullYear() ? t('clock.md', params) : t('clock.ymd', params)\n return `${day} ${clock}`\n}\n\nfunction MessageChrome(props: {\n text: string\n time: number\n t: UserNodeProps['t']\n children?: ReactNode\n}): React.ReactElement {\n const [copied, setCopied] = useState(false)\n const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined)\n const pending = useRef(false)\n useEffect(() => () => {\n pending.current = false\n if (timer.current !== undefined) clearTimeout(timer.current)\n }, [])\n const copy = () => {\n if (copied || pending.current) return\n pending.current = true\n void writeClipboard(props.text).then(ok => {\n pending.current = false\n if (!ok) return\n setCopied(true)\n timer.current = setTimeout(() => { setCopied(false) }, 1000)\n })\n }\n return (\n <div className=\"dsm-user-chrome\">\n <span className=\"dsm-user-time\">{messageClock(props.time, props.t)}</span>\n {props.children}\n <Tooltip label={copied ? props.t('copied') : props.t('copy')} side=\"bottom\">\n <Button size=\"sm\" variant=\"ghost\" className=\"dsm-icon-action\" aria-label={copied ? props.t('copied') : props.t('copy')} onClick={copy}>\n {copied ? <IconCheckOutlineRegular /> : <IconCopyOutlineRegular />}\n </Button>\n </Tooltip>\n </div>\n )\n}\n\n/** User-message bubble whose own action row edits the exact prompt in place. */\nexport function UserNodeWithEdit(props: UserNodeProps): React.ReactElement {\n const { text, attachments, rest } = contentParts(props.node.data.content)\n const compactImages = attachments.length > 1\n const truncated = (total: number) => props.t('json.truncated', { total })\n const data = props.node.data\n return (\n <EditActions promptSeq={data.seq} sessionId={props.sessionId} locale={props.locale} host={props.host}\n nativeRetry={props.nativeRetry} useSessionAccess={props.useSessionAccess} ids={props.ids} messageId={props.node.id}\n render={(actions, editor) => <div className={`${FREE_CHAT_ROOT} dsm-user-row`}>\n {editor}\n <div className=\"dsm-user-original\" hidden={Boolean(editor)}>{!props.renderMessageImages && props.renderFactorySlot ? props.renderFactorySlot('conversation.chat.user.content', {\n content: {\n text, attachments, extraBlocks: rest,\n ...data.referenceLabels === undefined ? {} : { referenceLabels: data.referenceLabels },\n },\n loadImage: props.loadImage,\n facts: {\n ...data.referenceLabels === undefined ? {} : { sessionLabels: data.referenceLabels },\n ...data.skillNames === undefined ? {} : { skillNames: data.skillNames },\n },\n interactive: true,\n }) : <div className=\"dsm-user-stack\">\n {attachments.length > 0 ? (\n <div className=\"dsm-user-attachments\" data-message-attachments>\n {attachments.map((attachment, index) => attachment.type === 'image' ? (\n <Fragment key={`image:${index}`}>\n {props.renderMessageImages?.({ images: [attachment.image], align: 'end', compact: compactImages })}\n </Fragment>\n ) : (\n <span key={`file:${index}`} className=\"dsm-file-card\" title={attachment.file.name}>\n <FileTypeIcon path={attachment.file.name} className=\"dsm-file-icon\" />\n <span className=\"dsm-file-content\">\n <span className=\"dsm-file-name\">{attachment.file.name}</span>\n <span className=\"dsm-file-meta\">\n {[fileExtension(attachment.file.name).toUpperCase().slice(0, 8), fileSizeText(attachment.file.bytes)].filter(Boolean).join(' ')}\n </span>\n </span>\n </span>\n ))}\n </div>\n ) : null}\n {text !== '' || rest.length > 0 ? (\n <div className=\"dsm-user-bubble\">\n {text}\n {rest.map((block, index) => <JsonBlock key={index} label={props.t('message.extraBlock')} payload={block} truncatedLabel={truncated} />)}\n </div>\n ) : null}\n {data.referenceLabels !== undefined && data.referenceLabels.length > 0 ? (\n <div className=\"dsm-reference-summary\">\n {props.t('message.referenceSummary', { labels: data.referenceLabels.join(props.t('message.referenceSeparator')) })}\n </div>\n ) : null}\n </div>}\n <MessageChrome text={text} time={data.time} t={props.t}>\n <UserMessageActions\n messageId={props.node.id}\n text={text}\n sessionId={props.sessionId ?? ''}\n locale={props.locale}\n model={props.nativeRetry}\n hideEdit={Boolean(actions)}\n />\n {actions}\n </MessageChrome></div>\n </div>} />\n )\n}\n","import type { PromptContent } from './edit-host.ts'\n\nexport const RETRY_CAPABILITIES_ENDPOINT = 'retry.capabilities'\nexport const RETRY_PREVIEW_ENDPOINT = 'retry.preview'\nexport const RETRY_COMMIT_ENDPOINT = 'retry.commit'\n\nexport interface RetryCapabilities {\n readonly retry: boolean\n readonly retryModified: boolean\n readonly retryContent: boolean\n}\n\nexport interface RetryPreviewRequest {\n readonly sessionId: string\n readonly messageId: string\n}\n\nexport interface RetryPreviewValue {\n readonly sessionId: string\n readonly messageId: string\n readonly promptSeq: number\n readonly branchRevision: number\n readonly inputRevision: string\n readonly eligible: boolean\n readonly modified: boolean\n readonly reason?: string\n}\n\nexport interface RetryCommitRequest {\n readonly sessionId: string\n readonly messageId: string\n readonly expectedRevision: number\n readonly expectedInputRevision: string\n readonly requestId: string\n readonly text?: string\n readonly content?: readonly PromptContent[]\n readonly allowModified?: boolean\n}\n\nexport interface RetryCommitValue {\n /** The forked session the conversation continues in. */\n readonly sessionId: string\n /** The session the prompt was edited out of. */\n readonly sourceSessionId: string\n /** Whether the source session was moved to the archive. */\n readonly archived: boolean\n}\n","import type { PresenceRpc } from './presence-model.ts'\nimport {\n RETRY_CAPABILITIES_ENDPOINT,\n RETRY_COMMIT_ENDPOINT,\n RETRY_PREVIEW_ENDPOINT,\n type RetryCapabilities,\n type RetryCommitRequest,\n type RetryCommitValue,\n type RetryPreviewRequest,\n type RetryPreviewValue,\n} from './retry-contracts.ts'\nimport { TEMP_WORKSPACE_CHANNEL } from './contracts.ts'\nimport { HostOperationError, unwrap } from './session-actions.ts'\n\nexport interface RetryHost {\n capabilities: () => Promise<RetryCapabilities>\n preview: (request: RetryPreviewRequest, signal?: AbortSignal) => Promise<RetryPreviewValue>\n commit: (request: RetryCommitRequest, signal?: AbortSignal) => Promise<RetryCommitValue>\n}\n\nexport function bindRetryHost(rpc: PresenceRpc | undefined): RetryHost {\n const call = (endpoint: string, payload: unknown, signal?: AbortSignal) => {\n if (typeof rpc?.call !== 'function') throw new HostOperationError('session/lifecycle-unavailable')\n return rpc.call(TEMP_WORKSPACE_CHANNEL, endpoint, payload, signal)\n }\n return {\n async capabilities() {\n const value = await unwrap(call(RETRY_CAPABILITIES_ENDPOINT, {}))\n if (!isCapabilities(value)) throw new HostOperationError('session-manager/unavailable')\n return value\n },\n async preview(request, signal) {\n const value = await unwrap(call(RETRY_PREVIEW_ENDPOINT, request, signal))\n if (!isPreview(value)) throw new HostOperationError('session-manager/unavailable')\n return value\n },\n async commit(request, signal) {\n const value = await unwrap(call(RETRY_COMMIT_ENDPOINT, request, signal))\n if (!isCommit(value)) throw new HostOperationError('session-manager/unavailable')\n return value\n },\n }\n}\n\n/**\n * Commit then navigate: the forked child is the chat the user keeps, so the\n * browser follows a successful commit to the new session. `open` is absent\n * only when the host has no workspace navigation; the commit value returns\n * either way.\n */\nexport function retryCommitAndOpen(\n commit: RetryHost['commit'],\n open: ((sessionId: string) => void | Promise<void>) | undefined,\n): RetryHost['commit'] {\n return async (request, signal) => {\n const value = await commit(request, signal)\n try { await open?.(value.sessionId) }\n catch { throw new HostOperationError('session/retry-pending') }\n return value\n }\n}\n\nfunction isCapabilities(value: unknown): value is RetryCapabilities {\n if (typeof value !== 'object' || value === null) return false\n const item = value as Partial<RetryCapabilities>\n return typeof item.retry === 'boolean'\n && typeof item.retryModified === 'boolean'\n && typeof item.retryContent === 'boolean'\n}\n\nfunction isPreview(value: unknown): value is RetryPreviewValue {\n if (typeof value !== 'object' || value === null) return false\n const item = value as Partial<RetryPreviewValue>\n return typeof item.sessionId === 'string'\n && typeof item.messageId === 'string'\n && Number.isSafeInteger(item.promptSeq)\n && typeof item.branchRevision === 'number'\n && typeof item.inputRevision === 'string'\n && typeof item.eligible === 'boolean'\n && typeof item.modified === 'boolean'\n}\n\nfunction isCommit(value: unknown): value is RetryCommitValue {\n if (typeof value !== 'object' || value === null) return false\n const item = value as Partial<RetryCommitValue>\n return typeof item.sessionId === 'string'\n && typeof item.sourceSessionId === 'string'\n && typeof item.archived === 'boolean'\n}\n","import type { Context } from '@deepseek-ai/cordis'\nimport { MenuItemButton } from '@deepseek-ai/dsh-client-ui-primitives'\nimport { useSyncExternalStore } from 'react'\nimport { copyLocale, type CopyLocale, type UiTextKey } from './ui-copy.ts'\nimport {\n CONTINUE_GHOST_ID,\n PLUGIN_NAME,\n CONTINUE_GHOST_SLOT,\n DELETE_DIALOG_ID,\n TEMP_WORKSPACE_CHANNEL,\n USER_ACTIONS_ID,\n USER_ACTIONS_SLOT,\n WELCOME_BACK_CARD_ID,\n TURN_TAIL_SLOT,\n SESSION_SETTINGS_ITEMS,\n} from './contracts.ts'\nimport { installContextMenuForwarding } from './context-menu.ts'\nimport { CreateNoticeDialog, DeleteChatDialog } from './free-panel.tsx'\nimport { installTemporaryWorkspacePicker, TemporaryWorkspaceNotice, type PickerRegistry } from './temporary-picker.tsx'\nimport { bindTemporaryWorkspaceHost, createTemporaryWorkspaceModel } from './temporary-workspace.ts'\nimport { bindHost, createFreeChatModel, createRetryModel, type FreeChatModel, type RetryModel } from './session-actions.ts'\nimport { bindPresenceHost, createContinueModel, createPresenceConfigModel, createWelcomeBackModel } from './presence-model.ts'\nimport { AutoContinueOption } from './auto-continue-option.tsx'\nimport { modelSettingsChangesIdentity } from '@klarkxy/dsh-plugin-kit/contracts'\nimport { registerSessionSettingsItem } from '@klarkxy/dsh-plugin-kit/client-utils'\nimport { registerAuxiliaryModelSettings } from '@klarkxy/dsh-plugin-kit/auxiliary-model-client'\nimport { createModelSettingsSubscriber, mountModelSettingsChanges } from '@klarkxy/dsh-plugin-kit/model-settings-client'\nimport { MODEL_CATALOG_INJECT, readModelCatalog } from '@klarkxy/dsh-model-route'\nimport type { RenderFactorySlot } from '@klarkxy/dsh-plugin-kit/model-picker'\nimport { ContinueGhost, WelcomeBackCard, type WelcomeBackTurn } from './presence-panel.tsx'\nimport {\n AgentActionsSettings,\n AutoContinueSettings,\n ComposerSettings,\n HandoffSettings,\n ReturnSettings,\n SessionSettingsDetails,\n} from './settings-panel.tsx'\nimport { freeChatCss } from './styles.ts'\nimport { UserMessageActions } from './user-actions.tsx'\nimport { UserNodeWithEdit } from './user-node.tsx'\nimport { bindEditHost } from './edit-host.ts'\nimport { bindRetryHost, retryCommitAndOpen } from './retry-host.ts'\nimport { uiText } from './ui-copy.ts'\n\nexport const name = 'dsh-session-manager-client'\nexport const inject = ['slots', 'locale', 'sessions', 'uiWorkspace', 'connection', 'workspaces', 'layout', 'conversation', ...MODEL_CATALOG_INJECT] as const\n\ninterface LocaleService {\n getSnapshot(): { active: string }\n subscribe(listener: () => void): () => void\n register?(namespace: string, dictionaries: { zh: Record<string, string>; en: Record<string, string> }): (() => void) | void\n}\n\ninterface MenuProps {\n sessionId: string\n useMenuOpenState: () => [boolean, (open: boolean) => void]\n}\n\ninterface SlotRegistry {\n inject(key: string, callback: () => (() => void) | void): () => void\n register(spec: Record<string, unknown>, render: (props: never) => unknown): () => void\n}\n\ntype Client = Context & {\n slots: SlotRegistry\n locale?: LocaleService\n sessions?: Parameters<typeof bindHost>[0]['sessions']\n uiWorkspace?: Parameters<typeof bindHost>[0]['uiWorkspace']\n remote?: { session?: { modelCatalog?: () => Promise<unknown> } }\n connection?: {\n generation?: { subscribe(listener: () => void): () => void }\n rpc?: { call(channel: string, endpoint: string, payload: unknown, signal?: AbortSignal): Promise<unknown> }\n }\n on?(name: string, listener: () => void): () => void\n}\n\nexport function apply(ctx: Context): void {\n const client = ctx as Client\n mountModelSettingsChanges(client, PLUGIN_NAME)\n const host = bindHost(client)\n const chats = createFreeChatModel(host)\n const retryHost = bindRetryHost(client.connection?.rpc)\n const retries = createRetryModel({\n list: host.list,\n capabilities: () => retryHost.capabilities(),\n previewRetry: request => retryHost.preview(request),\n retry: retryCommitAndOpen(retryHost.commit, host.openSession),\n })\n const editHost = bindEditHost(client as unknown as Parameters<typeof bindEditHost>[0])\n const temporaryHost = bindTemporaryWorkspaceHost(client as unknown as Parameters<typeof bindTemporaryWorkspaceHost>[0])\n const temporary = createTemporaryWorkspaceModel(temporaryHost, undefined,\n () => uiText(copyLocale(client.locale?.getSnapshot().active), 'tempWorkspace'))\n const presenceHost = bindPresenceHost(client)\n const continues = createContinueModel(presenceHost)\n const welcomeBack = createWelcomeBackModel(presenceHost)\n const presenceConfig = createPresenceConfigModel(presenceHost)\n // Model catalog access uses the same dependency contract as every model menu.\n const settingsSubscriber = createModelSettingsSubscriber(client as unknown as Parameters<typeof createModelSettingsSubscriber>[0], PLUGIN_NAME, modelSettingsChangesIdentity(PLUGIN_NAME))\n const subscribeSettings = (onChange: () => void, onError?: (message: string) => void) =>\n settingsSubscriber.subscribe(onChange, onError)\n const modelCatalog = () => readModelCatalog(client)\n const subscribeCatalog = (onChange: () => void) => client.connection?.generation?.subscribe(onChange)\n client.effect(() => {\n const stops: Array<() => void> = []\n // The relay needs no host slot and no service; a non-browser host simply skips it.\n if (typeof document !== 'undefined') stops.push(installContextMenuForwarding(document))\n stops.push(client.slots.inject('sidebar.workspaces.session.menu.item', () => (\n client.slots.register({\n name: 'sidebar.workspaces.session.menu.item',\n id: DELETE_DIALOG_ID,\n order: 510,\n }, props => <DeleteMenuItem locale={client.locale} model={chats} {...props as MenuProps} />)\n )))\n stops.push(installTemporaryWorkspacePicker(client.slots as unknown as PickerRegistry, temporary,\n temporaryHost.createWorkspace, client.locale))\n stops.push(client.slots.inject('conversation.hero.options', () => (\n client.slots.register({\n name: 'conversation.hero.options',\n id: 'auto-continue',\n order: 30,\n inject: () => ({\n call: (endpoint: string, payload: unknown) => client.connection?.rpc?.call(TEMP_WORKSPACE_CHANNEL, endpoint, payload),\n subscribeGeneration: (listener: () => void) => client.connection?.generation?.subscribe(listener),\n }),\n }, props => (\n <AutoContinueOption\n sessionId={(props as { sessionId: string }).sessionId}\n call={(props as { call: (endpoint: string, payload: unknown) => Promise<unknown> }).call}\n subscribeGeneration={(props as { subscribeGeneration?: (listener: () => void) => (() => void) | undefined }).subscribeGeneration}\n useSession={(props as { useSession?: <T>(selector: (snapshot: import('./auto-continue-option.tsx').AutoContinueSessionSnapshotLike) => T) => T }).useSession}\n locale={useLiveLocale(client.locale)}\n />\n ))\n )))\n stops.push(client.slots.inject(USER_ACTIONS_SLOT, () => (\n client.slots.register({\n name: USER_ACTIONS_SLOT,\n id: USER_ACTIONS_ID,\n order: 10,\n inject: (sessionId: string) => ({ sessionId }),\n }, props => (\n <UserMessageActions\n messageId={(props as { messageId: string }).messageId}\n text={(props as { text: string }).text}\n sessionId={(props as { sessionId?: string }).sessionId ?? ''}\n locale={useLiveLocale(client.locale)}\n model={retries}\n />\n ))\n )))\n stops.push(client.slots.inject(CONTINUE_GHOST_SLOT, () => (\n client.slots.register({\n name: CONTINUE_GHOST_SLOT,\n id: CONTINUE_GHOST_ID,\n order: 10,\n }, props => (\n <ContinueGhost\n sessionId={(props as { sessionId?: string }).sessionId}\n useInput={(props as { useInput?: never }).useInput}\n useSession={(props as { useSession?: never }).useSession}\n useSessionStatus={(props as { useSessionStatus?: never }).useSessionStatus}\n inputActions={(props as { inputActions?: never }).inputActions}\n locale={useLiveLocale(client.locale)}\n model={continues}\n />\n ))\n )))\n // The stock host has no additive user-action slot. Replace only its user\n // renderer, preserving the bubble, copy, and clock while adding exact-seq editing.\n stops.push(client.slots.inject('conversation.chat.node', () => (\n client.slots.register({ name: 'conversation.chat.node', key: 'user', locale: 'chat', priority: -10 }, props => {\n const input = props as unknown as Parameters<typeof UserNodeWithEdit>[0]\n return (\n <UserNodeWithEdit\n {...input}\n sessionId={(props as { sessionId?: string }).sessionId}\n locale={useLiveLocale(client.locale)}\n host={editHost}\n nativeRetry={retries}\n />\n )\n })\n )))\n // Recap card lives in the chat flow at the latest completed turn's tail,\n // after the shipped deliverables/plan/schedule entries (orders 0/0/20).\n stops.push(client.slots.inject(TURN_TAIL_SLOT, () => (\n client.slots.register({\n name: TURN_TAIL_SLOT,\n id: WELCOME_BACK_CARD_ID,\n order: 30,\n }, props => (\n <WelcomeBackCard\n sessionId={(props as { sessionId?: string }).sessionId}\n turn={(props as { turn?: WelcomeBackTurn }).turn}\n useChat={(props as { useChat?: never }).useChat}\n useInput={(props as { useInput?: never }).useInput}\n locale={useLiveLocale(client.locale)}\n model={welcomeBack}\n />\n ))\n )))\n // Session preferences contribute four rows to the shared Session\n // Management settings section. The kit-owned base service owns the page,\n // so this plugin neither registers a section itself nor falls back to the\n // General page. Every row's body mounts on first expand only, so model-\n // catalog and config reads do not run until the user opens it, and stays\n // mounted while collapsed so a fold never drops an in-progress draft.\n // The rows share presenceConfig (loads dedupe); the live settings change\n // stream reloads it at the plugin level, so the rows do not subscribe.\n const registerSettingsRow = (\n item: (typeof SESSION_SETTINGS_ITEMS)[number],\n testId: string,\n titleKey: UiTextKey,\n descKey: UiTextKey,\n body: (locale: CopyLocale, renderFactorySlot?: RenderFactorySlot) => React.ReactNode,\n ) => stops.push(registerSessionSettingsItem(\n ctx,\n item,\n slotProps => {\n const locale = useLiveLocale(client.locale)\n return (\n <SessionSettingsDetails testId={testId} titleKey={titleKey} descKey={descKey} locale={locale}>\n {body(locale, (slotProps as { renderFactorySlot?: RenderFactorySlot } | undefined)?.renderFactorySlot)}\n </SessionSettingsDetails>\n )\n },\n ))\n const catalogProps = { modelCatalog, subscribeCatalog }\n registerSettingsRow(\n SESSION_SETTINGS_ITEMS[0],\n 'session-manager-composer-settings-item',\n 'composerGroupTitle',\n 'composerGroupHint',\n (locale, renderFactorySlot) => <ComposerSettings model={presenceConfig} locale={locale} renderFactorySlot={renderFactorySlot} {...catalogProps} />,\n )\n registerSettingsRow(\n SESSION_SETTINGS_ITEMS[1],\n 'session-manager-auto-continue-settings-item',\n 'autoContinueGroup',\n 'autoContinueGroupHint',\n (locale, renderFactorySlot) => <AutoContinueSettings model={presenceConfig} locale={locale} renderFactorySlot={renderFactorySlot} {...catalogProps} />,\n )\n registerSettingsRow(\n SESSION_SETTINGS_ITEMS[2],\n 'session-manager-return-settings-item',\n 'returnGroupTitle',\n 'returnGroupHint',\n (locale, renderFactorySlot) => <ReturnSettings model={presenceConfig} locale={locale} renderFactorySlot={renderFactorySlot} {...catalogProps} />,\n )\n registerSettingsRow(\n SESSION_SETTINGS_ITEMS[3],\n 'session-manager-handoff-settings-item',\n 'handoffGroupTitle',\n 'handoffGroupHint',\n (locale, renderFactorySlot) => <HandoffSettings model={presenceConfig} locale={locale} renderFactorySlot={renderFactorySlot} {...catalogProps} />,\n )\n registerSettingsRow(\n SESSION_SETTINGS_ITEMS[4],\n 'session-manager-agent-actions-settings-item',\n 'agentActionsGroup',\n 'agentActionsGroupHint',\n locale => <AgentActionsSettings model={presenceConfig} locale={locale} />,\n )\n stops.push(client.slots.inject('shell.overlay', () => (\n client.slots.register({\n name: 'shell.overlay',\n id: DELETE_DIALOG_ID,\n order: 40,\n }, () => {\n const locale = useLiveLocale(client.locale)\n return (\n <>\n <style>{freeChatCss}</style>\n <TemporaryWorkspaceNotice model={temporary} locale={locale} />\n <DeleteChatDialog model={chats} locale={locale} />\n <CreateNoticeDialog model={chats} locale={locale} />\n </>\n )\n })\n )))\n // Shared \"default auxiliary model\" card on the Models settings page: one\n // root-owned card for every participant plugin, released with this effect.\n stops.push(registerAuxiliaryModelSettings(ctx))\n // Return triggers: window refocus, tab visibility, current-session switch, first mount.\n const findCurrent = () => Object.values(client.sessions?.list.getSnapshot().byId ?? {})\n .find(row => (row?.retainedBy?.mainView ?? 0) > 0)?.id ?? ''\n let current = findCurrent()\n const onReturn = () => {\n const id = findCurrent()\n if (id !== '') void welcomeBack.check(id)\n }\n let lastThresholds: string | undefined\n let lastContinuation: string | undefined\n stops.push(presenceConfig.subscribe(() => {\n const config = presenceConfig.getSnapshot()\n if (config.phase !== 'ready' || config.saving || config.values === undefined) return\n const continuation = JSON.stringify([config.values.continueMode, config.values.continueText, config.values.ghostModel])\n if (continuation !== lastContinuation) {\n lastContinuation = continuation\n continues.invalidateAll()\n }\n const thresholds = `${config.values.recapMinutes}:${config.values.compactMinutes}`\n if (thresholds !== lastThresholds) {\n lastThresholds = thresholds\n welcomeBack.invalidate()\n onReturn()\n }\n }))\n // Keep synchronization alive even when the settings page is never opened.\n stops.push(subscribeSettings(() => { void presenceConfig.load() }))\n const refreshConfig = () => { void presenceConfig.load().then(onReturn) }\n const watchGeneration = client.connection?.generation?.subscribe(refreshConfig)\n if (watchGeneration) stops.push(watchGeneration)\n if (typeof window !== 'undefined') {\n const refreshOnReturn = refreshConfig\n const onVisibility = () => { if (!document.hidden) refreshOnReturn() }\n window.addEventListener('focus', refreshOnReturn)\n document.addEventListener('visibilitychange', onVisibility)\n const timer = setTimeout(refreshOnReturn, 1_500)\n // A continuously visible conversation must also cross an idle threshold\n // without requiring the user to blur the window or switch sessions.\n const idleTimer = setInterval(() => {\n if (!document.hidden) onReturn()\n }, 30_000)\n stops.push(() => {\n window.removeEventListener('focus', refreshOnReturn)\n document.removeEventListener('visibilitychange', onVisibility)\n clearTimeout(timer)\n clearInterval(idleTimer)\n })\n }\n const watchList = client.sessions?.list.subscribe(() => {\n const id = findCurrent()\n if (id !== current) {\n current = id\n if (id !== '') void welcomeBack.check(id)\n }\n })\n if (typeof watchList === 'function') stops.push(watchList)\n const reset = client.on?.('connection/reset', () => {\n void chats.reloadCapabilities()\n void retries.load()\n refreshConfig()\n })\n if (typeof reset === 'function') stops.push(reset)\n void chats.reloadCapabilities()\n void retries.load()\n return () => {\n chats.cancel()\n retries.cancel()\n temporary.cancel()\n continues.cancel()\n welcomeBack.cancel()\n presenceConfig.cancel()\n for (const stop of stops) stop()\n }\n })\n}\n\nfunction DeleteMenuItem(props: MenuProps & { locale?: LocaleService; model: FreeChatModel }): React.ReactElement | null {\n const locale = useLiveLocale(props.locale)\n const snapshot = useSyncExternalStore(props.model.subscribe, props.model.getSnapshot, props.model.getSnapshot)\n const [, setMenuOpen] = props.useMenuOpenState()\n if (!snapshot.controls.delete) return null\n return (\n <MenuItemButton danger onSelect={() => {\n props.model.requestDelete(props.sessionId)\n setMenuOpen(false)\n }}>\n {uiText(locale, 'deleteChat')}\n </MenuItemButton>\n )\n}\n\nfunction useLiveLocale(locale: LocaleService | undefined): CopyLocale {\n const active = useSyncExternalStore(\n listener => locale?.subscribe(listener) ?? (() => {}),\n () => locale?.getSnapshot().active ?? 'en',\n () => locale?.getSnapshot().active ?? 'en',\n )\n return copyLocale(active)\n}\n\nexport type { FreeChatModel, RetryModel }\n"],"mappings":";;;;;;AAIA,SAAgB,WAAW,QAAwC;CACjE,OAAO,QAAQ,YAAY,CAAC,CAAC,WAAW,IAAI,IAAI,OAAO;AACzD;AAOA,MAAM,UAAU;CACd,IAAI;EACF,UAAU;EACV,SAAS;EACT,SAAS;EACT,OAAO;EACP,SAAS;EACT,SAAS;EACT,aAAa;EACb,cAAc;EACd,gBAAgB;CAClB;CACA,IAAI;EACF,UAAU;EACV,SAAS;EACT,SAAS;EACT,OAAO;EACP,SAAS;EACT,SAAS;EACT,aAAa;EACb,cAAc;EACd,gBAAgB;CAClB;AACF;AAIA,MAAM,OAAO;CACX,IAAI;EACF,eAAe;EACf,cAAc;EACd,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AAK,KAAK;EACjD,MAAW,mBAAmB;EAC9B,QAAa,KAAK;EAClB,aAAa;GACX,MAAM,OAAO;GACb,QAAQ,OAAO;GACf,UAAU,OAAO;GACjB,UAAU,OAAO;GACjB,YAAY,OAAO;GACnB,eAAe,OAAO;GACtB,KAAK,MAAM,QAAQ,OAAO,KAAK;EACjC;CACF,CAAC;AACH;AAEA,SAAS,eAAe,OAAgG;CACtH,MAAM,SAAS,cAAc,MAAM,MAAM;CACzC,MAAM,YAAA,GAAWC,MAAAA,qBAAAA,CAAqB,MAAM,MAAM,WAAW,MAAM,MAAM,aAAa,MAAM,MAAM,WAAW;CAC7G,MAAM,GAAG,eAAe,MAAM,iBAAiB;CAC/C,IAAI,CAAC,SAAS,SAAS,QAAQ,OAAO;CACtC,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,sCAAAA,gBAAD;EAAgB,QAAA;EAAO,gBAAgB;GACrC,MAAM,MAAM,cAAc,MAAM,SAAS;GACzC,YAAY,KAAK;EACnB;EACG,UAAA,OAAO,QAAQ,YAAY;CACd,CAAA;AAEpB;AAEA,SAAS,cAAc,QAA+C;CAMpE,OAAO,YALD,GAASD,MAAAA,qBAAAA,EACb,aAAY,QAAQ,UAAU,QAAQ,YAAY,CAAC,UAC7C,QAAQ,YAAY,CAAC,CAAC,UAAU,YAChC,QAAQ,YAAY,CAAC,CAAC,UAAU,IAEtB,CAAM;AAC1B"}
|
|
1
|
+
{"version":3,"file":"client.inner.cjs","names":["useRef","useState","useCallback","useMemo","Button","useRef","useState","useId","useMemo","rankByName","observeStickyMenuGroups","createPortal","MenuSurface","IconChevronRightOutlineRegular","Input","IconCloseFillRegular","IconCheckOutlineRegular","MenuGroup","isValidElement","cloneElement","useSyncExternalStore","Modal","Button","useRef","useSyncExternalStore","useState","useRef","useCallback","Menu","IconFolderCloseRegular","IconPlusOutlineRegular","IconNewChatOutlineRegular","Modal","Button","store","useState","useRef","useCallback","Menu","Tooltip","Pill","IconRefreshOutlineRegular","IconChevronDownOutlineRegular","createElement","useRef","useMemo","IconChevronDownOutlineRegular","useCallback","useSyncExternalStore","useState","useRef","Button","IconChevronDownOutlineRegular","useSyncExternalStore","useRef","useState","Button","IconCloseFillRegular","useRef","useCallback","useState","useSyncExternalStore","useId","SegmentedTabs","Input","Switch","IconChevronDownOutlineRegular","useState","FileTypeIcon","useRef","Button","useState","useSyncExternalStore","useRef","Tooltip","Button","Modal","useSyncExternalStore","useState","useRef","Tooltip","Button","Modal","useState","useRef","writeClipboard","Tooltip","Button","IconCheckOutlineRegular","IconCopyOutlineRegular","Fragment","FileTypeIcon","fileExtension","fileSizeText","JsonBlock","input","useSyncExternalStore","MenuItemButton"],"sources":["../src/ui-copy.ts","../src/contracts.ts","../src/context-menu.ts","../../dsh-plugin-kit/src/official-ui.ts","../../dsh-model-route/src/route.ts","../../dsh-model-route/src/catalog.ts","../../dsh-model-route/src/catalog-ui.tsx","../../dsh-model-route/src/menu.ts","../../dsh-model-route/src/ui.tsx","../src/styles.ts","../src/free-panel.tsx","../src/temporary-picker.tsx","../src/temporary-workspace.ts","../src/session-actions.ts","../src/welcome-continuation.ts","../src/presence-model.ts","../src/auto-continue-option.tsx","../../dsh-plugin-kit/src/contracts.ts","../../dsh-plugin-kit/src/client-utils.ts","../../dsh-model-route/src/model-picker.ts","../../dsh-plugin-kit/src/model-picker.tsx","../../dsh-plugin-kit/src/model-settings-client.ts","../../dsh-plugin-kit/src/auxiliary-model-client.tsx","../src/presence-panel.tsx","../src/settings-panel.tsx","../src/message-editor.tsx","../src/edit-icon.tsx","../src/user-actions.tsx","../src/edit-host.ts","../src/edit-actions.tsx","../src/user-node.tsx","../src/retry-contracts.ts","../src/retry-host.ts","../src/client.tsx"],"sourcesContent":["/** Failure identity stored by the UI. The sentence is derived from the active locale. */\n\nexport type CopyLocale = 'zh' | 'en'\n\nexport function copyLocale(active: string | undefined): CopyLocale {\n return active?.toLowerCase().startsWith('zh') ? 'zh' : 'en'\n}\n\nexport interface OperationFailure {\n readonly code: string\n readonly reason?: string\n}\n\nconst reasons = {\n zh: {\n modified: '后续操作可能涉及修改,暂时不能重试。',\n unknown: '无法确认这个操作的结果。',\n pending: '这条消息还在等待处理。',\n stale: '这个聊天已经更新,请再试一次。',\n running: '这个聊天仍在运行。请等待当前工作结束后再试。',\n cleanup: '清理没有完成。',\n unsupported: '当前版本不能完成这个操作。',\n retryPending: '重发尚未完成。再次发送会继续同一次操作,不会新建另一份聊天。',\n retryUncertain: '上次创建聊天的结果无法确认,已停止再次创建。请先检查会话列表中是否已有新聊天。',\n },\n en: {\n modified: 'Later operations may have made changes. Retry is unavailable.',\n unknown: \"This action's result could not be confirmed.\",\n pending: 'This message is still pending.',\n stale: 'This chat has changed. Try again.',\n running: 'This chat is still running. Wait for the current work to finish, then try again.',\n cleanup: 'Cleanup did not finish.',\n unsupported: 'This runtime cannot complete that action.',\n retryPending: 'Resend is incomplete. Send again to continue the same operation without creating another chat.',\n retryUncertain: 'The previous chat creation could not be confirmed. Another chat will not be created; check the session list for an existing new chat.',\n },\n} as const\n\nexport type FailureReason = keyof typeof reasons.zh\n\nconst text = {\n zh: {\n tempWorkspace: '临时工作区',\n createFailed: '无法创建临时工作区',\n retryList: '重试',\n deleteChat: '删除聊天',\n deleting: '正在删除',\n deleteFree: '将删除这个聊天及其拥有的文件。',\n deleteOrdinary: '将删除这个聊天。项目文件会保留。',\n cancel: '取消',\n close: '关闭',\n retry: '重试',\n edit: '编辑并重发',\n send: '发送',\n editTitle: '编辑并重发',\n editBranchWarning: '对话将从这条消息继续,之前的版本会移入归档。已执行的文件、命令和外部修改不会撤销,模型可能再次执行相关操作。',\n editConfirm: '确认重发',\n editAddAttachment: '添加附件',\n editRemoveAttachment: '删除附件',\n editImage: '图片',\n editPreviewFailed: '预览不可用',\n draft: '消息文本',\n continueDefault: '继续',\n welcomeBack: '欢迎回来',\n recapSummary: '在聊什么',\n recapProgress: '目前进展',\n recapNextStep: '建议下一步',\n cacheNotice: '离开时间较久,模型的提示缓存可能已失效,下一次发送会重新处理完整上下文。可以压缩上下文,或在新会话中继续;也可以忽略提示直接发送。',\n compactNow: '压缩上下文',\n compacting: '正在压缩',\n compactCommandSent: '已调用宿主压缩命令,结果请查看对话中的压缩记录。',\n continueNew: '在新会话中继续',\n creatingContinuation: '正在创建新会话',\n continueNewHint: '在来源会话的工作区新建会话,将摘要和原会话 ID 填入草稿,不自动发送。',\n compactNothing: '没有值得压缩的内容。',\n settingsTitle: '会话管理',\n composerGroupTitle: '输入框建议',\n composerGroupHint: '输入框为空时显示的下一句建议',\n modeFixed: '固定文本',\n modeAuto: '模型生成',\n composerUsageHint: '按 Tab 填入建议,点击建议直接发送。',\n ghostModelLabel: '生成模型',\n continueSourceLabel: '内容来源',\n continueTextLabel: '固定文本内容',\n continueTextPlaceholder: '留空使用默认「继续」',\n returnGroupTitle: '回到会话时',\n returnGroupHint: '长时间离开后显示摘要或建议压缩',\n awayMinutesLabel: '离开超过',\n recapEnabledLabel: '显示会话摘要',\n recapEnabledHint: '在对话中回顾上次进展。',\n compactEnabledLabel: '建议压缩上下文',\n compactEnabledHint: '长时间离开后,建议先压缩上下文。',\n recapModelLabel: '摘要模型',\n judgeModelLabel: '判断模型',\n judgeModelHint: '判断回复是否提前结束,并写出继续消息。',\n handoffGroupTitle: '会话交接',\n handoffGroupHint: '智能体读取其他会话时生成的交接摘要',\n handoffModelLabel: '摘要模型',\n handoffModelHint: '智能体请求会话交接摘要时使用。',\n autoContinue: '自动继续',\n autoContinueOff: '关闭',\n autoContinueCautious: '谨慎',\n autoContinueBold: '奔放',\n autoContinueTooltip: '回复提前结束时自动发送继续。谨慎:有明确依据才继续;奔放:没完成就继续,低风险的选择按推荐方案走。会话开始后锁定。',\n autoContinueLocked: '请在会话开始前选择自动继续',\n autoContinueStale: '状态已在别处更改,已刷新',\n autoContinueFailed: '切换失败',\n autoContinueGroup: '自动继续',\n autoContinueGroupHint: '回复提前结束时自动发送继续',\n autoContinueModeHint: '开启方式(关闭/谨慎/奔放)在创建会话时按会话选择。',\n autoContinueMaxLabel: '续跑次数上限',\n autoContinueMaxHint: '你每发一条消息之后,最多自动继续的次数(1–10)。',\n autoContinueMaxInvalid: '请填写 1–10 的整数。',\n minutesUnit: '分钟',\n agentActionsGroup: '代理操作',\n agentActionsGroupHint: '允许 agent 自主操作会话',\n allowSelfForkLabel: '允许自我 fork',\n allowSelfForkHint: '允许 agent 自行 fork 当前会话,创建独立分支。',\n allowSendMessageLabel: '允许发送消息',\n allowSendMessageHint: '允许 agent 向其他未归档会话发送消息;空闲会话会被唤醒,运行中的会话会排队接收。',\n modelFollowOption: '默认辅助模型',\n settingsSaving: '正在保存',\n settingsSaved: '已保存',\n settingsLoading: '正在加载',\n settingsUnavailable: '当前宿主不支持在线修改配置',\n minutesInvalid: '请填写大于等于 1 的整数分钟。',\n },\n en: {\n tempWorkspace: 'Temporary Workspace',\n createFailed: 'Could not create the temporary workspace',\n retryList: 'Retry',\n deleteChat: 'Delete chat',\n deleting: 'Deleting',\n deleteFree: 'This deletes this chat and its owned files.',\n deleteOrdinary: 'This deletes this chat. Project files remain.',\n cancel: 'Cancel',\n close: 'Close',\n retry: 'Retry',\n edit: 'Edit and resend',\n send: 'Send',\n editTitle: 'Edit and resend',\n editBranchWarning: 'The conversation continues from this message; the previous version moves to the archive. File, command, and external changes already made are not undone — the model may perform those actions again.',\n editConfirm: 'Confirm resend',\n editAddAttachment: 'Add attachments',\n editRemoveAttachment: 'Remove attachment',\n editImage: 'Image',\n editPreviewFailed: 'Preview unavailable',\n draft: 'Message text',\n continueDefault: 'Continue',\n welcomeBack: 'Welcome back',\n recapSummary: 'What you were discussing',\n recapProgress: 'Where things stand',\n recapNextStep: 'Suggested next step',\n cacheNotice: 'The model prompt cache may have expired, so the next message reprocesses the full context. Compact the context, continue in a new session, or ignore this notice and send normally.',\n compactNow: 'Compact context',\n compacting: 'Compacting',\n compactCommandSent: 'Host compaction command invoked. See the compaction entry in the conversation for its result.',\n continueNew: 'Continue in a new session',\n creatingContinuation: 'Creating new session',\n continueNewHint: \"Create a session in the source session's workspace and fill its draft with the recap and source session ID, without sending.\",\n compactNothing: 'There is nothing useful to compact.',\n settingsTitle: 'Session Management',\n composerGroupTitle: 'Composer suggestion',\n composerGroupHint: 'The suggested next message shown in an empty composer',\n modeFixed: 'Fixed text',\n modeAuto: 'Model-generated',\n composerUsageHint: 'Press Tab to fill the suggestion, or click it to send.',\n ghostModelLabel: 'Generation model',\n continueSourceLabel: 'Source',\n continueTextLabel: 'Fixed text',\n continueTextPlaceholder: 'Empty uses the default \"Continue\"',\n returnGroupTitle: 'When you return',\n returnGroupHint: 'Show a recap or suggest compaction after time away',\n awayMinutesLabel: 'Away for more than',\n recapEnabledLabel: 'Show session recap',\n recapEnabledHint: 'Review your previous progress in the conversation.',\n compactEnabledLabel: 'Suggest context compaction',\n compactEnabledHint: 'Suggest compacting the context after a long time away.',\n recapModelLabel: 'Recap model',\n judgeModelLabel: 'Judge model',\n judgeModelHint: 'Decides whether a reply stopped early and writes the follow-up.',\n handoffGroupTitle: 'Session handoff',\n handoffGroupHint: 'Handoff summaries an agent generates when reading another session',\n handoffModelLabel: 'Summary model',\n handoffModelHint: 'Used when an agent asks for a session handoff summary.',\n autoContinue: 'Auto-continue',\n autoContinueOff: 'Off',\n autoContinueCautious: 'Cautious',\n autoContinueBold: 'Bold',\n autoContinueTooltip: 'Sends a follow-up when a reply stops early. Cautious: continues only on clear evidence. Bold: continues unless done, taking the recommended option on low-risk choices. Locked once the session starts.',\n autoContinueLocked: 'Choose Auto-continue before the session starts',\n autoContinueStale: 'State changed elsewhere; refreshed',\n autoContinueFailed: 'Could not change Auto-continue',\n autoContinueGroup: 'Auto-continue',\n autoContinueGroupHint: 'Send a follow-up when a reply stops early',\n autoContinueModeHint: 'The mode (Off / Cautious / Bold) is chosen per session when creating it.',\n autoContinueMaxLabel: 'Maximum continuations',\n autoContinueMaxHint: 'How many times it may continue automatically after each message you send (1–10).',\n autoContinueMaxInvalid: 'Enter a whole number from 1 to 10.',\n minutesUnit: 'minutes',\n agentActionsGroup: 'Agent actions',\n agentActionsGroupHint: 'Let the agent act on sessions on its own',\n allowSelfForkLabel: 'Allow self-fork',\n allowSelfForkHint: 'Let the agent fork the current session into an independent branch.',\n allowSendMessageLabel: 'Allow sending messages',\n allowSendMessageHint: 'Let the agent message other unarchived sessions; idle sessions are woken, running sessions queue the message.',\n modelFollowOption: 'Default auxiliary model',\n settingsSaving: 'Saving',\n settingsSaved: 'Saved',\n settingsLoading: 'Loading',\n settingsUnavailable: 'This runtime cannot edit the plugin configuration',\n minutesInvalid: 'Enter a whole number of minutes of at least 1.',\n },\n} as const\n\nexport type UiTextKey = keyof typeof text.zh\n\nexport function uiText(locale: CopyLocale, key: UiTextKey): string {\n return text[locale][key]\n}\n\nexport function failureReason(failure: OperationFailure): FailureReason {\n if (failure.code === 'session/retry-pending') return 'retryPending'\n if (failure.code === 'session/retry-uncertain') return 'retryUncertain'\n if (failure.code === 'session/lifecycle-unavailable' || failure.code === 'session/retry-media-unavailable'\n || failure.code === 'session-manager/unavailable') return 'unsupported'\n if (failure.code === 'session-manager/busy') return 'running'\n if (\n failure.code === 'session/retry-revision'\n || failure.code === 'session/branch-moved'\n || failure.code === 'session/retry-input'\n || failure.code === 'session/retry-conflict'\n ) return 'stale'\n if (failure.code === 'session/delete-pending') return 'cleanup'\n if (failure.code === 'session/agent-busy' && failure.reason === 'free-session-work-active') return 'running'\n if (failure.reason === 'modified' || failure.reason === 'pending' || failure.reason === 'running' || failure.reason === 'stale') {\n return failure.reason\n }\n if (failure.reason === 'stop-failed' || failure.reason === 'not-quiet') return 'running'\n if (failure.reason === 'not-human-prompt' || failure.reason === 'missing-evidence') return 'unknown'\n return 'unknown'\n}\n\nexport function failureText(locale: CopyLocale, failure: OperationFailure): string {\n return reasons[locale][failureReason(failure)]\n}\n\nexport function deleteBody(locale: CopyLocale, classification: 'free' | 'ordinary'): string {\n return classification === 'free' ? text[locale].deleteFree : text[locale].deleteOrdinary\n}\n\n/** Idle duration sentence on the welcome-back card. */\nexport function idleText(locale: CopyLocale, minutes: number): string {\n return locale === 'zh' ? `距离上次响应已约 ${minutes} 分钟。` : `About ${minutes} minutes have passed since the last response.`\n}\n\n/** Compaction outcome line; a null token count means the host did not report one. */\nexport function compactedText(locale: CopyLocale, tokens: number | null): string {\n if (locale === 'zh') return tokens === null ? '上下文已压缩。' : `上下文已压缩,约 ${tokens} tokens 的历史被折叠。`\n return tokens === null ? 'Context compacted.' : `Context compacted; about ${tokens} tokens of history were folded.`\n}\n","/** Shared names and bounds for cross-session discovery. */\n\nexport const PLUGIN_NAME = '@klarkxy/dsh-session-manager'\n/** Temporary-workspace row inside the New Session workspace picker (host list slot). */\nexport const TEMP_WORKSPACE_ITEM_ID = '@klarkxy/dsh-session-manager.temp-workspace'\nexport const TEMP_WORKSPACE_CHANNEL = '/dsh-session-manager'\nexport const TEMP_WORKSPACE_FLOW_SLOT = 'session-manager.workspace.directoryFlow'\nexport const USER_ACTIONS_SLOT = 'conversation.chat.user-actions'\nexport const USER_ACTIONS_ID = '@klarkxy/dsh-session-manager.user-actions'\nexport const DELETE_DIALOG_ID = '@klarkxy/dsh-session-manager.delete-chat'\n\nexport const LIST_TOOL = 'list_sessions'\nexport const SEARCH_TOOL = 'search_sessions'\nexport const READ_TOOL = 'read_session'\nexport const FORK_TOOL = 'fork_session'\nexport const SEND_TOOL = 'send_session_message'\n/**\n * Durable message-source kind shared with the host's adjacent-agent delivery\n * (dsh-subagent/continuation-messages): `form: 'relay'` plus the sender's\n * session id. Agent tools must never stamp `kind: 'user'` — the session\n * prompt endpoint's user-rpc source is the only path that may claim it.\n */\nexport const AGENT_MESSAGE_KIND = 'agent-message'\n\n/** Endpoints on the shared TEMP_WORKSPACE_CHANNEL beyond temporary-directory allocation. */\nexport const WELCOME_BACK_PREPARE_ENDPOINT = 'welcomeback.prepare'\nexport const WELCOME_BACK_COMPACT_ENDPOINT = 'welcomeback.compact'\nexport const CONTINUE_SUGGEST_ENDPOINT = 'continue.suggest'\nexport const EDIT_PREPARE_ENDPOINT = 'edit.prepare'\nexport const EDIT_FILE_ENDPOINT = 'edit.file'\nexport const CONFIG_READ_ENDPOINT = 'config.read'\nexport const CONFIG_WRITE_ENDPOINT = 'config.write'\nexport const AUTO_CONTINUE_STATUS_ENDPOINT = 'autocontinue.status'\nexport const AUTO_CONTINUE_UPDATE_ENDPOINT = 'autocontinue.update'\n/** This plugin's rows inside the shared Session Management settings list. */\nexport const SESSION_SETTINGS_ITEMS = [\n { id: 'session-manager.composer', order: 60 },\n { id: 'session-manager.auto-continue', order: 62 },\n { id: 'session-manager.return', order: 64 },\n { id: 'session-manager.handoff', order: 66 },\n { id: 'session-manager.agent-actions', order: 68 },\n] as const\n\n/**\n * Stable feature ids stamped on `callLlmText` requests: each generated call is\n * attributed to its own per-session × feature context. The ghost bucket is\n * never shared with the judge — see buildAuxiliaryUserText in the kit.\n */\nexport const FEATURE_RECAP = 'session-manager.recap'\nexport const FEATURE_GHOST = 'session-manager.ghost'\nexport const FEATURE_JUDGE = 'session-manager.judge'\nexport const FEATURE_HANDOFF = 'session-manager.handoff'\n\n/** Card entry id in the chat flow; the recap renders at the latest completed turn's tail. */\nexport const WELCOME_BACK_CARD_ID = '@klarkxy/dsh-session-manager.welcome-back'\nexport const TURN_TAIL_SLOT = 'conversation.chat.turnTail'\nexport const CONTINUE_GHOST_ID = '@klarkxy/dsh-session-manager.continue-ghost'\nexport const CONTINUE_GHOST_SLOT = 'conversation.input.overlay'\n\nexport const DEFAULT_RECAP_MINUTES = 15\nexport const DEFAULT_COMPACT_MINUTES = 60\n/** Idle thresholds accept one week at most; 0 disables the feature. */\nexport const MAX_IDLE_MINUTES = 10_080\nexport const MAX_CONTINUE_TEXT_CHARS = 200\n/** Cap every model-written recap section shown in the UI. */\nexport const MAX_RECAP_SECTION_CHARS = 600\nexport type ContinueMode = 'fixed' | 'auto'\nexport const CONTINUE_MODES: readonly ContinueMode[] = ['fixed', 'auto']\n/** Per-session automatic continuation stance; 'off' never sends one. */\nexport type AutoContinueMode = 'off' | 'cautious' | 'bold'\nexport const AUTO_CONTINUE_MODES: readonly AutoContinueMode[] = ['off', 'cautious', 'bold']\nexport const DEFAULT_AUTO_CONTINUE_MAX = 3\nexport const MIN_AUTO_CONTINUE_MAX = 1\nexport const MAX_AUTO_CONTINUE_MAX = 10\n\n/** The per-session auto-continue row as the hero option sees it. */\nexport interface AutoContinueStatus {\n readonly sessionId: string\n /** 'executor' for subagent threads: they never carry their own option. */\n readonly role: 'coordinator' | 'executor'\n /** The locked mode; 'off' when the session has no record yet. */\n readonly mode: AutoContinueMode\n /** Automatic continuations allowed after each human message. */\n readonly max: number\n /** The session record's revision; 0 when the session has no record yet. */\n readonly revision: number\n /** No edit is allowed once the first turn starts, or while the session is cold. */\n readonly locked: boolean\n}\n\n/** Model-written welcome-back recap; an empty section means not established. */\nexport interface RecapPayload {\n readonly summary: string\n readonly progress: string\n readonly nextStep: string\n}\n\nexport interface EditPrepareRequest {\n readonly sessionId: string\n readonly promptSeq: number\n}\n\nexport type EditContent = { readonly type: 'text'; readonly text: string }\n | { readonly type: 'image'; readonly attachmentId: string }\n | { readonly type: 'file'; readonly attachmentId: string; readonly name: string; readonly bytes: number }\n\nexport interface EditPrepareValue {\n readonly sessionId: string\n readonly promptSeq: number\n readonly text: string\n /** Original order; images are read through the source Session's authorized endpoint. */\n readonly content?: readonly EditContent[]\n /** The host recorded later file changes after this prompt. */\n readonly modified: boolean\n}\n\nexport interface WelcomeBackPrepareRequest {\n readonly sessionId: string\n /**\n * The lastResponseAt the client already answered for this session. The host\n * skips the recap model call when the mark is unchanged, so a dismissed\n * card costs one cheap observation instead of a model call.\n */\n readonly knownLastResponseAt?: number\n}\n\nexport type WelcomeBackPrepareValue =\n | { readonly show: false }\n | {\n readonly show: true\n readonly sessionId: string\n readonly lastResponseAt: number\n readonly idleMinutes: number\n /** Null when the recap model was unavailable or failed; a compact suggestion still shows. */\n readonly recap: RecapPayload | null\n readonly compactSuggested: boolean\n readonly compactAvailable: boolean\n /** Host-resolved compaction threshold in minutes; 0 means the suggestion is disabled. */\n readonly compactMinutes: number\n }\n\nexport interface WelcomeBackCompactRequest {\n readonly sessionId: string\n readonly requestId: string\n}\n\nexport type WelcomeBackCompactValue =\n | { readonly compacted: true; readonly shadowedTokens: number | null }\n | { readonly compacted: false; readonly reason: 'busy' | 'unavailable' | 'nothing' }\n\nexport interface ContinueSuggestRequest {\n readonly sessionId: string\n /**\n * Last event sequence the client already cached a suggestion for. When it\n * still matches the active branch, the host returns the stored line and\n * skips another model call.\n */\n readonly knownSeq?: number\n}\n\nexport interface ContinueSuggestValue {\n /** Null means there is no continuation to show. */\n readonly text: string | null\n /** Active-branch sequence this text belongs to; absent while a turn is still open. */\n readonly seq?: number\n /** True while the latest turn has not ended, so the composer keeps its own placeholder. */\n readonly pending?: true\n /** Empty fixed text uses the localized default once a turn has ended. */\n readonly fallback?: true\n}\n\n/** The user-facing presence settings view served to the bundle config page. */\nexport interface ConfigView {\n readonly recapMinutes: number\n readonly compactMinutes: number\n readonly continueText: string\n readonly continueMode: ContinueMode\n /** Plugin-owned welcome-back recap model; null follows the default auxiliary model. */\n readonly model: { readonly provider: string; readonly model: string; readonly reasoningEffort?: string } | null\n /** Plugin-owned ghost model; null follows the default auxiliary model. */\n readonly ghostModel: { readonly provider: string; readonly model: string; readonly reasoningEffort?: string } | null\n /** Plugin-owned auto-continue judge model; null follows the default auxiliary model. */\n readonly judgeModel: { readonly provider: string; readonly model: string; readonly reasoningEffort?: string } | null\n /** Plugin-owned read_session handoff model; null follows the default auxiliary model. */\n readonly handoffModel: { readonly provider: string; readonly model: string; readonly reasoningEffort?: string } | null\n /** Initial auto-continue mode for sessions created later. */\n readonly autoContinueMode: AutoContinueMode\n /** Automatic continuations allowed after each human message in an auto-continue session. */\n readonly autoContinueMax: number\n /** Whether the agent may fork its own session without per-call approval. */\n readonly allowSelfFork: boolean\n /** Whether the agent may message other unarchived sessions without per-call approval. */\n readonly allowSendMessage: boolean\n}\n\n/** Sparse settings patch from the bundle config page; every key optional. */\nexport interface ConfigPatch {\n readonly recapMinutes?: number\n readonly compactMinutes?: number\n readonly continueText?: string\n readonly continueMode?: ContinueMode\n /** Null resumes following the default auxiliary model. */\n readonly model?: { readonly provider: string; readonly model: string; readonly reasoningEffort?: string } | null\n /** Null resumes following the default auxiliary model for the ghost. */\n readonly ghostModel?: { readonly provider: string; readonly model: string; readonly reasoningEffort?: string } | null\n /** Null resumes following the default auxiliary model for the auto-continue judge. */\n readonly judgeModel?: { readonly provider: string; readonly model: string; readonly reasoningEffort?: string } | null\n /** Null resumes following the default auxiliary model for read_session handoff summaries. */\n readonly handoffModel?: { readonly provider: string; readonly model: string; readonly reasoningEffort?: string } | null\n readonly autoContinueMode?: AutoContinueMode\n readonly autoContinueMax?: number\n readonly allowSelfFork?: boolean\n readonly allowSendMessage?: boolean\n}\n\nexport interface ConfigWriteRequest {\n readonly patch: ConfigPatch\n}\n\nexport const DEFAULT_PAGE_CHARS = 4_000\nexport const MIN_PAGE_CHARS = 200\nexport const MAX_PAGE_CHARS = 16_000\nexport const DEFAULT_LIST_LIMIT = 20\nexport const MAX_LIST_LIMIT = 100\nexport const DEFAULT_SEARCH_LIMIT = 20\nexport const MAX_SEARCH_LIMIT = 50\nexport const TOOL_SUMMARY_CHARS = 160\n\n/** Conversation reading pages by turn count, never by output size. */\nexport const DEFAULT_TURN_LIMIT = 5\nexport const MAX_TURN_LIMIT = 20\n/** Deterministic preview caps in Unicode code points; full text stays in details mode. */\nexport const PREVIEW_REQUEST_CHARS = 256\nexport const PREVIEW_CONTEXT_CHARS = 128\nexport const PREVIEW_RESPONSE_CHARS = 512\n\nexport interface Config {\n /** Maximum serialized UTF-8 bytes of one read_session details/handoff page, including item metadata. Conversation turn previews do not use this budget. */\n pageChars?: number\n /** Maximum sessions returned by one list_sessions page. */\n listLimit?: number\n /** Maximum sessions returned by one search_sessions page. */\n searchLimit?: number\n /** Idle minutes since the last response before the welcome-back recap card may appear; 0 disables it. */\n recapMinutes?: number\n /** Idle minutes since the last response before the card also suggests context compaction; 0 disables it. */\n compactMinutes?: number\n /** Fixed ghost continuation text; empty falls back to the localized default (\"继续\"/\"Continue\"). */\n continueText?: string\n /** fixed: send continueText; auto: generate the ghost once after the previous turn ends and cache it in the session. */\n continueMode?: ContinueMode\n /** Initial auto-continue mode for sessions created later. */\n autoContinueMode?: AutoContinueMode\n /** Automatic continuations allowed after each human message in an auto-continue session. */\n autoContinueMax?: number\n /** Register the fork_session tool: one-call forks of the calling session, approved once by the toggle. */\n allowSelfFork?: boolean\n /** Register the send_session_message tool: agent-attributed messages to other unarchived sessions, approved once by the toggle. */\n allowSendMessage?: boolean\n}\n\nexport interface ResolvedConfig {\n readonly pageChars: number\n readonly listLimit: number\n readonly searchLimit: number\n readonly recapMinutes: number\n readonly compactMinutes: number\n readonly continueText: string\n readonly continueMode: ContinueMode\n readonly autoContinueMode: AutoContinueMode\n readonly autoContinueMax: number\n readonly allowSelfFork: boolean\n readonly allowSendMessage: boolean\n}\n\nexport function resolveConfig(config: Config = {}): ResolvedConfig {\n return {\n pageChars: boundInteger(config.pageChars, DEFAULT_PAGE_CHARS, MIN_PAGE_CHARS, MAX_PAGE_CHARS, 'pageChars'),\n listLimit: boundInteger(config.listLimit, DEFAULT_LIST_LIMIT, 1, MAX_LIST_LIMIT, 'listLimit'),\n searchLimit: boundInteger(config.searchLimit, DEFAULT_SEARCH_LIMIT, 1, MAX_SEARCH_LIMIT, 'searchLimit'),\n recapMinutes: boundInteger(config.recapMinutes, DEFAULT_RECAP_MINUTES, 0, MAX_IDLE_MINUTES, 'recapMinutes'),\n compactMinutes: boundInteger(config.compactMinutes, DEFAULT_COMPACT_MINUTES, 0, MAX_IDLE_MINUTES, 'compactMinutes'),\n continueText: boundText(config.continueText, MAX_CONTINUE_TEXT_CHARS, 'continueText'),\n continueMode: boundMode(config.continueMode, 'continueMode'),\n autoContinueMode: boundAutoContinueMode(config.autoContinueMode, 'autoContinueMode'),\n autoContinueMax: boundInteger(config.autoContinueMax, DEFAULT_AUTO_CONTINUE_MAX, MIN_AUTO_CONTINUE_MAX, MAX_AUTO_CONTINUE_MAX, 'autoContinueMax'),\n allowSelfFork: boundFlag(config.allowSelfFork, 'allowSelfFork'),\n allowSendMessage: boundFlag(config.allowSendMessage, 'allowSendMessage'),\n }\n}\n\nfunction boundFlag(value: boolean | undefined, name: string): boolean {\n const resolved = value ?? false\n if (typeof resolved !== 'boolean') {\n throw new TypeError(`${PLUGIN_NAME}: ${name} must be a boolean`)\n }\n return resolved\n}\n\nfunction boundInteger(value: number | undefined, fallback: number, min: number, max: number, name: string): number {\n const resolved = value ?? fallback\n if (!Number.isInteger(resolved) || resolved < min || resolved > max) {\n throw new TypeError(`${PLUGIN_NAME}: ${name} must be an integer from ${min} to ${max}`)\n }\n return resolved\n}\n\nfunction boundText(value: string | undefined, maxChars: number, name: string): string {\n const resolved = value?.trim() ?? ''\n if (Array.from(resolved).length > maxChars) {\n throw new TypeError(`${PLUGIN_NAME}: ${name} must be at most ${maxChars} characters`)\n }\n return resolved\n}\n\nfunction boundMode(value: ContinueMode | undefined, name: string): ContinueMode {\n const resolved = value ?? 'fixed'\n if (!CONTINUE_MODES.includes(resolved)) {\n throw new TypeError(`${PLUGIN_NAME}: ${name} must be one of ${CONTINUE_MODES.join(', ')}`)\n }\n return resolved\n}\n\nfunction boundAutoContinueMode(value: AutoContinueMode | undefined, name: string): AutoContinueMode {\n const resolved = value ?? 'off'\n if (!AUTO_CONTINUE_MODES.includes(resolved)) {\n throw new TypeError(`${PLUGIN_NAME}: ${name} must be one of ${AUTO_CONTINUE_MODES.join(', ')}`)\n }\n return resolved\n}\n","/**\n * Relay sidebar right-clicks to the host's own session actions menu.\n *\n * dsh-client-ui-workspace SessionNodeItem renders a keyed treeitem, with a\n * trailing rowActions span. Its first button is the Menu anchor; subsequent\n * buttons are contributed row actions. The span stops click propagation, so\n * clicking the anchor opens the menu without opening the session. Menu portals\n * outside the tree and the row carries a *_menuOpen class while it is open.\n * Blank rows, search results, and AnimatedRows exit clones have no keyed menu\n * anchor and are left alone. CSS-module hash prefixes vary between host builds.\n */\nconst ROW_SELECTOR = '[role=\"treeitem\"][data-row-key^=\"session:\"]'\nconst ACTIONS_SELECTOR = 'span[class*=\"_rowActions\"]'\n\n/** Resolve a live session row in the sidebar tree. */\nexport function findSessionRow(target: Element): HTMLElement | null {\n if (typeof target.closest !== 'function') return null\n const row = target.closest<HTMLElement>(ROW_SELECTOR)\n if (row === null || row.closest('[role=\"tree\"]') === null || row.closest('[inert]') !== null) return null\n return row\n}\n\n/** Forward a context-menu gesture only when the host provides a menu anchor. */\nexport function forwardContextMenu(event: Event): boolean {\n if (event.defaultPrevented) return false\n const target = event.target\n if (target === null || typeof (target as Element).closest !== 'function') return false\n const element = target as Element\n const row = findSessionRow(element)\n if (row === null) return false\n const actions = row.querySelector(ACTIONS_SELECTOR)\n const trigger = actions?.querySelector<HTMLButtonElement>('button')\n if (trigger == null || trigger.disabled) return false\n // Other row actions (pin/archive/etc.) must never fire on right-click.\n if (element.closest(ACTIONS_SELECTOR) !== null && !trigger.contains(element)) return false\n event.preventDefault()\n // The host anchor toggles. Repeated context-menu gestures should keep it open.\n if (!Array.from(row.classList).some(name => name.endsWith('_menuOpen'))) {\n trigger.focus({ preventScroll: true })\n trigger.click()\n }\n return true\n}\n\n/** Capture-phase relay; disposing the client removes the listener. */\nexport function installContextMenuForwarding(doc: Document): () => void {\n const listener = (event: Event) => { forwardContextMenu(event) }\n doc.addEventListener('contextmenu', listener, true)\n return () => { doc.removeEventListener('contextmenu', listener, true) }\n}\n","/**\n * Shared contract that keeps every plugin's browser-side UI on the official\n * DeepSeek Harness Web design language.\n *\n * Two rules produce that language, and both are load-bearing here:\n *\n * 1. Colour, radius, elevation and focus come from the host theme's real\n * `--dsw-*` tokens, written under their own names. Plugins never invent a\n * token, never alias the official ones behind a private palette (a private\n * alias is just a second, diverging theme), and never carries a literal\n * fallback — the host publishes light and dark, and a literal would pin one\n * of them. The only non-colour custom properties used are the host's own\n * content-font axis and frame clearance.\n *\n * 2. Anything the host already ships is used, not reimplemented. Controls come\n * from `@deepseek-ai/dsh-client-ui-primitives` (`Button`, `Input`,\n * `Checkbox`, `Switch`, `Tag`, `Pill`, `SegmentedControl`, `Menu`, `Modal`,\n * `Tooltip`, `Toast`, `DisclosureRow`, `StateDot`, `PathLabel`, the settings\n * form suite). This module only styles what primitives do not cover: page\n * scaffolding, field layout, banners, empty states and scroll regions.\n *\n * The metrics below are transcribed from the primitives' own CSS modules so a\n * feature panel lines up pixel-for-pixel with a native one: the 14/22 body and\n * 13/20 compact type tiers, the 0.5px hairline scale, and the elevation family\n * that draws a surface's edge in its shadow (`border: 0`) instead of a border.\n */\n\n/**\n * Every `--dsw-*` token this repo is allowed to reference, grouped by role.\n *\n * Plugins may only colour through this list. It is exported so the guard test\n * can fail a build when a stylesheet reaches for anything else — the failure\n * mode this prevents is silent: an unknown token resolves to nothing, so a\n * border disappears or a label inherits the wrong colour with no error anywhere.\n */\nexport const OFFICIAL_THEME_TOKENS = {\n /** Surfaces, from the page up to the topmost nested card. */\n surface: [\n '--dsw-alias-bg-base',\n '--dsw-alias-bg-layer-1',\n '--dsw-alias-bg-layer-2',\n '--dsw-alias-bg-layer-3',\n '--dsw-alias-bg-layer-4',\n '--dsw-alias-bg-module-platform',\n '--dsw-alias-bg-overlay',\n ],\n /** Hairlines. l1 is near-invisible on a menu surface, so menus use l2+. */\n border: ['--dsw-alias-border-l1', '--dsw-alias-border-l2', '--dsw-alias-border-l3', '--dsw-alias-border-l4'],\n /** Text. `caption` is menu shortcut text, `dimmed` is placeholder text. */\n label: [\n '--dsw-alias-label-primary',\n '--dsw-alias-label-secondary',\n '--dsw-alias-label-tertiary',\n '--dsw-alias-label-caption',\n '--dsw-alias-label-dimmed',\n '--dsw-alias-label-error',\n '--dsw-alias-label-primary-foreground',\n ],\n /** Interactive fills. The `-danger` hover belongs to destructive rows. */\n interactive: [\n '--dsw-alias-interactive-bg-hover',\n '--dsw-alias-interactive-bg-active',\n '--dsw-alias-interactive-bg-hover-danger',\n ],\n /** Accent and status. `business` is the focus ring's default colour. */\n accent: [\n '--dsw-alias-brand-primary',\n '--dsw-alias-button-primary-fill',\n '--dsw-alias-button-primary-hover',\n '--dsw-alias-button-tool-bar-fill',\n '--dsw-alias-button-tool-bar-hover',\n '--dsw-alias-button-ghost-active-fill',\n '--dsw-alias-button-ghost-active-border',\n ],\n state: [\n '--dsw-alias-state-business-primary',\n '--dsw-alias-state-success-primary',\n '--dsw-alias-state-warn-primary',\n '--dsw-alias-state-error-primary',\n '--dsw-alias-state-idle-primary',\n ],\n /** Corner scale: sm 8, md 12, lg the large card, panel the modal. */\n radius: ['--dsw-radius-sm', '--dsw-radius-md', '--dsw-radius-lg', '--dsw-radius-panel'],\n /** An elevated surface draws its edge in the shadow, so it keeps border: 0. */\n elevation: [\n '--dsw-elevation-soft',\n '--dsw-elevation-stroke',\n '--dsw-elevation-stroke-color',\n '--dsw-elevation-panel',\n '--dsw-elevation-prominent',\n ],\n /** Floats, masks and scrollbars. */\n overlay: [\n '--dsw-menu-surface-fill',\n '--dsw-menu-backdrop-filter',\n '--dsw-mask-blur',\n '--dsw-alias-bg-mask-1',\n '--dsw-alias-menu-icon',\n '--dsw-alias-scrollbar-bg-l2',\n '--dsw-alias-scrollbar-hover-l2',\n '--dsw-shadow-lv3',\n ],\n /** Motion, focus and type axis, published by the host rather than by a component. */\n system: [\n '--dsw-focus-ring-width',\n '--dsw-focus-ring-color',\n '--dsw-font-markdown-code-font-family',\n '--ds-transition-duration',\n '--ds-ease-in-out',\n '--ds-font-family-code',\n '--dsh-scrollbar-thumb',\n '--dsh-scrollbar-thumb-hover',\n '--dsh-content-font-size-secondary',\n '--dsh-content-font-delta',\n '--dsh-frame-top-clearance',\n // Published by the conversation.input.model seat for narrow composer rows.\n '--dsh-composer-model-icon-display',\n '--dsh-composer-model-text-display',\n ],\n} as const\n\n/** Every official token name, flat. Used by the token guard test. */\nexport const OFFICIAL_THEME_TOKEN_NAMES: readonly string[] = Object.values(OFFICIAL_THEME_TOKENS).flat()\n\n/** The elevation steps a surface can be raised by, softest first. */\nexport type OfficialElevation = 'soft' | 'stroke' | 'panel' | 'prominent'\n\n/**\n * The host's focus ring shorthand, verbatim. Writing this per control is how\n * rings drift apart; a stylesheet that draws its own focus style should use\n * {@link officialFocus} instead. The colour fallback is the host's own default.\n */\nexport const OFFICIAL_FOCUS_RING =\n 'var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary))'\n\n/**\n * A complete `outline` declaration at the official geometry. `offset` defaults\n * to the 2px the native controls use; the host's inline field rules sit at 1px\n * and a segmented tab pulls the ring inside itself at -2px.\n */\nexport function officialFocus(offset = '2px'): string {\n return `outline: ${OFFICIAL_FOCUS_RING}; outline-offset: ${offset}`\n}\n\n/**\n * An elevated surface. The host draws a raised surface's edge inside its\n * shadow rather than as a border, so a card sets `border: 0` and takes the edge\n * from the elevation — which is also why its border stays off the alias-border\n * set that a flat, non-elevated rule would use.\n */\nexport function officialElevation(level: OfficialElevation): string {\n return `border: 0; box-shadow: var(--dsw-elevation-${level})`\n}\n\n/**\n * An elevated surface whose edge should read as a specific hairline. Rebinding\n * the stroke colour is how a menu card picks l1 while a panel picks l3, without\n * the two growing apart by hand.\n */\nexport function officialStrokedElevation(level: OfficialElevation, color: string): string {\n return `--dsw-elevation-stroke-color: ${color}; ${officialElevation(level)}`\n}\n\n/**\n * The shared stylesheet for a plugin UI, scoped under that plugin's root class.\n *\n * Scoping is what keeps this safe to always-bundle into every client: the rules\n * can only match inside the plugin's own subtree, so two plugins can both mount\n * `dsh-ui-card` without either styling the other's markup.\n *\n * Each recipe matches the root element *and* its descendants, because the\n * commonest arrangement is one element that is both — a surface that carries\n * the root class and `dsh-ui-card`, or a portaled dialog that is the root and\n * the `dsh-ui-surface`. A descendant-only scope would silently leave those\n * unstyled, with no error anywhere.\n *\n * A caveat worth knowing: `Modal` and `Menu` portal to `document.body`, so their\n * content leaves the plugin's subtree entirely. A portaled surface therefore\n * needs its own root class on an element inside the portal.\n *\n * Only patterns that primitives do not provide live here. If a control appears\n * below that `Button`/`Input`/`Switch`/`Tag`/`Menu` already covers, that is a\n * bug in this file: use the primitive and delete the recipe.\n */\nexport function officialUiCss(roots: string | readonly string[]): string {\n // One plugin often mounts several unrelated surfaces (a settings seat, a chat\n // card, a header menu), so the caller names every root. The rules below are\n // nested under a single selector list and use `&`, which the browser expands\n // per root — so one stylesheet covers all of them without duplicating itself.\n const scope = (typeof roots === 'string' ? [roots] : roots).map(root => `.${root}`).join(', ')\n const sheet = `\n/* Official DSH Web UI contract. Generated by @klarkxy/dsh-plugin-kit/official-ui.\n * Do not hand-edit the copy inside a plugin: change this module so every plugin\n * moves together. Scope: ${scope} */\n/* The scope rule below stays open for the whole sheet: every rule after it\n * nests with the parent selector, so one stylesheet can cover several unrelated\n * roots without leaking into a neighbouring plugin. Its closing brace is last. */\n${scope} {\n color: var(--dsw-alias-label-primary);\n font-family: inherit;\n font-size: 14px;\n line-height: 22px;\n min-width: 0;\n\n& *, & *::before, & *::after { box-sizing: border-box; }\n& h1, & h2, & h3, & h4, & p, & figure { margin: 0; }\n/* Keyboard focus only: pointer input keeps the native resting appearance. The\n * ring needs no radius of its own — the outline already follows the control's\n * own border-radius, and overriding it here would flatten every control. */\n& :focus-visible { ${officialFocus()}; }\n& [hidden] { display: none !important; }\n\n/* --- Type tiers. The same 14/22 and 13/20 steps the primitives use. --- */\n& .dsh-ui-title { font-size: 16px; line-height: 24px; font-weight: 500; color: var(--dsw-alias-label-primary); }\n& .dsh-ui-heading { font-size: 14px; line-height: 22px; font-weight: 500; color: var(--dsw-alias-label-primary); }\n& .dsh-ui-compact { font-size: 13px; line-height: 20px; color: var(--dsw-alias-label-primary); }\n& .dsh-ui-meta { font-size: 12px; line-height: 18px; color: var(--dsw-alias-label-secondary); }\n& .dsh-ui-hint { font-size: 12px; line-height: 18px; color: var(--dsw-alias-label-tertiary); }\n& .dsh-ui-error { font-size: 12px; line-height: 18px; color: var(--dsw-alias-state-error-primary); }\n& .dsh-ui-warn { color: var(--dsw-alias-state-warn-primary); }\n& .dsh-ui-success { color: var(--dsw-alias-state-success-primary); }\n& .dsh-ui-muted { color: var(--dsw-alias-label-tertiary); }\n& .dsh-ui-truncate { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n& .dsh-ui-wrap { min-width: 0; overflow-wrap: anywhere; }\n\n/* --- Layout scaffolding. --- */\n& .dsh-ui-stack { display: flex; flex-direction: column; gap: 12px; }\n& .dsh-ui-stack-lg { display: flex; flex-direction: column; gap: 20px; }\n/* Plugin detail pages share one reading column. These are layout recipes;\n * controls keep their own primitive styles. Form spacing follows the host's\n * settings-form/fields.module.css and SettingsForm.module.css. */\n& .dsh-ui-page { display: flex; flex-direction: column; gap: 16px; width: 100%; max-width: 760px; min-width: 0; }\n& .dsh-ui-form { display: flex; flex-direction: column; gap: 0; min-width: 0; }\n&.dsh-ui-form > .dsh-ui-field, & .dsh-ui-form > .dsh-ui-field { padding: 12px 0; }\n& .dsh-ui-form-footer { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding-top: 16px; min-width: 0; }\n& .dsh-ui-fields-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 20px; min-width: 0; margin: 0; padding: 0; border: 0; }\n@media (max-width: 560px) {\n & .dsh-ui-fields-grid { grid-template-columns: minmax(0, 1fr); }\n}\n& .dsh-ui-row { display: flex; align-items: center; gap: 8px; min-width: 0; }\n& .dsh-ui-row-wrap { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }\n& .dsh-ui-spacer { flex: 1; min-width: 0; }\n/* A 0.5px l2 rule is the host's section divider; reserve the same rhythm. */\n& .dsh-ui-divider { height: 0.5px; background: var(--dsw-alias-border-l2); }\n& .dsh-ui-section { display: flex; flex-direction: column; gap: 12px; padding-top: 16px; border-top: 0.5px solid var(--dsw-alias-border-l2); }\n\n/* --- Card: a raised surface whose edge lives in the shadow. --- */\n& .dsh-ui-card {\n ${officialElevation('stroke')}\n display: flex;\n flex-direction: column;\n gap: 12px;\n padding: 16px;\n border-radius: var(--dsw-radius-lg);\n background: var(--dsw-alias-bg-layer-1);\n color: var(--dsw-alias-label-primary);\n min-width: 0;\n}\n& .dsh-ui-card--flat { border: 0.5px solid var(--dsw-alias-border-l3); box-shadow: none; }\n& .dsh-ui-card--nested { background: var(--dsw-alias-bg-layer-2); }\n& .dsh-ui-card--plain { background: none; }\n\n/* --- Field: label, control, help, error. The control itself is an\n * official primitive, so this only owns the vertical rhythm. --- */\n& .dsh-ui-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }\n& .dsh-ui-field + .dsh-ui-field { border-top: 0.5px solid var(--dsw-alias-border-l2); padding-top: 12px; }\n/* Grid fields share a row, so the stacked-field divider must not win later in\n * the cascade. Reset it here, after the field recipe. */\n& .dsh-ui-fields-grid > .dsh-ui-field { padding: 0; border: 0; }\n& .dsh-ui-label { display: flex; align-items: center; gap: 6px; font-size: 13px; line-height: 20px; font-weight: 500; color: var(--dsw-alias-label-primary); }\n& .dsh-ui-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }\n& .dsh-ui-help { font-size: 12px; line-height: 1.6; color: var(--dsw-alias-label-secondary); }\n& .dsh-ui-help p { margin: 0; }\n& .dsh-ui-help p + p { margin-top: 8px; }\n& .dsh-ui-required { color: var(--dsw-alias-state-error-primary); }\n& .dsh-ui-control { width: 100%; min-width: 0; }\n/* An invalid control is marked on the control, not only in the message. */\n& .dsh-ui-control[aria-invalid='true'] { border-color: var(--dsw-alias-state-error-primary); }\n& .dsh-ui-readonly { display: flex; flex-direction: column; gap: 4px; min-width: 0; }\n& .dsh-ui-readonly > dt { font-size: 12px; line-height: 18px; color: var(--dsw-alias-label-tertiary); }\n& .dsh-ui-readonly > dd { margin: 0; font-size: 13px; line-height: 20px; overflow-wrap: anywhere; }\n\n/* --- Buttons row. A no-op container: it exists so actions line up on the\n * trailing edge the way every native panel does. --- */\n& .dsh-ui-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 4px; }\n& .dsh-ui-actions-end { justify-content: flex-end; }\n\n/* --- Banners. A banner is a left-rail notice, the shape used for warnings,\n * deprecations and blocking instructions. --- */\n& .dsh-ui-banner {\n display: flex;\n flex-direction: column;\n gap: 8px;\n padding: 10px 14px;\n border: 0.5px solid var(--dsw-alias-border-l3);\n border-left: 3px solid var(--dsw-alias-state-warn-primary);\n border-radius: var(--dsw-radius-md);\n background: var(--dsw-alias-bg-layer-1);\n font-size: 13px;\n line-height: 20px;\n color: var(--dsw-alias-label-secondary);\n}\n& .dsh-ui-banner-title { font-weight: 500; color: var(--dsw-alias-state-warn-primary); }\n& .dsh-ui-banner--info { border-left-color: var(--dsw-alias-state-business-primary); }\n& .dsh-ui-banner--danger { border-left-color: var(--dsw-alias-state-error-primary); }\n& .dsh-ui-banner--success { border-left-color: var(--dsw-alias-state-success-primary); }\n& .dsh-ui-banner p { margin: 0; }\n\n/* --- Inline notice: a transient confirmation with no chrome of its own. --- */\n& .dsh-ui-notice { display: flex; align-items: center; gap: 6px; font-size: 12px; line-height: 18px; color: var(--dsw-alias-state-success-primary); }\n& .dsh-ui-notice--error { color: var(--dsw-alias-state-error-primary); }\n\n/* --- Empty and loading states. Both sit in a dashed well so an empty panel\n * reads as \"nothing here yet\" rather than as a broken layout. --- */\n& .dsh-ui-empty {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n gap: 6px;\n padding: 20px 16px;\n border: 0.5px dashed var(--dsw-alias-border-l3);\n border-radius: var(--dsw-radius-md);\n font-size: 13px;\n line-height: 20px;\n color: var(--dsw-alias-label-secondary);\n}\n& .dsh-ui-loading { display: flex; align-items: center; gap: 8px; padding: 20px 0; font-size: 13px; line-height: 20px; color: var(--dsw-alias-label-secondary); }\n\n/* --- Selectable list. A row is a button-sized target with a hover fill and\n * a selected fill; the name carries the weight, the description does not. --- */\n& .dsh-ui-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; min-width: 0; }\n& .dsh-ui-list-scroll { max-height: min(66vh, 760px); overflow-y: auto; overflow-x: hidden; }\n& .dsh-ui-list-row { border-radius: var(--dsw-radius-md); }\n& .dsh-ui-list-row:hover { background: var(--dsw-alias-interactive-bg-hover); }\n& .dsh-ui-list-row[aria-selected='true'], & .dsh-ui-list-row[data-selected] { background: var(--dsw-alias-interactive-bg-active); }\n& .dsh-ui-list-item {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n gap: 4px;\n width: 100%;\n min-width: 0;\n padding: 10px 12px;\n border: 0;\n border-radius: var(--dsw-radius-md);\n background: none;\n font: inherit;\n color: inherit;\n text-align: start;\n cursor: pointer;\n}\n& .dsh-ui-list-item:disabled { cursor: default; }\n& .dsh-ui-list-item:disabled:hover { background: none; }\n& .dsh-ui-list-name { font-size: 14px; line-height: 22px; font-weight: 500; color: var(--dsw-alias-label-primary); overflow-wrap: anywhere; }\n& .dsh-ui-list-desc { font-size: 12px; line-height: 18px; color: var(--dsw-alias-label-tertiary); }\n\n/* --- Code and structured output. Wraps rather than scrolls, because a\n * feature panel is read rather than scanned. --- */\n& .dsh-ui-code {\n padding: 10px 12px;\n border: 0.5px solid var(--dsw-alias-border-l3);\n border-radius: var(--dsw-radius-md);\n background: var(--dsw-alias-bg-layer-1);\n font-family: var(--ds-font-family-code);\n font-size: 12px;\n line-height: 20px;\n color: var(--dsw-alias-label-secondary);\n overflow-wrap: anywhere;\n white-space: pre-wrap;\n}\n& .dsh-ui-scroll { max-height: 60vh; overflow: auto; overscroll-behavior: contain; }\n\n/* --- A toggle row: label on the left, switch on the trailing edge. This is\n * layout only; the switch itself is the official primitive. --- */\n& .dsh-ui-toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-width: 0; padding: 12px 0; }\n& .dsh-ui-toggle-row + .dsh-ui-toggle-row { border-top: 0.5px solid var(--dsw-alias-border-l2); }\n& .dsh-ui-toggle-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }\n& .dsh-ui-toggle-label { font-size: 14px; line-height: 22px; font-weight: 500; color: var(--dsw-alias-label-primary); }\n\n/* --- Floating surface: a panel anchored to a trigger. This is the material\n * a menu card is made of — the translucent fill plus its backdrop blur, with\n * the edge riding inside the prominent elevation. A plugin that hand-rolls this\n * is how tokens like --dsw-specific-menu get invented; use this instead. --- */\n& .dsh-ui-surface {\n --dsw-elevation-stroke-color: var(--dsw-alias-border-l1);\n --dsh-scrollbar-thumb: var(--dsw-alias-scrollbar-bg-l2);\n --dsh-scrollbar-thumb-hover: var(--dsw-alias-scrollbar-hover-l2);\n position: relative;\n display: flex;\n flex-direction: column;\n border: 0;\n border-radius: var(--dsw-radius-lg);\n background: var(--dsw-menu-surface-fill);\n backdrop-filter: var(--dsw-menu-backdrop-filter);\n box-shadow: var(--dsw-elevation-prominent);\n color: var(--dsw-alias-label-primary);\n font-size: 13px;\n line-height: 20px;\n min-width: 0;\n}\n& .dsh-ui-surface-body { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px 14px; overflow-y: auto; }\n& .dsh-ui-surface-head { display: flex; align-items: center; gap: 8px; min-width: 0; }\n& .dsh-ui-surface-title { font-size: 14px; line-height: 22px; font-weight: 500; color: var(--dsw-alias-label-primary); }\n\n/* --- Native select. The primitives ship no select, so a plugin that offers a\n * closed list of choices keeps the platform control and matches the official\n * settings field geometry exactly (34px, 0.5px l4, radius-md, layer-3). A\n * SegmentedControl is the primitive to reach for when the choices are few\n * enough to show at once. --- */\n& .dsh-ui-select {\n box-sizing: border-box;\n width: 100%;\n min-width: 0;\n height: 34px;\n padding: 0 12px;\n border: 0.5px solid var(--dsw-alias-border-l4);\n border-radius: var(--dsw-radius-md);\n background: var(--dsw-alias-bg-layer-3);\n font: inherit;\n font-size: 13px;\n line-height: 1.5;\n color: var(--dsw-alias-label-primary);\n cursor: pointer;\n}\n& .dsh-ui-select:focus-visible { outline: none; border-color: var(--dsw-alias-state-business-primary); }\n& .dsh-ui-select:disabled { color: var(--dsw-alias-label-tertiary); cursor: default; }\n& .dsh-ui-select[aria-invalid='true'] { border-color: var(--dsw-alias-state-error-primary); }\n\n/* --- Native textarea. The primitives ship no textarea either, so a settings\n * prompt keeps the platform element and the same field shell as the select:\n * 0.5px l4, radius-md, layer-3, 13/1.5 type. It grows vertically instead of\n * locking to the select's 34px row. --- */\n& .dsh-ui-textarea {\n box-sizing: border-box;\n width: 100%;\n min-width: 0;\n resize: vertical;\n padding: 8px 12px;\n border: 0.5px solid var(--dsw-alias-border-l4);\n border-radius: var(--dsw-radius-md);\n background: var(--dsw-alias-bg-layer-3);\n font: inherit;\n font-size: 13px;\n line-height: 1.5;\n color: var(--dsw-alias-label-primary);\n}\n& .dsh-ui-textarea:focus-visible { outline: none; border-color: var(--dsw-alias-state-business-primary); }\n& .dsh-ui-textarea:disabled { color: var(--dsw-alias-label-tertiary); cursor: default; }\n& .dsh-ui-textarea::placeholder { color: var(--dsw-alias-label-dimmed); }\n& .dsh-ui-textarea[aria-invalid='true'] { border-color: var(--dsw-alias-state-error-primary); }\n\n/* Long panels scroll inside themselves instead of growing the host page. */\n& .dsh-ui-panel { display: flex; flex-direction: column; gap: 16px; min-width: 0; }\n& .dsh-ui-panel-wide { max-width: 100%; }\n\n@media (prefers-reduced-motion: reduce) {\n & *, & *::before, & *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }\n}\n}\n`\n // Widen every recipe from \"a descendant of the root\" to \"the root, or one of\n // its descendants\". Written as a transform rather than by hand so no recipe\n // can be added later with only the descendant form. The pattern is narrow on\n // purpose: a leading `&` followed by one recipe class and no combinator, so\n // sibling and child rules such as `.dsh-ui-field + .dsh-ui-field` keep their\n // own meaning and are left alone.\n return sheet.replace(/^& (\\.dsh-ui-[a-z0-9-]+)(?=\\s*\\{)/gm, (_match, className: string) =>\n `&${className}, & ${className}`)\n}\n","/**\n * Shared model-route value contract.\n *\n * A feature plugin stores its model override as a ModelRoute on its own\n * settings page. Empty provider/model means \"follow the host default model\".\n * Pure and browser-safe: no cordis, no React, no schema library.\n */\n\n/** A concrete provider model a feature call should use. */\nexport interface ModelRoute {\n provider: string\n model: string\n reasoningEffort?: string\n}\n\n/** Empty route: no explicit model, the feature follows the host default. */\nexport function defaultModelRoute(): ModelRoute {\n return { provider: '', model: '' }\n}\n\n/** Structural check: both id fields are strings (either may be empty). */\nexport function isModelRouteValue(value: unknown): value is ModelRoute {\n if (!value || typeof value !== 'object' || Array.isArray(value)) return false\n const row = value as Record<string, unknown>\n return typeof row.provider === 'string' && typeof row.model === 'string'\n}\n\nconst MAX_ID_CHARS = 250\nconst MAX_EFFORT_CHARS = 80\n\nfunction asText(value: unknown): string | undefined {\n return typeof value === 'string' && value.trim() ? value.trim() : undefined\n}\n\n/**\n * Coerce a stored value into a ModelRoute. Anything malformed collapses to the\n * empty route, matching the per-plugin normalizers this contract replaces.\n */\nexport function normalizeModelRoute(value: unknown): ModelRoute {\n if (!value || typeof value !== 'object' || Array.isArray(value)) return defaultModelRoute()\n const row = value as Record<string, unknown>\n const provider = asText(row.provider) ?? ''\n const model = asText(row.model) ?? ''\n const effort = asText(row.reasoningEffort)\n if (!provider || !model || provider.length > MAX_ID_CHARS || model.length > MAX_ID_CHARS) return defaultModelRoute()\n return effort && effort.length <= MAX_EFFORT_CHARS ? { provider, model, reasoningEffort: effort } : { provider, model }\n}\n\n/** The override to actually call with: undefined when the route is empty. */\nexport function modelRouteOverride(route: ModelRoute | undefined): ModelRoute | undefined {\n const provider = route?.provider?.trim()\n const model = route?.model?.trim()\n if (!provider || !model) return undefined\n const effort = route?.reasoningEffort?.trim()\n return effort ? { provider, model, reasoningEffort: effort } : { provider, model }\n}\n\nconst KEY_SEPARATOR = '\\u001f'\n\n/** Stable key for one route, safe to use as a select-option value. */\nexport function modelRouteKey(provider: string, model: string): string {\n return provider && model ? `${provider}${KEY_SEPARATOR}${model}` : ''\n}\n\n/** Inverse of modelRouteKey; undefined for malformed keys. */\nexport function parseModelRouteKey(value: string): { provider: string; model: string } | undefined {\n const index = value.indexOf(KEY_SEPARATOR)\n if (index <= 0) return undefined\n const provider = value.slice(0, index)\n const model = value.slice(index + KEY_SEPARATOR.length)\n if (!provider || !model) return undefined\n return { provider, model }\n}\n\n/** True when both routes name the same target; two empty routes are equal. */\nexport function sameModelRoute(a: ModelRoute | undefined, b: ModelRoute | undefined): boolean {\n const left = modelRouteOverride(a)\n const right = modelRouteOverride(b)\n if (!left || !right) return !left === !right\n return left.provider === right.provider && left.model === right.model\n && (left.reasoningEffort ?? '') === (right.reasoningEffort ?? '')\n}\n","/**\n * Host model-catalog parsing shared by plugin settings UIs and model hubs.\n * Pure and browser-safe: no React, no host imports. The catalog envelope is\n * structural so hosts may add fields without breaking consumers.\n */\nimport { modelRouteKey, type ModelRoute } from './route.ts'\n\n/** One selectable model. `efforts` are the advertised reasoning efforts. */\nexport interface ModelMenuChoice {\n readonly provider: string\n readonly model: string\n readonly label: string\n /**\n * Provider display name from the catalog group. Optional: synthetic entries\n * (a saved route missing from the catalog) have no group, so consumers must\n * fall back to `provider`. Search matches it alongside the provider id.\n */\n readonly providerLabel?: string\n readonly efforts: ReadonlyArray<{ id: string; name: string }>\n}\n\n/** Both services are required: Cordis checks the nested namespace separately. */\nexport const MODEL_CATALOG_INJECT = ['remote', 'remote.session'] as const\n\nexport interface ModelCatalogFailure {\n readonly id: string\n readonly name: string\n readonly message: string\n}\n\n/** The catalog face this helper needs; stays structural so hosts may add more. */\nexport interface ModelCatalogClient {\n readonly remote?: {\n readonly session?: { readonly modelCatalog?: () => Promise<unknown> }\n }\n}\n\nfunction asRecord(value: unknown): Record<string, unknown> | undefined {\n return value && typeof value === 'object' && !Array.isArray(value) ? value as Record<string, unknown> : undefined\n}\n\nfunction asText(value: unknown): string | undefined {\n return typeof value === 'string' && value.trim() ? value.trim() : undefined\n}\n\n/** A useful diagnostic even when a transport rejects with a plain object. */\nexport function modelCatalogErrorMessage(value: unknown): string {\n if (value instanceof Error && value.message) return value.message\n const row = asRecord(value)\n return asText(row?.message) ?? asText(value) ?? 'Unable to load the model catalog.'\n}\n\n/**\n * Validate and unwrap a successful catalog without discarding provider failures\n * or newer host metadata. Names and metadata remain optional for older hosts.\n * A broken response is never presented as a successfully loaded empty menu.\n */\nexport function checkedModelCatalog(value: unknown): unknown {\n const envelope = asRecord(value)\n if (envelope?.ok === false) throw new Error(modelCatalogErrorMessage(envelope.error ?? envelope))\n const root = envelope?.ok === true ? asRecord(envelope.value) : envelope\n const malformed = (field: string): never => { throw new Error(`Invalid model catalog: ${field}.`) }\n if (!root || !Array.isArray(root.groups)) return malformed('groups must be an array')\n for (const value of root.groups) {\n const group = asRecord(value)\n if (!group || !asText(group.id) || !Array.isArray(group.models)) return malformed('each group needs an id and models array')\n for (const value of group.models) {\n const model = asRecord(value)\n if (!model || !asText(model.id)) return malformed('each model needs an id')\n if (model.reasoning !== undefined) {\n const reasoning = asRecord(model.reasoning)\n if (!reasoning || !Array.isArray(reasoning.efforts) || reasoning.efforts.some(value => !parseEffort(value))) {\n return malformed('reasoning efforts must be an array of identified efforts')\n }\n }\n }\n }\n if (root.failures !== undefined && (!Array.isArray(root.failures) || root.failures.some(value => {\n const failure = asRecord(value)\n return !failure || !asText(failure.id) || typeof failure.name !== 'string' || typeof failure.message !== 'string'\n }))) return malformed('failures must be an array of provider failures')\n return root\n}\n\n/** Read through the injected session namespace; absence and rejection are errors. */\nexport async function readModelCatalog(client: ModelCatalogClient): Promise<unknown> {\n const session = client.remote?.session\n if (typeof session?.modelCatalog !== 'function') {\n throw new Error('Model catalog unavailable: inject both remote and remote.session.')\n }\n return checkedModelCatalog(await session.modelCatalog())\n}\n\n/** Provider failures are partial results, not a transport failure. */\nexport function modelCatalogFailures(value: unknown): readonly ModelCatalogFailure[] {\n // Rendering can precede the checked load boundary (for example hub owner\n // snapshots). Invalid or absent data must not crash the whole settings page.\n try {\n const root = checkedModelCatalog(value) as { failures?: readonly ModelCatalogFailure[] }\n return root.failures ?? []\n } catch { return [] }\n}\n\n/** Text adapter for existing model-hub status messages. */\nexport function catalogFailures(value: unknown): string[] {\n return modelCatalogFailures(value).map(failure => `${failure.name || failure.id}: ${failure.message}`)\n}\n\nfunction parseEffort(value: unknown): { id: string; name: string } | undefined {\n const row = asRecord(value)\n const id = row ? asText(row.id) : undefined\n if (!id) return undefined\n return { id, name: row ? asText(row.name) ?? id : id }\n}\n\n/** Parse the host session catalog into flat choices, keeping a saved route selectable. */\nexport function parseModelMenuChoices(value: unknown, bound?: ModelRoute): ModelMenuChoice[] {\n const envelope = asRecord(value)\n // Host remote calls resolve to a result envelope ({ ok, value }); older hosts\n // and unit tests hand over the bare catalog. Accept both.\n const root = (envelope && envelope.ok === true ? asRecord(envelope.value) : undefined) ?? envelope ?? {}\n const groups = Array.isArray(root.groups) ? root.groups : []\n const choices: ModelMenuChoice[] = []\n for (const group of groups) {\n const groupRow = asRecord(group)\n const provider = groupRow ? asText(groupRow.id) : undefined\n if (!provider || !groupRow || !Array.isArray(groupRow.models)) continue\n const providerName = asText(groupRow.name) ?? provider\n for (const entry of groupRow.models) {\n const modelRow = asRecord(entry)\n const model = modelRow ? asText(modelRow.id) : undefined\n if (!model || !modelRow) continue\n const name = asText(modelRow.name) ?? model\n const reasoning = asRecord(modelRow.reasoning)\n const efforts = reasoning && Array.isArray(reasoning.efforts)\n ? reasoning.efforts.flatMap(effort => { const parsed = parseEffort(effort); return parsed ? [parsed] : [] })\n : []\n choices.push({ provider, model, label: `${providerName} / ${name}`, providerLabel: providerName, efforts })\n }\n }\n if (bound?.provider && bound.model && !choices.some(item => item.provider === bound.provider && item.model === bound.model)) {\n choices.push({ provider: bound.provider, model: bound.model, label: `${bound.provider} / ${bound.model}`, efforts: [] })\n }\n return choices\n}\n\n/** Reasoning-effort options for one choice; the saved value stays selectable. */\nexport function modelMenuEffortOptions(\n choice: ModelMenuChoice | undefined,\n current?: string,\n): Array<{ id: string; name: string }> {\n const listed = (choice?.efforts ?? []).map(item => ({ ...item }))\n if (current && !listed.some(item => item.id === current)) listed.push({ id: current, name: current })\n return listed\n}\n\n/** Flat set of known routes for DetectModelFieldsOptions.knownModel. */\nexport function knownModelFromChoices(choices: readonly ModelMenuChoice[]): (route: ModelRoute) => boolean {\n const known = new Set(choices.map(choice => modelRouteKey(choice.provider, choice.model)))\n return route => known.has(modelRouteKey(route.provider, route.model))\n}\n","import { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { Button } from '@deepseek-ai/dsh-client-ui-primitives'\nimport {\n checkedModelCatalog, modelCatalogErrorMessage, modelCatalogFailures, parseModelMenuChoices,\n type ModelCatalogFailure, type ModelMenuChoice,\n} from './catalog.ts'\n\nexport interface UseModelCatalogOptions {\n /** Used only on mount; subsequent changes come from load(). */\n readonly initialCatalog?: unknown\n /** Disables initial, focus, subscription, and manual refreshes. */\n readonly enabled?: boolean\n readonly subscribe?: (onChange: () => void) => (() => void) | undefined\n}\n\nexport interface ModelCatalogState {\n readonly catalog: unknown\n readonly choices: ModelMenuChoice[]\n readonly loading: boolean\n readonly error: string\n readonly failures: readonly ModelCatalogFailure[]\n readonly refresh: () => Promise<void>\n}\n\ntype Snapshot = Pick<ModelCatalogState, 'catalog' | 'loading' | 'error'>\n\n/**\n * Latest refresh wins, including retries while a previous request is pending.\n * Keep load stable (for example with useCallback); changing it invalidates the\n * previous source and fetches again, so switching clients cannot publish stale data.\n */\nexport function useModelCatalog(load: () => Promise<unknown>, options: UseModelCatalogOptions = {}): ModelCatalogState {\n const enabled = options.enabled !== false\n const enabledRef = useRef(enabled)\n enabledRef.current = enabled\n const live = useRef(false)\n const source = useRef(load)\n const revision = useRef(0)\n const [state, setState] = useState<Snapshot>(() => {\n try {\n return { catalog: options.initialCatalog === undefined ? undefined : checkedModelCatalog(options.initialCatalog), loading: enabled, error: '' }\n } catch (error) {\n return { catalog: undefined, loading: enabled, error: modelCatalogErrorMessage(error) }\n }\n })\n const refresh = useCallback(async (): Promise<void> => {\n if (!live.current || !enabledRef.current) return\n const request = ++revision.current\n setState(previous => ({ ...previous, loading: true, error: '' }))\n try {\n const catalog = checkedModelCatalog(await load())\n if (live.current && request === revision.current) setState({ catalog, loading: false, error: '' })\n } catch (error) {\n if (live.current && request === revision.current) {\n setState(previous => ({ ...previous, loading: false, error: modelCatalogErrorMessage(error) }))\n }\n }\n }, [load, enabled])\n\n useEffect(() => {\n live.current = true\n if (source.current !== load) {\n source.current = load\n // Last-good retention belongs to one source; a new client must not\n // inherit another client's models if its initial request fails.\n setState({ catalog: undefined, loading: enabled, error: '' })\n }\n if (enabled) void refresh()\n else setState(previous => ({ ...previous, loading: false }))\n return () => { live.current = false; ++revision.current }\n }, [enabled, refresh])\n\n useEffect(() => {\n if (!enabled) return\n const reload = (): void => { void refresh() }\n // No polling: the host owns catalog production, and focus is a cheap\n // recovery path for missed ordinary notifications or changed credentials.\n if (typeof window !== 'undefined') window.addEventListener('focus', reload)\n let unsubscribe: (() => void) | undefined\n try { unsubscribe = options.subscribe?.(reload) } catch (error) {\n setState(previous => ({ ...previous, error: modelCatalogErrorMessage(error) }))\n }\n return () => {\n if (typeof window !== 'undefined') window.removeEventListener('focus', reload)\n unsubscribe?.()\n }\n }, [enabled, refresh, options.subscribe])\n\n const choices = useMemo(() => parseModelMenuChoices(state.catalog), [state.catalog])\n const failures = useMemo(() => state.catalog === undefined ? [] : modelCatalogFailures(state.catalog), [state.catalog])\n return { ...state, choices, failures, refresh }\n}\n\nexport interface ModelCatalogStatusProps {\n readonly state: Pick<ModelCatalogState, 'loading' | 'error' | 'failures' | 'refresh'>\n readonly locale?: string\n}\n\n/**\n * Also accepts a mapped state from a caller that owns broader async orchestration.\n *\n * The dsh-ui-* classes carry the styling and resolve through the consuming\n * plugin's own officialUiCss scope (every consumer mounts its root class, so\n * e.g. `.dsh-model-hub .dsh-ui-loading` paints this); dsh-model-catalog-status\n * stays as a structural hook for tests and layout, never a colour source.\n */\nexport function ModelCatalogStatus({ state, locale }: ModelCatalogStatusProps) {\n const zh = locale?.toLowerCase().startsWith('zh') === true\n const copy = zh\n ? { loading: '正在加载模型…', error: '模型列表加载失败', partial: '部分提供商的模型未能加载', retry: '重试' }\n : { loading: 'Loading models…', error: 'Unable to load models', partial: 'Some providers could not load their models', retry: 'Retry' }\n if (!state.loading && !state.error && state.failures.length === 0) return null\n return <div className=\"dsh-model-catalog-status dsh-ui-stack\" lang={zh ? 'zh' : 'en'}>\n {state.loading ? <p role=\"status\" className=\"dsh-ui-loading\">{copy.loading}</p> : null}\n {state.error ? <p role=\"alert\" className=\"dsh-ui-error dsh-ui-wrap\">{copy.error}: {state.error}</p> : null}\n {state.failures.length > 0 ? <div role=\"status\" className=\"dsh-ui-meta\">\n <p>{copy.partial}</p>\n <ul className=\"dsh-ui-list\">{state.failures.map((failure, index) => <li key={`${failure.id}:${index}`}>{failure.name || failure.id}: {failure.message}</li>)}</ul>\n </div> : null}\n {state.error || state.failures.length > 0\n ? <div className=\"dsh-ui-actions\"><Button type=\"button\" size=\"sm\" disabled={state.loading} onClick={() => { void state.refresh() }}>{copy.retry}</Button></div>\n : null}\n </div>\n}\n","/**\n * Pure menu helpers over parsed catalog choices: provider grouping, display\n * names and search filtering. Pure and browser-safe like the rest of the core\n * entry — no React, no host imports. The popover component lives in `./ui.tsx`.\n */\nimport type { ModelMenuChoice } from './catalog.ts'\n\n/** Localize standard effort ids only when the provider has not supplied a display name. */\nexport function modelMenuEffortLabel(effort: { id: string; name: string }, locale?: string): string {\n if (effort.name !== effort.id) return effort.name\n const labels: Record<string, readonly [string, string]> = {\n off: ['关闭', 'Off'], none: ['无', 'None'], minimal: ['最低', 'Minimal'], low: ['低', 'Low'],\n medium: ['中', 'Medium'], high: ['高', 'High'], xhigh: ['极高', 'Extra high'],\n max: ['最高', 'Maximum'], ultra: ['超高', 'Ultra'],\n }\n return labels[effort.id]?.[locale?.toLowerCase().startsWith('zh') ? 0 : 1] ?? effort.name\n}\n\n/** One provider group in the menu, in catalog order, after applying the search query. */\nexport interface ModelMenuGroup {\n readonly provider: string\n /** Provider display name, from the catalog group or split from the \"Provider / Model\" label. */\n readonly name: string\n readonly items: readonly ModelMenuChoice[]\n}\n\n/** The short model label shown inside a provider group. */\nexport function modelMenuShortName(choice: ModelMenuChoice): string {\n const sep = choice.label.indexOf(' / ')\n return sep > 0 ? choice.label.slice(sep + 3) : choice.model\n}\n\n/** Group catalog choices by provider and filter them by a case-insensitive query. */\nexport function groupModelMenuChoices(choices: readonly ModelMenuChoice[], query: string): ModelMenuGroup[] {\n const needle = query.trim().toLowerCase()\n const matched = needle\n ? choices.filter(choice => choice.label.toLowerCase().includes(needle)\n || choice.model.toLowerCase().includes(needle)\n || choice.provider.toLowerCase().includes(needle)\n // The provider display name is a separate search channel: a catalog may\n // name a provider differently from its id, and callers search by name.\n || (choice.providerLabel?.toLowerCase().includes(needle) ?? false))\n : choices\n const groups: Array<{ provider: string; name: string; items: ModelMenuChoice[] }> = []\n for (const choice of matched) {\n const sep = choice.label.indexOf(' / ')\n const name = choice.providerLabel ?? (sep > 0 ? choice.label.slice(0, sep) : choice.provider)\n const last = groups.at(-1)\n if (last && last.provider === choice.provider) last.items.push(choice)\n else groups.push({ provider: choice.provider, name, items: [choice] })\n }\n return groups\n}\n","/**\n * ModelMenu: the standard editor of one model-route field — the visible half\n * of the x-model-route contract. A feature plugin's settings page renders it\n * for its own marked field; the model hub renders one per detected field.\n *\n * It is a plugin-side copy of the host's composer model picker\n * (dsh-client-ui-model-selection's ModelSelect), rebuilt from the official\n * primitives and the published bundle's behavior: one card that opens on the\n * root pane (Model / Effort cells), drills into the provider-grouped,\n * searchable model list or the effort list, and Escapes back before closing.\n * Sticky group headings, subsequence ranking, highlight walking and focus\n * hand-back all match the host. SYNC POINT: when the host's ModelSelect or\n * ModelSelect.module.css changes, this copy must be re-transcribed; styles\n * below may only reference allowlisted theme tokens (the --dsw-* set plus the\n * host's --ds-* motion tokens), never literal colors.\n *\n * It statically imports the primitives, so only browser clients should load\n * this entry; host code and node tests use the core entry (`./index.ts`).\n */\nimport { cloneElement, isValidElement, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type ReactNode } from 'react'\nimport { createPortal } from 'react-dom'\nimport {\n IconCheckOutlineRegular, IconChevronRightOutlineRegular, IconCloseFillRegular, Input, MenuGroup, MenuSurface,\n observeStickyMenuGroups, rankByName,\n} from '@deepseek-ai/dsh-client-ui-primitives'\nexport { useModelCatalog, ModelCatalogStatus } from './catalog-ui.tsx'\nexport type { UseModelCatalogOptions, ModelCatalogState, ModelCatalogStatusProps } from './catalog-ui.tsx'\nimport type { ModelMenuChoice } from './catalog.ts'\nimport { groupModelMenuChoices, modelMenuEffortLabel, modelMenuShortName } from './menu.ts'\n\n/** Extra rows rendered above the model groups (e.g. a plugin's \"follow\"/\"off\" modes). */\nexport interface ModelMenuLeadingItem {\n readonly id: string\n readonly label: ReactNode\n readonly selected?: boolean\n}\n\nexport interface ModelMenuProps {\n /** Active host locale, supplied by the owning plugin's live locale subscription. */\n readonly locale?: string\n readonly open: boolean\n readonly onOpenChange: (open: boolean) => void\n /** Trigger rendered in place; the menu anchors to it and returns focus to it. */\n readonly anchor: ReactNode\n readonly choices: readonly ModelMenuChoice[]\n readonly selected?: { readonly provider: string; readonly model: string }\n readonly onPick: (route: { provider: string; model: string }) => void\n readonly leading?: readonly ModelMenuLeadingItem[]\n readonly onPickLeading?: (id: string) => void\n /** Effort pane rows; the root Effort cell is hidden while this is empty. */\n readonly efforts?: ReadonlyArray<{ id: string; name: string }>\n readonly selectedEffort?: string\n readonly onPickEffort?: (effort: string | undefined) => void\n /** Root-cell labels and the values shown trailing them. */\n readonly modelLabel?: string\n readonly modelValue?: string\n readonly effortLabel?: string\n readonly effortValue?: string\n readonly defaultEffortLabel?: string\n readonly searchPlaceholder?: string\n readonly emptyLabel?: string\n readonly clearSearchLabel?: string\n /** Pane the menu opens on; default 'root'. 'model' opens the searchable model list directly. */\n readonly initialPane?: 'root' | 'model'\n /** Show the model search row even when the catalog has four or fewer choices. */\n readonly alwaysShowSearch?: boolean\n /**\n * Render the declared reasoning efforts as a discrete slider inside the model\n * pane. Additive: the effort list and the root Effort cell stay for the\n * default (false) mode, and only the caller-supplied effort rows are shown.\n */\n readonly reasoningSlider?: boolean\n /**\n * Optional banner rendered at the top of the menu card, above the search and\n * list — e.g. a directory status/error row. Pure library-local React content,\n * not a cross-factory data contract.\n */\n readonly menuHeader?: ReactNode\n /** Disable every action after opening; by default a true value also closes\n * the menu (closeOnDisable). */\n readonly disabled?: boolean\n /**\n * Submission in progress. Keeps the menu open (unlike `disabled`) and still\n * allows opening/closing and typing in search, but disables selection rows\n * and blocks repeated model/leading/effort/slider submissions.\n */\n readonly busy?: boolean\n /**\n * Close the card after a model pick. Default true (drill menus dismiss).\n * The composer picker sets false so a selection does not unmount the open\n * list — search and scroll belong to that card.\n */\n readonly closeOnPick?: boolean\n /**\n * Close the open card when `disabled` rises. Default true — a hard lock\n * dismisses. Keep-open callers (the composer picker) set false: an owner's\n * save-state \"disabled\" pulse gates actions without unmounting the open\n * list, and Escape/outside presses still dismiss while disabled.\n */\n readonly closeOnDisable?: boolean\n readonly className?: string\n /** Extra class on the portaled menu card, which renders under document.body. */\n readonly listClassName?: string\n}\n\ntype Pane = 'root' | 'model' | 'effort'\n\n/** Unplaced portal card: hidden but laid out at a fixed origin so measurements are real. */\nconst MEASURE_STYLE: CSSProperties = { visibility: 'hidden', left: 0, top: 0 }\n\nexport function ModelMenu(props: ModelMenuProps) {\n const language = props.locale?.toLowerCase().startsWith('zh') ? 'zh' : 'en'\n const copy = language === 'zh'\n ? { model: '模型', effort: '思考强度', default: '默认', search: '搜索模型…', empty: '没有匹配的模型', clear: '清除搜索' }\n : { model: 'Model', effort: 'Reasoning', default: 'Default', search: 'Search models…', empty: 'No matching models', clear: 'Clear search' }\n const {\n open, onOpenChange, anchor, choices, selected, onPick,\n leading = [], onPickLeading, efforts = [], selectedEffort, onPickEffort,\n modelLabel = copy.model, modelValue = '—', effortLabel = copy.effort, effortValue, defaultEffortLabel = copy.default,\n searchPlaceholder = copy.search, emptyLabel = copy.empty, clearSearchLabel = copy.clear,\n initialPane = 'root', alwaysShowSearch = false, reasoningSlider = false,\n menuHeader, disabled = false, busy = false, closeOnPick = true, closeOnDisable = true,\n className, listClassName,\n } = props\n const rootRef = useRef<HTMLSpanElement | null>(null)\n const openRef = useRef(open)\n openRef.current = open\n const pendingOpenRef = useRef(false)\n const pendingRestoreFocus = useRef(false)\n const [requestedOpen, setRequestedOpen] = useState(false)\n const menuRef = useRef<HTMLDivElement | null>(null)\n const groupsRef = useRef<HTMLDivElement | null>(null)\n const searchRef = useRef<HTMLInputElement | null>(null)\n const itemRefs = useRef<Array<HTMLButtonElement | null>>([])\n const paneFocus = useRef<Pane | 'drill' | null>(null)\n const [pane, setPane] = useState<Pane>('root')\n const [query, setQuery] = useState('')\n const [highlightedIndex, setHighlightedIndex] = useState<number | null>(null)\n /* Keyboard arrows only. Mouse focus and a rebuilt choices array must not scroll. */\n const [keyNav, setKeyNav] = useState(0)\n const [menuPos, setMenuPos] = useState<CSSProperties | null>(null)\n const id = useId()\n const showSearch = alwaysShowSearch || choices.length > 4\n const effortRows = useMemo(() => [{ id: '', name: defaultEffortLabel }, ...efforts.map(effort => ({ ...effort, name: modelMenuEffortLabel(effort, language) }))], [defaultEffortLabel, efforts, language])\n /* The official ranks each provider group by a case-insensitive ordered\n * subsequence (prefix hits first, then alignment score, then catalog order);\n * groups left empty by the query drop out. */\n const filteredGroups = useMemo(() => groupModelMenuChoices(choices, '').map(group => ({\n ...group,\n items: rankByName(group.items.map(choice => ({\n choice,\n name: modelMenuShortName(choice),\n // The match surface deliberately carries the provider id, provider display\n // name, model id and the full \"Provider / Model\" label — never only the\n // possibly-truncated short model name — so provider and model-id searches\n // resolve while the rendered name stays short.\n label: [choice.provider, choice.providerLabel, choice.model, choice.label].filter(Boolean).join(' '),\n })), showSearch ? query.trim() : ''),\n })).filter(group => group.items.length > 0), [choices, query, showSearch])\n const visibleModels = useMemo(() => filteredGroups.flatMap(group => group.items.map(item => item.choice)), [filteredGroups])\n const currentVisibleIndex = visibleModels.findIndex(choice => choice.provider === selected?.provider && choice.model === selected.model)\n const activeModelIndex = Math.min(highlightedIndex ?? Math.max(0, currentVisibleIndex), visibleModels.length - 1)\n const changeOpen = (next: boolean): void => {\n if (openRef.current === next) return\n openRef.current = next\n onOpenChange(next)\n }\n const requestOpen = (): void => {\n if (open || pendingOpenRef.current) return\n pendingOpenRef.current = true\n pendingRestoreFocus.current = false\n setRequestedOpen(true)\n }\n const close = (restoreFocus = false): void => {\n const active = document.activeElement\n pendingRestoreFocus.current = restoreFocus && (active === document.body\n || rootRef.current?.contains(active) === true || menuRef.current?.contains(active) === true)\n changeOpen(false)\n }\n const drill = (next: Pane): void => {\n setQuery('')\n setHighlightedIndex(null)\n paneFocus.current = 'drill'\n setPane(next)\n }\n /** Leave a drilled pane for the entry pane, handing the keyboard back to it.\n * A root entry refocuses the cell that opened the pane; a search-first\n * (model) entry refocuses that pane's own intent. */\n const back = (from: Pane): void => {\n paneFocus.current = initialPane === 'root' ? from : 'drill'\n setPane(initialPane)\n }\n const moveFocus = (offset: number): void => {\n const items = itemRefs.current.filter((item): item is HTMLButtonElement => item !== null && !item.disabled)\n if (!items.length) return\n const active = items.findIndex(item => item === document.activeElement)\n items[active === -1 ? (offset > 0 ? 0 : items.length - 1) : (active + offset + items.length) % items.length]?.focus()\n }\n\n // A selection can synchronously disable its trigger while the owner writes.\n // Retry on the owner's next render, once the native button can take focus.\n useLayoutEffect(() => {\n if (open || !pendingRestoreFocus.current) return\n const active = document.activeElement\n if (active !== document.body && !rootRef.current?.contains(active)) {\n pendingRestoreFocus.current = false\n return\n }\n const trigger = rootRef.current?.querySelector('button')\n if (!trigger || trigger.disabled) return\n trigger.focus()\n if (document.activeElement === trigger) pendingRestoreFocus.current = false\n })\n useEffect(() => {\n if (open || !pendingRestoreFocus.current) return\n const cancelOutside = (event: Event): void => {\n if (event.target instanceof Node && !rootRef.current?.contains(event.target)) pendingRestoreFocus.current = false\n }\n document.addEventListener('focusin', cancelOutside)\n document.addEventListener('pointerdown', cancelOutside)\n return () => {\n document.removeEventListener('focusin', cancelOutside)\n document.removeEventListener('pointerdown', cancelOutside)\n }\n })\n\n useEffect(() => {\n if (!requestedOpen) return\n pendingOpenRef.current = false\n setRequestedOpen(false)\n // The caller's trigger handler may also update the controlled open prop.\n // Check the committed state before supplying the missing open callback.\n if (!open) changeOpen(true)\n }, [requestedOpen, open])\n\n useEffect(() => {\n if (!open) return\n // A consumer may open directly at the model pane (a search-first picker).\n // The root cells stay reachable with Escape; the default stays 'root' and\n // leaves the trigger's keyboard focus intent untouched.\n setPane(initialPane)\n if (initialPane === 'model') paneFocus.current = 'drill'\n setQuery('')\n setHighlightedIndex(null)\n }, [open, initialPane])\n // A consumer that becomes busy/locked after opening must not leave actions\n // available. With closeOnDisable a true value also closes the card (the\n // trigger owns the disabled look); without it the open card stays mounted\n // and only dismissal stays available.\n useEffect(() => {\n if (disabled && open && closeOnDisable) changeOpen(false)\n }, [disabled, open, closeOnDisable])\n useEffect(() => {\n if (!open) return\n const closeOutside = (event: MouseEvent): void => {\n const target = event.target as Node\n if (rootRef.current?.contains(target) || menuRef.current?.contains(target)) return\n changeOpen(false)\n }\n /* The span's React onKeyDown already sees Escape from inside the menu —\n * portal rows bubble through the React tree. What it cannot see is focus\n * that is no longer in the tree at all: a disabled rise ejects the\n * focused row's focus to document.body, and Escape there never reaches\n * the span. This listener keeps dismissal reachable for that focus; the\n * openRef check means it never double-acts after the in-tree handler. */\n const escapeOutside = (event: KeyboardEvent): void => {\n if (event.key !== 'Escape' || event.defaultPrevented || event.isComposing) return\n if (!openRef.current) return\n event.preventDefault()\n if (pane !== initialPane) back(pane)\n else close(true)\n }\n document.addEventListener('mousedown', closeOutside)\n document.addEventListener('keydown', escapeOutside)\n return () => {\n document.removeEventListener('mousedown', closeOutside)\n document.removeEventListener('keydown', escapeOutside)\n }\n }, [open, onOpenChange, pane, initialPane])\n /* Focus intent after a pane change: the model pane takes the search field when\n * it has one, every other drill takes the checked row, and going back takes\n * the cell that opened the pane. */\n useEffect(() => {\n const intent = paneFocus.current\n // MenuSurface forwards the measurement visibility:hidden style. Browsers\n // refuse focus there, so keep intent until placement has made it visible.\n if (!open || menuPos === null || intent === null) return\n // Reopening resets a previously drilled pane in a separate commit. Entry\n // and return intent belong to the root cells, never the outgoing rows.\n if (intent !== 'drill' && pane !== 'root') return\n paneFocus.current = null\n if (intent === 'drill') {\n if (pane === 'model' && showSearch) { searchRef.current?.focus(); return }\n (menuRef.current?.querySelector<HTMLButtonElement>('[role=\"menuitemradio\"][aria-checked=\"true\"]:not([disabled])')\n ?? itemRefs.current.find(item => item !== null && !item.disabled))?.focus()\n return\n }\n itemRefs.current[intent === 'effort' ? 1 : 0]?.focus()\n }, [open, pane, showSearch, menuPos])\n useEffect(() => {\n const viewport = groupsRef.current\n if (viewport === null) return\n return observeStickyMenuGroups(viewport)\n }, [open, pane, filteredGroups])\n /* Scroll when the model pane opens, or when a keyboard arrow moves the\n * highlight. `visibleModels` is a new array whenever a directory snapshot\n * replaces `current` and the caller rebuilds equivalent choices — depending\n * on that array jumped scrollTop. Search may replace the rows; a model\n * click must not. */\n const modelPaneOpen = open && pane === 'model'\n const scrollSignal = !modelPaneOpen ? 'closed' : keyNav === 0 ? 'open' : `key:${keyNav}`\n const scrollSignalRef = useRef<string | null>(null)\n useLayoutEffect(() => {\n if (!modelPaneOpen || activeModelIndex < 0) {\n if (!modelPaneOpen) scrollSignalRef.current = null\n return\n }\n if (scrollSignalRef.current === scrollSignal) return\n scrollSignalRef.current = scrollSignal\n itemRefs.current[leading.length + activeModelIndex]?.scrollIntoView({ block: 'nearest' })\n }, [modelPaneOpen, scrollSignal, activeModelIndex, leading.length])\n /* The card hangs above the trigger, right-aligned, inside 12px viewport\n * margins — the official placement formula, re-run on scroll and resize. */\n useLayoutEffect(() => {\n if (!open) { setMenuPos(null); return }\n const place = (): void => {\n const rect = rootRef.current?.getBoundingClientRect()\n if (!rect) return\n const margin = 12, lw = menuRef.current?.offsetWidth ?? 0, lh = menuRef.current?.offsetHeight ?? 0\n let x = rect.right - lw, y = rect.top - 8 - lh\n if (lw > 0) x = Math.min(Math.max(x, margin), window.innerWidth - lw - margin)\n if (lh > 0) y = Math.min(Math.max(y, margin), window.innerHeight - lh - margin)\n setMenuPos(prev => (prev && prev.left === x && prev.top === y ? prev : { left: x, top: y }))\n }\n place()\n window.addEventListener('scroll', place, true)\n window.addEventListener('resize', place)\n return () => {\n window.removeEventListener('scroll', place, true)\n window.removeEventListener('resize', place)\n }\n }, [open, pane, choices, query])\n\n function onKeyDown(event: React.KeyboardEvent): void {\n if (event.defaultPrevented || event.nativeEvent.isComposing) return\n // Escape dismisses even while actions are disabled — a save lock gates\n // selection, not closing. A drilled pane backs out to the entry pane\n // first; the entry pane closes outright.\n if (event.key === 'Escape' && open) {\n event.preventDefault()\n if (pane !== initialPane) back(pane)\n else close(true)\n return\n }\n if (disabled) return\n if (!open && ['Enter', ' ', 'ArrowDown', 'ArrowUp'].includes(event.key)) {\n const button = event.target instanceof Element ? event.target.closest('button') : null\n if (!(button instanceof HTMLButtonElement) || button.disabled || !rootRef.current?.contains(button)) return\n // Prevent the native Enter/Space click from opening a second time.\n event.preventDefault()\n paneFocus.current = 'model'\n requestOpen()\n return\n }\n if (!open) return\n if (pane === 'model' && showSearch && (event.key === 'ArrowDown' || event.key === 'ArrowUp')) {\n event.preventDefault()\n if (visibleModels.length > 0) {\n setHighlightedIndex((activeModelIndex + (event.key === 'ArrowDown' ? 1 : -1) + visibleModels.length) % visibleModels.length)\n setKeyNav(n => n + 1)\n searchRef.current?.focus()\n }\n return\n }\n if (pane === 'model' && showSearch && event.target instanceof HTMLInputElement && (event.key === 'Enter' || (event.key === 'Tab' && !event.shiftKey))) {\n if (event.key === 'Tab' && visibleModels.length === 0) return\n event.preventDefault()\n const highlighted = visibleModels[activeModelIndex]\n // A submission in progress must not be repeated by Enter/Tab.\n if (highlighted && !busy) { onPick({ provider: highlighted.provider, model: highlighted.model }); if (closeOnPick) close(true) }\n return\n }\n if (event.key === 'Tab') {\n if (event.shiftKey) {\n event.preventDefault()\n if (pane !== initialPane) back(pane)\n else close(true)\n return\n }\n const focused = document.activeElement\n const rows = itemRefs.current.filter((item): item is HTMLButtonElement => item !== null)\n if (focused instanceof HTMLButtonElement && rows.includes(focused)) {\n event.preventDefault()\n focused.click()\n return\n }\n if (pane === 'model' && showSearch) {\n event.preventDefault()\n setHighlightedIndex(null)\n searchRef.current?.focus()\n }\n return\n }\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault()\n moveFocus(event.key === 'ArrowDown' ? 1 : -1)\n }\n }\n\n function onBlur(event: React.FocusEvent): void {\n const related = event.relatedTarget\n // A target already detached from the document (the menu re-rendering the\n // focused row) is inside for this purpose — never a dismissal.\n if (related instanceof Node\n && (rootRef.current?.contains(related) || menuRef.current?.contains(related)\n || !related.isConnected)) return\n // Keep-open mode never closes on a blur that has no connected next focus:\n // disabling the picked row, or a blur whose target raced a re-render, is\n // not the user dismissing the card. Outside presses, Escape, and focus\n // landing in a real outside node still close.\n if (!closeOnPick && !(related instanceof Node)) return\n // Disabling the focused row while a selection is in flight blurs it with\n // no next target. That is not a dismissal — closing here unmounts the card.\n if (busy && related == null) return\n if (open) changeOpen(false)\n }\n\n itemRefs.current = []\n let itemIndex = 0\n let modelIndex = 0\n const itemRef = () => {\n const at = itemIndex++\n return (node: HTMLButtonElement | null): void => { itemRefs.current[at] = node }\n }\n\n const menu = open && typeof document !== 'undefined'\n ? createPortal(\n <MenuSurface\n ref={menuRef}\n id={`${id}-menu`}\n className={`dsh-model-menu-menu${listClassName ? ` ${listClassName}` : ''}`}\n style={menuPos ?? MEASURE_STYLE}\n role={pane === 'model' ? 'group' : 'menu'}\n aria-label={modelLabel}\n lang={language}\n >\n {menuHeader ? <div className=\"dsh-model-menu-header\">{menuHeader}</div> : null}\n {pane === 'root' ? <>\n <button ref={itemRef()} type=\"button\" role=\"menuitem\" className=\"dsh-model-menu-cell\" disabled={disabled} onClick={() => drill('model')}>\n <span className=\"dsh-model-menu-cellLabel\">{modelLabel}</span>\n <span className=\"dsh-model-menu-cellValue\">{modelValue}</span>\n <IconChevronRightOutlineRegular className=\"dsh-model-menu-cellChevron\" />\n </button>\n {efforts.length > 0 && !reasoningSlider ? <button ref={itemRef()} type=\"button\" role=\"menuitem\" className=\"dsh-model-menu-cell\" disabled={disabled} onClick={() => drill('effort')}>\n <span className=\"dsh-model-menu-cellLabel\">{effortLabel}</span>\n <span className=\"dsh-model-menu-cellValue\">{effortValue ?? effortRows.find(row => row.id === (selectedEffort ?? ''))?.name ?? defaultEffortLabel}</span>\n <IconChevronRightOutlineRegular className=\"dsh-model-menu-cellChevron\" />\n </button> : null}\n </> : null}\n {pane === 'model' ? <>\n {showSearch ? <div className=\"dsh-model-menu-searchRow\">\n <Input\n ref={searchRef}\n disabled={disabled}\n className={`dsh-model-menu-search${query !== '' ? ' dsh-model-menu-searchWithQuery' : ''}`}\n type=\"text\"\n role=\"searchbox\"\n aria-label={searchPlaceholder}\n aria-controls={`${id}-models`}\n aria-activedescendant={activeModelIndex < 0 ? undefined : `${id}-model-${activeModelIndex}`}\n placeholder={searchPlaceholder}\n value={query}\n onChange={event => { setQuery(event.target.value); setHighlightedIndex(0) }}\n />\n {query !== '' ? <button type=\"button\" className=\"dsh-model-menu-searchClear\" aria-label={clearSearchLabel} disabled={disabled}\n onClick={() => { setQuery(''); setHighlightedIndex(null); searchRef.current?.focus() }}>\n <IconCloseFillRegular />\n </button> : null}\n </div> : null}\n <div ref={groupsRef} id={`${id}-models`} className=\"dsh-model-menu-groups scrollable\" role=\"menu\" aria-label={modelLabel}\n hidden={filteredGroups.length === 0}>\n {leading.length > 0 ? <div className=\"dsh-model-menu-leading\">\n {leading.map(item => (\n <button key={item.id} ref={itemRef()} type=\"button\" role=\"menuitemradio\" aria-checked={item.selected === true} disabled={disabled || busy}\n className={`dsh-model-menu-option${item.selected === true ? ' dsh-model-menu-selected' : ''}`}\n onClick={() => { if (disabled || busy) return; onPickLeading?.(item.id); if (closeOnPick) close(true) }}>\n <span className=\"dsh-model-menu-optionCopy\"><span className=\"dsh-model-menu-modelName\">{item.label}</span></span>\n <span className=\"dsh-model-menu-check\">{item.selected === true ? <IconCheckOutlineRegular /> : null}</span>\n </button>\n ))}\n </div> : null}\n {filteredGroups.map(group => (\n <MenuGroup key={group.provider} label={group.name}>\n {group.items.map(item => {\n const index = modelIndex++\n const choice = item.choice\n const checked = selected?.provider === choice.provider && selected.model === choice.model\n return <button\n key={`${choice.provider}/${choice.model}`}\n ref={itemRef()}\n type=\"button\"\n role=\"menuitemradio\"\n aria-checked={checked}\n id={`${id}-model-${index}`}\n tabIndex={showSearch ? -1 : 0}\n disabled={disabled || busy}\n onFocus={() => setHighlightedIndex(index)}\n data-highlighted={index === activeModelIndex ? '' : undefined}\n className={`dsh-model-menu-option dsh-model-menu-modelOption${checked ? ' dsh-model-menu-selected' : ''}${index === activeModelIndex ? ' dsh-model-menu-optionActive' : ''}`}\n onMouseMove={index === activeModelIndex ? undefined : () => {\n if (showSearch) setHighlightedIndex(index)\n else itemRefs.current[leading.length + index]?.focus()\n }}\n title={choice.label}\n onClick={() => { if (disabled || busy) return; onPick({ provider: choice.provider, model: choice.model }); if (closeOnPick) close(true) }}\n >\n <span className=\"dsh-model-menu-optionCopy\"><span className=\"dsh-model-menu-modelName\">{modelMenuShortName(choice)}</span></span>\n <span className=\"dsh-model-menu-check\">{checked ? <IconCheckOutlineRegular /> : null}</span>\n </button>\n })}\n </MenuGroup>\n ))}\n </div>\n {reasoningSlider && efforts.length > 0 && filteredGroups.length > 0\n ? <EffortSlider label={effortLabel} rows={effortRows} selected={selectedEffort ?? ''} disabled={disabled} busy={busy}\n onPick={value => onPickEffort?.(value)} />\n : null}\n {filteredGroups.length === 0 ? <div className=\"dsh-model-menu-empty\" role=\"status\">{emptyLabel}</div> : null}\n </> : null}\n {pane === 'effort' ? <>\n {effortRows.map(row => {\n const checked = (selectedEffort ?? '') === row.id\n return <button key={row.id || '__default'} ref={itemRef()} type=\"button\" role=\"menuitemradio\" aria-checked={checked} disabled={disabled || busy}\n className={`dsh-model-menu-option${checked ? ' dsh-model-menu-selected' : ''}`}\n onClick={() => { if (disabled || busy) return; onPickEffort?.(row.id || undefined); if (closeOnPick) close(true) }}>\n <span className=\"dsh-model-menu-optionCopy\"><span className=\"dsh-model-menu-modelName\">{row.name}</span></span>\n <span className=\"dsh-model-menu-check\">{checked ? <IconCheckOutlineRegular /> : null}</span>\n </button>\n })}\n </> : null}\n </MenuSurface>,\n document.body,\n )\n : null\n const trigger = isValidElement<Record<string, unknown>>(anchor)\n ? cloneElement(anchor, { 'aria-haspopup': 'menu', 'aria-expanded': open, 'aria-controls': open ? `${id}-menu` : undefined, 'aria-disabled': disabled || undefined })\n : anchor\n return <span ref={rootRef} className={`dsh-model-menu-root${className ? ` ${className}` : ''}`} onKeyDown={onKeyDown} onBlur={onBlur}\n onClick={event => {\n if (disabled || event.defaultPrevented) return\n const button = event.target instanceof Element ? event.target.closest('button') : null\n if (!(button instanceof HTMLButtonElement) || button.disabled || !rootRef.current?.contains(button)) return\n requestOpen()\n }}\n onMouseDown={event => { if (event.target instanceof Element && menuRef.current?.contains(event.target) && event.target.closest('button') !== null) event.preventDefault() }}>\n {trigger}{menu}\n </span>\n}\n\n/**\n * Discrete reasoning-effort slider shown under the model list in enhanced mode.\n *\n * A native range input (`step=1`) over exactly the rows the caller supplies —\n * the default row plus each effort the selected model advertises — so it can\n * never invent a level. It previews locally while dragging or arrowing and\n * commits only when the gesture ends (pointer up, key up, or blur), so a drag\n * does not write on every step. The menu stays open, so adjusting the effort\n * never loses the model selection or the search query.\n *\n * The input itself stays the entire interaction and accessibility surface —\n * keyboard, ARIA, disabled and the native step snapping all come from it —\n * while the track, gradient fill and thumb below are decorative layers painted\n * from the `--_p` percentage the preview position sets on the rail. Value\n * changes only update that custom property, so the CSS transitions animate\n * between levels without remounting nodes or restarting an animation.\n */\nfunction EffortSlider(props: {\n readonly label: string\n readonly rows: ReadonlyArray<{ id: string; name: string }>\n readonly selected: string\n readonly disabled?: boolean\n readonly busy?: boolean\n readonly onPick: (effort: string | undefined) => void\n}) {\n const { label, rows, selected, disabled = false, busy = false, onPick } = props\n const active = Math.max(0, rows.findIndex(row => row.id === selected))\n const [position, setPosition] = useState(active)\n const positionRef = useRef(position)\n // A committed selection from the owner resets the preview.\n useEffect(() => { positionRef.current = active; setPosition(active) }, [active])\n const preview = (next: number): void => {\n positionRef.current = next\n setPosition(next)\n }\n // Commit once per gesture: pointer up, key up, or leaving the control. A\n // submission already in flight must not be repeated.\n const commit = (): void => {\n if (disabled || busy) return\n const row = rows[positionRef.current]\n if (row !== undefined) onPick(row.id === '' ? undefined : row.id)\n }\n const max = Math.max(0, rows.length - 1)\n const percent = max > 0 ? Math.round((position / max) * 100) : 0\n return <div className=\"dsh-model-menu-sliderGroup\" role=\"group\" aria-label={label}>\n <div className=\"dsh-model-menu-sliderHead\">\n <span className=\"dsh-model-menu-sliderTitle\">{label}</span>\n <span className=\"dsh-model-menu-sliderValue\">{rows[position]?.name}</span>\n </div>\n <div className=\"dsh-model-menu-sliderRail\" style={{ '--_p': percent } as CSSProperties}>\n <input\n type=\"range\"\n className=\"dsh-model-menu-sliderInput\"\n min={0}\n max={max}\n step={1}\n value={position}\n disabled={disabled}\n aria-label={label}\n aria-disabled={disabled || busy || undefined}\n aria-valuetext={rows[position]?.name}\n onChange={event => {\n // Read the event target, not currentTarget: a synthetic change event may\n // carry a detached `{ value }` target, while a real range event targets\n // the input itself. Both must preview the same position.\n const value = Number((event.target as HTMLInputElement).value)\n if (Number.isFinite(value)) preview(value)\n }}\n onPointerUp={commit}\n onKeyUp={commit}\n onBlur={commit}\n />\n <span className=\"dsh-model-menu-sliderTrack\" aria-hidden=\"true\">\n <span className=\"dsh-model-menu-sliderFill\"><span className=\"dsh-model-menu-sliderFillBar\" /></span>\n <span className=\"dsh-model-menu-sliderNodes\">\n {rows.map((row, index) => (\n <span key={row.id || '__default'} data-covered={index <= position ? '' : undefined}\n className=\"dsh-model-menu-sliderNode\" style={{ '--_n': max > 0 ? Math.round((index / max) * 100) : 0 } as CSSProperties} />\n ))}\n </span>\n </span>\n <span className=\"dsh-model-menu-sliderThumb\" aria-hidden=\"true\" />\n </div>\n </div>\n}\n\n/**\n * ModelMenu styles, transcribed from the official ModelSelect.module.css (the\n * published dsh-client-ui-model-selection bundle): card capped at\n * min(360px, 100vh - 96px), 34px option cells at 13/18 with 5px 7px padding,\n * 34px root cells at 13/20, a borderless 12px search row with a clear button,\n * sticky group headings (MenuGroup's own CSS), and the l1-stroke prominent\n * elevation at portal z-index 1100. The trigger mirrors the composer's 28px\n * model pill, chevron rotating open. MenuSurface paints fill and backdrop.\n * Only allowlisted --dsw- and --ds- theme tokens may appear here — a literal\n * color is a bug.\n */\nexport const modelMenuCss = `\n.dsh-model-menu-root { min-width: 0; position: relative; display: inline-flex; }\n.dsh-model-menu-trigger {\n border-radius: var(--dsw-radius-sm);\n min-width: 0;\n max-width: min(360px, 45cqw);\n height: 28px;\n color: var(--dsw-alias-label-secondary);\n cursor: pointer;\n background: none;\n border: none;\n outline: none;\n align-items: center;\n gap: 4px;\n padding: 0 4px 0 8px;\n font-size: 13px;\n font-weight: 400;\n line-height: 20px;\n display: flex;\n}\n.dsh-model-menu-trigger:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover); }\n.dsh-model-menu-trigger:focus-visible:not([data-selection-focus]) { box-shadow: 0 0 0 var(--dsw-focus-ring-width) var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary)); }\n.dsh-model-menu-trigger:disabled { color: var(--dsw-alias-label-dimmed); cursor: default; }\n.dsh-model-menu-triggerLabel { text-overflow: ellipsis; white-space: nowrap; min-width: 0; overflow: hidden; }\n.dsh-model-menu-triggerEffort { text-overflow: ellipsis; white-space: nowrap; min-width: 0; color: var(--dsw-alias-label-caption); flex-shrink: 1000; overflow: hidden; }\n.dsh-model-menu-chevron { color: var(--dsw-alias-label-caption); flex: none; transition: transform var(--ds-transition-duration) var(--ds-ease-in-out); }\n.dsh-model-menu-chevronOpen { transform: rotate(180deg); }\n/* Portal overlay: the host publishes no z-index token, so the card keeps the\n * native menu layer's 1100 verbatim. */\n.dsh-model-menu-menu {\n z-index: 1100;\n --dsw-elevation-stroke-color: var(--dsw-alias-border-l1);\n width: max-content;\n min-width: min(240px, 100vw - 32px);\n max-width: min(420px, 100vw - 32px);\n max-height: min(360px, 100vh - 96px);\n box-shadow: var(--dsw-elevation-prominent);\n color: var(--dsw-alias-label-primary);\n --dsh-scrollbar-thumb: var(--dsw-alias-scrollbar-bg-l2);\n --dsh-scrollbar-thumb-hover: var(--dsw-alias-scrollbar-hover-l2);\n border: 0;\n flex-direction: column;\n padding: 4px;\n display: flex;\n position: fixed;\n overflow: hidden;\n}\n.dsh-model-menu-status, .dsh-model-menu-empty { color: var(--dsw-alias-label-tertiary); padding: 8px; font-size: 12px; line-height: 18px; }\n.dsh-model-menu-header { flex: none; padding: 2px 2px 4px; }\n.dsh-model-menu-searchRow { flex-shrink: 0; margin: 2px 0 3px; position: relative; }\n.dsh-model-menu-searchRow .dsh-model-menu-search { border-radius: var(--dsw-radius-md); background: none; border: 0 solid transparent; height: auto; padding: 5px 7px; display: flex; }\n.dsh-model-menu-searchRow .dsh-model-menu-search:focus-within { border-color: transparent; }\n.dsh-model-menu-searchWithQuery { padding-right: 34px; }\n.dsh-model-menu-searchRow .dsh-model-menu-search input { padding: 0; font-size: 12px; line-height: normal; }\n.dsh-model-menu-searchRow .dsh-model-menu-search input::placeholder { color: var(--dsw-alias-label-caption); }\n/* The clear button is a circle by geometry (border-radius: 50%), a shape the\n * radius token scale does not describe. */\n.dsh-model-menu-searchClear {\n width: 24px;\n height: 24px;\n color: var(--dsw-alias-label-secondary);\n cursor: pointer;\n background: none;\n border: none;\n border-radius: 50%;\n justify-content: center;\n align-items: center;\n padding: 0;\n display: inline-flex;\n position: absolute;\n top: 50%;\n right: 4px;\n transform: translateY(-50%);\n}\n.dsh-model-menu-searchClear:hover, .dsh-model-menu-searchClear:focus-visible { background: var(--dsw-alias-interactive-bg-hover); outline: none; }\n.dsh-model-menu-groups { min-height: 0; overflow-y: auto; }\n.dsh-model-menu-leading { border-bottom: 0.5px solid var(--dsw-alias-border-l2); margin-bottom: 3px; padding-bottom: 3px; }\n.dsh-model-menu-option {\n box-sizing: border-box;\n border-radius: var(--dsw-radius-md);\n width: auto;\n min-width: 100%;\n min-height: 34px;\n color: inherit;\n text-align: left;\n cursor: pointer;\n background: none;\n border: none;\n outline: none;\n align-items: center;\n gap: 6px;\n padding: 5px 7px;\n display: flex;\n}\n.dsh-model-menu-option:not(.dsh-model-menu-modelOption):hover:not(:disabled),\n.dsh-model-menu-option:focus-visible,\n.dsh-model-menu-optionActive:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover); }\n.dsh-model-menu-modelOption:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover); }\n.dsh-model-menu-selected { background: none; }\n.dsh-model-menu-option:disabled { color: var(--dsw-alias-label-dimmed); cursor: default; }\n.dsh-model-menu-optionCopy { flex-direction: column; flex: 1; min-width: 0; display: flex; }\n.dsh-model-menu-modelName { color: inherit; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 400; line-height: 18px; overflow: hidden; }\n.dsh-model-menu-check { color: var(--dsw-alias-label-primary); flex: 0 0 14px; place-items: center; display: grid; }\n.dsh-model-menu-check svg { width: 14px; height: 14px; }\n.dsh-model-menu-cell {\n box-sizing: border-box;\n border-radius: var(--dsw-radius-md);\n width: auto;\n min-width: 100%;\n height: 34px;\n color: var(--dsw-alias-label-primary);\n cursor: pointer;\n text-align: left;\n background: none;\n border: none;\n outline: none;\n align-items: center;\n gap: 6px;\n padding: 0 8px;\n font-size: 13px;\n line-height: 20px;\n display: flex;\n}\n.dsh-model-menu-cell:hover, .dsh-model-menu-cell:focus-visible { background: var(--dsw-alias-interactive-bg-hover); }\n.dsh-model-menu-cellLabel { white-space: nowrap; flex: none; }\n.dsh-model-menu-cellValue { text-overflow: ellipsis; white-space: nowrap; text-align: right; min-width: 0; color: var(--dsw-alias-label-tertiary); flex: auto; overflow: hidden; }\n.dsh-model-menu-cellChevron { width: 12px; height: 12px; color: var(--dsw-alias-menu-icon); flex: none; }\n/* Discrete reasoning-effort slider under the model list (enhanced mode).\n * The painted control is layered over a fully functional native range input:\n * the input stays on top, transparent, and owns pointer/keyboard/ARIA, while\n * the decorative track, fill and thumb render beneath it at pointer-events:\n * none. Position lives in one custom property (--_p, 0–100) on the rail, so\n * the only animated work a level change triggers is a clip-path/left\n * transition — no keyframes, no element churn. */\n.dsh-model-menu-sliderGroup { border-top: 0.5px solid var(--dsw-alias-border-l2); flex: none; margin-top: 4px; padding: 6px 8px 8px; }\n.dsh-model-menu-sliderHead { align-items: baseline; justify-content: space-between; gap: 8px; margin: 0 2px 4px; display: flex; }\n.dsh-model-menu-sliderTitle { color: var(--dsw-alias-label-tertiary); font-size: 12px; line-height: 18px; }\n.dsh-model-menu-sliderValue { color: var(--dsw-alias-label-primary); font-size: 13px; font-weight: 600; line-height: 20px; transition: color var(--ds-transition-duration) var(--ds-ease-in-out); }\n.dsh-model-menu-sliderRail { position: relative; direction: ltr; height: 38px; margin-top: 2px; }\n.dsh-model-menu-sliderRail:has(:disabled) { opacity: 0.45; }\n.dsh-model-menu-sliderInput {\n appearance: none;\n -webkit-appearance: none;\n box-sizing: border-box;\n border: 0;\n cursor: pointer;\n direction: ltr;\n opacity: 0;\n margin: 0;\n padding: 0;\n width: 100%;\n height: 100%;\n position: absolute;\n inset: 0;\n z-index: 1;\n touch-action: pan-y;\n}\n.dsh-model-menu-sliderInput:disabled { cursor: default; }\n/* The transparent input must keep the painted thumb's geometry: an\n * appearance:none webkit thumb defaults to 16px, which would shift the\n * end-point positions 7px off the decorative 30px disc and misplace the\n * native drag hit target. Track gets the full rail height so the whole band\n * maps to values identically. */\n.dsh-model-menu-sliderInput::-webkit-slider-runnable-track { width: 100%; height: 100%; }\n.dsh-model-menu-sliderInput::-webkit-slider-thumb { appearance: none; -webkit-appearance: none; width: 30px; height: 30px; margin: 0; }\n.dsh-model-menu-sliderInput::-moz-range-track { width: 100%; height: 100%; }\n.dsh-model-menu-sliderInput::-moz-range-thumb { width: 30px; height: 30px; margin: 0; border: 0; }\n.dsh-model-menu-sliderTrack {\n pointer-events: none;\n border-radius: 999px;\n width: 100%;\n height: 26px;\n background: var(--dsw-alias-interactive-bg-hover);\n box-shadow: inset 0 0 0 0.5px var(--dsw-alias-border-l2);\n position: absolute;\n inset-inline: 0;\n top: 50%;\n transform: translateY(-50%);\n /* No overflow:hidden — it would clip the fill's drop-shadow glow; the bar's\n * own clip-path already supplies the rounded reveal shape. */\n}\n/* The accent ramp paints the full track width once and is revealed by an\n * animated clip-path, so raising the effort unwraps more of the spectrum\n * instead of squashing the same gradient into a narrower bar. The glow lives\n * on the un-clipped parent: a filter on the clipped element itself would be\n * clipped away with it. */\n.dsh-model-menu-sliderFill {\n display: block;\n height: 100%;\n filter: drop-shadow(0 0 5px var(--dsw-alias-state-business-primary));\n transition: filter var(--ds-transition-duration) var(--ds-ease-in-out);\n}\n.dsh-model-menu-sliderInput:hover:not(:disabled) ~ .dsh-model-menu-sliderTrack .dsh-model-menu-sliderFill,\n.dsh-model-menu-sliderInput:active:not(:disabled) ~ .dsh-model-menu-sliderTrack .dsh-model-menu-sliderFill {\n filter: drop-shadow(0 0 9px var(--dsw-alias-state-business-primary));\n}\n/* The fill stops at the thumb's center, not at the track edge — at a 30px\n * thumb the end stops sit 15px in from each side, matching the node dots. */\n.dsh-model-menu-sliderFillBar {\n display: block;\n height: 100%;\n background: linear-gradient(90deg,\n var(--dsw-alias-state-business-primary),\n var(--dsw-alias-state-success-primary),\n var(--dsw-alias-state-warn-primary),\n var(--dsw-alias-state-error-primary));\n clip-path: inset(0 calc(100% - 15px - (100% - 30px) * var(--_p, 0) / 100) 0 0 round 999px);\n transition: clip-path var(--ds-transition-duration) var(--ds-ease-in-out);\n}\n/* Stop dots: one per declared row (default + every advertised effort), evenly\n * spread across the band between the two thumb-center extremes (inset 15px,\n * i.e. half the 30px thumb). --_n is 0-100 along that band. A covered dot\n * reads as a pale pin through the gradient; an uncovered one stays a neutral\n * notch on the empty track. */\n.dsh-model-menu-sliderNodes {\n pointer-events: none;\n display: block;\n position: absolute;\n inset-inline: 15px;\n inset-block: 0;\n}\n.dsh-model-menu-sliderNode {\n pointer-events: none;\n box-sizing: border-box;\n width: 4px;\n height: 4px;\n border-radius: 50%;\n background: color-mix(in srgb, var(--dsw-alias-label-secondary) 35%, transparent);\n position: absolute;\n left: calc(var(--_n, 0) * 1%);\n top: 50%;\n transform: translate(-50%, -50%);\n transition: background-color var(--ds-transition-duration) var(--ds-ease-in-out),\n transform var(--ds-transition-duration) var(--ds-ease-in-out);\n}\n.dsh-model-menu-sliderNode[data-covered] { background: color-mix(in srgb, var(--dsw-alias-label-primary) 60%, transparent); }\n.dsh-model-menu-sliderThumb {\n pointer-events: none;\n box-sizing: border-box;\n border-radius: 50%;\n width: 30px;\n height: 30px;\n background: var(--dsw-alias-button-primary-fill);\n border: 0.5px solid var(--dsw-alias-border-l4);\n box-shadow: 0 0 0 3px var(--dsw-alias-interactive-bg-hover), var(--dsw-elevation-soft);\n position: absolute;\n left: calc((100% - 30px) * var(--_p, 0) / 100);\n top: 50%;\n transform: translateY(-50%) scale(0.92);\n transition: left var(--ds-transition-duration) var(--ds-ease-in-out),\n transform var(--ds-transition-duration) var(--ds-ease-in-out),\n box-shadow var(--ds-transition-duration) var(--ds-ease-in-out);\n}\n.dsh-model-menu-sliderInput:hover:not(:disabled) ~ .dsh-model-menu-sliderThumb { transform: translateY(-50%) scale(1); }\n.dsh-model-menu-sliderInput:active:not(:disabled) ~ .dsh-model-menu-sliderThumb {\n transform: translateY(-50%) scale(1.1);\n box-shadow: 0 0 0 4px var(--dsw-alias-interactive-bg-hover), 0 0 12px var(--dsw-alias-state-business-primary);\n}\n.dsh-model-menu-sliderInput:focus-visible ~ .dsh-model-menu-sliderThumb {\n box-shadow: 0 0 0 3px var(--dsw-alias-interactive-bg-hover),\n 0 0 0 calc(3px + var(--dsw-focus-ring-width)) var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary));\n}\n@media (prefers-reduced-motion: reduce) {\n .dsh-model-menu-sliderFill, .dsh-model-menu-sliderFillBar, .dsh-model-menu-sliderThumb,\n .dsh-model-menu-sliderNode, .dsh-model-menu-sliderValue { transition: none; }\n}\n`\n","import { officialUiCss } from '@klarkxy/dsh-plugin-kit/official-ui'\nimport { modelMenuCss } from '@klarkxy/dsh-model-route/ui'\n\nexport const FREE_CHAT_ROOT = 'dsh-free-chat'\n\n/** Host tokens and official scaffolding. Only the edit draft, the inline action row,\n * and the alert line survive the panel removal; the modals reuse the root class. */\nexport const freeChatCss = `${officialUiCss(FREE_CHAT_ROOT)}\n${modelMenuCss}\n.${FREE_CHAT_ROOT} .dsh-free-draft {\n width: 100%;\n min-height: 8em;\n}\n.${FREE_CHAT_ROOT} .dsh-free-actions {\n display: inline-flex;\n align-items: center;\n gap: 8px;\n min-width: 0;\n}\n.${FREE_CHAT_ROOT} .dsh-free-alert { margin: 0; }\n.${FREE_CHAT_ROOT} .dsh-free-warning {\n margin: 0 0 12px;\n color: var(--dsw-alias-label-secondary);\n}\n.${FREE_CHAT_ROOT}.dsm-user-row {\n display: flex;\n flex-direction: column;\n align-items: flex-end;\n gap: 6px;\n}\n.${FREE_CHAT_ROOT} .dsm-user-stack {\n display: flex;\n flex-direction: column;\n align-items: flex-end;\n gap: 8px;\n min-width: 0;\n max-width: 82%;\n}\n.${FREE_CHAT_ROOT} .dsm-user-bubble {\n max-width: 100%;\n padding: 10px 16px;\n border-radius: var(--dsw-radius-md);\n background: var(--dsw-alias-bg-layer-3);\n color: var(--dsw-alias-label-primary);\n font-size: 14px;\n line-height: 22px;\n white-space: pre-wrap;\n word-break: break-word;\n}\n.${FREE_CHAT_ROOT} .dsm-user-chrome {\n display: flex;\n align-items: center;\n gap: 8px;\n min-height: 28px;\n color: var(--dsw-alias-label-tertiary);\n}\n.${FREE_CHAT_ROOT} .dsm-user-time {\n font-size: 13px;\n white-space: nowrap;\n}\n.${FREE_CHAT_ROOT} .dsm-icon-action {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n padding: 6px;\n border: none;\n border-radius: var(--dsw-radius-sm);\n background: transparent;\n color: var(--dsw-alias-label-tertiary);\n cursor: pointer;\n}\n.${FREE_CHAT_ROOT} .dsm-icon-action:hover:not(:disabled) {\n background: var(--dsw-alias-interactive-bg-hover);\n color: var(--dsw-alias-label-secondary);\n}\n.${FREE_CHAT_ROOT} .dsm-icon-action svg { width: 15px; height: 15px; }\n.${FREE_CHAT_ROOT} .dsm-user-attachments {\n display: flex;\n flex-wrap: wrap;\n justify-content: flex-end;\n max-width: 100%;\n gap: 8px;\n}\n.${FREE_CHAT_ROOT} .dsm-file-card {\n display: inline-flex;\n flex: 0 0 240px;\n align-items: center;\n gap: 10px;\n box-sizing: border-box;\n width: 240px;\n min-height: 64px;\n padding: 8px 12px;\n border: 0.5px solid var(--dsw-alias-border-l2);\n border-radius: var(--dsw-radius-md);\n background: var(--dsw-alias-bg-layer-3);\n}\n.${FREE_CHAT_ROOT} .dsm-file-icon { flex: none; width: 28px; height: 28px; }\n.${FREE_CHAT_ROOT} .dsm-file-content {\n display: flex;\n flex: 1;\n flex-direction: column;\n min-width: 0;\n}\n.${FREE_CHAT_ROOT} .dsm-file-name {\n overflow: hidden;\n color: var(--dsw-alias-label-primary);\n font-size: 14px;\n font-weight: 500;\n line-height: 22px;\n white-space: nowrap;\n text-overflow: ellipsis;\n}\n.${FREE_CHAT_ROOT} .dsm-file-meta {\n overflow: hidden;\n color: var(--dsw-alias-label-tertiary);\n font-size: 12px;\n line-height: 15px;\n white-space: nowrap;\n text-overflow: ellipsis;\n}\n.${FREE_CHAT_ROOT} .dsm-reference-summary {\n color: var(--dsw-alias-label-tertiary);\n font-size: 13px;\n line-height: 18px;\n}\n/* General-section item: a named details group mirroring the host's native\n * item rows (16px vertical padding, a 0.5px l2 rule the shell drops on the\n * last item, 24px label-control gutter). The body mounts on first expand and\n * stays mounted while collapsed, so a fold never drops an unsaved draft. */\n.${FREE_CHAT_ROOT}.dsm-item {\n padding: 0;\n border-bottom: 0.5px solid var(--dsw-alias-border-l2);\n}\n.${FREE_CHAT_ROOT} .dsm-item-summary {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 24px;\n padding: 16px 0;\n list-style: none;\n cursor: pointer;\n}\n.${FREE_CHAT_ROOT} .dsm-item-summary::-webkit-details-marker { display: none; }\n.${FREE_CHAT_ROOT} .dsm-item-summary > span:first-child { min-width: 0; }\n.${FREE_CHAT_ROOT} .dsm-item-title {\n display: block;\n font-size: 14px;\n line-height: 20px;\n color: var(--dsw-alias-label-primary);\n}\n.${FREE_CHAT_ROOT} .dsm-item-desc {\n display: block;\n margin-top: 4px;\n font-size: 12px;\n line-height: 18px;\n color: var(--dsw-alias-label-secondary);\n}\n.${FREE_CHAT_ROOT} .dsm-item-chevron {\n width: 14px;\n height: 14px;\n color: var(--dsw-alias-label-secondary);\n transition: transform 0.15s ease;\n}\n.${FREE_CHAT_ROOT}.dsm-item[open] > .dsm-item-summary .dsm-item-chevron { transform: rotate(180deg); }\n.${FREE_CHAT_ROOT} .dsm-item-body { padding: 0 0 16px; }\n/* Settings row bodies: each collapsible row edits its own keys and saves on\n * change, so the body is one flat reading surface — a feature block per\n * switch/section, dependent controls indented underneath. */\n.${FREE_CHAT_ROOT} .dsm-settings {\n display: flex;\n flex-direction: column;\n gap: 12px;\n min-width: 0;\n}\n.${FREE_CHAT_ROOT} .dsm-feature {\n display: flex;\n flex-direction: column;\n gap: 8px;\n min-width: 0;\n}\n.${FREE_CHAT_ROOT} .dsm-feature + .dsm-feature {\n margin-top: 4px;\n padding-top: 4px;\n border-top: 0.5px solid var(--dsw-alias-border-l2);\n}\n.${FREE_CHAT_ROOT} .dsm-feature > .dsh-ui-toggle-row { padding: 8px 0; }\n.${FREE_CHAT_ROOT} .dsm-feature-options {\n display: flex;\n flex-direction: column;\n gap: 8px;\n padding: 0 0 8px 24px;\n}\n.${FREE_CHAT_ROOT} .dsm-feature-options[data-disabled='true'] .dsh-ui-label,\n.${FREE_CHAT_ROOT} .dsm-feature-options[data-disabled='true'] .dsh-ui-meta {\n color: var(--dsw-alias-label-tertiary);\n}\n/* A feature's model picker: label on the left, the menu trigger on the right;\n * narrow widths wrap the trigger under the label. */\n.${FREE_CHAT_ROOT} .dsm-model-field {\n display: flex;\n flex-direction: column;\n gap: 4px;\n min-width: 0;\n}\n.${FREE_CHAT_ROOT} .dsm-model-choice .dsh-model-menu-trigger:disabled {\n color: var(--dsw-alias-label-tertiary);\n cursor: not-allowed;\n}\n.${FREE_CHAT_ROOT} .dsm-model-choice {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: space-between;\n gap: 4px 16px;\n}\n.${FREE_CHAT_ROOT} .dsm-model-choice > .dsh-ui-label {\n flex: 1 1 120px;\n min-width: 120px;\n}\n.${FREE_CHAT_ROOT} .dsm-model-choice .dsh-model-menu-root {\n flex: 1 1 200px;\n min-width: min(200px, 100%);\n max-width: 280px;\n}\n.${FREE_CHAT_ROOT} .dsm-model-choice .dsh-model-menu-trigger {\n display: flex;\n justify-content: space-between;\n width: 100%;\n height: 32px;\n padding: 0 10px;\n border: 0.5px solid var(--dsw-alias-border-l4);\n border-radius: var(--dsw-radius-md);\n background: var(--dsw-alias-bg-layer-3);\n color: var(--dsw-alias-label-primary);\n}\n.${FREE_CHAT_ROOT} .dsm-model-choice .dsh-model-menu-triggerLabel {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n text-align: left;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.${FREE_CHAT_ROOT} .dsm-minutes-control {\n display: flex;\n align-items: center;\n gap: 8px;\n}\n.${FREE_CHAT_ROOT} .dsm-minutes { width: 88px; }\n.${FREE_CHAT_ROOT} .dsm-text-input { max-width: 320px; }\n/* Welcome-back card: one flat full-width row at the latest turn's tail in the\n * chat flow — a single bordered surface with the recap laid out inline, no\n * nested box. */\n.${FREE_CHAT_ROOT}.dsh-welcome-card {\n box-sizing: border-box;\n width: 100%;\n margin: 8px 0 0;\n padding: 8px 12px;\n border: 0.5px solid var(--dsw-alias-border-l4);\n border-radius: var(--dsw-radius-md);\n background: var(--dsw-alias-bg-layer-3);\n}\n.${FREE_CHAT_ROOT} .dsh-welcome-card-head {\n display: flex;\n align-items: baseline;\n gap: 8px;\n margin: 0 0 4px;\n}\n.${FREE_CHAT_ROOT} .dsh-welcome-card-title { font-weight: 600; }\n.${FREE_CHAT_ROOT} .dsh-welcome-card-idle {\n flex: 1;\n min-width: 0;\n color: var(--dsw-alias-label-secondary);\n font-size: 12px;\n}\n.${FREE_CHAT_ROOT} .dsh-welcome-card-close {\n align-self: flex-start;\n margin-left: auto;\n}\n.${FREE_CHAT_ROOT} .dsh-welcome-card-actions {\n display: flex;\n justify-content: flex-start;\n flex-wrap: wrap;\n gap: 8px;\n margin: 8px 0 0;\n}\n.${FREE_CHAT_ROOT} .dsh-welcome-recap {\n margin: 0;\n padding: 0;\n border: none;\n}\n.${FREE_CHAT_ROOT} .dsh-welcome-recap dt {\n margin: 6px 0 0;\n font-size: 12px;\n color: var(--dsw-alias-label-tertiary);\n}\n.${FREE_CHAT_ROOT} .dsh-welcome-recap dt:first-child { margin-top: 0; }\n.${FREE_CHAT_ROOT} .dsh-welcome-recap dd {\n margin: 0;\n white-space: pre-wrap;\n word-break: break-word;\n}\n.${FREE_CHAT_ROOT} .dsh-welcome-cache {\n margin: 6px 0 0;\n color: var(--dsw-alias-label-secondary);\n}\n.${FREE_CHAT_ROOT} .dsh-welcome-done { margin: 6px 0 0; }\n\n/* Hero-row Auto-continue chip: icon + mode label, tinted while a mode is on. */\n.${FREE_CHAT_ROOT}.smac-option {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n}\n.${FREE_CHAT_ROOT} .smac-chip {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n height: 28px;\n padding: 0 10px;\n border-radius: 999px;\n font-size: 13px;\n line-height: 20px;\n border: 1px solid var(--dsw-alias-border-l3);\n background: transparent;\n color: var(--dsw-alias-label-secondary);\n cursor: pointer;\n}\n.${FREE_CHAT_ROOT} .smac-chip svg { width: 16px; height: 16px; }\n.${FREE_CHAT_ROOT} .smac-chip .smac-chevron { width: 12px; height: 12px; }\n.${FREE_CHAT_ROOT} .smac-chip:hover:not(:disabled) {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n.${FREE_CHAT_ROOT} .smac-chip.smac-chip-on {\n background: var(--dsw-alias-button-primary-fill);\n border-color: var(--dsw-alias-button-primary-fill);\n color: var(--dsw-alias-label-primary-foreground);\n}\n.${FREE_CHAT_ROOT} .smac-chip.smac-chip-on:hover:not(:disabled) {\n background: var(--dsw-alias-button-primary-hover);\n border-color: var(--dsw-alias-button-primary-hover);\n}\n.${FREE_CHAT_ROOT} .smac-chip:disabled {\n opacity: 0.5;\n cursor: default;\n}\n.${FREE_CHAT_ROOT} .smac-note {\n font-size: 12px;\n line-height: 18px;\n color: var(--dsw-alias-label-tertiary);\n}\n\n.${FREE_CHAT_ROOT} .dsm-user-original { display: contents; }\n.${FREE_CHAT_ROOT} .dsm-user-original[hidden] { display: none; }\n.${FREE_CHAT_ROOT} .dsm-message-edit { width: min(100%, 720px); align-self: flex-end; }\n.${FREE_CHAT_ROOT} .dsm-message-editor { width: 100%; box-sizing: border-box; padding: 14px; border-radius: 18px; background: var(--dsw-alias-bg-layer-3); }\n.${FREE_CHAT_ROOT} .dsm-message-editor .dsh-free-draft { width: 100%; min-height: 80px; max-height: 360px; resize: vertical; border: none; background: transparent; box-shadow: none; padding: 4px; box-sizing: border-box; }\n.${FREE_CHAT_ROOT} .dsm-edit-footer { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }\n.${FREE_CHAT_ROOT} .dsm-edit-spacer { flex: 1; }\n.${FREE_CHAT_ROOT} .dsm-edit-attachments { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }\n.${FREE_CHAT_ROOT} .dsm-edit-attachment { display: flex; align-items: center; gap: 6px; border: 1px solid var(--dsw-alias-border-l2); border-radius: 10px; padding: 6px; max-width: 100%; }\n.${FREE_CHAT_ROOT} .dsm-edit-attachment img { width: 72px; height: 60px; object-fit: contain; border-radius: 6px; }\n.${FREE_CHAT_ROOT} .dsm-edit-attachment > span { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.${FREE_CHAT_ROOT} .dsm-edit-attachment > svg { width: 24px; height: 24px; }\n.${FREE_CHAT_ROOT} .dsm-edit-image { position: relative; padding: 0; border: none; }\n.${FREE_CHAT_ROOT} .dsm-edit-image img { width: auto; height: auto; max-width: 220px; max-height: 140px; object-fit: contain; border-radius: 10px; }\n.${FREE_CHAT_ROOT} .dsm-edit-image > button { position: absolute; top: 4px; right: 4px; border-radius: 50%; background: var(--dsw-alias-bg-layer-3); width: 24px; height: 24px; padding: 0; }\n`\n","import { useEffect, useRef, useSyncExternalStore } from 'react'\nimport { Button, Modal } from '@deepseek-ai/dsh-client-ui-primitives'\nimport type { FreeChatModel } from './session-actions.ts'\nimport { FREE_CHAT_ROOT } from './styles.ts'\nimport { deleteBody, failureText, uiText, type CopyLocale } from './ui-copy.ts'\n\n/** Create failures used to surface inside the standalone panel. The panel is gone,\n * so they get a small overlay instead; closing it dismisses the stored notice. */\nexport function CreateNoticeDialog(props: { model: FreeChatModel; locale: CopyLocale }): React.ReactElement | null {\n const snapshot = useSyncExternalStore(props.model.subscribe, props.model.getSnapshot, props.model.getSnapshot)\n const notice = snapshot.notice\n if (notice === undefined) return null\n const copy = (key: Parameters<typeof uiText>[1]) => uiText(props.locale, key)\n return (\n <Modal\n open\n className={FREE_CHAT_ROOT}\n title={copy('createFailed')}\n closeLabel={copy('close')}\n onClose={() => { props.model.dismissNotice() }}\n footer={(\n <Button variant=\"primary\" data-modal-autofocus onClick={() => { props.model.dismissNotice() }}>\n {copy('close')}\n </Button>\n )}\n >\n <p className=\"dsh-ui-error dsh-free-alert\" role=\"alert\">{failureText(props.locale, notice)}</p>\n </Modal>\n )\n}\n\nexport function DeleteChatDialog(props: { model: FreeChatModel; locale: CopyLocale }): React.ReactElement | null {\n const snapshot = useSyncExternalStore(props.model.subscribe, props.model.getSnapshot, props.model.getSnapshot)\n const request = snapshot.deleteRequest\n const confirmRef = useRef<HTMLButtonElement>(null)\n useEffect(() => {\n if (request?.failure) confirmRef.current?.focus()\n }, [request?.failure])\n if (request === undefined) return null\n const copy = (key: Parameters<typeof uiText>[1]) => uiText(props.locale, key)\n const label = request.busy ? copy('deleting') : request.failure ? copy('retryList') : copy('deleteChat')\n return (\n <Modal\n open\n className={FREE_CHAT_ROOT}\n title={copy('deleteChat')}\n closeLabel={copy('close')}\n description={deleteBody(props.locale, request.classification)}\n onClose={() => { props.model.cancelDelete() }}\n footer={(\n <>\n <Button variant=\"ghost\" data-modal-autofocus disabled={request.busy} onClick={() => { props.model.cancelDelete() }}>{copy('cancel')}</Button>\n <Button\n ref={confirmRef}\n variant=\"primary\"\n disabled={request.busy}\n onClick={() => { void props.model.confirmDelete() }}\n >\n {label}\n </Button>\n </>\n )}\n >\n <p>{request.title}</p>\n {request.failure ? <p className=\"dsh-ui-error dsh-free-alert\" role=\"alert\">{failureText(props.locale, request.failure)}</p> : null}\n </Modal>\n )\n}\n","import { useCallback, useEffect, useRef, useState, useSyncExternalStore, type ReactNode, type RefObject } from 'react'\nimport { Button, IconFolderCloseRegular, IconNewChatOutlineRegular, IconPlusOutlineRegular, Menu, Modal } from '@deepseek-ai/dsh-client-ui-primitives'\nimport type { StoredEntry } from '@deepseek-ai/dsh-client-ui-slots'\nimport type { DirectoryFlowOwnerProps, WorkspacePickerProps } from '@deepseek-ai/dsh-client-ui-workspace/client'\nimport { TEMP_WORKSPACE_FLOW_SLOT } from './contracts.ts'\nimport { FREE_CHAT_ROOT } from './styles.ts'\nimport { copyLocale, uiText, type CopyLocale } from './ui-copy.ts'\nimport type { TemporaryWorkspaceModel } from './temporary-workspace.ts'\n\nconst PICKER_SLOT = 'conversation.hero.workspace'\nconst DIRECTORY_SLOT = 'conversation.hero.workspace.directoryFlow'\n\n/** Public registry faces used by the version-bounded directory-flow compatibility adapter. */\nexport interface PickerRegistry {\n inject(key: string, callback: () => (() => void) | void): () => void\n register(options: Record<string, unknown>, component: unknown): () => void\n entriesOfSlot(key: string): readonly StoredEntry[]\n spec(key: string): { kind: string; scope: string } | undefined\n subscribe(key: string, listener: () => void): () => void\n onEntryError?(listener: (key: string, entry: StoredEntry, error: unknown) => void): () => void\n}\n\n/** Keep the host's native/web picker implementation and its injected capabilities.\n * Standard rc.2 offers no exported directory-flow factory. Only its simple root\n * registration can be mirrored; more complex future registrations restore the host picker.\n * Original entries and their ownership ledger are never changed.\n */\nexport function installTemporaryWorkspacePicker(slots: PickerRegistry, model: TemporaryWorkspaceModel,\n createWorkspace: (path: string) => Promise<{ workspaceId: string }>, locale?: {\n getSnapshot(): { active: string }; subscribe(listener: () => void): () => void\n }): () => void {\n if (typeof slots.entriesOfSlot !== 'function' || typeof slots.spec !== 'function' || typeof slots.subscribe !== 'function') {\n model.reportFailure(copyLocale(locale?.getSnapshot().active) === 'zh'\n ? '当前版本无法扩展工作区菜单,已保留原菜单。' : 'Could not extend the workspace menu. The original menu has been preserved.')\n return () => {}\n }\n return slots.inject(PICKER_SLOT, () => {\n let mirror: StoredEntry | undefined, stopMirror = () => {}, restored = false\n const failureMessage = () => copyLocale(locale?.getSnapshot().active) === 'zh'\n ? '当前版本无法扩展工作区菜单,已保留原菜单。' : 'Could not extend the workspace menu. The original menu has been preserved.'\n const renderPicker = (props: PickerProps) => <TemporaryWorkspacePicker {...props} model={model} createWorkspace={createWorkspace} locale={locale}\n getDirectoryFlow={() => mirror} subscribeFlow={listener => slots.subscribe(DIRECTORY_SLOT, listener)} />\n const stopPicker = slots.register({ name: PICKER_SLOT, priority: -10, locale: 'workspace',\n children: { [TEMP_WORKSPACE_FLOW_SLOT]: { kind: 'single', scope: 'root' } },\n }, renderPicker)\n const stopErrors = slots.onEntryError?.((key, entry) => {\n if (restored || (key !== TEMP_WORKSPACE_FLOW_SLOT && !(key === PICKER_SLOT && entry.component === renderPicker))) return\n restored = true; stopMirror(); mirror = undefined; stopPicker()\n model.reportFailure(failureMessage())\n }) ?? (() => {})\n const sync = () => {\n if (restored) return\n const next = slots.entriesOfSlot(DIRECTORY_SLOT)[0]\n if (next === mirror) return\n stopMirror(); stopMirror = () => {}; mirror = undefined\n if (next === undefined) return\n const spec = slots.spec(DIRECTORY_SLOT)\n if (spec?.kind !== 'single' || spec.scope !== 'root' || typeof next.component !== 'function'\n || next.children !== undefined || next.store !== undefined || next.locale !== undefined || next.select !== undefined) {\n restored = true; stopPicker()\n model.reportFailure(failureMessage())\n return\n }\n try {\n stopMirror = slots.register({ name: TEMP_WORKSPACE_FLOW_SLOT, ...next.inject ? { inject: next.inject } : {} }, next.component)\n mirror = next\n } catch (error) {\n restored = true; stopPicker()\n model.reportFailure(error instanceof Error ? error.message : 'Could not extend the workspace picker')\n }\n }\n const stopSource = slots.subscribe(DIRECTORY_SLOT, sync)\n sync()\n return () => { restored = true; stopErrors(); stopSource(); stopMirror(); stopPicker() }\n })\n}\n\n/** Standard conversation hero owner share; some published type graphs omit its merge. */\ntype PickerProps = Pick<WorkspacePickerProps, 'useWorkspaces'> & {\n open: boolean\n anchorRef?: RefObject<HTMLElement | null>\n selectedId?: string\n onPick(workspaceId: string): void\n onClose(): void\n t(key: string): string\n renderSlot(key: typeof TEMP_WORKSPACE_FLOW_SLOT, owner: DirectoryFlowOwnerProps): ReactNode\n}\n\nfunction TemporaryWorkspacePicker(props: PickerProps & {\n model: TemporaryWorkspaceModel; createWorkspace(path: string): Promise<{ workspaceId: string }>\n getDirectoryFlow(): StoredEntry | undefined; subscribeFlow(listener: () => void): () => void\n locale?: { getSnapshot(): { active: string }; subscribe(listener: () => void): () => void }\n}) {\n const workspaces = props.useWorkspaces(snapshot => snapshot)\n const state = useSyncExternalStore(props.model.subscribe, props.model.getSnapshot, props.model.getSnapshot)\n const source = useSyncExternalStore(props.subscribeFlow, props.getDirectoryFlow, props.getDirectoryFlow)\n const available = source !== undefined\n const locale = copyLocale(useSyncExternalStore(listener => props.locale?.subscribe(listener) ?? (() => {}),\n () => props.locale?.getSnapshot().active ?? 'en', () => 'en'))\n const [flowOpen, setFlowOpen] = useState(false), [adopting, setAdopting] = useState(false)\n const [failure, setFailure] = useState<string>()\n const epoch = useRef(0)\n useEffect(() => () => { epoch.current++ }, [])\n useEffect(() => { epoch.current++; setFlowOpen(false); setAdopting(false) }, [source])\n const busy = flowOpen || adopting || state.creating\n const getAnchorRect = useCallback(() => props.anchorRef?.current?.getBoundingClientRect() ?? null, [props.anchorRef])\n const openDirectory = () => { props.onClose(); setFailure(undefined); setFlowOpen(true) }\n return <>\n <Menu open={props.open} anchor={null} portal getAnchorRect={getAnchorRect} selectedId={props.selectedId}\n onClose={props.onClose} items={workspaces.items.map(workspace => ({ id: workspace.workspaceId,\n // The standard registry's first-use title is language-neutral; all user titles stay verbatim.\n label: workspace.title === 'default-workspace' ? props.t('workspace.defaultName') : workspace.title,\n icon: <IconFolderCloseRegular size={16} />, disabled: busy }))}\n footer={[\n ...available ? [{ id: '::add-workspace', label: props.t('menu.addWorkspace'), icon: <IconPlusOutlineRegular size={16} />, disabled: busy }] : [],\n { id: '::temporary-workspace', label: uiText(locale, 'tempWorkspace'), icon: <IconNewChatOutlineRegular size={16} />, disabled: busy },\n ]}\n onSelect={id => {\n if (id === '::add-workspace') openDirectory()\n else if (id === '::temporary-workspace') { props.onClose(); void props.model.create() }\n else props.onPick(id as never)\n }} />\n {/* The picker renders straight into the host's conversation.hero.workspace\n * slot with no plugin-rooted ancestor, so the loading line carries the root\n * class itself for the dsh-ui-loading recipe to reach it. */}\n {props.open && workspaces.phase === 'pending' && <span role=\"status\" className={`${FREE_CHAT_ROOT} dsh-ui-loading`}>{props.t('picker.loading')}</span>}\n {props.renderSlot(TEMP_WORKSPACE_FLOW_SLOT, {\n open: flowOpen, busy: adopting,\n onCancel: () => { epoch.current++; setFlowOpen(false); setAdopting(false) },\n onError: message => { epoch.current++; setFlowOpen(false); setAdopting(false); setFailure(message) },\n onPicked: path => {\n if (adopting) return\n const ticket = ++epoch.current\n setAdopting(true)\n void props.createWorkspace(path).then(workspace => {\n if (ticket !== epoch.current) return\n setFlowOpen(false); props.onPick(workspace.workspaceId as never)\n }, error => {\n if (ticket !== epoch.current) return\n setFlowOpen(false); setFailure(error instanceof Error ? error.message : String(error))\n }).finally(() => { if (ticket === epoch.current) setAdopting(false) })\n },\n })}\n <Modal open={failure !== undefined} className={FREE_CHAT_ROOT} title={props.t('folderError.title')} closeLabel={props.t('close')}\n onClose={() => setFailure(undefined)} footer={<>\n <Button variant=\"outline\" onClick={() => setFailure(undefined)}>{props.t('cancel')}</Button>\n <Button variant=\"primary\" disabled={!available} onClick={openDirectory}>{props.t('folderError.retry')}</Button>\n </>}><p role=\"alert\">{failure}</p></Modal>\n </>\n}\n\nexport function TemporaryWorkspaceNotice({ model, locale }: { model: TemporaryWorkspaceModel; locale: CopyLocale }) {\n const state = useSyncExternalStore(model.subscribe, model.getSnapshot, model.getSnapshot)\n return <Modal open={state.failure !== undefined} className={FREE_CHAT_ROOT} title={uiText(locale, 'createFailed')}\n closeLabel={uiText(locale, 'close')} onClose={model.dismissFailure} footer={<>\n <Button variant=\"outline\" onClick={model.dismissFailure}>{uiText(locale, 'close')}</Button>\n <Button variant=\"primary\" disabled={state.creating} onClick={() => { void model.create() }}>{uiText(locale, 'retry')}</Button>\n </>}><p role=\"alert\">{state.failure}</p></Modal>\n}\n","import { TEMP_WORKSPACE_CHANNEL } from './contracts.ts'\n\nexport interface TemporaryWorkspaceHost {\n beginNavigation(): AbortSignal\n allocate(requestId: string, signal: AbortSignal): Promise<{ requestId: string; path: string }>\n createWorkspace(path: string): Promise<{ workspaceId: string }>\n renameWorkspace(workspaceId: string, title: string): Promise<unknown>\n openWorkspace(workspaceId: string, beforeOpen: () => void): Promise<void>\n}\n\nexport interface TemporaryWorkspaceSnapshot {\n readonly creating: boolean\n readonly failure?: string\n}\n\nexport function createTemporaryWorkspaceModel(host: TemporaryWorkspaceHost, ids = () => crypto.randomUUID(), label = () => 'Temporary Workspace') {\n const lifetime = new AbortController(), listeners = new Set<() => void>()\n let snapshot: TemporaryWorkspaceSnapshot = { creating: false }\n let pending: { requestId: string; title: string; path?: string; workspaceId?: string; named?: boolean } | undefined\n const publish = (next: TemporaryWorkspaceSnapshot) => {\n if (lifetime.signal.aborted) return\n snapshot = next\n for (const listener of listeners) listener()\n }\n return {\n getSnapshot: () => snapshot,\n subscribe(listener: () => void) { listeners.add(listener); return () => { listeners.delete(listener) } },\n dismissFailure() { publish({ creating: snapshot.creating }) },\n reportFailure(failure: string) { publish({ ...snapshot, failure }) },\n async create() {\n if (snapshot.creating || lifetime.signal.aborted) return\n // Capture before allocation/adoption so late completion cannot steal a newer navigation.\n const signal = AbortSignal.any([host.beginNavigation(), lifetime.signal])\n const action = pending ??= { requestId: ids(), title: label() }\n let opening = false\n publish({ creating: true })\n try {\n signal.throwIfAborted()\n if (action.path === undefined) {\n const allocated = await host.allocate(action.requestId, signal)\n if (allocated.requestId !== action.requestId || !allocated.path) throw new Error('Invalid temporary workspace response')\n action.path = allocated.path\n }\n signal.throwIfAborted()\n if (action.workspaceId === undefined) action.workspaceId = (await host.createWorkspace(action.path)).workspaceId\n signal.throwIfAborted()\n if (!action.named) {\n await host.renameWorkspace(action.workspaceId, `${action.title} ${action.requestId.slice(0, 8)}`)\n action.named = true\n }\n signal.throwIfAborted()\n opening = true\n await host.openWorkspace(action.workspaceId, () => lifetime.signal.throwIfAborted())\n // openWorkspace starts its own fenced navigation, invalidating our earlier signal.\n if (!lifetime.signal.aborted) pending = undefined\n } catch (error) {\n if (!lifetime.signal.aborted && (opening ? !(error instanceof Error && error.name === 'AbortError') : !signal.aborted)) {\n publish({ creating: false, failure: error instanceof Error ? error.message : 'Could not create the temporary workspace' })\n }\n } finally {\n publish({ ...snapshot, creating: false })\n }\n },\n cancel() { lifetime.abort(); listeners.clear() },\n }\n}\n\nexport type TemporaryWorkspaceModel = ReturnType<typeof createTemporaryWorkspaceModel>\n\nexport function bindTemporaryWorkspaceHost(ctx: {\n layout: { beginNavigation(): AbortSignal }\n connection: { rpc: { call(channel: string, endpoint: string, payload: unknown, signal?: AbortSignal): Promise<unknown> } }\n workspaces: { create(input: { path: string }): Promise<{ workspaceId: string }>; rename(workspaceId: string, title: string): Promise<unknown> }\n uiWorkspace: { openWorkspace(workspaceId: string, beforeOpen?: () => void): Promise<void> }\n}): TemporaryWorkspaceHost {\n return {\n beginNavigation: () => ctx.layout.beginNavigation(),\n async allocate(requestId, signal) {\n const raw = await ctx.connection.rpc.call(TEMP_WORKSPACE_CHANNEL, 'temporary.allocate', { requestId }, signal)\n const response = raw as { ok?: boolean; value?: { requestId: string; path: string }; error?: { message?: string } }\n if (response?.ok !== true || typeof response.value?.path !== 'string' || typeof response.value.requestId !== 'string') {\n throw new Error(response?.error?.message ?? 'Could not allocate the temporary workspace')\n }\n return response.value\n },\n createWorkspace: path => ctx.workspaces.create({ path }),\n renameWorkspace: (workspaceId, title) => ctx.workspaces.rename(workspaceId, title),\n openWorkspace: (workspaceId, beforeOpen) => ctx.uiWorkspace.openWorkspace(workspaceId, beforeOpen),\n }\n}\n","/**\n * Narrow client faces the host owner still has to publish.\n * Call these only when the live service actually has the method.\n * Do not call the session remote directly: manager.create still drops `kind`,\n * and delete/retry have to update the catalog and the open selection.\n */\nimport type { OperationFailure } from './ui-copy.ts'\nimport type { SessionListSnapshot } from './free-list.ts'\nimport type { PromptContent } from './edit-host.ts'\n\nexport interface SessionCapabilities {\n readonly retry: boolean\n /** Whether retry accepts explicit confirmation of later modifications. */\n readonly retryModified: boolean\n readonly retryContent?: boolean\n readonly freeSession: boolean\n readonly deleteSession: boolean\n}\n\nexport const UNSUPPORTED_CAPABILITIES: SessionCapabilities = {\n retry: false,\n retryModified: false,\n freeSession: false,\n deleteSession: false,\n}\n\n/**\n * `inputRevision` is an opaque token from preview.\n * An eligible preview without it is not a supported retry.\n */\nexport interface RetryPreview {\n readonly branchRevision: number\n readonly inputRevision: string\n readonly eligible: boolean\n readonly reason?: string\n}\n\n/** Base request shape of the host's retry API; an edit adds `text` or `content`. */\nexport interface DirectRetryRequest {\n readonly sessionId: string\n readonly messageId: string\n readonly expectedRevision: number\n readonly expectedInputRevision: string\n readonly requestId: string\n /** Explicit user confirmation keeps later file and external changes intact. */\n readonly allowModified?: boolean\n}\n\n/** Edit sends plain text only. The host keeps attachments. */\nexport interface EditRetryRequest extends DirectRetryRequest {\n readonly text?: string\n readonly content?: readonly PromptContent[]\n}\n\nexport interface DeleteOutcome {\n readonly phase: 'deleted' | 'cleanup-pending'\n}\n\nexport interface ObservableList {\n getSnapshot(): SessionListSnapshot\n subscribe(listener: () => void): () => void\n}\n\nexport interface SessionHost {\n readonly list: ObservableList\n capabilities?: () => Promise<unknown> | unknown\n create?: (opts: { kind: 'free' }) => Promise<unknown>\n previewRetry?: (request: { sessionId: string; messageId: string }) => Promise<unknown>\n retry?: (request: DirectRetryRequest | EditRetryRequest) => Promise<unknown>\n openSession?: (sessionId: string) => void\n deleteSession?: (sessionId: string, requestId: string) => Promise<unknown>\n}\n\ninterface RemoteFailure {\n readonly code?: string\n readonly message?: string\n readonly details?: { readonly reason?: string }\n}\n\ninterface RemoteResult {\n readonly ok: boolean\n readonly value?: unknown\n readonly error?: RemoteFailure\n}\n\nexport function isRecoverable(failure: OperationFailure): boolean {\n return failure.code === 'transport' || failure.code === 'session/delete-pending'\n || failure.code === 'session/retry-pending' || failure.code === 'session/retry-uncertain'\n}\n\nexport function isStaleRetryFailure(failure: OperationFailure | undefined): boolean {\n return failure?.code === 'session/retry-revision'\n || failure?.code === 'session/branch-moved'\n || failure?.code === 'session/retry-input'\n || failure?.code === 'session/retry-conflict'\n}\n\nexport function readFailure(error: unknown): OperationFailure {\n if (isFailure(error)) return { code: error.code, ...error.reason === undefined ? {} : { reason: error.reason } }\n if (typeof error === 'object' && error !== null) {\n const record = error as { code?: unknown; reason?: unknown; message?: unknown; rpcError?: RemoteFailure }\n const rpc = record.rpcError\n if (typeof rpc?.code === 'string') {\n return { code: rpc.code, ...reasonOf(rpc) === undefined ? {} : { reason: reasonOf(rpc) } }\n }\n if (typeof record.code === 'string') {\n const reason = typeof record.reason === 'string' ? record.reason : undefined\n return { code: record.code, ...reason === undefined ? {} : { reason } }\n }\n }\n return { code: 'transport', reason: 'unknown' }\n}\n\nfunction isFailure(error: unknown): error is OperationFailure {\n return typeof error === 'object' && error !== null && 'code' in error && typeof (error as { code: unknown }).code === 'string'\n && (error as { name?: string }).name === 'HostOperationError'\n}\n\nexport class HostOperationError extends Error implements OperationFailure {\n override readonly name = 'HostOperationError'\n readonly reason?: string\n constructor(readonly code: string, reason?: string) {\n super(code)\n if (reason !== undefined) this.reason = reason\n }\n}\n\nfunction reasonOf(error: RemoteFailure | undefined): string | undefined {\n return typeof error?.details?.reason === 'string' ? error.details.reason : undefined\n}\n\nfunction isRemoteResult(value: unknown): value is RemoteResult {\n if (typeof value !== 'object' || value === null || !('ok' in value)) return false\n const ok = (value as { ok: unknown }).ok\n return typeof ok === 'boolean' && ('value' in value || 'error' in value)\n}\n\nexport async function unwrap(value: unknown): Promise<unknown> {\n const resolved = await value\n if (!isRemoteResult(resolved)) return resolved\n if (!resolved.ok) {\n throw new HostOperationError(resolved.error?.code ?? 'transport', reasonOf(resolved.error))\n }\n return resolved.value\n}\n\nexport async function readCapabilities(host: SessionHost): Promise<SessionCapabilities> {\n if (typeof host.capabilities !== 'function') return UNSUPPORTED_CAPABILITIES\n try {\n const value = await unwrap(host.capabilities())\n if (typeof value !== 'object' || value === null) return UNSUPPORTED_CAPABILITIES\n const record = value as Partial<SessionCapabilities>\n return {\n retry: record.retry === true,\n retryModified: record.retryModified === true,\n ...record.retryContent === true ? { retryContent: true } : {},\n freeSession: record.freeSession === true,\n deleteSession: record.deleteSession === true,\n }\n } catch {\n return UNSUPPORTED_CAPABILITIES\n }\n}\n\nexport function controlsFor(capabilities: SessionCapabilities, ready: boolean, host: SessionHost): {\n create: boolean\n delete: boolean\n retry: boolean\n} {\n return {\n create: ready && capabilities.freeSession && typeof host.create === 'function',\n delete: ready && capabilities.deleteSession && typeof host.deleteSession === 'function',\n retry: ready && capabilities.retry && typeof host.previewRetry === 'function' && typeof host.retry === 'function',\n }\n}\n\nfunction sessionIdOf(value: unknown): string {\n if (typeof value === 'string' && value !== '') return value\n if (typeof value === 'object' && value !== null && typeof (value as { sessionId?: unknown }).sessionId === 'string') {\n return (value as { sessionId: string }).sessionId\n }\n throw new HostOperationError('session/lifecycle-unavailable')\n}\n\n/** Pass only `{ kind: 'free' }`. A cwd or workspace is rejected by free create, and must not be invented. */\nexport async function createFreeSession(host: SessionHost): Promise<string> {\n if (typeof host.create !== 'function') throw new HostOperationError('session/lifecycle-unavailable')\n return sessionIdOf(await unwrap(host.create({ kind: 'free' })))\n}\n\nexport async function deleteOwnedSession(host: SessionHost, sessionId: string, requestId: string): Promise<DeleteOutcome> {\n if (typeof host.deleteSession !== 'function') throw new HostOperationError('session/lifecycle-unavailable')\n const value = await unwrap(host.deleteSession(sessionId, requestId))\n if (typeof value !== 'object' || value === null) throw new HostOperationError('session/delete-pending', 'missing-outcome')\n const phase = (value as { phase?: unknown }).phase\n if (phase !== 'deleted' && phase !== 'cleanup-pending') {\n throw new HostOperationError('session/delete-pending', 'missing-outcome')\n }\n return { phase }\n}\n\n/** Build the body for one edited prompt; the host keeps the original attachments when only text changes. */\nexport function editRetryRequest(input: {\n sessionId: string\n messageId: string\n expectedRevision: number\n expectedInputRevision: string\n requestId: string\n text: string\n content?: readonly PromptContent[]\n allowModified?: boolean\n}): EditRetryRequest {\n return {\n sessionId: input.sessionId,\n messageId: input.messageId,\n expectedRevision: input.expectedRevision,\n expectedInputRevision: input.expectedInputRevision,\n requestId: input.requestId,\n ...input.content === undefined ? { text: input.text } : { content: input.content },\n ...input.allowModified === true ? { allowModified: true } : {},\n }\n}\n\nexport class SubmissionLedger {\n private active = false\n private unresolved: EditRetryRequest | undefined\n\n get busy(): boolean {\n return this.active\n }\n\n pending(): EditRetryRequest | undefined {\n return this.unresolved\n }\n\n /** Resend the stored body. A non-recoverable result drops it; a lost reply keeps it. */\n async replay(execute: (body: EditRetryRequest) => Promise<unknown>): Promise<void> {\n const body = this.unresolved\n if (body === undefined) return\n if (this.active) throw new HostOperationError('busy', 'running')\n this.active = true\n try {\n await execute(body)\n this.unresolved = undefined\n } catch (error) {\n const failure = readFailure(error)\n if (!isRecoverable(failure) && failure.reason !== 'aborted') this.unresolved = undefined\n throw error instanceof HostOperationError ? error : new HostOperationError(failure.code, failure.reason)\n } finally {\n this.active = false\n }\n }\n\n /** First submission of a body built from the current preview. */\n async submit(body: EditRetryRequest, execute: () => Promise<unknown>): Promise<void> {\n if (this.active || this.unresolved !== undefined) throw new HostOperationError('busy', 'running')\n this.active = true\n try {\n await execute()\n this.unresolved = undefined\n } catch (error) {\n const failure = readFailure(error)\n this.unresolved = isRecoverable(failure) ? body : undefined\n throw error instanceof HostOperationError ? error : new HostOperationError(failure.code, failure.reason)\n } finally {\n this.active = false\n }\n }\n}\n\ninterface Listener {\n (): void\n}\n\nfunction store() {\n const listeners = new Set<Listener>()\n return {\n subscribe(listener: Listener): () => void {\n listeners.add(listener)\n return () => { listeners.delete(listener) }\n },\n emit(): void {\n for (const listener of listeners) listener()\n },\n }\n}\n\nexport interface DeleteRequestState {\n readonly sessionId: string\n readonly title: string\n readonly classification: 'free' | 'ordinary'\n readonly requestId: string\n readonly busy: boolean\n readonly failure?: OperationFailure\n}\n\nexport interface FreeChatSnapshot {\n readonly controls: ReturnType<typeof controlsFor>\n readonly capabilitiesReady: boolean\n readonly creating: boolean\n readonly notice?: OperationFailure\n readonly deleteRequest?: DeleteRequestState\n}\n\nexport interface FreeChatModel {\n subscribe(listener: Listener): () => void\n getSnapshot(): FreeChatSnapshot\n reloadCapabilities(): Promise<void>\n create(): Promise<void>\n dismissNotice(): void\n requestDelete(sessionId: string): void\n cancelDelete(): void\n confirmDelete(): Promise<void>\n cancel(): void\n}\n\nexport function createFreeChatModel(host: SessionHost, ids: () => string = () => crypto.randomUUID()): FreeChatModel {\n const events = store()\n let capabilities = UNSUPPORTED_CAPABILITIES\n let capabilitiesReady = false\n let creating = false\n let notice: OperationFailure | undefined\n let deleteRequest: DeleteRequestState | undefined\n let generation = 0\n let snapshot: FreeChatSnapshot = build()\n\n function build(): FreeChatSnapshot {\n return {\n controls: controlsFor(capabilities, capabilitiesReady, host),\n capabilitiesReady,\n creating,\n ...notice === undefined ? {} : { notice },\n ...deleteRequest === undefined ? {} : { deleteRequest },\n }\n }\n\n function publish(): void {\n snapshot = build()\n events.emit()\n }\n\n return {\n subscribe: events.subscribe,\n getSnapshot: () => snapshot,\n async reloadCapabilities() {\n capabilities = await readCapabilities(host)\n capabilitiesReady = true\n publish()\n },\n async create() {\n if (!controlsFor(capabilities, capabilitiesReady, host).create || creating) return\n const ticket = generation\n creating = true\n notice = undefined\n publish()\n try {\n const id = await createFreeSession(host)\n if (ticket !== generation) return\n if (typeof host.openSession !== 'function') throw new HostOperationError('session/lifecycle-unavailable', 'open-session')\n host.openSession(id)\n } catch (error) {\n if (ticket !== generation) return\n notice = readFailure(error)\n } finally {\n if (ticket === generation) {\n creating = false\n publish()\n }\n }\n },\n dismissNotice() {\n if (notice === undefined) return\n notice = undefined\n publish()\n },\n requestDelete(sessionId) {\n if (!controlsFor(capabilities, capabilitiesReady, host).delete) return\n const row = host.list.getSnapshot().byId[sessionId]\n deleteRequest = {\n sessionId,\n title: row?.displayTitle ?? row?.title ?? sessionId,\n classification: row?.classification === 'free' ? 'free' : 'ordinary',\n requestId: ids(),\n busy: false,\n }\n publish()\n },\n cancelDelete() {\n if (deleteRequest?.busy) return\n deleteRequest = undefined\n publish()\n },\n async confirmDelete() {\n const current = deleteRequest\n if (current === undefined || current.busy) return\n const ticket = generation\n deleteRequest = { ...current, busy: true, failure: undefined }\n publish()\n try {\n const outcome = await deleteOwnedSession(host, current.sessionId, current.requestId)\n if (ticket !== generation) return\n if (outcome.phase !== 'deleted') {\n deleteRequest = {\n ...current,\n busy: false,\n failure: { code: 'session/delete-pending', reason: 'pending' },\n }\n publish()\n return\n }\n // The host clears the open selection itself; there is no panel to jump to.\n deleteRequest = undefined\n } catch (error) {\n if (ticket !== generation) return\n const failure = readFailure(error)\n deleteRequest = { ...current, busy: false, failure }\n }\n if (ticket === generation) publish()\n },\n cancel() {\n generation += 1\n creating = false\n notice = undefined\n deleteRequest = undefined\n publish()\n },\n }\n}\n\nexport interface RetrySnapshot {\n readonly controlsRetry: boolean\n readonly controlsContent?: boolean\n readonly busy: boolean\n readonly editing: boolean\n /** The current preview found later modifications that the user must acknowledge. */\n readonly modified: boolean\n readonly draft: string\n readonly sessionId: string\n readonly messageId: string\n readonly failure?: OperationFailure\n}\n\nexport interface RetryModel {\n subscribe(listener: Listener): () => void\n getSnapshot(): RetrySnapshot\n load(): Promise<void>\n beginEdit(sessionId: string, messageId: string, text: string, signal: AbortSignal): Promise<void>\n setDraft(text: string): void\n cancelEdit(): void\n sendEdit(sessionId: string, messageId: string, signal: AbortSignal, content?: readonly PromptContent[], confirmed?: boolean): Promise<void>\n retire(sessionId: string, messageId: string): void\n cancel(): void\n}\n\nexport function createRetryModel(host: SessionHost, ids: () => string = () => crypto.randomUUID()): RetryModel {\n const events = store()\n const ledger = new SubmissionLedger()\n let capabilities = UNSUPPORTED_CAPABILITIES\n let ready = false\n let busy = false\n let editing = false\n let modified = false\n let editNeedsPreview = false\n let draft = ''\n let failure: OperationFailure | undefined\n let expectedRevision = 0\n let expectedInputRevision = ''\n let ownerSession = ''\n let ownerMessage = ''\n let call = 0\n let snapshot: RetrySnapshot = build()\n\n function build(): RetrySnapshot {\n return {\n controlsRetry: controlsFor(capabilities, ready, host).retry,\n controlsContent: ready && capabilities.retryContent === true,\n busy,\n editing,\n modified,\n draft,\n sessionId: ownerSession,\n messageId: ownerMessage,\n ...failure === undefined ? {} : { failure },\n }\n }\n\n function publish(): void {\n snapshot = build()\n events.emit()\n }\n\n function readPreview(value: unknown): RetryPreview {\n if (typeof value !== 'object' || value === null || typeof (value as { branchRevision?: unknown }).branchRevision !== 'number') {\n throw new HostOperationError('session/lifecycle-unavailable')\n }\n const record = value as { branchRevision: number; eligible?: boolean; reason?: string; inputRevision?: unknown }\n const inputRevision = typeof record.inputRevision === 'string' ? record.inputRevision : ''\n const eligible = record.eligible === true\n if ((eligible || record.reason === 'modified') && inputRevision === '') {\n throw new HostOperationError('session/lifecycle-unavailable', 'input-revision')\n }\n return {\n branchRevision: record.branchRevision,\n inputRevision,\n eligible,\n ...typeof record.reason === 'string' ? { reason: record.reason } : {},\n }\n }\n\n async function preview(sessionId: string, id: string, signal: AbortSignal, ticket: number): Promise<RetryPreview | undefined> {\n if (ticket !== call || signal.aborted) return undefined\n if (typeof host.previewRetry !== 'function') throw new HostOperationError('session/lifecycle-unavailable')\n const value = await unwrap(host.previewRetry({ sessionId, messageId: id }))\n if (ticket !== call || signal.aborted) return undefined\n return readPreview(value)\n }\n\n async function callRetry(body: EditRetryRequest, signal: AbortSignal, ticket: number): Promise<void> {\n if (signal.aborted || ticket !== call) throw new HostOperationError('busy', 'aborted')\n if (typeof host.retry !== 'function') throw new HostOperationError('session/lifecycle-unavailable')\n await unwrap(host.retry(body))\n }\n\n function settle(): void {\n if (!ledger.busy) busy = false\n publish()\n }\n\n async function replaySame(signal: AbortSignal): Promise<void> {\n if (signal.aborted) return\n const pending = ledger.pending()\n const ticket = ++call\n busy = true\n failure = undefined\n publish()\n try {\n await ledger.replay(async body => { await callRetry(body, signal, ticket) })\n if (\n pending !== undefined\n && ticket === call\n && !signal.aborted\n && ownerSession === pending.sessionId\n && ownerMessage === pending.messageId\n ) {\n editing = false\n modified = false\n editNeedsPreview = false\n }\n } catch (error) {\n if (ticket === call && !signal.aborted) failure = readFailure(error)\n } finally {\n settle()\n }\n }\n\n function samePending(sessionId: string, id: string): boolean {\n const pending = ledger.pending()\n return pending !== undefined && pending.sessionId === sessionId && pending.messageId === id\n }\n\n return {\n subscribe: events.subscribe,\n getSnapshot: () => snapshot,\n async load() {\n capabilities = await readCapabilities(host)\n ready = true\n publish()\n },\n async beginEdit(sessionId, id, text, signal) {\n if (busy || !controlsFor(capabilities, ready, host).retry || signal.aborted) return\n if (editing && (ownerSession !== sessionId || ownerMessage !== id)) return\n if (ledger.pending() !== undefined) {\n if (!samePending(sessionId, id)) return\n await replaySame(signal)\n return\n }\n const ticket = ++call\n busy = true\n failure = undefined\n modified = false\n editNeedsPreview = false\n ownerSession = sessionId\n ownerMessage = id\n publish()\n try {\n const seen = await preview(sessionId, id, signal, ticket)\n if (seen === undefined) return\n if (signal.aborted || ticket !== call) return\n expectedRevision = seen.branchRevision\n expectedInputRevision = seen.inputRevision\n if (!seen.eligible && (seen.reason !== 'modified' || !capabilities.retryModified)) {\n failure = { code: 'session/retry-blocked', reason: seen.reason ?? 'unknown' }\n return\n }\n modified = !seen.eligible\n draft = text\n editing = true\n } catch (error) {\n if (ticket === call && !signal.aborted) failure = readFailure(error)\n } finally {\n settle()\n }\n },\n setDraft(text) {\n if (!editing || ownerSession === '' || ownerMessage === '') return\n draft = text\n publish()\n },\n cancelEdit() {\n if (busy) return\n editing = false\n modified = false\n editNeedsPreview = false\n publish()\n },\n async sendEdit(sessionId, id, signal, content, confirmed) {\n if (signal.aborted || busy || !controlsFor(capabilities, ready, host).retry) return\n if (!editing || ownerSession !== sessionId || ownerMessage !== id) return\n if (ledger.pending() !== undefined) {\n if (!samePending(sessionId, id)) return\n await replaySame(signal)\n return\n }\n const ticket = ++call\n busy = true\n const refresh = editNeedsPreview || isStaleRetryFailure(failure)\n failure = undefined\n const text = draft\n publish()\n try {\n if (signal.aborted || ticket !== call) return\n if (refresh) {\n // Revalidate both tokens after a conflict; ordinary first sends keep\n // the beginEdit preview, and lost replies still replay exactly above.\n editNeedsPreview = true\n const seen = await preview(sessionId, id, signal, ticket)\n if (seen === undefined) return\n expectedRevision = seen.branchRevision\n expectedInputRevision = seen.inputRevision\n if (!seen.eligible && (seen.reason !== 'modified' || !capabilities.retryModified)) {\n failure = { code: 'session/retry-blocked', reason: seen.reason ?? 'unknown' }\n return\n }\n modified = !seen.eligible\n editNeedsPreview = false\n }\n if (content !== undefined && capabilities.retryContent !== true) throw new HostOperationError('session/lifecycle-unavailable')\n const body = editRetryRequest({\n sessionId,\n messageId: id,\n expectedRevision,\n expectedInputRevision,\n requestId: ids(),\n text,\n ...content === undefined ? {} : { content },\n allowModified: confirmed === true,\n })\n await ledger.submit(body, () => callRetry(body, signal, ticket))\n if (ticket === call && !signal.aborted) {\n editing = false\n modified = false\n editNeedsPreview = false\n }\n } catch (error) {\n const nextFailure = readFailure(error)\n if (isStaleRetryFailure(nextFailure)) editNeedsPreview = true\n if (ticket === call && !signal.aborted) failure = nextFailure\n } finally {\n settle()\n }\n },\n retire(sessionId, messageId) {\n if (ownerSession !== sessionId || ownerMessage !== messageId) return\n call += 1\n editing = false\n modified = false\n editNeedsPreview = false\n failure = undefined\n draft = ''\n if (!ledger.busy) busy = false\n publish()\n },\n cancel() {\n call += 1\n editing = false\n modified = false\n editNeedsPreview = false\n failure = undefined\n if (!ledger.busy) busy = false\n publish()\n },\n }\n}\n\nexport function bindHost(ctx: {\n sessions?: {\n list?: ObservableList\n capabilities?: SessionHost['capabilities']\n create?: (opts?: { workspaceId?: string; cwd?: string; sessionId?: string }) => Promise<unknown>\n previewRetry?: SessionHost['previewRetry']\n retry?: SessionHost['retry']\n }\n uiWorkspace?: {\n openSession?: SessionHost['openSession']\n deleteSession?: SessionHost['deleteSession']\n }\n}): SessionHost {\n const sessions = ctx.sessions\n const workspace = ctx.uiWorkspace\n const empty: ObservableList = {\n getSnapshot: () => ({ ids: [], byId: {}, phase: 'ready' }),\n subscribe: () => () => {},\n }\n return {\n list: sessions?.list ?? empty,\n ...typeof sessions?.capabilities === 'function' ? { capabilities: () => sessions.capabilities!() } : {},\n ...typeof sessions?.create === 'function'\n ? { create: (opts: { kind: 'free' }) => (sessions.create as (input: { kind: 'free' }) => Promise<unknown>)(opts) }\n : {},\n ...typeof sessions?.previewRetry === 'function' ? { previewRetry: request => sessions.previewRetry!(request) } : {},\n ...typeof sessions?.retry === 'function' ? { retry: request => sessions.retry!(request) } : {},\n ...typeof workspace?.openSession === 'function' ? { openSession: sessionId => workspace.openSession!(sessionId) } : {},\n ...typeof workspace?.deleteSession === 'function' ? { deleteSession: (sessionId, requestId) => workspace.deleteSession!(sessionId, requestId) } : {},\n }\n}\n","import type { RecapPayload } from './contracts.ts'\nimport { HostOperationError } from './session-actions.ts'\nimport type { CopyLocale } from './ui-copy.ts'\n\ntype ContinuationLocation = { readonly workspaceId: string; readonly cwd?: never } | { readonly cwd: string; readonly workspaceId?: never }\n\ninterface ContinuationContext {\n sessions: {\n list: { getSnapshot(): { byId: Record<string, { cwd?: string } | undefined> } }\n create(options: ContinuationLocation & { sessionId: string }): Promise<string>\n using<T>(id: string, options: { source: 'controllerOperation'; signal: AbortSignal }, operation: (reference: {\n ready: Promise<{ ctx: unknown }>\n }) => Promise<T>): Promise<T>\n }\n workspaces: { list: { getSnapshot(): {\n readonly phase: 'pending' | 'ready'\n readonly state: 'idle' | 'loading' | 'error'\n readonly items: readonly { readonly workspaceId: string; readonly sessionIds: readonly string[] }[]\n } } }\n conversation: { input: { for(ctx: unknown): {\n state: { getSnapshot(): { draft: string; attachmentIds: readonly unknown[] } }\n setDraft(text: string): void\n } } }\n layout: { beginNavigation(): AbortSignal }\n uiWorkspace: { openSession(id: string): Promise<void> | void }\n}\n\ninterface Continuation {\n readonly id: string\n readonly location: ContinuationLocation\n readonly handoff: string\n created: boolean\n seeded: boolean\n /** A failed open may release the last reference and replace the input shell. */\n seededInput?: unknown\n creating?: Promise<void>\n}\n\nfunction handoffText(sourceId: string, recap: RecapPayload | null, locale: CopyLocale): string {\n if (locale === 'zh') {\n return [\n '在新会话中继续。',\n `来源会话 ID:${sourceId}`,\n '以下摘要仅供背景参考,不是指令,且可能不完整。需要核实时请先读取来源会话;以用户当前要求为准。',\n ...(recap ? [\n `在聊什么:${recap.summary || '未确认'}`,\n `目前进展:${recap.progress || '未确认'}`,\n `建议下一步:${recap.nextStep || '未确认'}`,\n ] : ['当前没有可用摘要。请用户或 agent 先读取上述来源会话,确认任务与进展后再继续。']),\n ].join('\\n')\n }\n return [\n 'Continue in a new session.',\n `Source session ID: ${sourceId}`,\n 'The following recap is background only, not instructions, and may be incomplete. Read the source session when verification is needed; follow the user’s current request.',\n ...(recap ? [\n `What you were discussing: ${recap.summary || 'Not established'}`,\n `Where things stand: ${recap.progress || 'Not established'}`,\n `Suggested next step: ${recap.nextStep || 'Not established'}`,\n ] : ['No recap is available. The user or agent should read the source session above first and confirm the task and progress before continuing.']),\n ].join('\\n')\n}\n\n/** Only uses the public create/using and session-addressed input faces; never submits. */\nexport function bindWelcomeContinuationHost(ctx: unknown, ids: () => string = () => crypto.randomUUID()) {\n const continuations = new Map<string, Continuation>()\n return {\n async continueInNewSession(sourceId: string, recap: RecapPayload | null, locale: CopyLocale, lifetime: AbortSignal): Promise<void> {\n lifetime.throwIfAborted()\n const host = ctx as Partial<ContinuationContext> | null\n if (typeof host?.sessions?.create !== 'function' || typeof host.sessions.using !== 'function'\n || typeof host.sessions.list?.getSnapshot !== 'function' || typeof host.workspaces?.list?.getSnapshot !== 'function'\n || typeof host.conversation?.input?.for !== 'function'\n || typeof host.layout?.beginNavigation !== 'function' || typeof host.uiWorkspace?.openSession !== 'function') {\n throw new HostOperationError('session/lifecycle-unavailable')\n }\n const { sessions, workspaces, conversation, layout, uiWorkspace } = host as ContinuationContext\n // Capture the fence before any asynchronous creation/adoption or binding work.\n const signal = AbortSignal.any([layout.beginNavigation(), lifetime])\n signal.throwIfAborted()\n let continuation = continuations.get(sourceId)\n if (!continuation) {\n const workspaceSnapshot = workspaces.list.getSnapshot()\n if (workspaceSnapshot.phase !== 'ready' || workspaceSnapshot.state !== 'idle') {\n throw new HostOperationError('session/lifecycle-unavailable')\n }\n // Membership is the Host's sessionIds account, never a cwd match or\n // whichever workspace happens to be selected when the request settles.\n const owners = workspaceSnapshot.items.filter(row => row.sessionIds.includes(sourceId))\n if (owners.length > 1) throw new HostOperationError('session/lifecycle-unavailable')\n const owner = owners[0]\n let location: ContinuationLocation\n if (owner !== undefined) {\n if (!owner.workspaceId.trim()) throw new HostOperationError('session/lifecycle-unavailable')\n location = { workspaceId: owner.workspaceId }\n } else {\n // A confirmed ungrouped source stays ungrouped in its own directory.\n const cwd = sessions.list.getSnapshot()?.byId?.[sourceId]?.cwd\n if (typeof cwd !== 'string' || !cwd.trim()) throw new HostOperationError('session/lifecycle-unavailable')\n location = { cwd }\n }\n const id = ids()\n if (!id || id === sourceId) throw new HostOperationError('session/lifecycle-unavailable')\n continuation = { id, location, handoff: handoffText(sourceId, recap, locale), created: false, seeded: false }\n continuations.set(sourceId, continuation)\n }\n const target = continuation\n if (!target.created) {\n // Keep the preallocated id even if the Host created it but its reply was lost.\n // Concurrent clicks share creation; each caller still owns its navigation fence.\n target.creating ??= (async () => {\n const created = await sessions.create({ ...target.location, sessionId: target.id })\n if (created !== target.id) throw new HostOperationError('session/lifecycle-unavailable')\n target.created = true\n })().finally(() => { target.creating = undefined })\n await target.creating\n }\n signal.throwIfAborted()\n await sessions.using(target.id, { source: 'controllerOperation', signal }, async reference => {\n const binding = await reference.ready\n signal.throwIfAborted()\n if (!binding?.ctx) throw new HostOperationError('session/lifecycle-unavailable')\n const input = conversation.input.for(binding.ctx)\n if (typeof input?.setDraft !== 'function' || typeof input.state?.getSnapshot !== 'function') {\n throw new HostOperationError('session/lifecycle-unavailable')\n }\n const state = input.state.getSnapshot()\n if (typeof state?.draft !== 'string' || !Array.isArray(state.attachmentIds)) {\n throw new HostOperationError('session/lifecycle-unavailable')\n }\n signal.throwIfAborted()\n if (state.attachmentIds.length || (state.draft !== '' && !(target.seeded && state.draft === target.handoff))) {\n throw new HostOperationError('session/retry-conflict', 'modified')\n }\n if (!target.seeded || target.seededInput !== input) {\n input.setDraft(target.handoff)\n target.seeded = true\n target.seededInput = input\n }\n // openSession owns a fresh navigation; do not test our old fence after it.\n signal.throwIfAborted()\n await uiWorkspace.openSession(target.id)\n })\n // Only failed attempts reuse the target. A later welcome-back activity\n // must create a genuinely new session rather than reopening this child.\n if (continuations.get(sourceId) === target) continuations.delete(sourceId)\n },\n }\n}\n","/**\n * Client models for the continue ghost and the welcome-back card.\n * Business state lives here, not in React state, mirroring session-actions.ts.\n */\nimport {\n CONFIG_READ_ENDPOINT,\n CONFIG_WRITE_ENDPOINT,\n CONTINUE_SUGGEST_ENDPOINT,\n TEMP_WORKSPACE_CHANNEL,\n WELCOME_BACK_COMPACT_ENDPOINT,\n WELCOME_BACK_PREPARE_ENDPOINT,\n type ConfigPatch,\n type ConfigView,\n type RecapPayload,\n type WelcomeBackCompactValue,\n type WelcomeBackPrepareValue,\n} from './contracts.ts'\nimport { HostOperationError, readFailure, unwrap } from './session-actions.ts'\nimport type { CopyLocale, OperationFailure } from './ui-copy.ts'\nimport { bindWelcomeContinuationHost } from './welcome-continuation.ts'\n\nexport interface PresenceRpc {\n call(channel: string, endpoint: string, payload: unknown, signal?: AbortSignal): Promise<unknown>\n}\n\nexport interface PresenceHost {\n readonly rpc?: PresenceRpc\n /** Native commands use the target session's composed capabilities. */\n readonly compactContext?: (sessionId: string, signal: AbortSignal) => Promise<void>\n readonly continueInNewSession?: (sessionId: string, recap: RecapPayload | null, locale: CopyLocale, signal: AbortSignal) => Promise<void>\n}\n\n/** Narrow the plugin client's connection face without redeclaring the Context type. */\nexport function bindPresenceHost(ctx: unknown): PresenceHost {\n const client = ctx as {\n connection?: { rpc?: PresenceRpc }\n sessions?: {\n using?: <T>(id: string, options: { source: 'controllerOperation'; signal: AbortSignal }, operation: (reference: {\n ready: Promise<{ session: { command(line: string): Promise<unknown> } }>\n }) => Promise<T>) => Promise<T>\n }\n }\n return {\n ...bindWelcomeContinuationHost(ctx),\n ...(typeof client.connection?.rpc?.call === 'function' ? { rpc: client.connection.rpc } : {}),\n ...(typeof client.sessions?.using === 'function' ? {\n compactContext: async (sessionId: string, signal: AbortSignal) => {\n await client.sessions!.using!(sessionId, { source: 'controllerOperation', signal }, async reference => {\n const binding = await reference.ready\n signal.throwIfAborted()\n const result = await unwrap(binding.session.command('/compact')) as { matched?: boolean } | undefined\n // matched is command admission, NOT a successful compaction. The\n // native command/done node owns the eventual outcome in the chat.\n if (result?.matched !== true) throw new HostOperationError('session-manager/unavailable')\n })\n },\n } : {}),\n }\n}\n\nfunction requireRpc(host: PresenceHost): PresenceRpc {\n if (typeof host.rpc?.call !== 'function') throw new HostOperationError('session/lifecycle-unavailable')\n return host.rpc\n}\n\nasync function callPresence<T>(host: PresenceHost, endpoint: string, payload: unknown, signal?: AbortSignal): Promise<T> {\n const raw = await unwrap(requireRpc(host).call(TEMP_WORKSPACE_CHANNEL, endpoint, payload, signal))\n return raw as T\n}\n\ninterface Listener {\n (): void\n}\n\nfunction store() {\n const listeners = new Set<Listener>()\n return {\n subscribe(listener: Listener): () => void {\n listeners.add(listener)\n return () => { listeners.delete(listener) }\n },\n emit(): void {\n for (const listener of listeners) listener()\n },\n }\n}\n\n/* ------------------------------------------------------------------ */\n/* Continue ghost */\n/* ------------------------------------------------------------------ */\n\nexport interface ContinueSessionState {\n /** undefined until the first resolve settles; null means show nothing. */\n readonly text?: string | null\n /** Active-branch sequence this text belongs to; absent while a turn is still open. */\n readonly seq?: number\n /** The latest turn is still open, so the shipped placeholder stays. */\n readonly pending?: true\n /** Empty fixed text uses the localized default once a turn has ended. */\n readonly fallback?: true\n}\n\nconst EMPTY_CONTINUE: ContinueSessionState = {}\n\nexport interface ContinueModel {\n subscribe(listener: Listener): () => void\n /** Stable per-session snapshot identity for useSyncExternalStore selectors. */\n getSnapshot(sessionId: string): ContinueSessionState\n /** Resolve the suggestion for the latest ended turn. Safe to call on every mount. */\n load(sessionId: string): void\n /** The previous turn ended: drop the cached line so the next load generates once. */\n invalidate(sessionId: string): void\n /** Drop every cached line and revoke every pending reply on config changes. */\n invalidateAll(): void\n cancel(): void\n}\n\nexport function createContinueModel(host: PresenceHost): ContinueModel {\n const events = store()\n const states = new Map<string, ContinueSessionState>()\n const inflight = new Map<string, AbortController>()\n const lifetime = new AbortController()\n let empty = EMPTY_CONTINUE\n\n function read(sessionId: string): ContinueSessionState {\n return states.get(sessionId) ?? empty\n }\n function write(sessionId: string, next: ContinueSessionState): void {\n if (lifetime.signal.aborted) return\n states.set(sessionId, next)\n events.emit()\n }\n\n return {\n subscribe: events.subscribe,\n getSnapshot: read,\n load(sessionId) {\n if (sessionId === '' || lifetime.signal.aborted || inflight.has(sessionId)) return\n const current = read(sessionId)\n // A settled seq-less line is final (fixed text, fallback, empty model\n // line); a pending answer is not — the host saw an open turn, so an\n // explicit load must be able to re-ask once it has ended. Without this\n // a stranded turn or a missed running edge would pin the ghost forever.\n if (current.text !== undefined && current.seq === undefined && current.pending !== true) return\n const ticket = new AbortController()\n inflight.set(sessionId, ticket)\n const signal = AbortSignal.any([lifetime.signal, ticket.signal])\n void callContinueSuggest(host, sessionId, current.text ? current.seq : undefined, signal)\n .then(value => {\n if (signal.aborted || inflight.get(sessionId) !== ticket) return\n write(sessionId, value)\n })\n .catch(() => {\n // A rejected RPC is not a settled suggestion: the server owner may\n // have cancelled while our signal stayed active. Preserve the\n // snapshot without emitting, so explicit loads can retry and a\n // mounted empty composer does not start an automatic retry loop.\n })\n .finally(() => {\n if (inflight.get(sessionId) === ticket) inflight.delete(sessionId)\n })\n },\n invalidate(sessionId) {\n if (sessionId === '') return\n inflight.get(sessionId)?.abort()\n inflight.delete(sessionId)\n if (!states.has(sessionId)) return\n states.delete(sessionId)\n events.emit()\n },\n invalidateAll() {\n for (const ticket of inflight.values()) ticket.abort()\n inflight.clear()\n states.clear()\n empty = {}\n events.emit()\n },\n cancel() {\n lifetime.abort()\n for (const ticket of inflight.values()) ticket.abort()\n inflight.clear()\n states.clear()\n },\n }\n}\n\nasync function callContinueSuggest(\n host: PresenceHost,\n sessionId: string,\n knownSeq: number | undefined,\n signal: AbortSignal,\n): Promise<ContinueSessionState> {\n const value = await callPresence<{ text?: unknown; seq?: unknown; pending?: unknown; fallback?: unknown }>(host, CONTINUE_SUGGEST_ENDPOINT, {\n sessionId,\n ...knownSeq === undefined ? {} : { knownSeq },\n }, signal)\n const text = typeof value?.text === 'string' && value.text.trim() !== '' ? value.text : null\n const seq = typeof value?.seq === 'number' && Number.isSafeInteger(value.seq) && value.seq >= 0 ? value.seq : undefined\n return {\n text,\n ...seq === undefined ? {} : { seq },\n ...value?.pending === true ? { pending: true as const } : {},\n ...value?.fallback === true ? { fallback: true as const } : {},\n }\n}\n\n/* ------------------------------------------------------------------ */\n/* Bundle settings (config.read / config.write) */\n/* ------------------------------------------------------------------ */\n\nexport interface PresenceConfigSnapshot {\n readonly phase: 'loading' | 'ready' | 'unavailable'\n readonly values?: ConfigView\n readonly saving: boolean\n /** Set briefly after a write is confirmed by a re-read (the write itself may drop with the reloading fiber). */\n readonly saved: boolean\n readonly failure?: OperationFailure\n}\n\nexport interface PresenceConfigModel {\n subscribe(listener: Listener): () => void\n getSnapshot(): PresenceConfigSnapshot\n load(): Promise<void>\n save(patch: ConfigPatch): Promise<void>\n cancel(): void\n}\n\n/**\n * A host that predates the agent-action flags returns a config view without\n * them, and a malformed one may carry a non-boolean. Both normalize to\n * false: an absent or unusable flag must never read as granted. Only a real\n * boolean true keeps the permission on.\n */\nfunction normalizeConfigView(view: ConfigView): ConfigView {\n return {\n ...view,\n allowSelfFork: view.allowSelfFork === true,\n allowSendMessage: view.allowSendMessage === true,\n }\n}\n\nexport function createPresenceConfigModel(host: PresenceHost, delay: (ms: number) => Promise<void> = ms => new Promise(resolve => setTimeout(resolve, ms))): PresenceConfigModel {\n const events = store()\n const lifetime = new AbortController()\n let phase: PresenceConfigSnapshot['phase'] = 'loading'\n let values: ConfigView | undefined\n let saving = false\n let saved = false\n let failure: OperationFailure | undefined\n let snapshot: PresenceConfigSnapshot = build()\n let readGeneration = 0\n /** Several settings rows share this model; collapse concurrent reads into one call. */\n let inflightLoad: Promise<void> | undefined\n\n function build(): PresenceConfigSnapshot {\n return {\n phase,\n ...values === undefined ? {} : { values },\n saving,\n saved,\n ...failure === undefined ? {} : { failure },\n }\n }\n function publish(): void {\n snapshot = build()\n events.emit()\n }\n function sameRoute(\n current: ConfigView['model'] | undefined,\n value: unknown,\n ): boolean {\n const route = value as ConfigView['model'] | undefined\n if (current === null || current === undefined) return route === null || route === undefined\n return route !== null && route !== undefined && current.provider === route.provider && current.model === route.model\n && current.reasoningEffort === route.reasoningEffort\n }\n function same(view: ConfigView | undefined, patch: ConfigPatch): boolean {\n if (view === undefined) return false\n return Object.entries(patch).every(([key, value]) => {\n if (key === 'model' || key === 'ghostModel' || key === 'judgeModel' || key === 'handoffModel') return sameRoute(view[key], value)\n return view[key as keyof ConfigView] === value\n })\n }\n\n async function doLoad() {\n const generation = ++readGeneration\n try {\n const view = await callPresence<ConfigView>(host, CONFIG_READ_ENDPOINT, {}, lifetime.signal)\n if (lifetime.signal.aborted || generation !== readGeneration) return\n values = normalizeConfigView(view)\n phase = 'ready'\n failure = undefined\n } catch (error) {\n if (lifetime.signal.aborted || generation !== readGeneration) return\n phase = 'unavailable'\n failure = readFailure(error)\n }\n publish()\n }\n\n return {\n subscribe: events.subscribe,\n getSnapshot: () => snapshot,\n load() {\n inflightLoad ??= doLoad().finally(() => { inflightLoad = undefined })\n return inflightLoad\n },\n async save(patch) {\n if (saving || lifetime.signal.aborted) return\n saving = true\n ++readGeneration\n saved = false\n failure = undefined\n publish()\n try {\n await callPresence<ConfigView>(host, CONFIG_WRITE_ENDPOINT, { patch }, lifetime.signal)\n } catch {\n // The host fiber reloads with the new config mid-write; confirm by re-reading.\n }\n try {\n for (let attempt = 0; attempt < 10 && !lifetime.signal.aborted; attempt++) {\n await delay(400)\n let view: ConfigView\n try {\n view = normalizeConfigView(await callPresence<ConfigView>(host, CONFIG_READ_ENDPOINT, {}, lifetime.signal))\n } catch (error) {\n // A config edit can temporarily remove the RPC while its Host\n // instance is replaced. One failed read is not a failed save.\n if (lifetime.signal.aborted || attempt === 9) throw error\n continue\n }\n if (same(view, patch)) {\n ++readGeneration\n values = normalizeConfigView(view)\n phase = 'ready'\n saved = true\n saving = false\n publish()\n return\n }\n }\n throw new HostOperationError('transport', 'unknown')\n } catch (error) {\n if (lifetime.signal.aborted) return\n saving = false\n failure = readFailure(error)\n publish()\n }\n },\n cancel() {\n lifetime.abort()\n },\n }\n}\n\n\n/* ------------------------------------------------------------------ */\n/* Welcome-back card */\n/* ------------------------------------------------------------------ */\n\nexport interface WelcomeBackCardState {\n readonly sessionId: string\n readonly idleMinutes: number\n readonly lastResponseAt: number\n readonly recap: RecapPayload | null\n readonly compactSuggested: boolean\n readonly compactAvailable: boolean\n /** Host-resolved threshold so the client can flip the suggestion on live as the idle clock crosses it. */\n readonly compactMinutes: number\n}\n\nexport interface WelcomeBackSnapshot {\n /** Present while this session's card is visible. */\n readonly card?: WelcomeBackCardState\n readonly compactBusy: boolean\n readonly continueBusy?: boolean\n /** Native command accepted; its own chat node reports success or failure. */\n readonly compactCommandSent?: boolean\n /** null = compacted but the host gave no token count. */\n readonly compactedTokens?: number | null\n readonly compactReason?: 'busy' | 'unavailable' | 'nothing'\n readonly failure?: OperationFailure\n}\n\nconst EMPTY_WELCOME_BACK: WelcomeBackSnapshot = { compactBusy: false }\n\nexport interface WelcomeBackModel {\n subscribe(listener: Listener): () => void\n /** Stable per-session snapshot identity for useSyncExternalStore selectors. */\n getSnapshot(sessionId: string): WelcomeBackSnapshot\n /** Ask the host whether this session deserves the card; events call this on return. */\n check(sessionId: string): Promise<void>\n /** Re-evaluate cached cards and dismissed marks after confirmed threshold changes. */\n invalidate(): void\n dismiss(sessionId: string): void\n compact(sessionId: string): Promise<void>\n continueInNewSession(sessionId: string, locale: CopyLocale): Promise<void>\n cancel(): void\n}\n\nexport function createWelcomeBackModel(\n host: PresenceHost,\n ids: () => string = () => crypto.randomUUID(),\n minIntervalMs = 10_000,\n): WelcomeBackModel {\n const events = store()\n const lifetime = new AbortController()\n /** Sessions already answered for one exact lastResponseAt; new activity re-arms the card. */\n const settled = new Map<string, number>()\n const checkedAt = new Map<string, number>()\n const capMarks = (map: Map<string, number>) => {\n while (map.size > 64) map.delete(map.keys().next().value!)\n }\n /** Per-session card plus its live compact operation fields. */\n const states = new Map<string, {\n card: WelcomeBackCardState\n compactBusy: boolean\n continueBusy?: boolean\n continueAbort?: AbortController\n compactCommandSent?: boolean\n compactedTokens: number | null | undefined\n compactReason: WelcomeBackSnapshot['compactReason']\n failure: OperationFailure | undefined\n }>()\n /** Stable snapshot per session, rebuilt only when its fields change. */\n const snapshots = new Map<string, WelcomeBackSnapshot>()\n const inflight = new Map<string, AbortController>()\n\n function read(sessionId: string): WelcomeBackSnapshot {\n return snapshots.get(sessionId) ?? EMPTY_WELCOME_BACK\n }\n function publish(sessionId: string): void {\n const state = states.get(sessionId)\n if (state === undefined) {\n snapshots.delete(sessionId)\n } else {\n snapshots.set(sessionId, {\n card: state.card,\n compactBusy: state.compactBusy,\n continueBusy: state.continueBusy === true,\n compactCommandSent: state.compactCommandSent === true,\n ...state.compactedTokens === undefined ? {} : { compactedTokens: state.compactedTokens },\n ...state.compactReason === undefined ? {} : { compactReason: state.compactReason },\n ...state.failure === undefined ? {} : { failure: state.failure },\n })\n }\n events.emit()\n }\n\n return {\n subscribe: events.subscribe,\n getSnapshot: read,\n async check(sessionId) {\n if (sessionId === '' || lifetime.signal.aborted || states.has(sessionId)) return\n const now = Date.now()\n const last = checkedAt.get(sessionId) ?? 0\n if (now - last < minIntervalMs) return\n if (inflight.has(sessionId)) return\n checkedAt.set(sessionId, now)\n capMarks(checkedAt)\n const ticket = new AbortController()\n inflight.set(sessionId, ticket)\n const signal = AbortSignal.any([lifetime.signal, ticket.signal])\n try {\n const value = await callPresence<WelcomeBackPrepareValue>(host, WELCOME_BACK_PREPARE_ENDPOINT, {\n sessionId,\n ...settled.has(sessionId) ? { knownLastResponseAt: settled.get(sessionId) } : {},\n }, signal)\n if (signal.aborted || inflight.get(sessionId) !== ticket || states.has(sessionId) || value.show !== true) return\n if (value.sessionId !== sessionId) return\n if (settled.get(sessionId) === value.lastResponseAt) return\n states.set(sessionId, {\n card: {\n sessionId,\n idleMinutes: value.idleMinutes,\n lastResponseAt: value.lastResponseAt,\n recap: value.recap,\n compactSuggested: value.compactSuggested,\n compactAvailable: value.compactAvailable,\n compactMinutes: value.compactMinutes,\n },\n compactBusy: false,\n compactedTokens: undefined,\n compactReason: undefined,\n failure: undefined,\n })\n publish(sessionId)\n } catch {\n // A failed or unavailable prepare stays silent: the card is a courtesy, never a blocker.\n } finally {\n if (inflight.get(sessionId) === ticket) inflight.delete(sessionId)\n }\n },\n invalidate() {\n for (const ticket of inflight.values()) ticket.abort()\n inflight.clear()\n checkedAt.clear()\n settled.clear()\n // Explicit operations keep ownership until they settle; configuration\n // refresh must not abort a user's chosen compaction or navigation.\n for (const [sessionId, state] of states) {\n if (state.compactBusy || state.continueBusy) continue\n states.delete(sessionId)\n snapshots.delete(sessionId)\n }\n events.emit()\n },\n dismiss(sessionId) {\n inflight.get(sessionId)?.abort()\n inflight.delete(sessionId)\n const state = states.get(sessionId)\n if (state === undefined) return\n state.continueAbort?.abort()\n settled.set(sessionId, state.card.lastResponseAt)\n capMarks(settled)\n states.delete(sessionId)\n publish(sessionId)\n },\n async compact(sessionId) {\n const state = states.get(sessionId)\n if (state === undefined || state.compactBusy || state.continueBusy || lifetime.signal.aborted) return\n state.compactBusy = true\n state.failure = undefined\n state.compactReason = undefined\n publish(sessionId)\n try {\n if (host.compactContext !== undefined) {\n await host.compactContext(sessionId, lifetime.signal)\n if (lifetime.signal.aborted || states.get(sessionId) !== state) return\n state.compactBusy = false\n state.compactCommandSent = true\n publish(sessionId)\n return\n }\n const value = await callPresence<WelcomeBackCompactValue>(host, WELCOME_BACK_COMPACT_ENDPOINT, {\n sessionId: state.card.sessionId,\n requestId: ids(),\n }, lifetime.signal)\n if (lifetime.signal.aborted || states.get(sessionId) !== state) return\n state.compactBusy = false\n if (value.compacted) state.compactedTokens = value.shadowedTokens\n else state.compactReason = value.reason\n publish(sessionId)\n } catch (error) {\n if (lifetime.signal.aborted || states.get(sessionId) !== state) return\n state.compactBusy = false\n state.failure = readFailure(error)\n publish(sessionId)\n }\n },\n async continueInNewSession(sessionId, locale) {\n const state = states.get(sessionId)\n if (state === undefined || state.compactBusy || state.continueBusy || lifetime.signal.aborted) return\n state.continueBusy = true\n state.continueAbort = new AbortController()\n state.failure = undefined\n publish(sessionId)\n try {\n if (host.continueInNewSession === undefined) throw new HostOperationError('session/lifecycle-unavailable')\n await host.continueInNewSession(sessionId, state.card.recap, locale,\n AbortSignal.any([lifetime.signal, state.continueAbort.signal]))\n if (lifetime.signal.aborted || states.get(sessionId) !== state) return\n settled.set(sessionId, state.card.lastResponseAt)\n capMarks(settled)\n states.delete(sessionId)\n publish(sessionId)\n } catch (error) {\n if (lifetime.signal.aborted || states.get(sessionId) !== state) return\n state.continueBusy = false\n if (!(error instanceof Error && error.name === 'AbortError')) state.failure = readFailure(error)\n publish(sessionId)\n }\n },\n cancel() {\n lifetime.abort()\n inflight.clear()\n states.clear()\n snapshots.clear()\n settled.clear()\n checkedAt.clear()\n },\n }\n}\n","/**\n * The hero-row Auto-continue option: a chip that opens a three-mode menu on a\n * blank session and locks once the session starts. Mirrors the delegation\n * chip's revision discipline: stale reads never roll the chip back, a 'stale'\n * rejection refetches, and 'session-locked' explains itself in the tooltip.\n */\nimport { IconChevronDownOutlineRegular, IconRefreshOutlineRegular, Menu, Pill, Tooltip } from '@deepseek-ai/dsh-client-ui-primitives'\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport {\n AUTO_CONTINUE_STATUS_ENDPOINT,\n AUTO_CONTINUE_UPDATE_ENDPOINT,\n type AutoContinueMode,\n type AutoContinueStatus,\n} from './contracts.ts'\nimport { FREE_CHAT_ROOT } from './styles.ts'\nimport { uiText, type CopyLocale } from './ui-copy.ts'\n\nclass RpcError extends Error {\n readonly code: string\n constructor(code: string, message: string) {\n super(message)\n this.name = 'RpcError'\n this.code = code\n }\n}\n\nasync function rpc<T>(call: (endpoint: string, payload: unknown) => Promise<unknown>, endpoint: string, payload: unknown): Promise<T> {\n const result = await call(endpoint, payload) as { ok: true; value: T } | { ok: false; error?: { code?: string; message?: string } } | undefined\n if (!result || result.ok !== true) {\n const failed = result && 'error' in result ? result.error : undefined\n throw new RpcError(failed?.code ?? 'unknown', failed?.message ?? '')\n }\n return result.value\n}\n\nexport interface AutoContinueSessionSnapshotLike {\n openState?: string\n running?: boolean\n blank?: boolean\n awaitingFirstTurn?: boolean\n pendingSubmissions?: readonly unknown[]\n}\n\nexport interface AutoContinueOptionProps {\n sessionId: string\n call: (endpoint: string, payload: unknown) => Promise<unknown>\n /** Host connection-generation subscription; refetches on reconnect. */\n subscribeGeneration?: (listener: () => void) => (() => void) | undefined\n /** Host per-session selector hook; a cold→open transition triggers a refetch. */\n useSession?: <T>(selector: (snapshot: AutoContinueSessionSnapshotLike) => T) => T\n locale: CopyLocale\n}\n\ntype Notice = '' | 'autoContinueStale' | 'autoContinueFailed' | 'autoContinueLocked'\n\nconst MODES: readonly AutoContinueMode[] = ['off', 'cautious', 'bold']\n\nexport function AutoContinueOption({ sessionId, call, subscribeGeneration, useSession, locale }: AutoContinueOptionProps) {\n const [status, setStatus] = useState<AutoContinueStatus>()\n const [saving, setSaving] = useState(false)\n const [notice, setNotice] = useState<Notice>('')\n const [open, setOpen] = useState(false)\n const generationRef = useRef(0)\n const readSeqRef = useRef(0)\n const openState = useSession?.(snapshot => snapshot.openState)\n const sessionRunning = useSession?.(snapshot => snapshot.running === true)\n const sessionBlank = useSession?.(snapshot => snapshot.blank)\n const submitting = useSession?.(snapshot => snapshot.awaitingFirstTurn === true || (snapshot.pendingSubmissions?.length ?? 0) > 0)\n\n const load = useCallback(async () => {\n const generation = generationRef.current\n const seq = ++readSeqRef.current\n try {\n const next = await rpc<AutoContinueStatus>(call, AUTO_CONTINUE_STATUS_ENDPOINT, { sessionId })\n if (generationRef.current !== generation || seq !== readSeqRef.current) return\n setStatus(prev => prev && prev.sessionId === next.sessionId && next.revision < prev.revision ? prev : next)\n } catch {\n // A failed refetch keeps the last known state; the chip stays put.\n }\n }, [call, sessionId])\n\n useEffect(() => {\n generationRef.current += 1\n readSeqRef.current += 1\n setStatus(undefined)\n setSaving(false)\n setNotice('')\n setOpen(false)\n }, [sessionId])\n\n useEffect(() => { void load() }, [load, openState, sessionRunning, sessionBlank])\n\n useEffect(() => {\n const off = subscribeGeneration?.(() => { void load() })\n const win = typeof window === 'undefined' ? undefined : window\n const onFocus = () => { void load() }\n win?.addEventListener('focus', onFocus)\n return () => { off?.(); win?.removeEventListener('focus', onFocus) }\n }, [load, subscribeGeneration])\n\n useEffect(() => {\n if (!notice) return\n const timer = setTimeout(() => setNotice(''), 4000)\n return () => clearTimeout(timer)\n }, [notice])\n\n const choose = useCallback(async (mode: AutoContinueMode) => {\n if (!status || saving || status.locked || sessionBlank === false || sessionRunning || submitting || mode === status.mode) return\n const generation = generationRef.current\n readSeqRef.current += 1\n setSaving(true)\n setNotice('')\n try {\n const next = await rpc<AutoContinueStatus>(call, AUTO_CONTINUE_UPDATE_ENDPOINT, {\n sessionId, mode, expectedRevision: status.revision,\n })\n if (generationRef.current !== generation) return\n setStatus(next)\n } catch (reason) {\n if (generationRef.current !== generation) return\n if (reason instanceof RpcError && (reason.code === 'stale' || reason.code === 'session-locked')) {\n setNotice(reason.code === 'stale' ? 'autoContinueStale' : 'autoContinueLocked')\n void load()\n } else {\n setNotice('autoContinueFailed')\n }\n } finally {\n if (generationRef.current === generation) setSaving(false)\n }\n }, [call, load, saving, sessionId, status, sessionBlank, sessionRunning, submitting])\n\n if (!status || status.role === 'executor' || sessionBlank === false) return null\n const mode = status.mode\n const locked = status.locked || sessionRunning === true || submitting === true\n const tooltip = locked\n ? uiText(locale, 'autoContinueLocked')\n : notice\n ? uiText(locale, notice)\n : uiText(locale, 'autoContinueTooltip')\n const modeKey = mode === 'cautious' ? 'autoContinueCautious' : mode === 'bold' ? 'autoContinueBold' : 'autoContinueOff'\n const label = `${uiText(locale, 'autoContinue')} · ${uiText(locale, modeKey)}`\n return (\n <span className={`${FREE_CHAT_ROOT} smac-option`}>\n <Menu\n open={open}\n align=\"end\"\n portal\n listClassName={FREE_CHAT_ROOT}\n selectedId={mode}\n items={MODES.map(value => ({\n id: value,\n label: uiText(locale, value === 'off' ? 'autoContinueOff' : value === 'cautious' ? 'autoContinueCautious' : 'autoContinueBold'),\n }))}\n onSelect={id => {\n setOpen(false)\n void choose(id as AutoContinueMode)\n }}\n onClose={() => setOpen(false)}\n anchor={(\n <Tooltip label={tooltip} side=\"bottom\" gap={4}>\n <Pill\n className={`smac-chip${mode !== 'off' ? ' smac-chip-on' : ''}`}\n active={mode !== 'off'}\n aria-haspopup=\"menu\"\n aria-expanded={open}\n aria-label={label}\n disabled={locked || saving}\n onClick={() => setOpen(current => !current)}\n >\n <IconRefreshOutlineRegular />\n <span className=\"smac-chip-label\">{label}</span>\n <IconChevronDownOutlineRegular className=\"smac-chevron\" />\n </Pill>\n </Tooltip>\n )}\n />\n {notice ? <span role=\"status\" className=\"smac-note\">{uiText(locale, notice)}</span> : null}\n </span>\n )\n}\n","import type { ContextFormed } from '@deepseek-ai/dsh-llm'\nimport { modelRouteOverride, type ModelRoute } from '@klarkxy/dsh-model-route'\n\n/**\n * The canonical home is @klarkxy/dsh-model-route; re-exported here so existing\n * plugin-kit consumers keep compiling.\n */\nexport type { ModelRoute }\n\n/** Public, browser-safe contracts. Host implementations stay in their owning packages. */\nexport type ProducerSourceKind = `plugin:${string}`\nexport type ProducerMessageSource = { kind: ProducerSourceKind; plugin: string } & ContextFormed\n\n/**\n * V4 sessions persist the producing extension in `kind`; the retired generic\n * `plugin` wrapper is not admitted. Each feature plugin declares its own kind.\n */\ndeclare module '@deepseek-ai/dsh-llm' {\n interface MessageSourceMap {\n [kind: ProducerSourceKind]: ProducerMessageSource\n }\n}\n\nexport function producerMessageSource(plugin: string): ProducerMessageSource {\n return { kind: `plugin:${plugin}`, plugin }\n}\n\nexport type RpcResult<T = unknown> = { ok: true; value: T } | { ok: false; error: { code: string; message: string } }\nexport const CHAT_EVENTS_SLOT = 'dsh-editor.chat.events'\nexport interface EvidenceRef { sessionId: string; seq: number; kind: 'user' | 'tool' | 'turn' | 'manual'; excerpt?: string }\nexport interface TaskContract {\n id: string\n sessionId: string\n sourceVersion: string\n revision: number\n goal: string\n deliverables: string[]\n inScope: string[]\n outOfScope: string[]\n constraints: string[]\n acceptance: string[]\n assumptions: string[]\n questions: string[]\n evidence: EvidenceRef[]\n readiness: 'pending' | 'clear-request' | 'user-confirmed' | 'disclosed-assumptions' | 'cancelled' | 'stale'\n updatedAt: number\n}\nexport interface TaskCheckpoint {\n id: string\n sessionId: string\n sourceVersion: string\n contractVersion?: number\n fromSeq: number\n toSeq: number\n revision: number\n status: 'running' | 'completed' | 'failed' | 'cancelled'\n items: Array<{ label: string; state: 'pending' | 'verified' | 'failed'; evidence: EvidenceRef[] }>\n constraints: string[]\n nextAction: string\n createdAt: number\n}\nexport type KnowledgeScope = { kind: 'global' } | { kind: 'project'; projectId: string }\nexport type KnowledgeKind = 'preference' | 'project-fact' | 'decision' | 'vocabulary' | 'activity' | 'lesson'\n/** Descriptive context, never an executable instruction or authorization. */\nexport interface ContextKnowledge {\n subject: string\n domain: string\n key: string\n aliases: string[]\n observedAt: number\n /** The user's own time expression, not an inferred completion date. */\n eventTime?: string\n activityStatus?: 'planned' | 'in-progress' | 'blocked' | 'paused' | 'completed' | 'cancelled' | 'unknown'\n}\n/** A scoped method. Observations remain candidates until explicitly accepted. */\nexport interface ProcedureKnowledge {\n origin: 'instruction' | 'observation'\n goal: string\n when: string[]\n steps: string[]\n avoid: string[]\n verify: string[]\n}\nexport interface MemoryRecord {\n id: string\n revision: number\n scope: KnowledgeScope\n kind: KnowledgeKind\n status: 'candidate' | 'active' | 'rejected' | 'superseded' | 'revoked' | 'deleted'\n title: string\n content: string\n tags: string[]\n evidence: EvidenceRef[]\n exceptions: string[]\n source: 'user' | 'memory' | 'dream' | 'self-improvement'\n context?: ContextKnowledge\n procedure?: ProcedureKnowledge\n createdAt: number\n updatedAt: number\n expiresAt?: number\n supersedes?: string[]\n /** Exact record revisions behind a derived candidate; revalidated on adoption. */\n basis?: Array<{ id: string; revision: number }>\n}\nexport type NewMemoryRecord = Omit<MemoryRecord, 'id' | 'revision' | 'createdAt' | 'updatedAt'>\nexport interface MemoryQuery { scope: KnowledgeScope; query?: string; kinds?: KnowledgeKind[]; statuses?: MemoryRecord['status'][]; limit?: number }\nexport interface MemoryMutationOptions { signal?: AbortSignal; isCurrent?: () => boolean }\nexport interface MemoryService {\n list(query: MemoryQuery): Promise<MemoryRecord[]>\n create(record: NewMemoryRecord, options?: MemoryMutationOptions): Promise<MemoryRecord>\n update(id: string, patch: Partial<Pick<MemoryRecord, 'title' | 'content' | 'tags' | 'exceptions' | 'status' | 'expiresAt'>>, expectedRevision: number, options?: MemoryMutationOptions): Promise<MemoryRecord>\n /** Explicit user promotion, persisted atomically on the same record; preserves expiry and evidence. */\n promoteToGlobal(id: string, expectedRevision: number, options?: MemoryMutationOptions): Promise<MemoryRecord>\n remove(id: string, expectedRevision: number, options?: MemoryMutationOptions): Promise<void>\n recall(query: MemoryQuery): Promise<MemoryRecord[]>\n}\n\n/**\n * The session creation metadata the host snapshots when it creates a delegated child\n * thread. Mirrors `CreateAgentOptions.meta` in `@deepseek-ai/dsh-agent`; it is durable\n * session data, so it survives a restart and needs no ancestry walk.\n */\nexport interface SubagentSessionLike {\n readonly header?: {\n readonly parentSession?: unknown\n readonly origin?: unknown\n readonly delegationDepth?: unknown\n readonly isSeeded?: unknown\n readonly classification?: unknown\n }\n}\n\n/**\n * True when `session` is a delegated child thread rather than a human-driven top-level\n * conversation.\n *\n * A message's `source.kind === 'user'` cannot answer this: a lead agent's dispatch prompt\n * is delivered as the child's own user message, so delegated work is indistinguishable\n * from a person typing once you only look at the message. Plugins use this to keep\n * automatic writes and derived model calls on top-level sessions.\n */\nexport function isSubagentSession(session: unknown): boolean {\n const header = (session as SubagentSessionLike | null | undefined)?.header\n if (!header || typeof header !== 'object') return false\n if (header.origin === 'subagent' || Number(header.delegationDepth ?? 0) > 0) return true\n // Native human forks also persist parentSession for history lineage. A fork's\n // seeded header distinguishes it from legacy children whose parent is the\n // only marker. Native rc.2 forks omit depth; patched hosts may persist zero.\n // Explicit delegation and unknown metadata still keep the child guard.\n const humanFork = header.isSeeded === true\n && (header.delegationDepth === undefined || header.delegationDepth === 0)\n && header.origin === undefined\n && (header.classification === undefined || header.classification === 'ordinary' || header.classification === 'free')\n return Boolean(header.parentSession) && !humanFork\n}\n\n/** Project keys come only from the host-validated session directory, never client input. */\nexport function projectIdFromCwd(cwd: string | undefined): string | undefined {\n if (typeof cwd !== 'string') return undefined\n const normalized = cwd.trim().replaceAll('\\\\', '/')\n if (!normalized) return undefined\n return normalized === '/' || /^[A-Za-z]:\\/$/.test(normalized) ? normalized : normalized.replace(/\\/+$/, '')\n}\n\n/**\n * One settings owner's Remote stream. Typert accepts either case in an RPC\n * segment, so the Cordis service key and the wire namespace use the same\n * Pascal segment. The scope's first letter stays uppercase.\n */\nexport interface ModelSettingsChangesIdentity {\n readonly service: string\n readonly namespace: string\n}\n\n/** `@klarkxy/dsh-git-commit` becomes `KlarkxyDshGitCommitModelSettingsChanges`. */\nexport function modelSettingsChangesIdentity(packageName: string): ModelSettingsChangesIdentity {\n const scoped = /^@([^/]+)\\/(.+)$/.exec(packageName)\n const body = scoped ? `${scoped[1]}/${scoped[2]}` : packageName\n const parts = body.split(/[^A-Za-z0-9]+/).filter(Boolean)\n if (!parts.length) throw new Error('Model settings package name has no RPC segment')\n const segment = `${parts.map(part => part.charAt(0).toUpperCase() + part.slice(1)).join('')}ModelSettingsChanges`\n if (!/^[A-Z][A-Za-z0-9]*$/.test(segment)) throw new Error(`Model settings sync name is not an RPC segment: ${segment}`)\n return { service: segment, namespace: segment }\n}\n\n/**\n * Repository extension: a native web provider announces that its local\n * availability changed. Kind is `search` or `fetch`; id is the provider id.\n * Listeners refresh management state and must not treat this as a network probe.\n */\nexport const WEB_PROVIDER_AVAILABILITY_EVENT = 'web/provider-availability-updated' as const\n\n/**\n * Optional display metadata a provider may attach when it registers directly\n * with `ctx.web`. Execution and credentials stay with the provider; this object\n * is display-only and must never carry secret values.\n */\nexport interface DshWebManagementDescriptor {\n readonly id: string\n readonly label: string\n readonly description: string\n readonly defaultBaseURL?: string\n readonly credentialRef?: string\n /** True when the key is shared with another surface. The page must not delete it. */\n readonly credentialShared?: boolean\n /** Optional notice naming the settings surface that owns a shared credential. */\n readonly credentialHint?: string\n readonly billing: 'request' | 'model-and-tools' | 'none' | 'unknown'\n /** Optional provider-supplied billing summary. */\n readonly pricing?: string\n /** Public HTTPS page explaining provider charges. */\n readonly pricingUrl?: string\n /** Public HTTPS page where the user can create an API key. */\n readonly signupUrl?: string\n /** Plugin that owns configuration. Native providers keep their settings there. */\n readonly configurationOwner?: string\n /** Explicit settings link supplied by the provider, never inferred from its id. */\n readonly configurationUrl?: string\n /** Fixed legacy route migrated by a bundle-owned adapter; not used by native plugins. */\n readonly legacyId?: string\n}\n\n/**\n * Host Creator agent-preset id (`agentPresets.composedPreset`).\n * Plugins that gate Creator-only tools or prompt sections compare against this.\n */\nexport const CREATOR_PRESET_ID = 'cordis'\n\n/**\n * Shared \"Session Management\" settings section id. The section is provided by\n * shared infrastructure (see `registerSessionSettingsItem` in `client-utils`),\n * not by any one business plugin: every participant registers only a row into\n * {@link SESSION_SETTINGS_ITEM_SLOT}, so any enabled subset yields the same page.\n */\nexport const SESSION_SETTINGS_SECTION_ID = 'session-manager'\n\n/**\n * Child list slot declared by the shared Session Management page. Neutral\n * naming on purpose: participants never import each other, they only\n * contribute `{id, order}` rows into this slot while the page is alive.\n */\nexport const SESSION_SETTINGS_ITEM_SLOT = 'dsh.session-settings.item'\n\n/**\n * Host-owned nav icon seat: a root-scoped list where each entry's `id` must\n * equal the `settings.section` id it decorates. Owner props are\n * `{size, active}`; icons stay `aria-hidden` so the section label remains the\n * accessible name. Contributors into a shared section may register the same\n * icon `id` with different priorities — the ledger keeps every entry while the\n * host renders one icon per section.\n */\nexport const SETTINGS_SECTION_ICON_SLOT = 'settings.section.icon'\n\n/* Shared auxiliary-model default. Feature plugins may store a global default\n * route that fills the tier between their own saved override and the live\n * session model. The durable state is a root-context singleton (like the\n * shared session-settings page): it exists while any participant retains it\n * and is never owned by a business plugin. See `auxiliary-model.ts`. */\n\n/** Root context service key holding the shared auxiliary-model state. */\nexport const AUXILIARY_MODEL_SERVICE = 'dshAuxiliaryModel'\n\n/** Authenticated host-RPC channel for get/set of the shared default. */\nexport const AUXILIARY_MODEL_CHANNEL = '/dsh-auxiliary-model'\n\n/** Model-settings namespace under which the shared default is published. */\nexport const AUXILIARY_MODEL_NS = '@klarkxy/dsh-plugin-kit/auxiliary-model'\n\n/**\n * Typert identity of the shared change stream. Mounted on the root context\n * with ownerNs filtering, so frames only carry {@link AUXILIARY_MODEL_NS}.\n */\nexport const AUXILIARY_MODEL_CHANGES_IDENTITY = modelSettingsChangesIdentity('@klarkxy/dsh-plugin-kit')\n\n/** The value the shared default persists: `model: null` means follow the live session/host model. */\nexport interface AuxiliaryModelDefaults {\n readonly revision: number\n readonly model: ModelRoute | null\n}\n\n/** Shape of the root singleton; produced and owned by `auxiliary-model.ts`. */\nexport interface AuxiliaryModelShared {\n readonly ready: Promise<void>\n snapshot(): AuxiliaryModelDefaults\n}\n\nfunction sharedAuxiliaryModel(host: unknown): AuxiliaryModelShared | undefined {\n const root = (host as { root?: unknown } | undefined)?.root as { get?(name: string, strict?: boolean): unknown } | undefined\n try {\n const shared = root?.get?.(AUXILIARY_MODEL_SERVICE, false) as AuxiliaryModelShared | undefined\n return shared && typeof shared.snapshot === 'function' ? shared : undefined\n } catch { return undefined }\n}\n\n/**\n * Synchronously read the shared auxiliary default; `undefined` only when no\n * participant retains the singleton or the default is legitimately unset.\n * An initialization or snapshot failure propagates: silently falling back to\n * a different model after a storage error would spend the wrong budget.\n */\nexport function getAuxiliaryModel(host: unknown): ModelRoute | undefined {\n const shared = sharedAuxiliaryModel(host)\n if (!shared) return undefined\n return modelRouteOverride(shared.snapshot().model ?? undefined)\n}\n","import type { Context } from '@deepseek-ai/cordis'\nimport { createElement, useCallback, useEffect, useRef, useSyncExternalStore, type ReactNode } from 'react'\nimport { SESSION_SETTINGS_ITEM_SLOT, SESSION_SETTINGS_SECTION_ID, SETTINGS_SECTION_ICON_SLOT } from './contracts.ts'\nimport type { PluginLogger } from './log-shared.ts'\n\n/** Fixed pause for failing background reads; manual work is never replayed. */\nexport function createPluginReadGate(now: () => number = Date.now, logger?: PluginLogger) {\n let pausedUntil = 0\n let epoch = 0\n return {\n canRead: () => now() >= pausedUntil,\n reset: () => { epoch++; pausedUntil = 0 },\n async run<T>(read: () => Promise<T>): Promise<T> {\n const current = epoch\n try {\n const value = await read()\n if (current === epoch) {\n if (pausedUntil > 0) logger?.debug('read-gate.resumed', 'Background read gate recovered.')\n pausedUntil = 0\n }\n return value\n } catch (error) {\n // The native Connection error is an Error with this exact HTTP text.\n // Authentication, application failures, and cancellation stay distinct.\n const message = error instanceof Error ? error.message : ''\n if (current === epoch && (/(?:^|\\s)transport failure for .+: HTTP (?:404|405|503)\\b/.test(message)\n || (error instanceof TypeError && /^(?:Failed to fetch|fetch failed|NetworkError when attempting to fetch resource\\.?)$/i.test(message)))) {\n pausedUntil = now() + 30_000\n logger?.warn('read-gate.paused', 'Background reads paused for 30s after transport failure.', error)\n }\n throw error\n }\n },\n }\n}\n\nexport interface NativeSurfaceClient {\n sessions: {\n binding?(sessionId: string): { eventSource: { subscribe(listener: () => void): () => void } } | undefined\n }\n uiWorkspace: { current?: { getSnapshot(): { sessionId: string } | undefined; subscribe(listener: () => void): () => void } }\n uiSession: { adapter: { current: { getSnapshot(): { key?: string }; subscribe(listener: () => void): () => void } } }\n locale: { getSnapshot(): { active: string }; subscribe(listener: () => void): () => void }\n connection?: { generation?: { subscribe(listener: () => void): () => void } }\n}\n\n/** The Editor retains its manuscript session separately; native DSH exposes the main-view binding. */\nexport function selectedSessionId(client: Pick<NativeSurfaceClient, 'uiWorkspace' | 'uiSession'>): string {\n const workspace = client.uiWorkspace?.current\n return workspace\n ? workspace.getSnapshot()?.sessionId ?? ''\n : client.uiSession.adapter.current.getSnapshot().key ?? ''\n}\n\n/**\n * Owner props are data the host composed, never a Cordis context: reading an\n * undeclared property off one throws instead of returning undefined, which\n * would crash the slot entry and abdicate its cell for good. Tolerate a\n * throwing read so a mistaken prop degrades to \"not supplied\".\n */\nfunction read(source: unknown, key: string): unknown {\n if (source === null || typeof source !== 'object') return undefined\n try {\n return (source as Record<string, unknown>)[key]\n } catch {\n return undefined\n }\n}\n\nfunction readString(source: unknown, key: string): string | undefined {\n const value = read(source, key)\n return typeof value === 'string' ? value : undefined\n}\n\n/** Owner props win; native settings only supplies close, so resolve its selected session. */\nexport function useNativeSeat(client: NativeSurfaceClient, props?: unknown) {\n const current = useSyncExternalStore(\n useCallback((fn: () => void) => (client.uiWorkspace?.current ?? client.uiSession.adapter.current).subscribe(fn), [client]),\n useCallback(() => selectedSessionId(client), [client]),\n () => '',\n )\n const language = useSyncExternalStore(\n useCallback((fn: () => void) => client.locale.subscribe(fn), [client]),\n useCallback(() => client.locale.getSnapshot().active, [client]),\n () => 'en',\n )\n const sessionId = readString(props, 'sessionId') ?? readString(read(props, 'owner'), 'sessionId') ?? current\n const requestedLocale = read(props, 'locale') ?? read(read(props, 'owner'), 'locale') ?? language\n return { sessionId, locale: (String(requestedLocale).startsWith('zh') ? 'zh' : 'en') as 'zh' | 'en',\n hidden: read(props, 'hidden') === true || read(read(props, 'owner'), 'hidden') === true }\n}\n\n/** Refresh on native log boundaries/reconnect/focus. Read-only settling is bounded to an observed job. */\nexport function useFeatureRefresh(\n client: NativeSurfaceClient, sessionId: string, refresh: () => void,\n working = false, enabled = true,\n): void {\n const refreshRef = useRef(refresh)\n refreshRef.current = refresh\n useEffect(() => {\n if (!enabled) return\n let timer: ReturnType<typeof setTimeout> | undefined\n const queue = () => {\n if (typeof document !== 'undefined' && document.visibilityState === 'hidden') return\n clearTimeout(timer)\n timer = setTimeout(() => refreshRef.current(), 150)\n }\n const source = sessionId ? client.sessions.binding?.(sessionId)?.eventSource : undefined\n const stopEvents = source?.subscribe(queue)\n const stopConnection = client.connection?.generation?.subscribe(queue)\n const visibility = () => { if (document.visibilityState === 'visible') queue() }\n window.addEventListener('focus', queue)\n document.addEventListener('visibilitychange', visibility)\n // Details are collapsed by default; opening an existing panel must get current state.\n document.addEventListener('toggle', queue, true)\n return () => {\n clearTimeout(timer)\n stopEvents?.(); stopConnection?.()\n window.removeEventListener('focus', queue)\n document.removeEventListener('visibilitychange', visibility)\n document.removeEventListener('toggle', queue, true)\n }\n }, [client, sessionId, enabled])\n useEffect(() => {\n if (!enabled || !working) return\n let delay = 250\n const until = Date.now() + 300_000\n let timer: ReturnType<typeof setTimeout>\n const tick = () => {\n if (Date.now() >= until) return\n if (document.visibilityState !== 'hidden') refreshRef.current()\n delay = Math.min(delay * 2, 2000)\n timer = setTimeout(tick, delay)\n }\n timer = setTimeout(tick, delay)\n return () => clearTimeout(timer)\n }, [client, sessionId, working, enabled])\n}\n\n/* Shared \"Session Management\" settings page. The page is root-owned shared\n * infrastructure, not a business plugin: any participant alone yields the same\n * section, and participants never import each other. Synchronization crosses\n * separately bundled copies of this helper through the Cordis root context —\n * `root.get`/`root.provide` is the only rendezvous, so no window global or\n * module singleton is needed and no participant depends on another being enabled.\n */\n\n/** A row contributed into the shared Session Management page. */\nexport interface SessionSettingsItemSpec {\n readonly id: string\n readonly order: number\n}\n\n/* Original line icons for settings-section navigation seats. The official\n * `dsh-client-ui-primitives` icon set covers generic glyphs only; these keep\n * the same conventions (16×16 viewBox, 1px stroke, round caps, currentColor)\n * so the plugin set stays visually consistent with the native nav. Colors\n * never appear here: `currentColor` lets the host style the active state, and\n * `aria-hidden` keeps the section label the single accessible name. */\n\n/** Owner props the host's `settings.section.icon` seat hands to its cell. */\nexport interface SettingsSectionIconProps {\n readonly size?: number\n /** Selection state; the nav styles active icons through color, not geometry. */\n readonly active?: boolean\n}\n\ntype IconChild = readonly [tag: string, attrs: Record<string, string | number>]\n\n/** One `<svg>` with the shared icon chrome; children are plain elements. */\nfunction lineIcon(children: IconChild[]) {\n return function SettingsSectionIcon(props: SettingsSectionIconProps): ReactNode {\n return createElement('svg', {\n 'aria-hidden': 'true',\n width: props.size ?? 16,\n height: props.size ?? 16,\n viewBox: '0 0 16 16',\n fill: 'none',\n stroke: 'currentColor',\n strokeWidth: 1,\n strokeLinecap: 'round',\n strokeLinejoin: 'round',\n }, ...children.map(([tag, attrs], index) => createElement(tag, { key: index, ...attrs })))\n }\n}\n\n/** Chat bubble for the shared Session Management section. */\nexport const IconSessionSettings = lineIcon([\n ['path', { d: 'M8.5 13a5.5 5.5 0 0 0 5.5-5.5A5.5 5.5 0 0 0 8.5 2 5.5 5.5 0 0 0 3 7.5a5.48 5.48 0 0 0 .9 3L2.8 12.6a.5.5 0 0 0 .62.62l2.9-.98a5.48 5.48 0 0 0 2.18.76Z' }],\n])\n\n/** Serif-flavoured letter A for the Font section. */\nexport const IconFontSettings = lineIcon([\n ['path', { d: 'M3.3 12.6 7.9 3.1a.5.5 0 0 1 .9 0l4.6 9.5' }],\n ['path', { d: 'M5.2 9.4h6.3' }],\n ['path', { d: 'M2.4 12.6h2.4' }],\n ['path', { d: 'M11.9 12.6h2.4' }],\n])\n\n/** Keyboard for the Shortcuts section. */\nexport const IconKeyboardSettings = lineIcon([\n ['rect', { x: 1.75, y: 4.75, width: 12.5, height: 7.5, rx: 1.2 }],\n ['path', { d: 'M4.5 7.25h0' }],\n ['path', { d: 'M8 7.25h0' }],\n ['path', { d: 'M11.5 7.25h0' }],\n ['path', { d: 'M5.25 9.75h5.5' }],\n])\n\n/** Linked model nodes for the Model Management section. */\nexport const IconModelNetworkSettings = lineIcon([\n ['line', { x1: 10.6, y1: 5.3, x2: 8.8, y2: 7.1 }],\n ['line', { x1: 7.2, y1: 8.9, x2: 5.4, y2: 10.7 }],\n ['circle', { cx: 12, cy: 4, r: 1.9 }],\n ['circle', { cx: 4, cy: 12, r: 1.9 }],\n ['circle', { cx: 8, cy: 8, r: 1.5 }],\n])\n\n/**\n * Contribute the nav icon of a `settings.section` entry. The `settings\n * .section.icon` seat is declared by the host independently of the section\n * list, so the wait runs in parallel: the icon appears as soon as both seats\n * exist and unloading removes it again, restoring the host's default glyph.\n * The `id` must equal the section id; `order`/`priority` mirror `order` so the\n * icon cell sorts like its section and, for shared sections, several\n * contributors can register the same icon id under different priorities\n * without duplicating nav entries.\n */\nexport function registerSettingsSectionIcon(\n ctx: Context,\n sectionId: string,\n order: number,\n component: (props: SettingsSectionIconProps) => ReactNode,\n): () => void {\n const slots = (ctx as unknown as { slots: SessionSettingsSlots }).slots\n return slots.inject(SETTINGS_SECTION_ICON_SLOT, () =>\n slots.register({ name: SETTINGS_SECTION_ICON_SLOT, id: sectionId, order, priority: order }, component))\n}\n\ninterface SessionSettingsSlots {\n inject(key: string, callback: () => Iterable<(() => void) | void> | (() => void) | void): () => void\n register(spec: Record<string, unknown>, render: unknown): () => void\n}\n\ninterface SessionSettingsRoot {\n get(name: string, strict?: boolean): unknown\n provide(name: string, value: unknown): () => void\n readonly slots?: SessionSettingsSlots\n}\n\n/** Private Cordis rendezvous; every bundled copy of this helper resolves the same root service. */\nconst SESSION_SETTINGS_PAGE_SERVICE = 'dshSessionSettingsPage'\n\ninterface SessionSettingsPage {\n retain(): void\n release(): void\n}\n\n/** The page component renders only its declared child list: items paint their own titles and styles. */\nfunction SessionSettingsPageView(props: { renderSlot: (key: string, owner: Record<string, never>) => ReactNode }): ReactNode {\n return props.renderSlot(SESSION_SETTINGS_ITEM_SLOT, {})\n}\n\n/**\n * Acquire the root-owned page service, creating and providing it on first use.\n * One counter covers participants, the section wait and the provider: the last\n * release removes the wait and then the provider synchronously (Cordis deletes\n * the impl before its async disposer awaits), so a later acquire sees a clean\n * get() miss and can re-establish the page.\n */\nfunction acquireSessionSettingsPage(root: SessionSettingsRoot): SessionSettingsPage {\n const existing = root.get(SESSION_SETTINGS_PAGE_SERVICE, false) as SessionSettingsPage | undefined\n if (existing) return existing\n const slots = root.slots as SessionSettingsSlots\n let users = 0\n let stopPage: (() => void) | undefined\n let unprovide: (() => void) | undefined\n const page: SessionSettingsPage = {\n retain() {\n // The reservation is counted before the throwing install, so a failure\n // lets the caller's release() undo it fully instead of leaking the service.\n users += 1\n if (!stopPage) {\n stopPage = slots.inject('settings.section', () => slots.register(\n {\n name: 'settings.section',\n id: SESSION_SETTINGS_SECTION_ID,\n order: 30,\n label: () => {\n const locale = root.get('locale', false) as { getSnapshot?(): { active?: unknown } } | undefined\n return String(locale?.getSnapshot?.().active ?? '').startsWith('zh') ? '会话管理' : 'Session Management'\n },\n children: { [SESSION_SETTINGS_ITEM_SLOT]: { kind: 'list', scope: 'root' } },\n },\n SessionSettingsPageView,\n ))\n }\n },\n release() {\n if (users <= 0) return\n users -= 1\n if (users > 0) return\n // The last contributor tears the section down; collapsing its children\n // declaration clears the item slot for every other bundle as well.\n stopPage?.()\n stopPage = undefined\n unprovide?.()\n },\n }\n unprovide = root.provide(SESSION_SETTINGS_PAGE_SERVICE, page)\n return page\n}\n\n/**\n * Contribute one row to the shared Session Management settings page.\n *\n * `ctx` is the plugin's own context: the row's slot wait unloads with the\n * plugin, while the page itself is retained on the shared root context for as\n * long as any contributor lives. There is no fallback seat — when every\n * contributor is gone the section disappears with the page. Returns a disposer.\n * Shared root-owned infrastructure (the auxiliary-model card) calls this on\n * `ctx.root` so its row, icon and page share are owned by the root lifetime\n * and released by the returned disposer, not by any plugin fiber.\n */\nexport function registerSessionSettingsItem(\n ctx: Context,\n item: SessionSettingsItemSpec,\n component: (props: never) => ReactNode,\n): () => void {\n const slots = (ctx as unknown as { slots: SessionSettingsSlots }).slots\n const root = ctx.root as unknown as SessionSettingsRoot\n const page = acquireSessionSettingsPage(root)\n let stopItem: (() => void) | undefined\n let stopIcon: (() => void) | undefined\n try {\n page.retain()\n stopItem = slots.inject(SESSION_SETTINGS_ITEM_SLOT, () => slots.register({ name: SESSION_SETTINGS_ITEM_SLOT, ...item }, component))\n // Every contributor also waits on the nav-icon seat, registering the same\n // section icon id under its own priority (its row order). Same-id entries\n // coexist on the ledger while the host renders one icon, so no contributor\n // owns the icon and none depends on another for it; the wait lives with\n // this ctx, so it fires now on fresh loads and retro-fills on HMR.\n stopIcon = slots.inject(SETTINGS_SECTION_ICON_SLOT, () => slots.register(\n { name: SETTINGS_SECTION_ICON_SLOT, id: SESSION_SETTINGS_SECTION_ID, order: item.order, priority: item.order },\n IconSessionSettings,\n ))\n } catch (error) {\n // A synchronous failure (for example a duplicate row id or a failing page\n // install) must not pin the shared page for a contributor that never joined.\n stopIcon?.()\n stopItem?.()\n page.release()\n throw error\n }\n // The disposer may be invoked by both ctx.effect and an explicit caller;\n // releasing twice would unbalance the shared refcount.\n let disposed = false\n return () => {\n if (disposed) return\n disposed = true\n stopIcon?.()\n stopItem?.()\n page.release()\n }\n}\n","/**\n * Shared `klarkxy.model-picker` Factory contract.\n *\n * `@klarkxy/dsh-model-picker` registers one root-scoped Component Factory under\n * this name: a searchable model picker with a reasoning-effort slider, built on\n * the same ModelMenu recipe this package ships. Feature plugins opt in by\n * calling `renderFactorySlot('klarkxy.model-picker', props, options)` inside a\n * slot component; when no definition is registered the renderer resolves the\n * caller's `options.fallback`, so each consumer keeps its own native menu as\n * the fallback and gains the shared picker only while the plugin is installed.\n *\n * This entry is pure types and constants — no React, no host imports — so a\n * consumer can `import type` the declaration and the input/local props without\n * depending on the business plugin at runtime. The `SlotFactoryMap` merge is\n * what makes the `renderFactorySlot`/`registerFactory` calls type-check on\n * both sides; import it for the types only.\n */\nimport type { ModelMenuChoice, ModelCatalogFailure } from './catalog.ts'\nimport type { HostObservable } from '@deepseek-ai/dsh-client-ui-slots'\n\n/** Registered Factory name — the `renderFactorySlot`/`registerFactory` key. */\nexport const MODEL_PICKER_FACTORY = 'klarkxy.model-picker'\n/** The one caller-selectable local position: the trigger rendered in place. */\nexport const MODEL_PICKER_ANCHOR_SLOT = 'anchor'\n\n/** Extra row the picker renders above the model groups (pure data; no React). */\nexport interface ModelPickerLeadingItem {\n readonly id: string\n readonly label: string\n readonly selected?: boolean\n}\n\n/** Status banner data the picker renders inside the menu header, above the groups. */\nexport interface ModelPickerStatus {\n /** Whole-request failure text; renders with a retry action. */\n readonly error?: string | null\n /** Advisory row (e.g. the saved route left the catalog); rendered warn-toned, no retry. */\n readonly warning?: string\n /** Whether the owner is loading or selecting (dims the banner). */\n readonly busy?: boolean\n /** Provider-local failures; still usable groups stay selectable. */\n readonly failures?: readonly ModelCatalogFailure[]\n /** Reload action the banner's retry buttons call. */\n readonly retry?: () => void\n}\n\n/**\n * Occurrence input (`renderFactorySlot` `props`). Everything here is data or\n * callbacks — React content travels through the `anchor` local slot instead.\n */\nexport interface ModelPickerProps {\n /** Active UI language; `'zh*'` selects the built-in Chinese copy. */\n readonly locale?: string\n /** Flat catalog choices (grouped internally by provider). */\n readonly choices: readonly ModelMenuChoice[]\n /** Current selection highlight. */\n readonly selected?: { readonly provider: string; readonly model: string }\n /** Model pick; the picker closes after the callback runs. */\n readonly onPick: (route: { provider: string; model: string }) => void\n /** Extra rows above the model groups (e.g. a \"follow default\" row). */\n readonly leading?: readonly ModelPickerLeadingItem[]\n /** Leading-row pick; `undefined` keeps the menu open. */\n readonly onPickLeading?: (id: string) => void\n /** Declared reasoning-effort rows; the slider is hidden while empty. */\n readonly efforts?: ReadonlyArray<{ id: string; name: string }>\n /** Current effort id; `''`/undefined marks the provider-default row. */\n readonly selectedEffort?: string\n /** Effort pick; the menu stays open. `undefined` = provider default. */\n readonly onPickEffort?: (effort: string | undefined) => void\n /** Disables the trigger and every menu action. */\n readonly disabled?: boolean\n /** Trigger caption; the default anchor falls back to localized \"Select model\". */\n readonly triggerLabel?: string\n /** Current effort caption shown after the trigger label (\"model · high\"). */\n readonly triggerEffortLabel?: string\n /** Extra class on the default trigger button. */\n readonly triggerClassName?: string\n /** Show a spinner instead of the chevron while a selection settles. */\n readonly busy?: boolean\n /** Extra class on the portaled menu card. */\n readonly listClassName?: string\n /** Menu opens on the searchable model pane ('model') or the root cells. */\n readonly initialPane?: 'root' | 'model'\n /** Show the search row even for a small catalog. */\n readonly alwaysShowSearch?: boolean\n /** Show the reasoning-effort slider under the model list (default true here). */\n readonly reasoningSlider?: boolean\n /** Status banner rendered inside the menu header (load failures, retry). */\n readonly status?: ModelPickerStatus\n /** Menu open-state changes; the owner may react (e.g. refresh the catalog). */\n readonly onOpenChange?: (open: boolean) => void\n /** Copy overrides; every key is optional. */\n readonly modelLabel?: string\n readonly modelValue?: string\n readonly effortLabel?: string\n readonly defaultEffortLabel?: string\n readonly searchPlaceholder?: string\n readonly emptyLabel?: string\n readonly clearSearchLabel?: string\n readonly retryLabel?: string\n}\n\n/** Props one `anchor` local component receives (plus the framework kit). */\nexport interface ModelPickerAnchorProps {\n /** Mirror of `aria-expanded`; true while the menu is open. */\n readonly open: boolean\n /** Disabled state passed down by the owner. */\n readonly disabled: boolean\n /** Whether a selection is settling; the default anchor shows a spinner. */\n readonly busy: boolean\n /** Resolved trigger caption. */\n readonly label: string\n /** Resolved effort caption appended to the caption, if any. */\n readonly effortLabel?: string\n /** Extra class on the trigger element. */\n readonly className?: string\n /** Anchored-popup marker the picker stamps on the trigger (always 'menu'). */\n readonly 'aria-haspopup'?: 'menu'\n /** Mirror of `open`, for ARIA-compliant custom anchors. */\n readonly 'aria-expanded'?: boolean\n /** Menu element id while the menu is mounted. */\n readonly 'aria-controls'?: string\n /** Resolved accessible name for the trigger. */\n readonly 'aria-label'?: string\n /** Set when the picker is disabled; custom anchors may read it instead of `disabled`. */\n readonly 'aria-disabled'?: boolean\n}\n\ndeclare module '@deepseek-ai/dsh-client-ui-slots' {\n interface SlotFactoryMap {\n /**\n * Reusable model picker: one searchable provider-grouped model list plus an\n * optional reasoning-effort slider. Consumers call `renderFactorySlot` with\n * `ModelPickerProps`; `options.slots.anchor` may supply a custom trigger\n * component typed `ModelPickerAnchorProps`, and `options.fallback` is the\n * menu rendered while no `klarkxy.model-picker` definition is registered.\n */\n 'klarkxy.model-picker': {\n scope: 'root'\n props: ModelPickerProps\n /** Occurrence inject face: the active-locale observable bound as a hook. */\n inject: { hooks: { activeLocale: HostObservable<{ active: string }> } }\n slots: {\n anchor: {\n scope: 'root'\n props: ModelPickerAnchorProps\n }\n }\n locale: 'model-picker'\n }\n }\n interface LocaleNamespaceMap {\n /** Copy owned by @klarkxy/dsh-model-picker. */\n 'model-picker':\n | 'trigger.fallback' | 'trigger.aria' | 'trigger.ariaEffort'\n | 'menu.model' | 'menu.effort' | 'effort.providerDefault'\n | 'search.placeholder' | 'search.clear' | 'search.empty' | 'empty.models'\n | 'status.loading' | 'error.action' | 'action.retry' | 'warning.unroutable'\n }\n}\n","/**\n * Optional shared model picker (`klarkxy.model-picker` Factory).\n *\n * `@klarkxy/dsh-model-picker`, when installed, registers one root-scoped\n * Component Factory under `MODEL_PICKER_FACTORY`: an enhanced model menu with\n * a searchable provider-grouped list and a reasoning-effort slider, built on\n * the same ModelMenu recipe. Consumers keep their own ModelMenu as the\n * `fallback`; when no definition is registered the renderer resolves that\n * fallback verbatim, so the shared picker is strictly opt-in and every saved\n * value keeps its existing write path.\n *\n * `renderFactorySlot` is a framework-composed prop, never a context: the\n * component a plugin registers into any slot receives it automatically, but\n * the plugin must pass it down to whichever child renders the menu (or to the\n * render callback handed to registerSessionSettingsItem).\n *\n * The Factory manages its own open state; a consumer's `open`/`onOpenChange`\n * pair belongs to the fallback menu only and must not be fed to both.\n */\nimport { useEffect, useMemo, useRef, type ReactNode } from 'react'\nimport { IconChevronDownOutlineRegular } from '@deepseek-ai/dsh-client-ui-primitives'\nimport type { RenderFactorySlot } from '@deepseek-ai/dsh-client-ui-slots'\nimport {\n MODEL_PICKER_FACTORY, MODEL_PICKER_ANCHOR_SLOT,\n type ModelPickerAnchorProps, type ModelPickerProps,\n} from '@klarkxy/dsh-model-route/model-picker'\n\nexport {\n MODEL_PICKER_ANCHOR_SLOT,\n MODEL_PICKER_FACTORY,\n type ModelPickerAnchorProps,\n type ModelPickerLeadingItem,\n type ModelPickerProps,\n type ModelPickerStatus,\n} from '@klarkxy/dsh-model-route/model-picker'\nexport type { RenderFactorySlot } from '@deepseek-ai/dsh-client-ui-slots'\n\n/**\n * The trigger every consumer used to hand its own ModelMenu, rebuilt as the\n * factory's `anchor` local component: identical classes and chevron, the menu\n * state coming from the occurrence's props instead of local open state.\n *\n * `ariaLabel` and `title` are the whole accessible name and tooltip (the\n * caller formats \"field: current route\" itself because the factory's resolved\n * caption may intentionally be a short name). The component identity stays\n * put across label changes — a new function would unmount the trigger, and\n * its cleanup would close a menu that `closeOnPick={false}` is keeping open.\n * The latest label, title, and `onClose` are read from refs.\n */\nexport function useModelMenuAnchor(ariaLabel: string, title?: string, onClose?: () => void): (props: ModelPickerAnchorProps) => ReactNode {\n const closeRef = useRef(onClose)\n const labelRef = useRef(ariaLabel)\n const titleRef = useRef(title)\n closeRef.current = onClose\n labelRef.current = ariaLabel\n titleRef.current = title\n return useMemo(() => {\n const ModelPickerTrigger = (props: ModelPickerAnchorProps): ReactNode => {\n /* A real unmount means the factory occurrence left (definition unloaded\n * or the row closed). `onOpenChange` only tracks user-driven opens, so\n * without this the fallback's shared open state could stay true. */\n useEffect(() => () => closeRef.current?.(), [])\n /* The factory injects its own aria set (aria-controls among them) plus\n * the caller's triggerClassName into the local component's props.\n * Forward exactly those attributes — a blanket {...props} spread would\n * leak framework props (including renderFactorySlot) onto the DOM. The\n * caller's label/title win over any injected aria-label; popup semantics\n * default to the mirror of the fallback trigger and yield to injected\n * values when present. */\n const record = props as unknown as Record<string, unknown>\n const injected: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(record)) {\n if (key.startsWith('aria-')) injected[key] = value\n }\n const extraClass = typeof record.className === 'string' ? ` ${record.className}` : ''\n return (\n <button\n type=\"button\"\n className={`dsh-model-menu-trigger${extraClass}`}\n disabled={props.disabled}\n aria-haspopup=\"menu\"\n aria-expanded={props.open}\n {...injected}\n aria-label={labelRef.current}\n title={titleRef.current}\n >\n <span className=\"dsh-model-menu-triggerLabel\">{props.label}</span>\n {props.effortLabel ? <span className=\"dsh-model-menu-triggerEffort\">{props.effortLabel}</span> : null}\n <IconChevronDownOutlineRegular className={`dsh-model-menu-chevron${props.open ? ' dsh-model-menu-chevronOpen' : ''}`} />\n </button>\n )\n }\n return ModelPickerTrigger\n }, [])\n}\n\n/**\n * Render the shared model picker while it is registered; `options.fallback`\n * whenever it is not (plugin absent, disabled, or unloaded).\n *\n * `options.anchor` is optional: the factory ships a default trigger, so only\n * consumers that need their own chrome (custom aria-label, tooltip, class)\n * pass one built with {@link useModelMenuAnchor}. The returned node is never\n * assumed to be the factory's own output — a defensive `?? fallback` covers a\n * renderer that yields null for an unregistered definition.\n */\nexport function renderModelPicker(\n renderFactorySlot: RenderFactorySlot | undefined,\n props: ModelPickerProps,\n options: {\n readonly anchor?: (props: ModelPickerAnchorProps) => ReactNode\n readonly fallback: ReactNode\n },\n): ReactNode {\n if (typeof renderFactorySlot !== 'function') return options.fallback\n const rendered = renderFactorySlot(MODEL_PICKER_FACTORY, props, {\n ...(options.anchor ? { slots: { [MODEL_PICKER_ANCHOR_SLOT]: options.anchor } } : {}),\n fallback: options.fallback,\n })\n return rendered ?? options.fallback\n}\n","import type { TypertRemoteContribution } from '@deepseek-ai/dsh-typert-protocol'\nimport { modelSettingsChangesIdentity, type ModelSettingsChangesIdentity } from './contracts.ts'\n\nexport type ModelSettingsChangeFrame = { kind: 'ready' } | { kind: 'changed'; ns: string; revision: number }\n\n/** This stream carries invalidations only; ready is never a settings snapshot. */\nexport function parseModelSettingsChangeFrame(value: unknown): ModelSettingsChangeFrame {\n if (!value || typeof value !== 'object' || Array.isArray(value)) throw new Error('Invalid model settings change frame')\n const frame = value as Record<string, unknown>\n if (frame.kind === 'ready' && Object.keys(frame).length === 1) return { kind: 'ready' }\n if (frame.kind === 'changed' && Object.keys(frame).length === 3 && typeof frame.ns === 'string' && frame.ns.length > 0\n && typeof frame.revision === 'number' && Number.isSafeInteger(frame.revision) && frame.revision >= 0) {\n return { kind: 'changed', ns: frame.ns, revision: frame.revision }\n }\n throw new Error('Invalid model settings change frame')\n}\n\n/** One owner's contribution. Each package mounts only its own endpoint. */\nexport function modelSettingsChangesRemote(packageName: string, identity: ModelSettingsChangesIdentity = modelSettingsChangesIdentity(packageName)): TypertRemoteContribution {\n return {\n package: packageName,\n descriptors: [{\n id: `${identity.namespace}/watch`,\n service: identity.service,\n namespace: identity.namespace,\n method: 'watch',\n mode: 'stream' as const,\n invocation: { kind: 'direct' as const },\n parameters: [],\n cancellation: { parameter: 'signal' as const },\n result: { mode: 'strict' as const, typeSymbol: 'ModelSettings.ChangeFrame', create: () => ({ parse: parseModelSettingsChangeFrame }) },\n }],\n }\n}\n\ninterface RemoteMountScope {\n remote: { $mount(contribution: TypertRemoteContribution): Promise<() => Promise<void>> }\n effect(callback: () => () => void | Promise<void>): unknown\n}\ninterface RemoteMountContext {\n inject(dependencies: string[], callback: (scope: unknown) => void): unknown\n}\n\n/** Mount from a synchronous apply. Disposal waits for an in-flight mount and\n * then withdraws it, so the contribution cannot outlive the plugin. */\nexport function mountModelSettingsChanges(ctx: RemoteMountContext, packageName: string): void {\n const contribution = modelSettingsChangesRemote(packageName)\n ctx.inject(['remote'], injected => {\n const scope = injected as RemoteMountScope\n const mounting = scope.remote.$mount(contribution)\n void mounting.catch(() => {})\n scope.effect(() => async () => {\n const unmount = await mounting.catch(() => undefined)\n await unmount?.()\n })\n })\n}\n\ninterface StreamItem {\n generation: number\n value: unknown\n signal: AbortSignal\n accept(): void\n}\ninterface ChangeStream extends AsyncIterable<StreamItem> { dispose(): Promise<void> }\ntype OpenChangeStream = (options: {\n name: string\n open(signal: AbortSignal): AsyncIterable<unknown>\n ended(accepted: boolean): Error\n}) => ChangeStream\nexport interface ModelSettingsSubscriberScope {\n remote: { $stream: OpenChangeStream } & Record<string, { watch?(signal: AbortSignal): AsyncIterable<unknown> } | OpenChangeStream | undefined>\n effect(callback: () => () => void | Promise<void>): unknown\n}\nexport interface ModelSettingsSubscriberContext {\n inject(dependencies: string[], callback: (scope: unknown) => void): unknown\n}\nexport interface ModelSettingsSubscriber {\n subscribe(onChange: () => void, onError?: (message: string) => void): () => void\n}\n\n/** Native RemoteStream owns carrier reconnects; no timers or browser transport.\n * A factory shares one logical stream while at least one subscriber remains. */\nexport function createModelSettingsSubscriber(\n ctx: ModelSettingsSubscriberContext,\n packageName: string,\n identity: ModelSettingsChangesIdentity = modelSettingsChangesIdentity(packageName),\n accept: (ns: string) => boolean = ns => ns === packageName,\n): ModelSettingsSubscriber {\n const endpoint = identity\n const listeners = new Set<{ change: () => void; error?: (message: string) => void }>()\n let injection: { dispose(): void | Promise<void> } | undefined\n let current: { stream: ChangeStream; active: boolean } | undefined\n let lifecycle = 0\n let failureMessage: string | undefined\n const report = (message: string) => {\n failureMessage = message\n for (const listener of [...listeners]) {\n try { listener.error?.(message) } catch { /* Isolate page callbacks. */ }\n }\n }\n const invalidate = () => {\n for (const listener of [...listeners]) {\n if (!listeners.has(listener)) continue\n try { listener.change() } catch (error) {\n try { listener.error?.(error instanceof Error ? error.message : String(error)) } catch { /* Isolate callbacks. */ }\n }\n }\n }\n const start = () => {\n const life = ++lifecycle\n injection = ctx.inject(['remote', `remote.${endpoint.namespace}`], injected => {\n if (life !== lifecycle || !listeners.size) return\n const scope = injected as ModelSettingsSubscriberScope\n const service = scope.remote[endpoint.namespace]\n if (!service || !('watch' in service) || !service.watch) { report('Model settings sync service unavailable'); return }\n const watch = service.watch\n const stream = scope.remote.$stream({\n name: 'Model settings sync',\n open: signal => watch(signal),\n ended: accepted => new Error(`Model settings sync stream ended ${accepted ? 'after' : 'before'} ready; refresh or reopen the page`),\n })\n const session = { stream, active: true }\n current = session\n scope.effect(() => () => {\n session.active = false\n if (current === session) {\n current = undefined\n if (life === lifecycle && listeners.size) report('Model settings sync service unavailable')\n }\n return stream.dispose()\n })\n void (async () => {\n let generation: number | undefined\n let ready = false\n try {\n for await (const item of stream) {\n if (!session.active || life !== lifecycle || !listeners.size) break\n if (item.signal.aborted) continue\n if (generation !== item.generation) { generation = item.generation; ready = false }\n const frame = parseModelSettingsChangeFrame(item.value)\n if (frame.kind === 'ready') {\n ready = true\n failureMessage = undefined\n // Accept the validated invalidation baseline, not fetched data.\n // Every current listener queues its own latest settings read.\n item.accept()\n invalidate()\n } else {\n if (!ready) throw new Error('Model settings sync change arrived before ready')\n if (accept(frame.ns)) invalidate()\n }\n }\n } catch (error) {\n if (session.active && life === lifecycle) report(error instanceof Error ? error.message : String(error))\n } finally {\n if (current === session) current = undefined\n session.active = false\n await stream.dispose().catch(() => {})\n }\n })()\n }) as { dispose(): void | Promise<void> }\n queueMicrotask(() => {\n if (life === lifecycle && listeners.size && !current) report('Model settings sync service unavailable')\n })\n }\n return Object.freeze({ subscribe(onChange: () => void, onError?: (message: string) => void) {\n const listener = { change: onChange, error: onError }\n listeners.add(listener)\n if (!injection) start()\n else if (failureMessage) queueMicrotask(() => {\n if (listeners.has(listener) && failureMessage) {\n try { listener.error?.(failureMessage) } catch { /* Isolate callbacks. */ }\n }\n })\n return () => {\n if (!listeners.delete(listener) || listeners.size) return\n lifecycle++\n if (current) { current.active = false; void current.stream.dispose().catch(() => {}) }\n current = undefined\n failureMessage = undefined\n const previous = injection\n injection = undefined\n try { void Promise.resolve(previous?.dispose()).catch(() => {}) } catch { /* Already unloaded. */ }\n }\n } })\n}\n","/**\n * Shared \"default auxiliary model\" settings card.\n *\n * Any number of feature plugins call `registerAuxiliaryModelSettings(ctx)`\n * from their client half; a single card appears as the `auxiliary-model` row\n * of the shared Session Management settings column for as long as at least\n * one participant lives. The card is root-owned shared infrastructure, not a\n * business plugin: every bundled copy of this helper rendezvouses on the same\n * Cordis root service, so no participant depends on another being enabled, the\n * card is mounted once (duplicate row ids would throw), and the last\n * `release()` removes it. The card also retains the shared page itself, so a\n * lone auxiliary plugin still yields the column — participants never depend\n * on another business plugin providing their settings page.\n *\n * The storage side lives in the shared host service behind the plugin-kit RPC\n * channel: `defaults.get` returns `{revision, model}` and `defaults.set`\n * carries `{model, expectedRevision}` with an empty provider/model clearing\n * the override. Cross-window invalidation rides the existing model-settings\n * change stream — no polling is added anywhere in this file.\n */\nimport type { Context } from '@deepseek-ai/cordis'\nimport { Button, IconChevronDownOutlineRegular } from '@deepseek-ai/dsh-client-ui-primitives'\nimport { useCallback, useEffect, useRef, useState, useSyncExternalStore, type ReactNode } from 'react'\nimport {\n readModelCatalog, modelMenuEffortLabel, modelMenuEffortOptions, parseModelMenuChoices, type ModelRoute,\n} from '@klarkxy/dsh-model-route'\nimport { ModelCatalogStatus, ModelMenu, modelMenuCss, useModelCatalog } from '@klarkxy/dsh-model-route/ui'\nimport { officialUiCss } from './official-ui.ts'\nimport { renderModelPicker, useModelMenuAnchor, type RenderFactorySlot } from './model-picker.tsx'\nimport {\n createModelSettingsSubscriber, modelSettingsChangesRemote, type ModelSettingsSubscriber,\n} from './model-settings-client.ts'\nimport { registerSessionSettingsItem } from './client-utils.ts'\nimport {\n AUXILIARY_MODEL_CHANNEL, AUXILIARY_MODEL_CHANGES_IDENTITY, AUXILIARY_MODEL_NS,\n type AuxiliaryModelDefaults, type RpcResult,\n} from './contracts.ts'\n\nconst AUXILIARY_MODEL_PACKAGE = '@klarkxy/dsh-plugin-kit'\n\n/** The stored row; re-exported so card consumers share the contract shape. */\nexport type AuxiliaryModelSnapshot = AuxiliaryModelDefaults\n\n/* The card is one row of the shared Session Management column: the item slot\n * is a root-scope list declared by the shared page, and row ids must be\n * unique. The row sorts ahead of every business participant. */\nexport const AUXILIARY_MODEL_SEAT_ID = 'auxiliary-model'\nexport const AUXILIARY_MODEL_SEAT_ORDER = 55\n\n/** Private Cordis rendezvous; every bundled copy resolves the same root service. */\nconst AUXILIARY_MODEL_CARD_SERVICE = 'dshAuxiliaryModelSettingsCard'\n\n/** Theme-token-only stylesheet: officialUiCss scope plus the shared ModelMenu recipe. */\nexport const auxiliaryModelCss = `${officialUiCss('ams-root')}${modelMenuCss}\n.ams-root .ams-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }\n`\n\nconst auxiliaryCopy = {\n zh: {\n title: '默认辅助模型',\n help: '各辅助功能(如标题生成、摘要)没有单独指定模型时使用的模型;仅影响声明使用它的功能。',\n model: '辅助模型',\n modelDefault: '跟随会话或宿主默认',\n modelHint: '不选择模型时,各功能按自己的规则决定对话模型。',\n effortDefault: '跟随模型默认',\n loading: '正在读取设置…',\n failed: '无法读取模型设置。',\n stale: '设置已被其他窗口更新,请刷新后重试。',\n saveFailed: '保存失败,原设置未更改。请重试。',\n saved: '已保存。',\n retry: '重试',\n refresh: '刷新设置',\n syncUnavailable: '自动刷新不可用,请手动刷新设置。',\n },\n en: {\n title: 'Default Auxiliary Model',\n help: 'The model used by auxiliary features (such as title generation or summarizing) that do not name their own model; only features that opted in are affected.',\n model: 'Auxiliary model',\n modelDefault: 'Follow session or host default',\n modelHint: 'With no model selected, each feature follows its own rules for the conversation model.',\n effortDefault: 'Follow model default',\n loading: 'Loading settings…',\n failed: 'Could not load model settings.',\n stale: 'Settings were changed elsewhere; refresh and retry.',\n saveFailed: 'Save failed; the previous setting was not changed. Try again.',\n saved: 'Saved.',\n retry: 'Retry',\n refresh: 'Refresh settings',\n syncUnavailable: 'Automatic refresh unavailable; refresh settings manually.',\n },\n} as const\ntype AuxiliaryCopy = (typeof auxiliaryCopy)['zh'] | (typeof auxiliaryCopy)['en']\n\n/** A failed RPC keeps its code so the card can translate known rejections. */\nclass AuxiliaryRpcError extends Error {\n constructor(readonly code: string, message: string) { super(message); this.name = 'AuxiliaryRpcError' }\n}\n\n/** The client services this card reads; the shared service passes ctx.root. */\nexport interface AuxiliaryModelClient {\n connection: {\n rpc: { call(channel: string, endpoint: string, payload: unknown): Promise<unknown> }\n generation?: { subscribe(listener: () => void): () => void }\n }\n remote?: { session?: { modelCatalog?: () => Promise<unknown> } }\n locale?: { getSnapshot(): { active: string }; subscribe(listener: () => void): () => void }\n}\n\n/** Host UI language, following live switches with the host's English fallback. */\nfunction useAuxiliaryLocale(client: AuxiliaryModelClient): 'zh' | 'en' {\n const subscribe = useCallback((listener: () => void) => client.locale?.subscribe(listener) ?? (() => {}), [client])\n const snapshot = useCallback(() => client.locale?.getSnapshot().active ?? 'en', [client])\n return String(useSyncExternalStore(subscribe, snapshot, snapshot)).startsWith('zh') ? 'zh' : 'en'\n}\n\nfunction isAbort(error: unknown): boolean {\n return error instanceof Error && (error.name === 'AbortError' || /abort|cancel/i.test(error.message))\n}\n\n/* A revision mismatch is a lost race, not a broken save: the stored row moved\n * past the one the user edited. The host reports it as auxiliary-model/conflict;\n * the message fallback covers older hosts that surfaced it as internal. */\nfunction isStaleRejection(error: unknown): boolean {\n if (!(error instanceof AuxiliaryRpcError)) return false\n return error.code === 'stale' || error.code === 'auxiliary-model/conflict'\n || /changed|revision|reload|stale|conflict/i.test(error.message)\n}\n\nasync function callAuxiliaryRpc<T>(\n client: AuxiliaryModelClient, endpoint: string, payload: unknown = {},\n): Promise<T> {\n const result = await client.connection.rpc.call(AUXILIARY_MODEL_CHANNEL, endpoint, payload) as RpcResult<T> | undefined\n if (!result || result.ok !== true) {\n const error = result && 'error' in result ? result.error : undefined\n throw new AuxiliaryRpcError(error?.code ?? 'unknown', error?.message ?? `RPC ${endpoint} failed`)\n }\n return result.value\n}\n\n/**\n * The shared card. All state comes from the shared host service over the\n * plugin-kit RPC channel; the card only renders the stored row.\n */\nexport function AuxiliaryModelCard({ client, subscribe, renderFactorySlot }: {\n client: AuxiliaryModelClient\n /** Settings-change invalidation; injected for tests without a live stream. */\n subscribe?: (change: () => void, error?: (message: string) => void) => () => void\n /** Framework-composed factory renderer; absent under direct test renders. */\n renderFactorySlot?: RenderFactorySlot\n}): ReactNode {\n const language = useAuxiliaryLocale(client)\n const text: AuxiliaryCopy = auxiliaryCopy[language]\n const [settings, setSettings] = useState<AuxiliaryModelSnapshot>()\n const loadCatalog = useCallback(() => readModelCatalog(client), [client])\n const subscribeCatalog = useCallback(\n (change: () => void) => client.connection.generation?.subscribe(change), [client])\n const catalogState = useModelCatalog(loadCatalog, { subscribe: subscribeCatalog })\n const { refresh: refreshCatalog } = catalogState\n const choices = parseModelMenuChoices(catalogState.catalog, settings?.model ?? undefined)\n const [menuOpen, setMenuOpen] = useState(false)\n const [error, setError] = useState<'' | 'failed' | 'stale' | 'saveFailed'>('')\n const [note, setNote] = useState(false)\n const [busy, setBusy] = useState(false)\n const [syncError, setSyncError] = useState('')\n const operation = useRef({ epoch: 0, active: false, reading: false, writing: false, pending: false })\n const refreshRef = useRef<() => void>(() => {})\n\n const refresh = () => {\n const state = operation.current\n if (!state.active) return\n if (state.reading || state.writing) { state.pending = true; return }\n state.pending = false; state.reading = true; setBusy(true)\n const epoch = state.epoch\n void callAuxiliaryRpc<AuxiliaryModelSnapshot>(client, 'defaults.get').then(next => {\n if (state.active && state.epoch === epoch && !state.pending) {\n setSettings(next); setError('')\n }\n }).catch(reason => {\n if (state.active && state.epoch === epoch && !state.pending && !isAbort(reason)) setError('failed')\n }).finally(() => {\n if (!state.active || state.epoch !== epoch) return\n state.reading = false; setBusy(false)\n if (state.pending) refreshRef.current()\n })\n }\n refreshRef.current = refresh\n useEffect(() => {\n const state = operation.current\n state.epoch++; state.active = true; state.reading = false; state.writing = false; state.pending = false\n setBusy(false); setSettings(undefined); setError(''); setNote(false)\n refreshRef.current()\n return () => { state.active = false; state.epoch++ }\n }, [client])\n // Cross-window invalidation rides the shared model-settings change stream.\n useEffect(() => {\n setSyncError('')\n let live = true\n let stop: (() => void) | undefined\n try {\n stop = subscribe?.(() => {\n if (live) { setSyncError(''); refreshCatalog(); refreshRef.current() }\n }, message => { if (live) setSyncError(message) })\n } catch {\n // A subscriber that cannot even attach degrades to manual refresh.\n if (live) setSyncError('Model settings sync service unavailable')\n }\n return () => { live = false; try { stop?.() } catch { /* detach is best-effort */ } }\n }, [subscribe, refreshCatalog])\n\n const save = useCallback((model: ModelRoute | null) => {\n const state = operation.current\n if (!settings || !state.active || state.writing || state.reading) return\n state.writing = true\n const epoch = state.epoch\n setBusy(true); setNote(false); setError('')\n void callAuxiliaryRpc<AuxiliaryModelSnapshot>(client, 'defaults.set', {\n model: model ?? { provider: '', model: '' },\n expectedRevision: settings.revision,\n }).then(next => {\n if (state.active && state.epoch === epoch) { setSettings(next); setNote(true); refreshCatalog() }\n }).catch(reason => {\n if (state.active && state.epoch === epoch) {\n setError(isStaleRejection(reason) ? 'stale' : 'saveFailed')\n }\n }).finally(() => {\n if (!state.active || state.epoch !== epoch) return\n state.writing = false; setBusy(false)\n if (state.pending) refreshRef.current()\n })\n }, [client, settings, refreshCatalog])\n\n const locked = busy\n const current = settings?.model ?? { provider: '', model: '' }\n const follow = !current.provider || !current.model\n const selected = follow ? undefined : choices.find(item => item.provider === current.provider && item.model === current.model)\n const efforts = follow ? [] : modelMenuEffortOptions(selected, current.reasoningEffort)\n const currentLabel = follow ? text.modelDefault : selected?.label ?? `${current.provider} / ${current.model}`\n const selectedEffort = efforts.find(item => item.id === (current.reasoningEffort || ''))\n const effortName = selectedEffort ? modelMenuEffortLabel(selectedEffort, language) : undefined\n // The shared picker's anchor mirrors the trigger the fallback menu renders.\n const anchor = useModelMenuAnchor(`${text.model}: ${settings ? currentLabel : ''}`, undefined,\n () => setMenuOpen(false))\n if (!settings) {\n return <section className=\"ams-root dsh-ui-card\" data-testid=\"auxiliary-model-settings\">\n <span className=\"dsh-ui-heading\">{text.title}</span>\n <p className=\"dsh-ui-help\">{text.help}</p>\n {error\n ? <p role=\"alert\" className=\"dsh-ui-error\">{text[error]}</p>\n : <p role=\"status\" className=\"dsh-ui-hint\">{text.loading}</p>}\n {syncError && <p role=\"status\" className=\"dsh-ui-hint\">{text.syncUnavailable}</p>}\n <div className=\"dsh-ui-actions\">\n <Button variant=\"ghost\" size=\"sm\" disabled={locked} onClick={() => refreshRef.current()}>{text.retry}</Button>\n </div>\n </section>\n }\n\n\n return <section className=\"ams-root dsh-ui-card\" data-testid=\"auxiliary-model-settings\">\n <span className=\"dsh-ui-heading\">{text.title}</span>\n <p className=\"dsh-ui-help\">{text.help}</p>\n <div className=\"dsh-ui-field\">\n <span className=\"dsh-ui-label\">{text.model}</span>\n <ModelCatalogStatus state={catalogState} locale={language} />\n {renderModelPicker(renderFactorySlot, {\n locale: language,\n disabled: locked,\n busy: locked,\n onOpenChange: next => setMenuOpen(next && !locked),\n listClassName: 'ams-root ams-menu-portal',\n choices,\n selected: follow ? undefined : { provider: current.provider, model: current.model },\n onPick: picked => save({ provider: picked.provider, model: picked.model }),\n leading: [{ id: 'default', label: text.modelDefault, selected: follow }],\n onPickLeading: () => save(null),\n efforts,\n selectedEffort: current.reasoningEffort || '',\n onPickEffort: effort => save(follow\n ? null\n : { provider: current.provider, model: current.model, ...(effort ? { reasoningEffort: effort } : {}) }),\n triggerLabel: currentLabel,\n triggerEffortLabel: !follow && efforts.length ? (effortName ?? text.effortDefault) : undefined,\n modelLabel: text.model,\n modelValue: currentLabel,\n defaultEffortLabel: text.effortDefault,\n }, {\n anchor,\n fallback: <ModelMenu\n locale={language}\n open={menuOpen && !locked}\n onOpenChange={next => setMenuOpen(next && !locked)}\n listClassName=\"ams-root ams-menu-portal\"\n anchor={<button type=\"button\" className=\"dsh-model-menu-trigger\" disabled={locked}\n aria-label={`${text.model}: ${currentLabel}`}>\n <span className=\"dsh-model-menu-triggerLabel\">{currentLabel}</span>\n {!follow && efforts.length ? <span className=\"dsh-model-menu-triggerEffort\">{effortName ?? text.effortDefault}</span> : null}\n <IconChevronDownOutlineRegular className={`dsh-model-menu-chevron${menuOpen && !locked ? ' dsh-model-menu-chevronOpen' : ''}`} />\n </button>}\n choices={choices}\n selected={follow ? undefined : { provider: current.provider, model: current.model }}\n onPick={picked => save({ provider: picked.provider, model: picked.model })}\n leading={[{ id: 'default', label: text.modelDefault, selected: follow }]}\n onPickLeading={() => save(null)}\n efforts={efforts}\n selectedEffort={current.reasoningEffort || ''}\n onPickEffort={effort => save(follow\n ? null\n : { provider: current.provider, model: current.model, ...(effort ? { reasoningEffort: effort } : {}) })}\n modelLabel={text.model}\n modelValue={currentLabel}\n defaultEffortLabel={text.effortDefault}\n />,\n })}\n <span className=\"dsh-ui-hint\">{text.modelHint}</span>\n </div>\n <div className=\"ams-row\">\n {syncError && <p role=\"status\" className=\"dsh-ui-hint\">{text.syncUnavailable}</p>}\n {error && <p role=\"alert\" className=\"dsh-ui-error\">{text[error]}</p>}\n {note && <p role=\"status\" className=\"dsh-ui-notice\">{text.saved}</p>}\n {error || syncError ? (\n <Button variant=\"ghost\" size=\"sm\" disabled={locked} onClick={() => refreshRef.current()}>{text.refresh}</Button>\n ) : null}\n </div>\n </section>\n}\n\ninterface AuxiliaryRoot {\n get(name: string, strict?: boolean): unknown\n provide(name: string, value: unknown): () => void\n inject(deps: string[], callback: (scope: unknown) => void): AuxiliaryFiber\n}\ninterface AuxiliaryFiber {\n dispose(): void | Promise<void>\n}\ninterface AuxiliaryRemoteMountScope {\n remote: { $mount(contribution: unknown): Promise<unknown> }\n effect(cb: () => () => void | Promise<void>): unknown\n}\n\n/* The client-side stream descriptor mount, serialized through one root\n * coordinator. Its tail carries mounts and unmounts in strict order: a new\n * mount cannot start while a previous fiber's unmount is in flight, and a\n * lease that closes before its continuation runs never mounts at all. The\n * coordinator leaves the store only when the queue is drained and no lease\n * is active — a fast teardown→re-acquire chains onto the same tail instead\n * of hitting \"already registered\" or overlapping a second mount. */\ninterface AuxiliaryWatchLease {\n fiber: AuxiliaryFiber | undefined\n closed: boolean\n done(): void\n}\ninterface AuxiliaryWatchCoordinator {\n tail: Promise<void>\n active: number\n mount(): AuxiliaryWatchLease\n}\nconst AUXILIARY_MODEL_WATCH_COORDINATOR = 'dshAuxiliaryModelWatchCoordinator'\n\nfunction acquireWatchCoordinator(root: AuxiliaryRoot): AuxiliaryWatchCoordinator {\n const existing = root.get(AUXILIARY_MODEL_WATCH_COORDINATOR, false) as AuxiliaryWatchCoordinator | undefined\n if (existing) return existing\n let unprovide: (() => void) | undefined\n const coordinator: AuxiliaryWatchCoordinator = {\n tail: Promise.resolve(),\n active: 0,\n mount() {\n coordinator.active += 1\n const previousTail = coordinator.tail\n const lease: AuxiliaryWatchLease = {\n closed: false,\n done() {\n if (lease.closed) return\n lease.closed = true\n coordinator.active -= 1\n const owned = lease.fiber\n lease.fiber = undefined\n // The unmount joins the tail every later mount waits on.\n coordinator.tail = coordinator.tail\n .then(() => Promise.resolve(owned?.dispose()).catch(() => {}))\n // Unprovide only once the queue is really drained: a newer lease\n // already queued on this coordinator must keep it alive.\n void coordinator.tail.then(() => {\n if (coordinator.active > 0) return\n try {\n if (root.get(AUXILIARY_MODEL_WATCH_COORDINATOR, false) === coordinator) {\n void Promise.resolve(unprovide?.()).catch(() => {})\n }\n } catch { /* Root already unloading. */ }\n })\n },\n fiber: undefined,\n }\n void previousTail.then(() => {\n // A release that beat the mount ends here: nothing mounted, nothing\n // to unmount, and the tail already moved on.\n if (lease.closed) return\n // mountModelSettingsChanges performs this exact inject/$mount pair;\n // it is repeated here only because that helper returns void and the\n // fiber must be captured for symmetric teardown.\n try {\n lease.fiber = root.inject(['remote'], injected => {\n const scope = injected as AuxiliaryRemoteMountScope\n const mounting = scope.remote.$mount(\n modelSettingsChangesRemote(AUXILIARY_MODEL_PACKAGE, AUXILIARY_MODEL_CHANGES_IDENTITY),\n ) as Promise<(() => Promise<void>) | undefined>\n void mounting.catch(() => {})\n scope.effect(() => async () => {\n const unmount = await mounting.catch(() => undefined)\n await unmount?.()\n })\n })\n } catch { /* remote unavailable: the card degrades to manual refresh */ }\n })\n return lease\n },\n }\n unprovide = root.provide(AUXILIARY_MODEL_WATCH_COORDINATOR, coordinator)\n return coordinator\n}\n\ninterface AuxiliaryCardService {\n retain(): void\n release(): void\n}\n\n/**\n * Acquire the root-owned card service, creating it on first use. One counter\n * covers participants, the seat wait and the change-stream mount: the last\n * release removes the wait, then the watch contribution, then the provider\n * itself synchronously (Cordis deletes the impl before its async disposer\n * awaits), so a later acquire sees a clean get() miss and can re-establish.\n */\nfunction acquireAuxiliaryModelCard(root: AuxiliaryRoot, ctx: Context): AuxiliaryCardService {\n const existing = root.get(AUXILIARY_MODEL_CARD_SERVICE, false) as AuxiliaryCardService | undefined\n if (existing) return existing\n let users = 0\n let styleElement: HTMLStyleElement | undefined\n let stopItem: (() => void) | undefined\n let unprovide: (() => void) | undefined\n // The client-side stream descriptor hangs off the shared root context —\n // never a plugin fiber — so the first participant's unload cannot take the\n // card's change stream down. The coordinator still unmounts it, in tail\n // order, on the last release.\n const watchLease = acquireWatchCoordinator(root).mount()\n const subscriber: ModelSettingsSubscriber = createModelSettingsSubscriber(\n ctx.root as unknown as Parameters<typeof createModelSettingsSubscriber>[0],\n AUXILIARY_MODEL_PACKAGE,\n AUXILIARY_MODEL_CHANGES_IDENTITY,\n ns => ns === AUXILIARY_MODEL_NS,\n )\n const render = (props: { renderFactorySlot?: RenderFactorySlot }) => <AuxiliaryModelCard\n client={root as unknown as AuxiliaryModelClient}\n subscribe={subscriber.subscribe}\n renderFactorySlot={props.renderFactorySlot} />\n const service: AuxiliaryCardService = {\n retain() {\n // The reservation is counted before the throwing installs, so a failure\n // lets the caller's release() undo it fully instead of leaking the service.\n users += 1\n if (styleElement === undefined && typeof document !== 'undefined') {\n styleElement = document.createElement('style')\n styleElement.setAttribute('data-plugin', 'dsh-auxiliary-model-shared')\n styleElement.textContent = auxiliaryModelCss\n document.head.appendChild(styleElement)\n }\n /* The card is a participant of the shared column too: the root-owned\n * call contributes its row AND retains the page and nav icon, which is\n * what guarantees a lone auxiliary plugin still creates the Session\n * Management section — no business plugin has to provide it. The waits\n * sit on the root context, so they live exactly as long as the card. */\n if (!stopItem) {\n stopItem = registerSessionSettingsItem(ctx.root, {\n id: AUXILIARY_MODEL_SEAT_ID,\n order: AUXILIARY_MODEL_SEAT_ORDER,\n }, render)\n }\n },\n release() {\n if (users <= 0) return\n users -= 1\n if (users > 0) return\n stopItem?.()\n stopItem = undefined\n styleElement?.remove()\n styleElement = undefined\n watchLease.done()\n // The store entry leaves synchronously, like the shared page service:\n // the next acquire must not see a stale \"already registered\" marker.\n try { void Promise.resolve(unprovide?.()).catch(() => {}) } catch { /* Root already unloading. */ }\n unprovide = undefined\n },\n }\n unprovide = root.provide(AUXILIARY_MODEL_CARD_SERVICE, service)\n return service\n}\n\n/**\n * Show the shared \"default auxiliary model\" card while the calling plugin is\n * enabled.\n *\n * `ctx` is the plugin's own client context: the card itself is retained on the\n * shared root context for as long as any participant lives, so an arbitrary\n * subset of enabled plugins yields the same single card. The mount's slot wait\n * and the change-stream contribution are owned by the root service — the first\n * participant's unload cannot take the card down. Returns a disposer; it may\n * be invoked by both ctx.effect and an explicit caller and releases at most\n * once, so a double call cannot unbalance the shared refcount.\n */\nexport function registerAuxiliaryModelSettings(ctx: Context): () => void {\n const root = ctx.root as unknown as AuxiliaryRoot\n const service = acquireAuxiliaryModelCard(root, ctx)\n try {\n service.retain()\n } catch (error) {\n // A synchronous failure (for example a duplicate row id) must not pin the\n // shared card for a participant that never joined.\n service.release()\n throw error\n }\n let disposed = false\n return () => {\n if (disposed) return\n disposed = true\n service.release()\n }\n}\n","import { useEffect, useRef, useState, useSyncExternalStore } from 'react'\nimport { Button, IconCloseFillRegular } from '@deepseek-ai/dsh-client-ui-primitives'\nimport type { ContinueModel, WelcomeBackModel } from './presence-model.ts'\nimport { FREE_CHAT_ROOT } from './styles.ts'\nimport { compactedText, failureText, idleText, uiText, type CopyLocale } from './ui-copy.ts'\n\n/** Narrow slot standard props the components rely on; the host keeps the real types. */\nexport interface GhostInputState {\n readonly draft: string\n readonly phase: string\n readonly attachmentIds: readonly unknown[]\n}\n\nexport interface GhostSessionState {\n readonly blank: boolean\n}\n\nexport interface GhostStatusState {\n readonly running?: boolean\n}\n\nexport interface GhostSlotProps {\n readonly sessionId?: string\n readonly useInput?: <T>(selector: (state: GhostInputState) => T) => T\n readonly useSession?: <T>(selector: (state: GhostSessionState) => T) => T\n readonly useSessionStatus?: <T>(selector: (state: ReadonlyMap<string, GhostStatusState>) => T) => T\n readonly inputActions?: {\n setDraft(text: string): void\n }\n}\n\n/**\n * Grey inline-completion for an empty composer, IDE style: the shipped\n * placeholder's own text becomes the continuation (native look, zero\n * positioning), and Tab fills it into the draft for a normal send.\n * The rendered element is a hidden anchor; all work happens in effects.\n */\nexport function ContinueGhost(props: GhostSlotProps & {\n model: ContinueModel\n locale: CopyLocale\n}): React.ReactElement | null {\n const sessionId = props.sessionId ?? ''\n const draft = props.useInput?.(state => state.draft) ?? ''\n const phase = props.useInput?.(state => state.phase) ?? 'plain'\n // The host placeholder shows exactly when the draft and attachment rail are\n // both empty; the ghost replaces its text under the same condition.\n const bare = (props.useInput?.(state => state.attachmentIds.length) ?? 0) === 0\n const blank = props.useSession?.(state => state.blank) ?? true\n const running = props.useSessionStatus?.(state => state.get(sessionId)?.running === true) ?? false\n const snapshot = useSyncExternalStore(\n props.model.subscribe,\n () => props.model.getSnapshot(sessionId),\n () => props.model.getSnapshot(sessionId),\n )\n // An unresolved or still-open turn keeps the shipped placeholder. Empty fixed\n // text becomes the localized default; an empty model line shows nothing.\n const shown = running || snapshot.pending === true || snapshot.text === undefined\n ? ''\n : (snapshot.text ?? (snapshot.fallback === true ? uiText(props.locale, 'continueDefault') : ''))\n const idle = sessionId !== '' && !blank && bare && draft === '' && phase === 'plain' && !running\n const active = shown !== '' && idle\n const text = shown\n const latest = useRef({ active, text })\n useEffect(() => {\n latest.current = { active, text }\n }, [active, text])\n\n const wasRunning = useRef(false)\n useEffect(() => {\n const finished = wasRunning.current && !running\n wasRunning.current = running\n // A falling edge is the previous turn ending. Drop the cached line so the\n // next idle composer asks once for the new cut.\n if (finished && sessionId !== '') props.model.invalidate(sessionId)\n if (idle && !running) props.model.load(sessionId)\n }, [props.model, idle, running, sessionId])\n // Config invalidation can happen while this same idle composer stays\n // mounted. Its empty snapshot must start a fresh load too.\n useEffect(() => {\n if (idle && !running && snapshot.text === undefined) props.model.load(sessionId)\n }, [props.model, idle, running, sessionId, snapshot])\n\n // Replace the shipped placeholder's text while the composer is empty. Class\n // hashes change per host build, so the DOM contract is the stable data\n // attributes [data-composer-card] / [data-composer-placeholder]; the editor's\n // own [data-placeholder] attribute keeps the original text for restore.\n const anchorRef = useRef<HTMLSpanElement>(null)\n useEffect(() => {\n if (!active) return\n const anchor = anchorRef.current\n const card = anchor?.closest('[data-composer-card]') ?? document.querySelector('[data-composer-card]')\n if (!card) return\n const write = () => {\n const placeholder = card.querySelector('[data-composer-placeholder]')\n if (placeholder !== null && placeholder.textContent !== latest.current.text) {\n placeholder.textContent = latest.current.text\n }\n }\n write()\n const observer = new MutationObserver(write)\n observer.observe(card, { subtree: true, childList: true, characterData: true })\n return () => {\n observer.disconnect()\n const placeholder = card.querySelector('[data-composer-placeholder]')\n const original = card.querySelector('[data-composer-input]')?.getAttribute('data-placeholder')\n // Only undo our own write; a genuinely different placeholder stays.\n if (placeholder !== null && typeof original === 'string' && placeholder.textContent === latest.current.text) {\n placeholder.textContent = original\n }\n }\n }, [active, text])\n\n useEffect(() => {\n const onKey = (event: KeyboardEvent) => {\n if (event.key !== 'Tab' || event.shiftKey || event.ctrlKey || event.metaKey || event.altKey) return\n if (event.isComposing || event.keyCode === 229) return\n const current = latest.current\n if (!current.active) return\n // Only this composer's editor. Dialogs and every other field keep Tab.\n // The anchor normally sits in the card. A single page-level card is the\n // fallback when the slot mounts beside it; several cards and no match\n // means leave the key alone.\n const target = event.target\n if (!(target instanceof HTMLElement)) return\n if (target.closest('[role=\"dialog\"]') !== null) return\n const anchored = anchorRef.current?.closest('[data-composer-card]')\n const fromTarget = target.closest('[data-composer-card]')\n const only = document.querySelectorAll('[data-composer-card]')\n const card = anchored ?? (fromTarget !== null && only.length === 1 ? fromTarget : null) ?? (only.length === 1 ? only[0] : null)\n const composer = card?.querySelector('[data-composer-input]') ?? null\n if (composer === null || (target !== composer && !composer.contains(target))) return\n event.preventDefault()\n event.stopPropagation()\n props.inputActions?.setDraft(current.text)\n }\n document.addEventListener('keydown', onKey, true)\n return () => document.removeEventListener('keydown', onKey, true)\n }, [props.inputActions])\n\n return <span ref={anchorRef} hidden data-sm-ghost-anchor=\"\" />\n}\n\n/**\n * Narrow TurnLocation face the card needs from the conversation.chat.turnTail\n * owner props; the host keeps the real type.\n */\nexport interface WelcomeBackTurn {\n readonly turn: number\n readonly start?: { readonly time: number }\n readonly end?: { readonly time: number }\n}\n\n/** Narrow ChatSnapshot face used to find the latest loaded turn. */\nexport interface WelcomeBackChatState {\n readonly timeline: { readonly turnOrder: readonly number[] }\n}\n\n/**\n * The merged return card inside the chat flow: model recap past the recap\n * threshold, compaction offer past the compact one. It renders at the latest\n * completed turn's tail instead of opening a modal, so it suggests rather\n * than intercepts a send.\n */\nexport function WelcomeBackCard(props: {\n sessionId?: string\n turn?: WelcomeBackTurn\n useChat?: <T>(selector: (state: WelcomeBackChatState) => T) => T\n useInput?: <T>(selector: (state: GhostInputState) => T) => T\n model: WelcomeBackModel\n locale: CopyLocale\n}): React.ReactElement | null {\n const sessionId = props.sessionId ?? ''\n const snapshot = useSyncExternalStore(\n props.model.subscribe,\n () => props.model.getSnapshot(sessionId),\n () => props.model.getSnapshot(sessionId),\n )\n const lastTurn = props.useChat?.(state => state.timeline.turnOrder[state.timeline.turnOrder.length - 1])\n const inputPhase = props.useInput?.(state => state.phase)\n const card = snapshot.card\n // Live idle clock: the prepared value is a fixed snapshot, so the card\n // recomputes the minutes against lastResponseAt every half minute and the\n // compaction offer can cross its threshold while the card is visible.\n const [liveMinutes, setLiveMinutes] = useState(() => card === undefined ? 0 : Math.max(0, Math.floor((Date.now() - card.lastResponseAt) / 60_000)))\n useEffect(() => {\n if (card === undefined) return\n const tick = () => setLiveMinutes(Math.max(0, Math.floor((Date.now() - card.lastResponseAt) / 60_000)))\n tick()\n const timer = setInterval(tick, 30_000)\n return () => clearInterval(timer)\n }, [card])\n // Sending closes the card: once the composer leaves the plain phase the\n // user has continued, and dismiss() records the activity mark so a fresh\n // response re-arms the card without another model call.\n const phaseRef = useRef(inputPhase)\n useEffect(() => {\n const previous = phaseRef.current\n phaseRef.current = inputPhase\n if (inputPhase === undefined || previous === inputPhase) return\n if (previous === 'plain' && sessionId !== '') props.model.dismiss(sessionId)\n }, [inputPhase, sessionId, props.model])\n if (sessionId === '' || card === undefined) return null\n // The slot dispatches once per completed turn; only the latest one's tail\n // hosts the card, so it reads as the bottom of the conversation chain.\n if (props.turn === undefined || lastTurn === undefined || props.turn.turn !== lastTurn) return null\n // A response newer than the prepared mark makes the recap stale: the user\n // already continued, so the card never reappears at the new turn's tail.\n const respondedAt = props.turn.end?.time ?? props.turn.start?.time\n if (respondedAt !== undefined && card.lastResponseAt < respondedAt) return null\n const copy = (key: Parameters<typeof uiText>[1]) => uiText(props.locale, key)\n const recap = card.recap\n const settled = snapshot.compactedTokens !== undefined || snapshot.compactReason === 'nothing'\n const liveCompactSuggested = card.compactSuggested || (card.compactMinutes > 0 && liveMinutes >= card.compactMinutes)\n // Root-level capability probes cannot see preset-isolated commands. Always\n // offer the explicit action; the native target-session command fails closed.\n const offerCompact = liveCompactSuggested && !settled\n const actionBusy = snapshot.compactBusy || snapshot.continueBusy === true\n return (\n <div className={`${FREE_CHAT_ROOT} dsh-welcome-card`}>\n <div className=\"dsh-welcome-card-head\">\n <span className=\"dsh-welcome-card-title\">{copy('welcomeBack')}</span>\n <span className=\"dsh-welcome-card-idle\">{idleText(props.locale, liveMinutes)}</span>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n className=\"dsh-welcome-card-close\"\n aria-label={copy('close')}\n icon={<IconCloseFillRegular />}\n onClick={() => { props.model.dismiss(sessionId) }}\n />\n </div>\n {recap !== null ? (\n <dl className=\"dsh-welcome-recap\">\n <dt>{copy('recapSummary')}</dt>\n <dd>{recap.summary}</dd>\n {recap.progress !== '' ? <dt>{copy('recapProgress')}</dt> : null}\n {recap.progress !== '' ? <dd>{recap.progress}</dd> : null}\n {recap.nextStep !== '' ? <dt>{copy('recapNextStep')}</dt> : null}\n {recap.nextStep !== '' ? <dd>{recap.nextStep}</dd> : null}\n </dl>\n ) : null}\n {liveCompactSuggested ? <p className=\"dsh-welcome-cache\">{copy('cacheNotice')}</p> : null}\n {liveCompactSuggested ? (\n <div className=\"dsh-welcome-card-actions\">\n {offerCompact ? (\n <Button\n type=\"button\"\n variant=\"outline\"\n disabled={actionBusy}\n onClick={() => { void props.model.compact(sessionId) }}\n >\n {snapshot.compactBusy ? copy('compacting') : copy('compactNow')}\n </Button>\n ) : null}\n <Button\n type=\"button\"\n variant=\"outline\"\n disabled={actionBusy}\n title={copy('continueNewHint')}\n onClick={() => { void props.model.continueInNewSession(sessionId, props.locale) }}\n >\n {snapshot.continueBusy ? copy('creatingContinuation') : copy('continueNew')}\n </Button>\n </div>\n ) : null}\n {snapshot.compactCommandSent ? (\n <p className=\"dsh-welcome-done\" role=\"status\">{copy('compactCommandSent')}</p>\n ) : null}\n {snapshot.compactedTokens !== undefined ? (\n <p className=\"dsh-welcome-done\" role=\"status\">{compactedText(props.locale, snapshot.compactedTokens)}</p>\n ) : null}\n {snapshot.compactReason === 'nothing' ? <p className=\"dsh-welcome-done\" role=\"status\">{copy('compactNothing')}</p> : null}\n {snapshot.compactReason === 'busy' || snapshot.compactReason === 'unavailable' ? (\n <p className=\"dsh-ui-error dsh-free-alert\" role=\"alert\">\n {failureText(props.locale, { code: snapshot.compactReason === 'busy' ? 'session-manager/busy' : 'session-manager/unavailable' })}\n </p>\n ) : null}\n {snapshot.failure ? <p className=\"dsh-ui-error dsh-free-alert\" role=\"alert\">{failureText(props.locale, snapshot.failure)}</p> : null}\n </div>\n )\n}\n","import { useCallback, useEffect, useId, useRef, useState, useSyncExternalStore } from 'react'\nimport { Input, SegmentedTabs, Switch, IconChevronDownOutlineRegular } from '@deepseek-ai/dsh-client-ui-primitives'\nimport { modelRouteKey, parseModelMenuChoices } from '@klarkxy/dsh-model-route'\nimport { ModelMenu, ModelCatalogStatus, useModelCatalog } from '@klarkxy/dsh-model-route/ui'\nimport { renderModelPicker, useModelMenuAnchor, type RenderFactorySlot } from '@klarkxy/dsh-plugin-kit/model-picker'\nimport { DEFAULT_COMPACT_MINUTES, DEFAULT_RECAP_MINUTES, type ConfigPatch, type ConfigView } from './contracts.ts'\nimport type { PresenceConfigModel, PresenceConfigSnapshot } from './presence-model.ts'\nimport { FREE_CHAT_ROOT } from './styles.ts'\nimport { failureText, uiText, type CopyLocale, type UiTextKey } from './ui-copy.ts'\n\n/** Enabled thresholds are whole minutes of at least 1. 0 stays the stored \"off\" value and is not a valid enabled draft. */\nfunction minutesOf(text: string): number | undefined {\n if (!/^[1-9]\\d*$/.test(text.trim())) return undefined\n const value = Number.parseInt(text.trim(), 10)\n return Number.isSafeInteger(value) && value >= 1 ? value : undefined\n}\n\n/** Automatic continuations per human message: a whole number from 1 to 10. */\nfunction autoMaxOf(text: string): number | undefined {\n if (!/^\\d+$/.test(text.trim())) return undefined\n const value = Number.parseInt(text.trim(), 10)\n return Number.isSafeInteger(value) && value >= 1 && value <= 10 ? value : undefined\n}\n\nconst missingCatalog = async (): Promise<unknown> => { throw new Error('Model catalog service unavailable') }\n\ninterface RowProps {\n model: PresenceConfigModel\n locale: CopyLocale\n}\n\nfunction copy(locale: CopyLocale, key: UiTextKey): string {\n return uiText(locale, key)\n}\n\n/**\n * Sparse save-on-change writer shared by every row. Each patch holds only the\n * keys that changed, so an untouched model selector can never overwrite a\n * stored route's reasoningEffort. The single-flight model drops a second save\n * while one is in flight, so edits queue as one merged patch and flush when\n * the current save settles.\n */\ninterface PatchWriter {\n send(patch: ConfigPatch, row: symbol): void\n /** The row that issued the latest write; only that row shows the save status. */\n lastRow: symbol | undefined\n}\n\n// One queue per config model, shared by every row: a per-row queue would leave\n// a patch stranded when another row's save holds the single-flight slot.\nconst writers = new WeakMap<PresenceConfigModel, PatchWriter>()\n\nfunction writerFor(model: PresenceConfigModel): PatchWriter {\n let writer = writers.get(model)\n if (writer !== undefined) return writer\n let queue: ConfigPatch | undefined\n const flush = () => {\n if (queue === undefined || model.getSnapshot().saving) return\n const patch = queue\n queue = undefined\n void model.save(patch).finally(flush)\n }\n writer = {\n lastRow: undefined,\n send(patch, row) {\n writer!.lastRow = row\n queue = { ...queue, ...patch }\n flush()\n },\n }\n writers.set(model, writer)\n return writer\n}\n\nfunction useConfigPatch(model: PresenceConfigModel): { send: (patch: ConfigPatch) => void; owns: () => boolean } {\n const row = useRef(Symbol('row')).current\n const writer = writerFor(model)\n const send = useCallback((patch: ConfigPatch) => writer.send(patch, row), [writer, row])\n return { send, owns: () => writer.lastRow === row }\n}\n\n/**\n * One controlled text/number input bound to a stored string. The draft follows\n * external writes only while untouched — a focused, edited draft is never\n * wiped by a settings reload. The commit runs on blur and Enter: valid input\n * normalizes and saves when it differs; invalid input keeps the draft and its\n * inline error and is never written.\n */\nfunction useTextSetting<T>(props: {\n stored: string\n parse: (draft: string) => { readonly value: T; readonly draft: string } | undefined\n send: (value: T) => void\n}): {\n draft: string\n invalid: boolean\n inputProps: {\n value: string\n onChange: (event: { target: { value: string } }) => void\n onBlur: () => void\n onKeyDown: (event: { key: string }) => void\n }\n} {\n const [draft, setDraft] = useState(props.stored)\n const seen = useRef(props.stored)\n const touched = useRef(false)\n useEffect(() => {\n if (props.stored === seen.current) return\n seen.current = props.stored\n // Follow the stored value while untouched, or once it caught up with the\n // draft (our own save confirmed); an edited, unsaved draft stays put.\n setDraft(current => {\n if (touched.current && current !== props.stored) return current\n touched.current = false\n return props.stored\n })\n }, [props.stored])\n const commit = useCallback(() => {\n const parsed = props.parse(draft)\n if (parsed === undefined) return\n setDraft(parsed.draft)\n // Normalizing may fold the draft back to the stored value (\"015\" -> 15);\n // only a real change writes.\n if (parsed.draft === seen.current) {\n touched.current = false\n return\n }\n props.send(parsed.value)\n }, [draft, props.parse, props.send])\n return {\n draft,\n invalid: props.parse(draft) === undefined,\n inputProps: {\n value: draft,\n onChange: event => {\n touched.current = true\n setDraft(event.target.value)\n },\n onBlur: commit,\n onKeyDown: event => { if (event.key === 'Enter') commit() },\n },\n }\n}\n\n/** Per-row write status: one line under the controls, only while it has something to say. */\nfunction SaveStatus(props: { snapshot: PresenceConfigSnapshot; locale: CopyLocale; owns: () => boolean }): React.ReactElement | null {\n const { snapshot, locale } = props\n if (!props.owns()) return null\n if (snapshot.saving) return <p className=\"dsh-ui-notice\" role=\"status\">{copy(locale, 'settingsSaving')}</p>\n if (snapshot.failure) return <p className=\"dsh-ui-notice dsh-ui-notice--error\" role=\"alert\">{failureText(locale, snapshot.failure)}</p>\n if (snapshot.saved) return <p className=\"dsh-ui-notice\" role=\"status\">{copy(locale, 'settingsSaved')}</p>\n return null\n}\n\n/** Shared loading/unavailable body: every row reads the same config snapshot. */\nfunction useRowGate(props: RowProps): { snapshot: PresenceConfigSnapshot; values?: ConfigView; gate?: React.ReactElement } {\n const snapshot = useSyncExternalStore(props.model.subscribe, props.model.getSnapshot, props.model.getSnapshot)\n useEffect(() => {\n if (snapshot.phase === 'loading') void props.model.load()\n }, [props.model, snapshot.phase])\n if (snapshot.phase === 'loading') {\n return { snapshot, gate: <p className=\"dsh-ui-loading\">{copy(props.locale, 'settingsLoading')}</p> }\n }\n if (snapshot.phase === 'unavailable' || snapshot.values === undefined) {\n return {\n snapshot,\n gate: (\n <p className=\"dsh-ui-error\" role=\"alert\">\n {snapshot.failure ? failureText(props.locale, snapshot.failure) : copy(props.locale, 'settingsUnavailable')}\n </p>\n ),\n }\n }\n return { snapshot, values: snapshot.values }\n}\n\n/** 输入框建议 / Composer suggestion row. */\nexport function ComposerSettings(props: RowProps & CatalogProps): React.ReactElement {\n const { snapshot, values, gate } = useRowGate(props)\n const { send, owns } = useConfigPatch(props.model)\n const tabsId = useId()\n const field = useTextSetting<string>({\n stored: values?.continueText ?? '',\n parse: draft => ({ value: draft.trim(), draft: draft.trim() }),\n send: useCallback(value => send({ continueText: value }), [send]),\n })\n if (gate !== undefined || values === undefined) return gate ?? <></>\n const fixedPanelId = `${tabsId}-fixed-panel`\n const autoPanelId = `${tabsId}-auto-panel`\n return (\n <div className=\"dsm-settings\">\n <div className=\"dsm-feature\">\n <div className=\"dsh-ui-field\">\n <span className=\"dsh-ui-label\">{copy(props.locale, 'continueSourceLabel')}</span>\n <SegmentedTabs<'fixed' | 'auto'>\n label={copy(props.locale, 'continueSourceLabel')}\n items={[\n { id: `${tabsId}-fixed`, panelId: fixedPanelId, value: 'fixed', label: copy(props.locale, 'modeFixed') },\n { id: `${tabsId}-auto`, panelId: autoPanelId, value: 'auto', label: copy(props.locale, 'modeAuto') },\n ]}\n value={values.continueMode}\n onChange={value => { if (value !== values.continueMode) send({ continueMode: value }) }}\n />\n </div>\n <div\n role=\"tabpanel\"\n id={fixedPanelId}\n aria-labelledby={`${tabsId}-fixed`}\n hidden={values.continueMode !== 'fixed'}\n >\n {values.continueMode === 'fixed' ? (\n <label className=\"dsh-ui-field\">\n <span className=\"dsh-ui-label\">{copy(props.locale, 'continueTextLabel')}</span>\n <Input\n className=\"dsm-text-input\"\n placeholder={copy(props.locale, 'continueTextPlaceholder')}\n {...field.inputProps}\n />\n </label>\n ) : null}\n </div>\n <div\n role=\"tabpanel\"\n id={autoPanelId}\n aria-labelledby={`${tabsId}-auto`}\n hidden={values.continueMode !== 'auto'}\n >\n {values.continueMode === 'auto'\n ? <ModelField {...props} field=\"ghostModel\" labelKey=\"ghostModelLabel\" route={values.ghostModel} send={send} />\n : null}\n </div>\n <p className=\"dsh-ui-hint\">{copy(props.locale, 'composerUsageHint')}</p>\n <SaveStatus snapshot={snapshot} locale={props.locale} owns={owns} />\n </div>\n </div>\n )\n}\n\n/** 自动继续 / Auto-continue row. */\nexport function AutoContinueSettings(props: RowProps & CatalogProps): React.ReactElement {\n const { snapshot, values, gate } = useRowGate(props)\n const { send, owns } = useConfigPatch(props.model)\n const errorId = useId()\n const field = useTextSetting<number>({\n stored: String(values?.autoContinueMax ?? ''),\n parse: draft => {\n const value = autoMaxOf(draft)\n return value === undefined ? undefined : { value, draft: String(value) }\n },\n send: useCallback(value => send({ autoContinueMax: value }), [send]),\n })\n if (gate !== undefined || values === undefined) return gate ?? <></>\n return (\n <div className=\"dsm-settings\">\n <div className=\"dsm-feature\">\n <label className=\"dsh-ui-field\">\n <span className=\"dsh-ui-label\">{copy(props.locale, 'autoContinueMaxLabel')}</span>\n <Input\n className=\"dsm-minutes\"\n inputMode=\"numeric\"\n aria-invalid={field.invalid || undefined}\n aria-describedby={field.invalid ? `${errorId}-max-error` : undefined}\n {...field.inputProps}\n />\n </label>\n <p className=\"dsh-ui-hint\">{copy(props.locale, 'autoContinueMaxHint')}</p>\n {field.invalid ? <p id={`${errorId}-max-error`} className=\"dsh-ui-error\" role=\"alert\">{copy(props.locale, 'autoContinueMaxInvalid')}</p> : null}\n <ModelField {...props} field=\"judgeModel\" labelKey=\"judgeModelLabel\" route={values.judgeModel} send={send} />\n <p className=\"dsh-ui-hint\">{copy(props.locale, 'judgeModelHint')}</p>\n <p className=\"dsh-ui-hint\">{copy(props.locale, 'autoContinueModeHint')}</p>\n <SaveStatus snapshot={snapshot} locale={props.locale} owns={owns} />\n </div>\n </div>\n )\n}\n\n/** One return-feature block: a switch row and its gated \"away for N minutes\" input. */\nfunction ThresholdBlock(props: RowProps & {\n field: 'recapMinutes' | 'compactMinutes'\n titleKey: 'recapEnabledLabel' | 'compactEnabledLabel'\n hintKey: 'recapEnabledHint' | 'compactEnabledHint'\n minutes: number | undefined\n fallback: number\n send: (patch: ConfigPatch) => void\n /** Extra options that belong to this feature, gated with its switch. */\n extra?: (enabled: boolean) => React.ReactNode\n}): React.ReactElement {\n const enabled = (props.minutes ?? 0) > 0\n const errorId = useId()\n const input = useTextSetting<number>({\n stored: String(enabled ? props.minutes : props.fallback),\n parse: draft => {\n const value = minutesOf(draft)\n return value === undefined ? undefined : { value, draft: String(value) }\n },\n send: useCallback(value => props.send({ [props.field]: value }), [props.send, props.field]),\n })\n const toggle = (next: boolean) => {\n if (next === enabled) return\n if (!next) {\n props.send({ [props.field]: 0 })\n return\n }\n // Enabling saves the shown draft when it is valid, else the feature's default.\n props.send({ [props.field]: minutesOf(input.draft) ?? props.fallback })\n }\n return (\n <div className=\"dsm-feature\">\n <div className=\"dsh-ui-toggle-row\">\n <span className=\"dsh-ui-toggle-text\">\n <span className=\"dsh-ui-toggle-label\">{copy(props.locale, props.titleKey)}</span>\n <span className=\"dsh-ui-hint\">{copy(props.locale, props.hintKey)}</span>\n </span>\n <Switch\n label={copy(props.locale, props.titleKey)}\n checked={enabled}\n onChange={toggle}\n />\n </div>\n <div className=\"dsm-feature-options\" data-disabled={enabled ? undefined : 'true'}>\n <label className=\"dsh-ui-field\">\n <span className=\"dsm-minutes-control\">\n <span className=\"dsh-ui-label\">{copy(props.locale, 'awayMinutesLabel')}</span>\n <Input\n className=\"dsm-minutes\"\n inputMode=\"numeric\"\n disabled={!enabled}\n aria-label={`${copy(props.locale, 'awayMinutesLabel')} ${copy(props.locale, 'minutesUnit')}`}\n aria-invalid={enabled && input.invalid ? true : undefined}\n aria-describedby={enabled && input.invalid ? `${errorId}-minutes-error` : undefined}\n {...input.inputProps}\n />\n <span className=\"dsh-ui-meta\">{copy(props.locale, 'minutesUnit')}</span>\n </span>\n </label>\n {enabled && input.invalid ? <p id={`${errorId}-minutes-error`} className=\"dsh-ui-error\" role=\"alert\">{copy(props.locale, 'minutesInvalid')}</p> : null}\n {props.extra?.(enabled)}\n </div>\n </div>\n )\n}\n\n/** 回到会话时 / When you return row. */\nexport function ReturnSettings(props: RowProps & CatalogProps): React.ReactElement {\n const { snapshot, values, gate } = useRowGate(props)\n const { send, owns } = useConfigPatch(props.model)\n if (gate !== undefined || values === undefined) return gate ?? <></>\n return (\n <div className=\"dsm-settings\">\n <ThresholdBlock\n {...props}\n field=\"recapMinutes\"\n titleKey=\"recapEnabledLabel\"\n hintKey=\"recapEnabledHint\"\n minutes={values.recapMinutes}\n fallback={DEFAULT_RECAP_MINUTES}\n send={send}\n extra={enabled => (\n <ModelField {...props} field=\"model\" labelKey=\"recapModelLabel\" route={values.model} send={send} disabled={!enabled} />\n )}\n />\n <ThresholdBlock\n {...props}\n field=\"compactMinutes\"\n titleKey=\"compactEnabledLabel\"\n hintKey=\"compactEnabledHint\"\n minutes={values.compactMinutes}\n fallback={DEFAULT_COMPACT_MINUTES}\n send={send}\n />\n <SaveStatus snapshot={snapshot} locale={props.locale} owns={owns} />\n </div>\n )\n}\n\ntype ModelField = 'model' | 'ghostModel' | 'judgeModel' | 'handoffModel'\n\n/** Catalog wiring for the rows that carry a model picker. */\ninterface CatalogProps {\n modelCatalog?: () => Promise<unknown>\n subscribeCatalog?: (onChange: () => void) => (() => void) | undefined\n /** Framework-composed factory renderer; absent under direct test renders. */\n renderFactorySlot?: RenderFactorySlot\n}\n\n/**\n * One feature's model picker. The catalog loads with the row (first expand);\n * a stored route missing from the catalog stays selectable so a refresh or a\n * partial outage never hides the current choice.\n */\nfunction ModelField(props: RowProps & CatalogProps & {\n field: ModelField\n labelKey: UiTextKey\n route: { readonly provider: string; readonly model: string; readonly reasoningEffort?: string } | null\n send: (patch: ConfigPatch) => void\n disabled?: boolean\n}): React.ReactElement {\n const catalog = useModelCatalog(props.modelCatalog ?? missingCatalog, { subscribe: props.subscribeCatalog })\n const [open, setOpen] = useState(false)\n const label = copy(props.locale, props.labelKey)\n const selected = props.route === null ? undefined : { provider: props.route.provider, model: props.route.model }\n const choices = parseModelMenuChoices(catalog.catalog)\n if (selected && !choices.some(choice => choice.provider === selected.provider && choice.model === selected.model)) {\n choices.push({ provider: selected.provider, model: selected.model, label: `${selected.provider} / ${selected.model}`, efforts: [] })\n }\n const key = selected === undefined ? '' : modelRouteKey(selected.provider, selected.model)\n const value = choices.find(choice => modelRouteKey(choice.provider, choice.model) === key)?.label\n ?? copy(props.locale, 'modelFollowOption')\n const anchor = useModelMenuAnchor(`${label}: ${value}`, undefined, () => setOpen(false))\n const pick = (route: { provider: string; model: string }) => {\n // Re-picking the same route writes nothing: an unchanged selection\n // must not strip a stored route's reasoningEffort.\n if (selected && route.provider === selected.provider && route.model === selected.model) return\n props.send({ [props.field]: { provider: route.provider, model: route.model } })\n }\n return (\n <div className=\"dsm-model-field\">\n <div className=\"dsm-model-choice\">\n <span className=\"dsh-ui-label\">{label}</span>\n {renderModelPicker(props.renderFactorySlot, {\n locale: props.locale,\n disabled: props.disabled,\n onOpenChange: next => setOpen(next && !props.disabled),\n listClassName: FREE_CHAT_ROOT,\n choices,\n selected,\n onPick: pick,\n leading: [{ id: 'follow', label: copy(props.locale, 'modelFollowOption'), selected: selected === undefined }],\n onPickLeading: () => { if (props.route !== null) props.send({ [props.field]: null }) },\n triggerLabel: value,\n modelValue: value,\n }, {\n anchor,\n fallback: <ModelMenu\n locale={props.locale}\n open={open && !props.disabled}\n onOpenChange={next => setOpen(next && !props.disabled)}\n listClassName={FREE_CHAT_ROOT}\n anchor={<button type=\"button\" className=\"dsh-model-menu-trigger\" disabled={props.disabled} aria-label={`${label}: ${value}`} aria-haspopup=\"menu\" aria-expanded={open}>\n <span className=\"dsh-model-menu-triggerLabel\">{value}</span>\n <IconChevronDownOutlineRegular className={`dsh-model-menu-chevron${open ? ' dsh-model-menu-chevronOpen' : ''}`} />\n </button>}\n choices={choices}\n selected={selected}\n onPick={pick}\n leading={[{ id: 'follow', label: copy(props.locale, 'modelFollowOption'), selected: selected === undefined }]}\n onPickLeading={() => { if (props.route !== null) props.send({ [props.field]: null }) }}\n modelValue={value}\n />,\n })}\n </div>\n <ModelCatalogStatus state={catalog} locale={props.locale} />\n </div>\n )\n}\n\n/** 会话交接 / Session handoff row: the model behind read_session handoff summaries. */\nexport function HandoffSettings(props: RowProps & CatalogProps): React.ReactElement {\n const { snapshot, values, gate } = useRowGate(props)\n const { send, owns } = useConfigPatch(props.model)\n if (gate !== undefined || values === undefined) return gate ?? <></>\n return (\n <div className=\"dsm-settings\">\n <div className=\"dsm-feature\">\n <ModelField {...props} field=\"handoffModel\" labelKey=\"handoffModelLabel\" route={values.handoffModel} send={send} />\n <p className=\"dsh-ui-hint\">{copy(props.locale, 'handoffModelHint')}</p>\n <SaveStatus snapshot={snapshot} locale={props.locale} owns={owns} />\n </div>\n </div>\n )\n}\n\n/**\n * 代理操作 / Agent actions row.\n *\n * Two independent switches: each one saves only its own field, so toggling\n * one never rewrites the other. Both default to off, and the agent decides\n * on its own once a switch is on — there is no per-call approval here.\n *\n * The switches share one sparse writer: the config model accepts a single\n * write at a time, so a second click while a save is in flight must queue\n * rather than be dropped. The shared writer merges the pending patches and\n * flushes them once the current save settles.\n */\nexport function AgentActionsSettings(props: RowProps): React.ReactElement {\n const { snapshot, values, gate } = useRowGate(props)\n const { send, owns } = useConfigPatch(props.model)\n if (gate !== undefined || values === undefined) return gate ?? <></>\n return (\n <div className=\"dsm-settings\">\n <div className=\"dsm-feature\">\n <div className=\"dsh-ui-toggle-row\">\n <span className=\"dsh-ui-toggle-text\">\n <span className=\"dsh-ui-toggle-label\">{copy(props.locale, 'allowSelfForkLabel')}</span>\n <span className=\"dsh-ui-hint\">{copy(props.locale, 'allowSelfForkHint')}</span>\n </span>\n <Switch\n label={copy(props.locale, 'allowSelfForkLabel')}\n checked={values.allowSelfFork === true}\n onChange={next => { send({ allowSelfFork: next }) }}\n />\n </div>\n </div>\n <div className=\"dsm-feature\">\n <div className=\"dsh-ui-toggle-row\">\n <span className=\"dsh-ui-toggle-text\">\n <span className=\"dsh-ui-toggle-label\">{copy(props.locale, 'allowSendMessageLabel')}</span>\n <span className=\"dsh-ui-hint\">{copy(props.locale, 'allowSendMessageHint')}</span>\n </span>\n <Switch\n label={copy(props.locale, 'allowSendMessageLabel')}\n checked={values.allowSendMessage === true}\n onChange={next => { send({ allowSendMessage: next }) }}\n />\n </div>\n </div>\n <SaveStatus snapshot={snapshot} locale={props.locale} owns={owns} />\n </div>\n )\n}\n\n/**\n * One collapsible row in the shared Session Management section: a named\n * details group. The body mounts on the first expand only — opening the page\n * must not fire every feature's config and model reads — and stays mounted\n * afterwards so collapsing never drops an in-progress text draft.\n */\nexport function SessionSettingsDetails(props: {\n testId: string\n titleKey: UiTextKey\n descKey: UiTextKey\n locale: CopyLocale\n children?: React.ReactNode\n}): React.ReactElement {\n const [visited, setVisited] = useState(false)\n return (\n <details\n className={`${FREE_CHAT_ROOT} dsm-item`}\n data-testid={props.testId}\n onToggle={event => { if ((event.currentTarget as HTMLDetailsElement).open) setVisited(true) }}\n >\n <summary className=\"dsm-item-summary\">\n <span>\n <span className=\"dsm-item-title\">{copy(props.locale, props.titleKey)}</span>\n <span className=\"dsm-item-desc\">{copy(props.locale, props.descKey)}</span>\n </span>\n <IconChevronDownOutlineRegular className=\"dsm-item-chevron\" aria-hidden=\"true\" />\n </summary>\n {visited ? <div className=\"dsm-item-body\">{props.children}</div> : null}\n </details>\n )\n}\n","import { useEffect, useRef, useState } from 'react'\nimport { Button, FileTypeIcon } from '@deepseek-ai/dsh-client-ui-primitives'\nimport { unwrap } from './session-actions.ts'\nimport type { DraftAttachment, EditHost } from './edit-host.ts'\nimport { uiText, type CopyLocale } from './ui-copy.ts'\n\nfunction AttachmentPreview(props: { item: DraftAttachment; sessionId: string; host: EditHost; locale: CopyLocale }): React.ReactElement {\n const [src, setSrc] = useState<string>()\n const [failed, setFailed] = useState(false)\n const item = props.item\n const name = item.type === 'upload' ? item.file.name : item.type === 'file' ? item.name : uiText(props.locale, 'editImage')\n useEffect(() => {\n let active = true\n let url: string | undefined\n setSrc(undefined)\n setFailed(false)\n if (item.type === 'upload' && item.file.type.startsWith('image/')) {\n url = URL.createObjectURL(item.file)\n setSrc(url)\n } else if (item.type === 'image' && props.host.attachment) {\n void unwrap(props.host.attachment({ sessionId: props.sessionId, attachmentId: item.attachmentId })).then(value => {\n const image = value as { data?: string; attachment?: { mediaType?: string } }\n if (active && image.data && image.attachment?.mediaType?.startsWith('image/')) setSrc(`data:${image.attachment.mediaType};base64,${image.data}`)\n else if (active) setFailed(true)\n }).catch(() => { if (active) setFailed(true) })\n }\n return () => { active = false; if (url) URL.revokeObjectURL(url) }\n }, [item, props.host, props.sessionId])\n return <>\n {src ? <img src={src} alt={name} /> : <FileTypeIcon path={name} />}\n {item.type === 'file' || (item.type === 'upload' && !item.file.type.startsWith('image/')) ? <span title={name}>{name}</span> : null}\n {failed ? <span role=\"status\">{uiText(props.locale, 'editPreviewFailed')}</span> : null}\n </>\n}\n\n/** Lives in the original bubble; drafts and attachments remain local until Send. */\nexport function MessageEditor(props: {\n text: string; setText: (text: string) => void; attachments?: readonly DraftAttachment[]\n setAttachments?: (attachments: DraftAttachment[]) => void\n sessionId: string; host?: EditHost; locale: CopyLocale; busy: boolean; locked?: boolean\n error?: string; onCancel: () => void; onSend: () => void\n}): React.ReactElement {\n const textarea = useRef<HTMLTextAreaElement>(null)\n const copy = (key: Parameters<typeof uiText>[1]) => uiText(props.locale, key)\n const attachments = props.attachments ?? []\n const disabled = props.busy || props.locked === true\n useEffect(() => {\n textarea.current?.focus()\n textarea.current?.setSelectionRange(props.text.length, props.text.length)\n }, [])\n useEffect(() => {\n const element = textarea.current\n if (!element) return\n element.style.height = 'auto'\n element.style.height = `${Math.max(80, Math.min(element.scrollHeight, 360))}px`\n }, [props.text])\n const add = (files: File[]) => {\n if (!disabled && files.length > 0) props.setAttachments?.([...attachments, ...files.map(file => ({ type: 'upload' as const, file }))])\n }\n return <div className=\"dsm-message-edit\" role=\"group\" aria-label={copy('editTitle')}\n onDragOver={event => { if (!disabled && props.setAttachments && event.dataTransfer.types.includes('Files')) event.preventDefault() }}\n onDrop={event => { if (props.setAttachments && event.dataTransfer.files.length) { event.preventDefault(); add(Array.from(event.dataTransfer.files)) } }}>\n {attachments.length ? <div className=\"dsm-edit-attachments\">{attachments.map((item, index) => (\n <div className={`dsm-edit-attachment ${item.type === 'image' || (item.type === 'upload' && item.file.type.startsWith('image/')) ? 'dsm-edit-image' : ''}`} key={item.type === 'upload' ? `${index}:${item.file.name}` : `${index}:${item.attachmentId}`}>\n <AttachmentPreview item={item} sessionId={props.sessionId} host={props.host ?? {}} locale={props.locale} />\n {props.setAttachments ? <Button size=\"sm\" variant=\"ghost\" disabled={disabled} aria-label={`${copy('editRemoveAttachment')} ${index + 1}`}\n onClick={() => { props.setAttachments?.(attachments.filter((_, position) => position !== index)) }}>×</Button> : null}\n </div>\n ))}</div> : null}\n <div className=\"dsm-message-editor\">\n <textarea ref={textarea} className=\"dsh-ui-textarea dsh-free-draft\" aria-label={copy('draft')}\n value={props.text} disabled={disabled} onChange={event => { props.setText(event.target.value) }}\n onPaste={event => {\n const files = Array.from(event.clipboardData.files)\n if (files.length && props.setAttachments) { event.preventDefault(); add(files) }\n }} onKeyDown={event => { if (event.key === 'Escape' && !props.busy) { event.stopPropagation(); props.onCancel() } }} />\n {props.error ? <p className=\"dsh-ui-error\" role=\"alert\">{props.error}</p> : null}\n <div className=\"dsm-edit-footer\">\n <span className=\"dsm-edit-spacer\" />\n <Button variant=\"ghost\" disabled={props.busy} onClick={props.onCancel}>{copy('cancel')}</Button>\n <Button variant=\"primary\" disabled={props.busy || (!props.text.trim() && !attachments.length)} onClick={props.onSend}>{copy('send')}</Button>\n </div>\n </div>\n </div>\n}\n","/** The stock edit primitive includes a box; message editing uses a standalone pencil. */\nexport function EditMessageIcon(): React.ReactElement {\n return (\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" aria-hidden=\"true\">\n <path d=\"m10.5 2.5 3 3M2 14l1-4L10.5 2.5a2.12 2.12 0 0 1 3 3L6 13l-4 1Z\" stroke=\"currentColor\" strokeWidth=\"1\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </svg>\n )\n}\n","import { useEffect, useRef, useState, useSyncExternalStore } from 'react'\nimport { Button, Modal, Tooltip } from '@deepseek-ai/dsh-client-ui-primitives'\nimport { MessageEditor } from './message-editor.tsx'\nimport { EditMessageIcon } from './edit-icon.tsx'\nimport type { RetryModel } from './session-actions.ts'\nimport { FREE_CHAT_ROOT } from './styles.ts'\nimport { failureText, uiText, type CopyLocale } from './ui-copy.ts'\n\nexport function UserMessageActions(props: {\n messageId: string\n text: string\n sessionId: string\n locale: CopyLocale\n model: RetryModel\n hideEdit?: boolean\n}): React.ReactElement | null {\n const [confirming, setConfirming] = useState(false)\n const snapshot = useSyncExternalStore(props.model.subscribe, props.model.getSnapshot, props.model.getSnapshot)\n const signal = useRef<AbortController>(new AbortController())\n useEffect(() => {\n const controller = new AbortController()\n signal.current = controller\n return () => {\n controller.abort()\n props.model.retire(props.sessionId, props.messageId)\n }\n }, [props.model, props.sessionId, props.messageId])\n if (props.sessionId === '' || !snapshot.controlsRetry) return null\n const mine = snapshot.sessionId === props.sessionId && snapshot.messageId === props.messageId\n const copy = (key: Parameters<typeof uiText>[1]) => uiText(props.locale, key)\n const failure = mine ? snapshot.failure : undefined\n const editing = mine && snapshot.editing\n const draft = mine ? snapshot.draft : props.text\n return (\n <span className={`${FREE_CHAT_ROOT} dsh-free-actions`}>\n {!props.hideEdit ? <Tooltip label={copy('edit')} side=\"bottom\">\n <Button\n size=\"sm\"\n className=\"dsm-icon-action\"\n variant=\"ghost\"\n aria-label={copy('edit')}\n disabled={snapshot.busy || (snapshot.editing && !mine)}\n onClick={() => { void props.model.beginEdit(props.sessionId, props.messageId, props.text, signal.current.signal) }}\n >\n <EditMessageIcon />\n </Button>\n </Tooltip> : null}\n {failure && !editing ? <span className=\"dsh-ui-error dsh-free-alert\" role=\"alert\">{failureText(props.locale, failure)}</span> : null}\n {editing && !props.hideEdit ? <MessageEditor text={draft} setText={value => { props.model.setDraft(value) }}\n sessionId={props.sessionId} locale={props.locale} busy={snapshot.busy}\n error={failure ? failureText(props.locale, failure) : undefined}\n onCancel={() => { props.model.cancelEdit() }}\n onSend={() => { setConfirming(true) }} /> : null}\n <Modal open={confirming && editing} className={FREE_CHAT_ROOT} title={copy('editTitle')} closeLabel={copy('close')}\n onClose={() => { setConfirming(false) }} footer={<>\n <Button variant=\"ghost\" data-modal-autofocus onClick={() => { setConfirming(false) }}>{copy('cancel')}</Button>\n <Button variant=\"primary\" onClick={() => { setConfirming(false); void props.model.sendEdit(props.sessionId, props.messageId, signal.current.signal, undefined, true) }}>{copy('editConfirm')}</Button>\n </>}><p>{copy('editBranchWarning')}</p></Modal>\n </span>\n )\n}\n","import { EDIT_FILE_ENDPOINT, EDIT_PREPARE_ENDPOINT, TEMP_WORKSPACE_CHANNEL, type EditContent, type EditPrepareValue } from './contracts.ts'\nimport type { PresenceRpc } from './presence-model.ts'\nimport { HostOperationError, unwrap } from './session-actions.ts'\n\nexport type PromptContent = { readonly type: 'text'; readonly text: string }\n | { readonly type: 'image'; readonly data: string; readonly mediaType: string; readonly name?: string }\n | { readonly type: 'file'; readonly receiptId: string }\n\nexport type DraftAttachment = Exclude<EditContent, { type: 'text' }>\n | { readonly type: 'upload'; readonly file: File }\n\nexport interface EditHost {\n uploadFile?: (sessionId: string, file: File, signal: AbortSignal) => Promise<unknown>\n stageFile?: (request: { sessionId: string; promptSeq: number; attachmentId: string }, signal: AbortSignal) => Promise<unknown>\n prepare?: (request: { sessionId: string; promptSeq: number }, signal: AbortSignal) => Promise<unknown>\n attachment?: (request: { sessionId: string; attachmentId: string }) => Promise<unknown>\n}\n\ninterface EditClient {\n connection?: { rpc?: PresenceRpc }\n remote?: { session?: { attachment?: EditHost['attachment'] } }\n}\n\nexport function bindEditHost(client: EditClient): EditHost {\n const rpc = client.connection?.rpc\n const remote = client.remote?.session\n return {\n ...typeof rpc?.call === 'function' ? {\n prepare: (request, signal) => rpc.call(TEMP_WORKSPACE_CHANNEL, EDIT_PREPARE_ENDPOINT, request, signal),\n stageFile: (request, signal) => rpc.call(TEMP_WORKSPACE_CHANNEL, EDIT_FILE_ENDPOINT, request, signal),\n } : {},\n uploadFile: async (sessionId, file, signal) => {\n const query = new URLSearchParams({ sessionId, name: file.name })\n const response = await fetch(`/api/session/uploadFileBinary?${query}`, {\n method: 'POST', credentials: 'same-origin', headers: { 'content-type': 'application/octet-stream' }, body: file, signal,\n })\n if (!response.ok) throw new HostOperationError('session/attachment-invalid')\n return response.json()\n },\n ...typeof remote?.attachment === 'function' ? { attachment: request => remote.attachment!(request) } : {},\n }\n}\n\nfunction readPreview(value: unknown): EditPrepareValue {\n if (typeof value !== 'object' || value === null) throw new HostOperationError('session-manager/unavailable')\n const record = value as {\n sessionId?: unknown\n promptSeq?: unknown\n text?: unknown\n content?: unknown\n modified?: unknown\n }\n if (typeof record.sessionId !== 'string'\n || typeof record.promptSeq !== 'number'\n || typeof record.text !== 'string' || typeof record.modified !== 'boolean') {\n throw new HostOperationError('session-manager/unavailable')\n }\n const content = record.content\n if (content !== undefined && (!Array.isArray(content) || !content.every(isEditContent))) {\n throw new HostOperationError('session-manager/unavailable')\n }\n return {\n sessionId: record.sessionId,\n promptSeq: record.promptSeq,\n text: record.text,\n ...content === undefined ? {} : { content: content as EditContent[] },\n modified: record.modified,\n }\n}\n\nfunction isEditContent(value: unknown): value is EditContent {\n if (typeof value !== 'object' || value === null) return false\n const part = value as { type?: unknown; text?: unknown; attachmentId?: unknown; name?: unknown; bytes?: unknown }\n return part.type === 'text' ? typeof part.text === 'string'\n : (part.type === 'image' || (part.type === 'file' && typeof part.name === 'string' && typeof part.bytes === 'number'))\n && typeof part.attachmentId === 'string' && part.attachmentId !== ''\n}\n\ntype PendingContent = PromptContent | Exclude<DraftAttachment, { type: 'image' }>\n\n/** Build the exact body for the edited prompt; images are read from the source Session. */\nasync function buildContent(host: EditHost, preview: EditPrepareValue, text: string, signal: AbortSignal, attachments?: readonly DraftAttachment[]): Promise<PendingContent[]> {\n const content: PendingContent[] = []\n let wroteText = false\n const parts = attachments === undefined ? preview.content ?? [{ type: 'text' as const, text: preview.text }]\n : [{ type: 'text' as const, text }, ...attachments]\n for (const part of parts) {\n signal.throwIfAborted()\n if (part.type === 'text') {\n if (text === preview.text) content.push(part)\n else if (!wroteText) content.push({ type: 'text', text })\n wroteText = true\n continue\n }\n if (part.type === 'file') { content.push(part); continue }\n if (part.type === 'upload') {\n if (['image/png', 'image/jpeg', 'image/webp', 'image/gif'].includes(part.file.type)) {\n const data = await new Promise<string>((resolve, reject) => {\n const reader = new FileReader()\n reader.onload = () => { resolve(String(reader.result).split(',')[1]!) }\n reader.onerror = () => { reject(reader.error) }\n reader.readAsDataURL(part.file)\n })\n signal.throwIfAborted()\n content.push({ type: 'image', data, mediaType: part.file.type, name: part.file.name })\n } else content.push(part)\n continue\n }\n if (!host.attachment) throw new HostOperationError('session/lifecycle-unavailable')\n // Read against the source session, whose history authorizes this exact image.\n // Complete every read before staging, so a missing image cannot leave a half-staged body.\n const value = await unwrap(host.attachment({ sessionId: preview.sessionId, attachmentId: part.attachmentId }))\n const image = value as { attachment?: { attachmentId?: unknown; mediaType?: unknown; name?: unknown }; data?: unknown } | null\n if (image?.attachment?.attachmentId !== part.attachmentId || typeof image.data !== 'string' || image.data === ''\n || typeof image.attachment.mediaType !== 'string' || !image.attachment.mediaType.startsWith('image/')) {\n throw new HostOperationError('session/attachment-invalid')\n }\n content.push({\n type: 'image', data: image.data, mediaType: image.attachment.mediaType,\n ...typeof image.attachment.name === 'string' ? { name: image.attachment.name } : {},\n })\n }\n if (!wroteText && text !== '') content.push({ type: 'text', text })\n signal.throwIfAborted()\n return content\n}\n\nexport interface EditSubmission {\n readonly requestId: string\n /** Freeze bytes and receipts after confirmation so retries never reuse an id for a changed body. */\n prepared?: PendingContent[]\n content?: PromptContent[]\n receipts?: Map<number, string>\n}\n\n/** Prepare the exact edit body for the existing Session; the host sends it on submit. */\nexport async function prepareEditContent(\n host: EditHost, preview: EditPrepareValue, text: string, submission: EditSubmission,\n signal: AbortSignal, attachments?: readonly DraftAttachment[],\n): Promise<readonly PromptContent[]> {\n submission.prepared ??= await buildContent(host, preview, text, signal, attachments)\n await stageContent(host, preview, submission, preview.sessionId, signal)\n return submission.content!\n}\n\nasync function stageContent(host: EditHost, preview: EditPrepareValue, submission: EditSubmission, sessionId: string, signal: AbortSignal): Promise<void> {\n const prepared = submission.prepared!\n if (submission.content !== undefined) return\n const content: PromptContent[] = []\n const receipts = submission.receipts ??= new Map()\n for (const [index, part] of prepared.entries()) {\n signal.throwIfAborted()\n if (part.type !== 'upload' && !(part.type === 'file' && 'attachmentId' in part)) { content.push(part); continue }\n let receiptId = receipts.get(index)\n if (receiptId === undefined) {\n const result = part.type === 'upload'\n ? host.uploadFile?.(sessionId, part.file, signal)\n : host.stageFile?.({ sessionId: preview.sessionId, promptSeq: preview.promptSeq, attachmentId: part.attachmentId }, signal)\n if (!result) throw new HostOperationError('session/lifecycle-unavailable')\n const value = await unwrap(result) as { receiptId?: unknown }\n if (typeof value?.receiptId !== 'string' || value.receiptId === '') throw new HostOperationError('session/attachment-invalid')\n receiptId = value.receiptId\n receipts.set(index, receiptId)\n }\n content.push({ type: 'file', receiptId })\n }\n submission.content = content\n}\n\n/** Read the exact human prompt that the editor edits. */\nexport async function previewEdit(\n host: EditHost,\n sessionId: string,\n promptSeq: number,\n signal: AbortSignal,\n): Promise<EditPrepareValue> {\n if (typeof host.prepare !== 'function') throw new HostOperationError('session/lifecycle-unavailable')\n return readPreview(await unwrap(host.prepare({ sessionId, promptSeq }, signal)))\n}\n","import { useEffect, useRef, useState, useSyncExternalStore, type ReactNode } from 'react'\nimport { Button, Modal, Tooltip } from '@deepseek-ai/dsh-client-ui-primitives'\nimport { MessageEditor } from './message-editor.tsx'\nimport { EditMessageIcon } from './edit-icon.tsx'\nimport { HostOperationError, isStaleRetryFailure, readFailure, type RetryModel } from './session-actions.ts'\nimport { prepareEditContent, previewEdit, type DraftAttachment, type EditHost, type EditSubmission } from './edit-host.ts'\nimport type { EditPrepareValue } from './contracts.ts'\nimport { FREE_CHAT_ROOT } from './styles.ts'\nimport { failureText, uiText, type CopyLocale, type OperationFailure } from './ui-copy.ts'\n\n/** Edit one human prompt in its own Session; the host switches branches when the edit is sent. */\nexport function EditActions(props: {\n promptSeq?: number; sessionId?: string; messageId?: string; locale: CopyLocale\n host: EditHost; nativeRetry: RetryModel\n useSessionAccess?: (sessionId: string, action: string) => boolean\n ids?: () => string\n render?: (actions: ReactNode, editor: ReactNode) => React.ReactElement\n}): React.ReactElement | null {\n const sessionId = props.sessionId ?? ''\n const native = useSyncExternalStore(props.nativeRetry.subscribe, props.nativeRetry.getSnapshot, props.nativeRetry.getSnapshot)\n const [confirming, setConfirming] = useState(false)\n const [busy, setBusy] = useState(false)\n const [editing, setEditing] = useState(false)\n const [draft, setDraft] = useState('')\n const [attachments, setAttachments] = useState<DraftAttachment[]>([])\n const [mediaChanged, setMediaChanged] = useState(false)\n const [locked, setLocked] = useState(false)\n const [failure, setFailure] = useState<OperationFailure>()\n const preview = useRef<EditPrepareValue>()\n const submission = useRef<EditSubmission>()\n const signal = useRef(new AbortController())\n useEffect(() => {\n const controller = new AbortController()\n signal.current = controller\n return () => { controller.abort() }\n }, [sessionId, props.promptSeq])\n const allowed = props.useSessionAccess?.(sessionId, 'session/prompt') ?? true\n const copy = (key: Parameters<typeof uiText>[1]) => uiText(props.locale, key)\n const mine = native.sessionId === sessionId && native.messageId === props.messageId\n useEffect(() => {\n if (editing && !busy && native.controlsRetry && !mine) setEditing(false)\n }, [editing, busy, native.controlsRetry, mine])\n // Host capability is global and false while loading; it must not hide a new session's edit entry.\n if (!allowed || !sessionId || props.promptSeq === undefined || !props.host.prepare) return props.render?.(null, null) ?? null\n\n const run = async (action: 'edit' | 'send') => {\n if (busy || signal.current.signal.aborted) return\n setBusy(true)\n setFailure(undefined)\n try {\n if (!native.controlsRetry || !props.messageId) throw new HostOperationError('session/lifecycle-unavailable')\n if (action === 'edit') {\n const value = await previewEdit(props.host, sessionId, props.promptSeq!, signal.current.signal)\n await props.nativeRetry.beginEdit(sessionId, props.messageId, value.text, signal.current.signal)\n const state = props.nativeRetry.getSnapshot()\n if (!state.editing) { setFailure(state.failure); return }\n preview.current = value\n submission.current = { requestId: (props.ids ?? (() => crypto.randomUUID()))() }\n setDraft(value.text)\n setAttachments((value.content ?? []).filter((part): part is Exclude<NonNullable<EditPrepareValue['content']>[number], { type: 'text' }> => part.type !== 'text'))\n setMediaChanged(false)\n setLocked(false)\n setEditing(true)\n return\n }\n if (!preview.current || !submission.current) return\n if (mediaChanged && native.controlsContent !== true) throw new HostOperationError('session/retry-media-unavailable')\n setLocked(true)\n const content = mediaChanged ? await prepareEditContent(props.host, preview.current, draft, submission.current, signal.current.signal, attachments) : undefined\n props.nativeRetry.setDraft(draft)\n await props.nativeRetry.sendEdit(sessionId, props.messageId, signal.current.signal, content, true)\n const state = props.nativeRetry.getSnapshot()\n setFailure(state.failure)\n if (!state.editing) setEditing(false)\n else if (isStaleRetryFailure(state.failure)) setLocked(false)\n } catch (error) {\n if (!signal.current.signal.aborted) setFailure(readFailure(error))\n } finally {\n if (!signal.current.signal.aborted) setBusy(false)\n }\n }\n const cancel = () => {\n if (busy) return\n props.nativeRetry.cancelEdit()\n setEditing(false)\n setFailure(undefined)\n }\n const invalidatePrepared = () => {\n if (submission.current) submission.current = { requestId: submission.current.requestId }\n }\n const actions = <span className={`${FREE_CHAT_ROOT} dsh-free-actions`}>\n <Tooltip label={copy('edit')} side=\"bottom\">\n <Button className=\"dsm-icon-action\" size=\"sm\" variant=\"ghost\" aria-label={copy('edit')}\n disabled={busy || native.busy || (native.editing && !mine)} onClick={() => { void run('edit') }}><EditMessageIcon /></Button>\n </Tooltip>\n {failure && !editing ? <span className=\"dsh-ui-error dsh-free-alert\" role=\"alert\">{failureText(props.locale, failure)}</span> : null}\n </span>\n const editor = editing ? <MessageEditor text={draft} setText={text => { invalidatePrepared(); setDraft(text) }} attachments={attachments}\n setAttachments={native.controlsContent ? items => { invalidatePrepared(); setAttachments(items); setMediaChanged(true) } : undefined} sessionId={sessionId} host={props.host}\n locale={props.locale} busy={busy} locked={locked} onCancel={cancel} onSend={() => { setConfirming(true) }}\n error={failure ? failureText(props.locale, failure) : undefined} /> : null\n const content = props.render ? props.render(actions, editor) : <>{actions}{editor}</>\n return <>{content}<Modal open={confirming && editing} className={FREE_CHAT_ROOT} title={copy('editTitle')}\n closeLabel={copy('close')} onClose={() => { setConfirming(false) }} footer={<>\n <Button variant=\"ghost\" data-modal-autofocus onClick={() => { setConfirming(false) }}>{copy('cancel')}</Button>\n <Button variant=\"primary\" onClick={() => { setConfirming(false); void run('send') }}>{copy('editConfirm')}</Button>\n </>}><p>{copy('editBranchWarning')}</p></Modal></>\n}\n","import { Fragment, useEffect, useRef, useState, type ReactNode } from 'react'\nimport {\n Button,\n IconCheckOutlineRegular,\n IconCopyOutlineRegular,\n fileExtension,\n FileTypeIcon,\n fileSizeText,\n JsonBlock,\n Tooltip,\n writeClipboard,\n} from '@deepseek-ai/dsh-client-ui-primitives'\nimport { EditActions } from './edit-actions.tsx'\nimport type { EditHost } from './edit-host.ts'\nimport type { RetryModel } from './session-actions.ts'\nimport { UserMessageActions } from './user-actions.tsx'\nimport { FREE_CHAT_ROOT } from './styles.ts'\nimport type { CopyLocale } from './ui-copy.ts'\n\ninterface ContentBlock {\n type?: string\n text?: string\n attachment?: unknown\n}\n\ninterface PresentedImage {\n readonly type: 'image'\n readonly image: { readonly attachment: unknown }\n}\n\ninterface PresentedFile {\n readonly type: 'file'\n readonly file: {\n readonly attachmentId: string\n readonly name: string\n readonly bytes: number\n }\n}\n\ninterface UserNodeData {\n readonly seq: number\n readonly time: number\n readonly content: readonly ContentBlock[]\n readonly referenceLabels?: readonly string[]\n readonly skillNames?: readonly string[]\n}\n\ninterface UserNode {\n readonly id: string\n readonly data: UserNodeData\n}\n\ninterface UserContentInput {\n readonly content: {\n readonly text: string\n readonly attachments: readonly (PresentedImage | PresentedFile)[]\n readonly extraBlocks: readonly ContentBlock[]\n readonly referenceLabels?: readonly string[]\n }\n readonly loadImage?: unknown\n readonly facts: { readonly sessionLabels?: readonly string[]; readonly skillNames?: readonly string[] }\n readonly interactive: boolean\n}\n\ninterface UserNodeProps {\n readonly node: UserNode\n readonly sessionId?: string\n readonly locale: CopyLocale\n readonly host: EditHost\n readonly nativeRetry: RetryModel\n readonly useSessionAccess?: (sessionId: string, action: string) => boolean\n /** Current hosts own the complete content stack, including images and reference chips. */\n readonly renderFactorySlot?: (name: 'conversation.chat.user.content', input: UserContentInput) => ReactNode\n readonly loadImage?: unknown\n /** Older hosts expose only the image renderer. */\n readonly renderMessageImages?: (input: {\n readonly images: readonly { readonly attachment: unknown }[]\n readonly align: 'end'\n readonly compact: boolean\n }) => ReactNode\n readonly t: (key: string, params?: Record<string, unknown>) => string\n readonly ids?: () => string\n}\n\nfunction contentParts(content: readonly ContentBlock[]): {\n text: string\n attachments: (PresentedImage | PresentedFile)[]\n rest: ContentBlock[]\n} {\n const texts: string[] = []\n const attachments: (PresentedImage | PresentedFile)[] = []\n const rest: ContentBlock[] = []\n for (const block of content) {\n if (block.type === 'text' && typeof block.text === 'string') texts.push(block.text)\n else if (block.type === 'image' && block.attachment !== undefined) {\n attachments.push({ type: 'image', image: { attachment: block.attachment } })\n } else if (block.type === 'file' && block.attachment !== undefined) {\n attachments.push({ type: 'file', file: block.attachment as PresentedFile['file'] })\n } else rest.push(block)\n }\n return { text: texts.join(''), attachments, rest }\n}\n\nfunction pad2(value: number): string {\n return String(value).padStart(2, '0')\n}\n\nfunction messageClock(time: number, t: UserNodeProps['t']): string {\n const date = new Date(time)\n const now = new Date()\n const clock = `${pad2(date.getHours())}:${pad2(date.getMinutes())}`\n if (date.getFullYear() === now.getFullYear() && date.getMonth() === now.getMonth() && date.getDate() === now.getDate()) return clock\n const params = { y: date.getFullYear(), m: date.getMonth() + 1, d: date.getDate() }\n const day = date.getFullYear() === now.getFullYear() ? t('clock.md', params) : t('clock.ymd', params)\n return `${day} ${clock}`\n}\n\nfunction MessageChrome(props: {\n text: string\n time: number\n t: UserNodeProps['t']\n children?: ReactNode\n}): React.ReactElement {\n const [copied, setCopied] = useState(false)\n const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined)\n const pending = useRef(false)\n useEffect(() => () => {\n pending.current = false\n if (timer.current !== undefined) clearTimeout(timer.current)\n }, [])\n const copy = () => {\n if (copied || pending.current) return\n pending.current = true\n void writeClipboard(props.text).then(ok => {\n pending.current = false\n if (!ok) return\n setCopied(true)\n timer.current = setTimeout(() => { setCopied(false) }, 1000)\n })\n }\n return (\n <div className=\"dsm-user-chrome\">\n <span className=\"dsm-user-time\">{messageClock(props.time, props.t)}</span>\n {props.children}\n <Tooltip label={copied ? props.t('copied') : props.t('copy')} side=\"bottom\">\n <Button size=\"sm\" variant=\"ghost\" className=\"dsm-icon-action\" aria-label={copied ? props.t('copied') : props.t('copy')} onClick={copy}>\n {copied ? <IconCheckOutlineRegular /> : <IconCopyOutlineRegular />}\n </Button>\n </Tooltip>\n </div>\n )\n}\n\n/** User-message bubble whose own action row edits the exact prompt in place. */\nexport function UserNodeWithEdit(props: UserNodeProps): React.ReactElement {\n const { text, attachments, rest } = contentParts(props.node.data.content)\n const compactImages = attachments.length > 1\n const truncated = (total: number) => props.t('json.truncated', { total })\n const data = props.node.data\n return (\n <EditActions promptSeq={data.seq} sessionId={props.sessionId} locale={props.locale} host={props.host}\n nativeRetry={props.nativeRetry} useSessionAccess={props.useSessionAccess} ids={props.ids} messageId={props.node.id}\n render={(actions, editor) => <div className={`${FREE_CHAT_ROOT} dsm-user-row`}>\n {editor}\n <div className=\"dsm-user-original\" hidden={Boolean(editor)}>{!props.renderMessageImages && props.renderFactorySlot ? props.renderFactorySlot('conversation.chat.user.content', {\n content: {\n text, attachments, extraBlocks: rest,\n ...data.referenceLabels === undefined ? {} : { referenceLabels: data.referenceLabels },\n },\n loadImage: props.loadImage,\n facts: {\n ...data.referenceLabels === undefined ? {} : { sessionLabels: data.referenceLabels },\n ...data.skillNames === undefined ? {} : { skillNames: data.skillNames },\n },\n interactive: true,\n }) : <div className=\"dsm-user-stack\">\n {attachments.length > 0 ? (\n <div className=\"dsm-user-attachments\" data-message-attachments>\n {attachments.map((attachment, index) => attachment.type === 'image' ? (\n <Fragment key={`image:${index}`}>\n {props.renderMessageImages?.({ images: [attachment.image], align: 'end', compact: compactImages })}\n </Fragment>\n ) : (\n <span key={`file:${index}`} className=\"dsm-file-card\" title={attachment.file.name}>\n <FileTypeIcon path={attachment.file.name} className=\"dsm-file-icon\" />\n <span className=\"dsm-file-content\">\n <span className=\"dsm-file-name\">{attachment.file.name}</span>\n <span className=\"dsm-file-meta\">\n {[fileExtension(attachment.file.name).toUpperCase().slice(0, 8), fileSizeText(attachment.file.bytes)].filter(Boolean).join(' ')}\n </span>\n </span>\n </span>\n ))}\n </div>\n ) : null}\n {text !== '' || rest.length > 0 ? (\n <div className=\"dsm-user-bubble\">\n {text}\n {rest.map((block, index) => <JsonBlock key={index} label={props.t('message.extraBlock')} payload={block} truncatedLabel={truncated} />)}\n </div>\n ) : null}\n {data.referenceLabels !== undefined && data.referenceLabels.length > 0 ? (\n <div className=\"dsm-reference-summary\">\n {props.t('message.referenceSummary', { labels: data.referenceLabels.join(props.t('message.referenceSeparator')) })}\n </div>\n ) : null}\n </div>}\n <MessageChrome text={text} time={data.time} t={props.t}>\n <UserMessageActions\n messageId={props.node.id}\n text={text}\n sessionId={props.sessionId ?? ''}\n locale={props.locale}\n model={props.nativeRetry}\n hideEdit={Boolean(actions)}\n />\n {actions}\n </MessageChrome></div>\n </div>} />\n )\n}\n","import type { PromptContent } from './edit-host.ts'\n\nexport const RETRY_CAPABILITIES_ENDPOINT = 'retry.capabilities'\nexport const RETRY_PREVIEW_ENDPOINT = 'retry.preview'\nexport const RETRY_COMMIT_ENDPOINT = 'retry.commit'\n\nexport interface RetryCapabilities {\n readonly retry: boolean\n readonly retryModified: boolean\n readonly retryContent: boolean\n}\n\nexport interface RetryPreviewRequest {\n readonly sessionId: string\n readonly messageId: string\n}\n\nexport interface RetryPreviewValue {\n readonly sessionId: string\n readonly messageId: string\n readonly promptSeq: number\n readonly branchRevision: number\n readonly inputRevision: string\n readonly eligible: boolean\n readonly modified: boolean\n readonly reason?: string\n}\n\nexport interface RetryCommitRequest {\n readonly sessionId: string\n readonly messageId: string\n readonly expectedRevision: number\n readonly expectedInputRevision: string\n readonly requestId: string\n readonly text?: string\n readonly content?: readonly PromptContent[]\n readonly allowModified?: boolean\n}\n\nexport interface RetryCommitValue {\n /** The forked session the conversation continues in. */\n readonly sessionId: string\n /** The session the prompt was edited out of. */\n readonly sourceSessionId: string\n /** Whether the source session was moved to the archive. */\n readonly archived: boolean\n}\n","import type { PresenceRpc } from './presence-model.ts'\nimport {\n RETRY_CAPABILITIES_ENDPOINT,\n RETRY_COMMIT_ENDPOINT,\n RETRY_PREVIEW_ENDPOINT,\n type RetryCapabilities,\n type RetryCommitRequest,\n type RetryCommitValue,\n type RetryPreviewRequest,\n type RetryPreviewValue,\n} from './retry-contracts.ts'\nimport { TEMP_WORKSPACE_CHANNEL } from './contracts.ts'\nimport { HostOperationError, unwrap } from './session-actions.ts'\n\nexport interface RetryHost {\n capabilities: () => Promise<RetryCapabilities>\n preview: (request: RetryPreviewRequest, signal?: AbortSignal) => Promise<RetryPreviewValue>\n commit: (request: RetryCommitRequest, signal?: AbortSignal) => Promise<RetryCommitValue>\n}\n\nexport function bindRetryHost(rpc: PresenceRpc | undefined): RetryHost {\n const call = (endpoint: string, payload: unknown, signal?: AbortSignal) => {\n if (typeof rpc?.call !== 'function') throw new HostOperationError('session/lifecycle-unavailable')\n return rpc.call(TEMP_WORKSPACE_CHANNEL, endpoint, payload, signal)\n }\n return {\n async capabilities() {\n const value = await unwrap(call(RETRY_CAPABILITIES_ENDPOINT, {}))\n if (!isCapabilities(value)) throw new HostOperationError('session-manager/unavailable')\n return value\n },\n async preview(request, signal) {\n const value = await unwrap(call(RETRY_PREVIEW_ENDPOINT, request, signal))\n if (!isPreview(value)) throw new HostOperationError('session-manager/unavailable')\n return value\n },\n async commit(request, signal) {\n const value = await unwrap(call(RETRY_COMMIT_ENDPOINT, request, signal))\n if (!isCommit(value)) throw new HostOperationError('session-manager/unavailable')\n return value\n },\n }\n}\n\n/**\n * Commit then navigate: the forked child is the chat the user keeps, so the\n * browser follows a successful commit to the new session. `open` is absent\n * only when the host has no workspace navigation; the commit value returns\n * either way.\n */\nexport function retryCommitAndOpen(\n commit: RetryHost['commit'],\n open: ((sessionId: string) => void | Promise<void>) | undefined,\n): RetryHost['commit'] {\n return async (request, signal) => {\n const value = await commit(request, signal)\n try { await open?.(value.sessionId) }\n catch { throw new HostOperationError('session/retry-pending') }\n return value\n }\n}\n\nfunction isCapabilities(value: unknown): value is RetryCapabilities {\n if (typeof value !== 'object' || value === null) return false\n const item = value as Partial<RetryCapabilities>\n return typeof item.retry === 'boolean'\n && typeof item.retryModified === 'boolean'\n && typeof item.retryContent === 'boolean'\n}\n\nfunction isPreview(value: unknown): value is RetryPreviewValue {\n if (typeof value !== 'object' || value === null) return false\n const item = value as Partial<RetryPreviewValue>\n return typeof item.sessionId === 'string'\n && typeof item.messageId === 'string'\n && Number.isSafeInteger(item.promptSeq)\n && typeof item.branchRevision === 'number'\n && typeof item.inputRevision === 'string'\n && typeof item.eligible === 'boolean'\n && typeof item.modified === 'boolean'\n}\n\nfunction isCommit(value: unknown): value is RetryCommitValue {\n if (typeof value !== 'object' || value === null) return false\n const item = value as Partial<RetryCommitValue>\n return typeof item.sessionId === 'string'\n && typeof item.sourceSessionId === 'string'\n && typeof item.archived === 'boolean'\n}\n","import type { Context } from '@deepseek-ai/cordis'\nimport { MenuItemButton } from '@deepseek-ai/dsh-client-ui-primitives'\nimport { useSyncExternalStore } from 'react'\nimport { copyLocale, type CopyLocale, type UiTextKey } from './ui-copy.ts'\nimport {\n CONTINUE_GHOST_ID,\n PLUGIN_NAME,\n CONTINUE_GHOST_SLOT,\n DELETE_DIALOG_ID,\n TEMP_WORKSPACE_CHANNEL,\n USER_ACTIONS_ID,\n USER_ACTIONS_SLOT,\n WELCOME_BACK_CARD_ID,\n TURN_TAIL_SLOT,\n SESSION_SETTINGS_ITEMS,\n} from './contracts.ts'\nimport { installContextMenuForwarding } from './context-menu.ts'\nimport { CreateNoticeDialog, DeleteChatDialog } from './free-panel.tsx'\nimport { installTemporaryWorkspacePicker, TemporaryWorkspaceNotice, type PickerRegistry } from './temporary-picker.tsx'\nimport { bindTemporaryWorkspaceHost, createTemporaryWorkspaceModel } from './temporary-workspace.ts'\nimport { bindHost, createFreeChatModel, createRetryModel, type FreeChatModel, type RetryModel } from './session-actions.ts'\nimport { bindPresenceHost, createContinueModel, createPresenceConfigModel, createWelcomeBackModel } from './presence-model.ts'\nimport { AutoContinueOption } from './auto-continue-option.tsx'\nimport { modelSettingsChangesIdentity } from '@klarkxy/dsh-plugin-kit/contracts'\nimport { registerSessionSettingsItem } from '@klarkxy/dsh-plugin-kit/client-utils'\nimport { registerAuxiliaryModelSettings } from '@klarkxy/dsh-plugin-kit/auxiliary-model-client'\nimport { createModelSettingsSubscriber, mountModelSettingsChanges } from '@klarkxy/dsh-plugin-kit/model-settings-client'\nimport { MODEL_CATALOG_INJECT, readModelCatalog } from '@klarkxy/dsh-model-route'\nimport type { RenderFactorySlot } from '@klarkxy/dsh-plugin-kit/model-picker'\nimport { ContinueGhost, WelcomeBackCard, type WelcomeBackTurn } from './presence-panel.tsx'\nimport {\n AgentActionsSettings,\n AutoContinueSettings,\n ComposerSettings,\n HandoffSettings,\n ReturnSettings,\n SessionSettingsDetails,\n} from './settings-panel.tsx'\nimport { freeChatCss } from './styles.ts'\nimport { UserMessageActions } from './user-actions.tsx'\nimport { UserNodeWithEdit } from './user-node.tsx'\nimport { bindEditHost } from './edit-host.ts'\nimport { bindRetryHost, retryCommitAndOpen } from './retry-host.ts'\nimport { uiText } from './ui-copy.ts'\n\nexport const name = 'dsh-session-manager-client'\nexport const inject = ['slots', 'locale', 'sessions', 'uiWorkspace', 'connection', 'workspaces', 'layout', 'conversation', ...MODEL_CATALOG_INJECT] as const\n\ninterface LocaleService {\n getSnapshot(): { active: string }\n subscribe(listener: () => void): () => void\n register?(namespace: string, dictionaries: { zh: Record<string, string>; en: Record<string, string> }): (() => void) | void\n}\n\ninterface MenuProps {\n sessionId: string\n useMenuOpenState: () => [boolean, (open: boolean) => void]\n}\n\ninterface SlotRegistry {\n inject(key: string, callback: () => (() => void) | void): () => void\n register(spec: Record<string, unknown>, render: (props: never) => unknown): () => void\n}\n\ntype Client = Context & {\n slots: SlotRegistry\n locale?: LocaleService\n sessions?: Parameters<typeof bindHost>[0]['sessions']\n uiWorkspace?: Parameters<typeof bindHost>[0]['uiWorkspace']\n remote?: { session?: { modelCatalog?: () => Promise<unknown> } }\n connection?: {\n generation?: { subscribe(listener: () => void): () => void }\n rpc?: { call(channel: string, endpoint: string, payload: unknown, signal?: AbortSignal): Promise<unknown> }\n }\n on?(name: string, listener: () => void): () => void\n}\n\nexport function apply(ctx: Context): void {\n const client = ctx as Client\n mountModelSettingsChanges(client, PLUGIN_NAME)\n const host = bindHost(client)\n const chats = createFreeChatModel(host)\n const retryHost = bindRetryHost(client.connection?.rpc)\n const retries = createRetryModel({\n list: host.list,\n capabilities: () => retryHost.capabilities(),\n previewRetry: request => retryHost.preview(request),\n retry: retryCommitAndOpen(retryHost.commit, host.openSession),\n })\n const editHost = bindEditHost(client as unknown as Parameters<typeof bindEditHost>[0])\n const temporaryHost = bindTemporaryWorkspaceHost(client as unknown as Parameters<typeof bindTemporaryWorkspaceHost>[0])\n const temporary = createTemporaryWorkspaceModel(temporaryHost, undefined,\n () => uiText(copyLocale(client.locale?.getSnapshot().active), 'tempWorkspace'))\n const presenceHost = bindPresenceHost(client)\n const continues = createContinueModel(presenceHost)\n const welcomeBack = createWelcomeBackModel(presenceHost)\n const presenceConfig = createPresenceConfigModel(presenceHost)\n // Model catalog access uses the same dependency contract as every model menu.\n const settingsSubscriber = createModelSettingsSubscriber(client as unknown as Parameters<typeof createModelSettingsSubscriber>[0], PLUGIN_NAME, modelSettingsChangesIdentity(PLUGIN_NAME))\n const subscribeSettings = (onChange: () => void, onError?: (message: string) => void) =>\n settingsSubscriber.subscribe(onChange, onError)\n const modelCatalog = () => readModelCatalog(client)\n const subscribeCatalog = (onChange: () => void) => client.connection?.generation?.subscribe(onChange)\n client.effect(() => {\n const stops: Array<() => void> = []\n // The relay needs no host slot and no service; a non-browser host simply skips it.\n if (typeof document !== 'undefined') stops.push(installContextMenuForwarding(document))\n stops.push(client.slots.inject('sidebar.workspaces.session.menu.item', () => (\n client.slots.register({\n name: 'sidebar.workspaces.session.menu.item',\n id: DELETE_DIALOG_ID,\n order: 510,\n }, props => <DeleteMenuItem locale={client.locale} model={chats} {...props as MenuProps} />)\n )))\n stops.push(installTemporaryWorkspacePicker(client.slots as unknown as PickerRegistry, temporary,\n temporaryHost.createWorkspace, client.locale))\n stops.push(client.slots.inject('conversation.hero.options', () => (\n client.slots.register({\n name: 'conversation.hero.options',\n id: 'auto-continue',\n order: 30,\n inject: () => ({\n call: (endpoint: string, payload: unknown) => client.connection?.rpc?.call(TEMP_WORKSPACE_CHANNEL, endpoint, payload),\n subscribeGeneration: (listener: () => void) => client.connection?.generation?.subscribe(listener),\n }),\n }, props => (\n <AutoContinueOption\n sessionId={(props as { sessionId: string }).sessionId}\n call={(props as { call: (endpoint: string, payload: unknown) => Promise<unknown> }).call}\n subscribeGeneration={(props as { subscribeGeneration?: (listener: () => void) => (() => void) | undefined }).subscribeGeneration}\n useSession={(props as { useSession?: <T>(selector: (snapshot: import('./auto-continue-option.tsx').AutoContinueSessionSnapshotLike) => T) => T }).useSession}\n locale={useLiveLocale(client.locale)}\n />\n ))\n )))\n stops.push(client.slots.inject(USER_ACTIONS_SLOT, () => (\n client.slots.register({\n name: USER_ACTIONS_SLOT,\n id: USER_ACTIONS_ID,\n order: 10,\n inject: (sessionId: string) => ({ sessionId }),\n }, props => (\n <UserMessageActions\n messageId={(props as { messageId: string }).messageId}\n text={(props as { text: string }).text}\n sessionId={(props as { sessionId?: string }).sessionId ?? ''}\n locale={useLiveLocale(client.locale)}\n model={retries}\n />\n ))\n )))\n stops.push(client.slots.inject(CONTINUE_GHOST_SLOT, () => (\n client.slots.register({\n name: CONTINUE_GHOST_SLOT,\n id: CONTINUE_GHOST_ID,\n order: 10,\n }, props => (\n <ContinueGhost\n sessionId={(props as { sessionId?: string }).sessionId}\n useInput={(props as { useInput?: never }).useInput}\n useSession={(props as { useSession?: never }).useSession}\n useSessionStatus={(props as { useSessionStatus?: never }).useSessionStatus}\n inputActions={(props as { inputActions?: never }).inputActions}\n locale={useLiveLocale(client.locale)}\n model={continues}\n />\n ))\n )))\n // The stock host has no additive user-action slot. Replace only its user\n // renderer, preserving the bubble, copy, and clock while adding exact-seq editing.\n stops.push(client.slots.inject('conversation.chat.node', () => (\n client.slots.register({ name: 'conversation.chat.node', key: 'user', locale: 'chat', priority: -10 }, props => {\n const input = props as unknown as Parameters<typeof UserNodeWithEdit>[0]\n return (\n <UserNodeWithEdit\n {...input}\n sessionId={(props as { sessionId?: string }).sessionId}\n locale={useLiveLocale(client.locale)}\n host={editHost}\n nativeRetry={retries}\n />\n )\n })\n )))\n // Recap card lives in the chat flow at the latest completed turn's tail,\n // after the shipped deliverables/plan/schedule entries (orders 0/0/20).\n stops.push(client.slots.inject(TURN_TAIL_SLOT, () => (\n client.slots.register({\n name: TURN_TAIL_SLOT,\n id: WELCOME_BACK_CARD_ID,\n order: 30,\n }, props => (\n <WelcomeBackCard\n sessionId={(props as { sessionId?: string }).sessionId}\n turn={(props as { turn?: WelcomeBackTurn }).turn}\n useChat={(props as { useChat?: never }).useChat}\n useInput={(props as { useInput?: never }).useInput}\n locale={useLiveLocale(client.locale)}\n model={welcomeBack}\n />\n ))\n )))\n // Session preferences contribute four rows to the shared Session\n // Management settings section. The kit-owned base service owns the page,\n // so this plugin neither registers a section itself nor falls back to the\n // General page. Every row's body mounts on first expand only, so model-\n // catalog and config reads do not run until the user opens it, and stays\n // mounted while collapsed so a fold never drops an in-progress draft.\n // The rows share presenceConfig (loads dedupe); the live settings change\n // stream reloads it at the plugin level, so the rows do not subscribe.\n const registerSettingsRow = (\n item: (typeof SESSION_SETTINGS_ITEMS)[number],\n testId: string,\n titleKey: UiTextKey,\n descKey: UiTextKey,\n body: (locale: CopyLocale, renderFactorySlot?: RenderFactorySlot) => React.ReactNode,\n ) => stops.push(registerSessionSettingsItem(\n ctx,\n item,\n slotProps => {\n const locale = useLiveLocale(client.locale)\n return (\n <SessionSettingsDetails testId={testId} titleKey={titleKey} descKey={descKey} locale={locale}>\n {body(locale, (slotProps as { renderFactorySlot?: RenderFactorySlot } | undefined)?.renderFactorySlot)}\n </SessionSettingsDetails>\n )\n },\n ))\n const catalogProps = { modelCatalog, subscribeCatalog }\n registerSettingsRow(\n SESSION_SETTINGS_ITEMS[0],\n 'session-manager-composer-settings-item',\n 'composerGroupTitle',\n 'composerGroupHint',\n (locale, renderFactorySlot) => <ComposerSettings model={presenceConfig} locale={locale} renderFactorySlot={renderFactorySlot} {...catalogProps} />,\n )\n registerSettingsRow(\n SESSION_SETTINGS_ITEMS[1],\n 'session-manager-auto-continue-settings-item',\n 'autoContinueGroup',\n 'autoContinueGroupHint',\n (locale, renderFactorySlot) => <AutoContinueSettings model={presenceConfig} locale={locale} renderFactorySlot={renderFactorySlot} {...catalogProps} />,\n )\n registerSettingsRow(\n SESSION_SETTINGS_ITEMS[2],\n 'session-manager-return-settings-item',\n 'returnGroupTitle',\n 'returnGroupHint',\n (locale, renderFactorySlot) => <ReturnSettings model={presenceConfig} locale={locale} renderFactorySlot={renderFactorySlot} {...catalogProps} />,\n )\n registerSettingsRow(\n SESSION_SETTINGS_ITEMS[3],\n 'session-manager-handoff-settings-item',\n 'handoffGroupTitle',\n 'handoffGroupHint',\n (locale, renderFactorySlot) => <HandoffSettings model={presenceConfig} locale={locale} renderFactorySlot={renderFactorySlot} {...catalogProps} />,\n )\n registerSettingsRow(\n SESSION_SETTINGS_ITEMS[4],\n 'session-manager-agent-actions-settings-item',\n 'agentActionsGroup',\n 'agentActionsGroupHint',\n locale => <AgentActionsSettings model={presenceConfig} locale={locale} />,\n )\n stops.push(client.slots.inject('shell.overlay', () => (\n client.slots.register({\n name: 'shell.overlay',\n id: DELETE_DIALOG_ID,\n order: 40,\n }, () => {\n const locale = useLiveLocale(client.locale)\n return (\n <>\n <style>{freeChatCss}</style>\n <TemporaryWorkspaceNotice model={temporary} locale={locale} />\n <DeleteChatDialog model={chats} locale={locale} />\n <CreateNoticeDialog model={chats} locale={locale} />\n </>\n )\n })\n )))\n // Shared \"default auxiliary model\" card on the Models settings page: one\n // root-owned card for every participant plugin, released with this effect.\n stops.push(registerAuxiliaryModelSettings(ctx))\n // Return triggers: window refocus, tab visibility, current-session switch, first mount.\n const findCurrent = () => Object.values(client.sessions?.list.getSnapshot().byId ?? {})\n .find(row => (row?.retainedBy?.mainView ?? 0) > 0)?.id ?? ''\n let current = findCurrent()\n const onReturn = () => {\n const id = findCurrent()\n if (id !== '') void welcomeBack.check(id)\n }\n let lastThresholds: string | undefined\n let lastContinuation: string | undefined\n stops.push(presenceConfig.subscribe(() => {\n const config = presenceConfig.getSnapshot()\n if (config.phase !== 'ready' || config.saving || config.values === undefined) return\n const continuation = JSON.stringify([config.values.continueMode, config.values.continueText, config.values.ghostModel])\n if (continuation !== lastContinuation) {\n lastContinuation = continuation\n continues.invalidateAll()\n }\n const thresholds = `${config.values.recapMinutes}:${config.values.compactMinutes}`\n if (thresholds !== lastThresholds) {\n lastThresholds = thresholds\n welcomeBack.invalidate()\n onReturn()\n }\n }))\n // Keep synchronization alive even when the settings page is never opened.\n stops.push(subscribeSettings(() => { void presenceConfig.load() }))\n const refreshConfig = () => { void presenceConfig.load().then(onReturn) }\n const watchGeneration = client.connection?.generation?.subscribe(refreshConfig)\n if (watchGeneration) stops.push(watchGeneration)\n if (typeof window !== 'undefined') {\n const refreshOnReturn = refreshConfig\n const onVisibility = () => { if (!document.hidden) refreshOnReturn() }\n window.addEventListener('focus', refreshOnReturn)\n document.addEventListener('visibilitychange', onVisibility)\n const timer = setTimeout(refreshOnReturn, 1_500)\n // A continuously visible conversation must also cross an idle threshold\n // without requiring the user to blur the window or switch sessions.\n const idleTimer = setInterval(() => {\n if (!document.hidden) onReturn()\n }, 30_000)\n stops.push(() => {\n window.removeEventListener('focus', refreshOnReturn)\n document.removeEventListener('visibilitychange', onVisibility)\n clearTimeout(timer)\n clearInterval(idleTimer)\n })\n }\n const watchList = client.sessions?.list.subscribe(() => {\n const id = findCurrent()\n if (id !== current) {\n current = id\n if (id !== '') void welcomeBack.check(id)\n }\n })\n if (typeof watchList === 'function') stops.push(watchList)\n const reset = client.on?.('connection/reset', () => {\n void chats.reloadCapabilities()\n void retries.load()\n refreshConfig()\n })\n if (typeof reset === 'function') stops.push(reset)\n void chats.reloadCapabilities()\n void retries.load()\n return () => {\n chats.cancel()\n retries.cancel()\n temporary.cancel()\n continues.cancel()\n welcomeBack.cancel()\n presenceConfig.cancel()\n for (const stop of stops) stop()\n }\n })\n}\n\nfunction DeleteMenuItem(props: MenuProps & { locale?: LocaleService; model: FreeChatModel }): React.ReactElement | null {\n const locale = useLiveLocale(props.locale)\n const snapshot = useSyncExternalStore(props.model.subscribe, props.model.getSnapshot, props.model.getSnapshot)\n const [, setMenuOpen] = props.useMenuOpenState()\n if (!snapshot.controls.delete) return null\n return (\n <MenuItemButton danger onSelect={() => {\n props.model.requestDelete(props.sessionId)\n setMenuOpen(false)\n }}>\n {uiText(locale, 'deleteChat')}\n </MenuItemButton>\n )\n}\n\nfunction useLiveLocale(locale: LocaleService | undefined): CopyLocale {\n const active = useSyncExternalStore(\n listener => locale?.subscribe(listener) ?? (() => {}),\n () => locale?.getSnapshot().active ?? 'en',\n () => locale?.getSnapshot().active ?? 'en',\n )\n return copyLocale(active)\n}\n\nexport type { FreeChatModel, RetryModel }\n"],"mappings":";;;;;;AAIA,SAAgB,WAAW,QAAwC;CACjE,OAAO,QAAQ,YAAY,CAAC,CAAC,WAAW,IAAI,IAAI,OAAO;AACzD;AAOA,MAAM,UAAU;CACd,IAAI;EACF,UAAU;EACV,SAAS;EACT,SAAS;EACT,OAAO;EACP,SAAS;EACT,SAAS;EACT,aAAa;EACb,cAAc;EACd,gBAAgB;CAClB;CACA,IAAI;EACF,UAAU;EACV,SAAS;EACT,SAAS;EACT,OAAO;EACP,SAAS;EACT,SAAS;EACT,aAAa;EACb,cAAc;EACd,gBAAgB;CAClB;AACF;AAIA,MAAM,OAAO;CACX,IAAI;EACF,eAAe;EACf,cAAc;EACd,WAAW;EACX,YAAY;EACZ,UAAU;EACV,YAAY;EACZ,gBAAgB;EAChB,QAAQ;EACR,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;EACN,WAAW;EACX,mBAAmB;EACnB,aAAa;EACb,mBAAmB;EACnB,sBAAsB;EACtB,WAAW;EACX,mBAAmB;EACnB,OAAO;EACP,iBAAiB;EACjB,aAAa;EACb,cAAc;EACd,eAAe;EACf,eAAe;EACf,aAAa;EACb,YAAY;EACZ,YAAY;EACZ,oBAAoB;EACpB,aAAa;EACb,sBAAsB;EACtB,iBAAiB;EACjB,gBAAgB;EAChB,eAAe;EACf,oBAAoB;EACpB,mBAAmB;EACnB,WAAW;EACX,UAAU;EACV,mBAAmB;EACnB,i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