Release 1.3.0 with AI reply bubbles and bottom process frame

This commit is contained in:
QQ 2026-11-28 23:11:32 +08:00
parent 6bbca59f8d
commit ef5be0408c
14 changed files with 562 additions and 291 deletions

View File

@ -1,5 +1,13 @@
# Changelog # Changelog
## 1.3.0 — 2026-11-28
- 新增左侧 AI 回复气泡(柔灰底色、左下对话尾角,适配浅色 / 深色 / 毛玻璃主题),多段回复合并在同一个气泡内、无段间横线,内部代码块自动提亮底色。
- 思考与工具过程框移至 AI 回复气泡下方,与 AI 气泡共用最大宽度 `90%`(窄屏 `92%`);收起时呈现贴合胶囊,展开时保留内部滚动上限与顶部分割线;流式波次使用稳定 key,避免实时折叠重挂载。
- 操作栏(复制 / 赞踩 / 分叉 / 指标 / 时间)移至气泡与过程框外侧最下方,移除已完成过程框标题上重复的「用时」展示。
- 修复窄宽下回答操作栏与 `TurnMetrics` 指标胶囊挤压折行变形、以及指标浮卡在窄屏下冲出右侧边界的问题。
- 验证:`tsc --noEmit`、`vitest run`(34 个文件 / 258 个用例)、`tsdown` 构建通过。
## 1.2.0 — 2026-11-28 ## 1.2.0 — 2026-11-28
- 阅读视图改为直接接管「对话」页签:在 `conversation.view` 里以 `id: 'chat'`、`priority: -10` 遮蔽官方 ChatView,并隐藏官方那条页签账本行(只清空其 View `id`,不删除条目、不提前释放子槽与 store),插件卸载时原样恢复;三次方重注册在遮蔽期间会被自动重新隐藏。 - 阅读视图改为直接接管「对话」页签:在 `conversation.view` 里以 `id: 'chat'`、`priority: -10` 遮蔽官方 ChatView,并隐藏官方那条页签账本行(只清空其 View `id`,不删除条目、不提前释放子槽与 store),插件卸载时原样恢复;三次方重注册在遮蔽期间会被自动重新隐藏。

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{ {
"name": "dsh-better-chat", "name": "dsh-better-chat",
"version": "1.2.3", "version": "1.3.0",
"description": "DSH 聊天增强插件:审批回车批准 / Esc 拒绝、权限 UI、插件商店更新、默认自动审查。", "description": "DSH 聊天增强插件:审批回车批准 / Esc 拒绝、权限 UI、插件商店更新、默认自动审查。",
"type": "module", "type": "module",
"license": "MIT", "license": "MIT",

View File

@ -1,12 +1,11 @@
import { Fragment, memo } from 'react'; import { memo } from 'react';
import type { RefObject } from 'react'; import type { RefObject } from 'react';
import type { ChatConversationViewNode, ChatNode, ChatNodeKind } from '@deepseek-ai/dsh-client-ui-chat/client'; import type { ChatConversationViewNode, ChatNode, ChatNodeKind } from '@deepseek-ai/dsh-client-ui-chat/client';
import { Blocks, CopyAnswer } from './Blocks.js'; import { Blocks } from './Blocks.js';
import { ReasoningCard } from './ReasoningCard.js'; import { ReasoningCard } from './ReasoningCard.js';
import { OfficialActions, OfficialAssistantBody } from './OfficialContent.js'; import { OfficialAssistantBody } from './OfficialContent.js';
import { Disclosure, ProcessFragment } from './motion.js'; import { ProcessFragment } from './motion.js';
import type { ProcessSeam } from './live-turn.js'; import { assistantSegments, hasVisibleBody, isEarlierNarration } from './projection.js';
import { assistantSegments, forkAnchorSeq, hasVisibleBody, isEarlierNarration } from './projection.js';
import type { TurnBoundary } from './projection.js'; import type { TurnBoundary } from './projection.js';
import type { BlockRenderProps, ReaderProps } from './types.js'; import type { BlockRenderProps, ReaderProps } from './types.js';
import { answerRowAttrs } from './chat-seat.js'; import { answerRowAttrs } from './chat-seat.js';
@ -20,9 +19,8 @@ type SeatProps = BlockRenderProps & Pick<ReaderProps, 'useChat' | 'sessionId'> &
nodeKey: string; boundary: TurnBoundary; pinned?: boolean; processOpen?: boolean; nodeKey: string; boundary: TurnBoundary; pinned?: boolean; processOpen?: boolean;
}; };
export const AssistantNode = memo(function AssistantNode({ useChat, nodeKey, boundary, processOpen = false, pinned = false, folded = false, partStart, seamSummary, seamAfter = false, motion, onRead, returnFocusTo, ...render }: SeatProps & { export const AssistantNode = memo(function AssistantNode({ useChat, nodeKey, boundary, processOpen = false, pinned = false, folded = false, partStart, motion, onRead, returnFocusTo, ...render }: SeatProps & {
motion: boolean; onRead: () => void; returnFocusTo: RefObject<HTMLButtonElement>; partStart?: number; folded?: boolean; motion: boolean; onRead: () => void; returnFocusTo: RefObject<HTMLButtonElement>; partStart?: number; folded?: boolean;
seamSummary?: ProcessSeam; seamAfter?: boolean;
}) { }) {
const node = useChat(snapshot => snapshot.nodes.get(nodeKey)); const node = useChat(snapshot => snapshot.nodes.get(nodeKey));
if (!node || node.visibility === 'hidden' || !isNode(node, 'assistant-step')) return null; if (!node || node.visibility === 'hidden' || !isNode(node, 'assistant-step')) return null;
@ -31,7 +29,6 @@ export const AssistantNode = memo(function AssistantNode({ useChat, nodeKey, bou
const earlier = isEarlierNarration(data, boundary); const earlier = isEarlierNarration(data, boundary);
const hasToolCalls = data.blocks.some(block => block.kind === 'tool-call'); const hasToolCalls = data.blocks.some(block => block.kind === 'tool-call');
const isProcessStep = earlier || folded || hasToolCalls || (boundary.latestStep > 0 && data.step < boundary.latestStep); const isProcessStep = earlier || folded || hasToolCalls || (boundary.latestStep > 0 && data.step < boundary.latestStep);
const body = data.blocks.filter(block => block.kind !== 'reasoning' && block.kind !== 'tool-call');
const visible = partStart === undefined ? parts : parts.filter(part => part.start === partStart); const visible = partStart === undefined ? parts : parts.filter(part => part.start === partStart);
const bodyProps = { streaming: data.status === 'running', holdFormatting: pinned, startedAt: data.time, interrupted: data.status === 'interrupted', liveText: true as const }; const bodyProps = { streaming: data.status === 'running', holdFormatting: pinned, startedAt: data.time, interrupted: data.status === 'interrupted', liveText: true as const };
return <>{visible.map(part => { return <>{visible.map(part => {
@ -44,31 +41,11 @@ export const AssistantNode = memo(function AssistantNode({ useChat, nodeKey, bou
</ReasoningCard> </ReasoningCard>
</ProcessFragment>; </ProcessFragment>;
if (!hasVisibleBody(part.blocks)) return null; if (!hasVisibleBody(part.blocks)) return null;
// Narration stays body prose and never enters a disclosure. The seam in
// the gap summarises folded process between two body blocks. A foreign
// assistant-step renderer receives these original blocks; Reader markdown,
// including the text transform, is only the fallback.
const isFinalAnswer = !isProcessStep; const isFinalAnswer = !isProcessStep;
return <Fragment key={part.start}> return <article className={css.answer} key={part.start} data-reader-body data-reader-anchor data-reader-key={nodeKey} data-reader-source-start={part.start}
{seamSummary && <div className={css.processSeamRow} data-reader-process-seam data-reader-process-seam-summary={seamSummary.summary}>
<Disclosure open={false} onChange={() => onRead()} ariaLabel={`执行记录,${seamSummary.summary}`}
label={<span title={seamSummary.summary}>查看 {seamSummary.count} 条执行记录</span>} />
</div>}
<article className={css.answer} data-reader-body data-reader-anchor data-reader-key={nodeKey} data-reader-source-start={part.start}
{...answerRowAttrs(nodeKey, part.start, data.turn)} {...answerRowAttrs(nodeKey, part.start, data.turn)}
data-reader-seam-after={seamAfter || undefined} data-answer-status={data.status} data-answer-phase={isFinalAnswer ? 'body' : 'process'}> data-answer-status={data.status} data-answer-phase={isFinalAnswer ? 'body' : 'process'}>
<OfficialAssistantBody {...render} node={node} blocks={part.blocks} {...bodyProps} /> <OfficialAssistantBody {...render} node={node} blocks={part.blocks} {...bodyProps} />
{isFinalAnswer && last && data.status === 'interrupted' && <span className={css.stopped}>已停止</span>} </article>;
{isFinalAnswer && last && data.status !== 'running' && boundary.status === 'closed' && (
<CopyAnswer blocks={body} onFork={(() => {
// The fork anchor must be the durable closing message seq (same as
// the official turn-tail branch). AssistantChatData carries no seq
// of its own; passing it would fork the whole session instead.
const anchor = forkAnchorSeq([data.finalNode, { seq: render.forkSeq }]);
return render.forkAt && anchor !== undefined ? () => render.forkAt!(anchor) : undefined;
})()} metrics={render.metrics} extraActions={<OfficialActions official={render.official} messageId={data.finalNode?.messageId} />} />
)}
</article>
</Fragment>;
})}</>; })}</>;
}); });

View File

@ -1,10 +1,10 @@
import { createContext, useContext, useEffect, useLayoutEffect, useRef, useState } from 'react'; import { createContext, Fragment, useContext, useEffect, useLayoutEffect, useRef, useState } from 'react';
import type { ReactNode } from 'react'; import type { ReactNode } from 'react';
import type { ChatSnapshot } from '@deepseek-ai/dsh-client-ui-chat/client'; import type { ChatSnapshot } from '@deepseek-ai/dsh-client-ui-chat/client';
import type { ReaderProps } from './types.js'; import type { ReaderProps } from './types.js';
import type { LiveStep, LiveTurnItem } from './live-turn.js'; import type { LiveStep, LiveTurnItem } from './live-turn.js';
import { collapseRows, containsNewUser, flowRows, FOLD_TIMING, groupProcessRows, retiringKeys } from './fold-choreography.js'; import { arrangeTurnWaves, collapseRows, containsNewUser, flowRows, FOLD_TIMING, retiringKeys } from './fold-choreography.js';
import type { FlowRow, FoldPhase } from './fold-choreography.js'; import type { FlowBucket, FlowRow, FoldPhase } from './fold-choreography.js';
import { Disclosure } from './motion.js'; import { Disclosure } from './motion.js';
import { FoldSummaryText } from './LiveFold.js'; import { FoldSummaryText } from './LiveFold.js';
import { DiffStat } from './DiffPanel.js'; import { DiffStat } from './DiffPanel.js';
@ -12,7 +12,7 @@ import { StreamMotionContext } from './streaming.js';
import css from './Reader.module.css'; import css from './Reader.module.css';
import { useSummaryLane } from './StickyLane.js'; import { useSummaryLane } from './StickyLane.js';
const FLOW_CELLS = ':scope > [data-flow-key], :scope > [data-reader-process-frame] > [data-reader-process-scroll] > [data-flow-key]'; const FLOW_CELLS = ':scope > [data-flow-key], :scope > [data-reader-answer-bubble] > [data-flow-key], :scope > [data-reader-process-frame] > [data-reader-process-scroll] > [data-flow-key]';
const FlowSnapshot = createContext<ChatSnapshot | null>(null); const FlowSnapshot = createContext<ChatSnapshot | null>(null);
/** Public projection only. Descendants cannot leak live data through a frozen frame. */ /** Public projection only. Descendants cannot leak live data through a frozen frame. */
export const useFlowChat: ReaderProps['useChat'] = selector => { export const useFlowChat: ReaderProps['useChat'] = selector => {
@ -279,18 +279,40 @@ export function ChoreographedFlow({ frame, motion, enabled, urgent, open, onOpen
const blocked = state.phase === 'collapse' || state.phase === 'count' || state.phase === 'settle'; const blocked = state.phase === 'collapse' || state.phase === 'count' || state.phase === 'settle';
const source = state.phase === 'idle' || state.phase === 'collapse' ? state.shown : state.target; const source = state.phase === 'idle' || state.phase === 'collapse' ? state.shown : state.target;
const rows = state.phase === 'collapse' ? collapseRows(state.shown.items, state.target.items) : flowRows(source.items); const rows = state.phase === 'collapse' ? collapseRows(state.shown.items, state.target.items) : flowRows(source.items);
const cells = rows.map(row => { type FlowCellEntry = { row: FlowRow; key: string; hidden: boolean; process: boolean; bucket: FlowBucket };
if (row.kind === 'summary') return { row, key: row.key, hidden: false, process: true }; const cells: FlowCellEntry[] = rows.map(row => {
if (row.kind === 'summary') return { row, key: row.key, hidden: false, process: true, bucket: 'process' };
if (row.step.kind === 'user') return { row, key: row.key, hidden: false, process: false, bucket: 'user' };
if (row.step.kind === 'body') {
const hidden = blocked && state.phase !== 'collapse' && !state.beforeKeys.has(row.key);
return { row, key: row.key, hidden, process: false, bucket: 'body' };
}
const node = row.step.kind === 'other' ? source.snapshot.nodes.get(row.step.nodeKey) : undefined; const node = row.step.kind === 'other' ? source.snapshot.nodes.get(row.step.nodeKey) : undefined;
const trigger = !!status && node?.kind === 'turn-trigger'; const trigger = !!status && node?.kind === 'turn-trigger';
const process = row.step.kind === 'reasoning' || row.step.kind === 'tool' || trigger const isProcess = row.step.kind === 'reasoning' || row.step.kind === 'tool' || trigger
|| (row.step.kind === 'other' && row.step.process === true && node?.kind !== 'turn-trigger'); || (row.step.kind === 'other' && row.step.process === true && node?.kind !== 'turn-trigger');
const hidden = (trigger && !processOpen) || !!row.foldKey && (!processOpen || !open[row.foldKey]) const hidden = (isProcess && !processOpen)
|| (trigger && !processOpen)
|| (!!row.foldKey && (!processOpen || !open[row.foldKey]))
|| (blocked && state.phase !== 'collapse' && !state.beforeKeys.has(row.key)); || (blocked && state.phase !== 'collapse' && !state.beforeKeys.has(row.key));
return { row, key: row.key, hidden, process: processOpen && process }; return { row, key: row.key, hidden, process: isProcess, bucket: isProcess ? 'process' : 'other' };
}); });
const header = { row: null, key: 'process-status', hidden: false, process: true }; const waves = arrangeTurnWaves(cells);
const groups = groupProcessRows(status ? [header, ...cells] : cells); let statusWaveIndex = -1;
if (status) {
for (let i = waves.length - 1; i >= 0; i--) {
if (!waves[i]!.user && waves[i]!.process.length > 0) { statusWaveIndex = i; break; }
}
if (statusWaveIndex < 0) {
for (let i = waves.length - 1; i >= 0; i--) {
if (!waves[i]!.user) { statusWaveIndex = i; break; }
}
}
if (statusWaveIndex < 0) {
waves.push({ key: 'process-status', body: [], other: [], process: [] });
statusWaveIndex = waves.length - 1;
}
}
const renderCell = ({ row, hidden, process }: { row: FlowRow; hidden: boolean; process: boolean }) => { const renderCell = ({ row, hidden, process }: { row: FlowRow; hidden: boolean; process: boolean }) => {
if (row.kind === 'summary') return <FlowCell key={row.key} rowKey={row.key} hidden={false} instant motion={motion} summary process={process}> if (row.kind === 'summary') return <FlowCell key={row.key} rowKey={row.key} hidden={false} instant motion={motion} summary process={process}>
<Summary item={row.item} open={processOpen && !!open[row.key]} onChange={value => onOpenChange(row.key, value)} motion={motion && state.phase !== 'collapse'} /> <Summary item={row.item} open={processOpen && !!open[row.key]} onChange={value => onOpenChange(row.key, value)} motion={motion && state.phase !== 'collapse'} />
@ -302,29 +324,39 @@ export function ChoreographedFlow({ frame, motion, enabled, urgent, open, onOpen
return <FlowSnapshot.Provider value={source.snapshot}> return <FlowSnapshot.Provider value={source.snapshot}>
<StreamMotionContext.Provider value={{ ...stream, paused: state.phase !== 'idle', resumed: state.phase === 'reveal' }}> <StreamMotionContext.Provider value={{ ...stream, paused: state.phase !== 'idle', resumed: state.phase === 'reveal' }}>
<div id={id} ref={root} className={css.choreographedFlow} data-reader-flow data-reader-transition={state.phase} data-ud-motion="fold-choreography"> <div id={id} ref={root} className={css.choreographedFlow} data-reader-flow data-reader-transition={state.phase} data-ud-motion="fold-choreography">
{groups.map((group, index) => { {waves.map((wave, index) => {
const first = group[0]!; if (wave.user) return renderCell(wave.user);
if (!first.process && first.row) return renderCell({ ...first, row: first.row }); const hasStatus = index === statusWaveIndex && !!status;
const key = first.row?.kind === 'summary' ? first.row.item.steps[0]?.key ?? first.key : first.key; const hasProcessRows = wave.process.length > 0;
const hasLocalToggle = !running && first.row?.kind === 'step' && !group.some(({ row }) => row?.kind === 'summary'); const showProcessFrame = hasStatus || (processOpen && hasProcessRows);
const collapsed = hasLocalToggle && collapsedFrames.has(key); const hasLocalToggle = !hasStatus && !running && hasProcessRows && !wave.process.some(({ row }) => row.kind === 'summary');
return <div key={`process:${key}`} className={css.processViewport} data-reader-process-frame data-reader-frame-collapsed={collapsed || undefined}> const localCollapsed = hasLocalToggle && collapsedFrames.has(wave.key);
{!first.row && <div className={css.turnStickyLanes} data-flow-process>{status}</div>} const hasVisibleProcessContent = wave.process.some(cell => !cell.hidden);
const scrollHidden = localCollapsed || (!processOpen && !wave.process.some(cell => cell.row.kind === 'summary')) || !hasVisibleProcessContent;
const frameCollapsed = scrollHidden;
return <Fragment key={`wave:${wave.key}`}>
{wave.body.length > 0 && <div className={css.answerBubble} data-reader-answer-bubble>
{wave.body.map(cell => renderCell(cell))}
</div>}
{wave.other.map(cell => renderCell(cell))}
{showProcessFrame && <div className={css.processViewport} data-reader-process-frame data-reader-frame-collapsed={frameCollapsed || undefined}>
{hasStatus && <div className={css.turnStickyLanes} data-flow-process>{status}</div>}
{hasLocalToggle && <div className={css.processFrameToggle}> {hasLocalToggle && <div className={css.processFrameToggle}>
<Disclosure open={!collapsed} ariaLabel="这段执行记录" onChange={nextOpen => { <Disclosure open={!localCollapsed} ariaLabel="这段执行记录" onChange={nextOpen => {
setCollapsedFrames(current => { setCollapsedFrames(current => {
const next = new Set(current); const next = new Set(current);
if (nextOpen) next.delete(key); if (nextOpen) next.delete(wave.key);
else next.add(key); else next.add(wave.key);
return next; return next;
}); });
}} label={collapsed ? `查看 ${group.length} 条执行记录` : '收起执行记录'} /> }} label={localCollapsed ? `查看 ${wave.process.length} 条执行记录` : '收起执行记录'} />
</div>} </div>}
<ProcessScroll hidden={collapsed} live={running && visible && state.phase === 'idle' && index === groups.length - 1 <ProcessScroll hidden={scrollHidden} live={running && visible && state.phase === 'idle' && index === waves.length - 1
&& group.some(({ row, hidden }) => !hidden && row?.kind === 'step' && !row.foldKey)}> && wave.process.some(({ row, hidden }) => !hidden && row.kind === 'step' && !row.foldKey)}>
{group.map(cell => cell.row && renderCell({ ...cell, row: cell.row }))} {wave.process.map(cell => renderCell(cell))}
</ProcessScroll> </ProcessScroll>
</div>; </div>}
</Fragment>;
})} })}
</div> </div>
</StreamMotionContext.Provider> </StreamMotionContext.Provider>

View File

@ -1,3 +1,4 @@
import type { RefObject } from 'react';
import css from './Reader.module.css'; import css from './Reader.module.css';
import { Disclosure } from './motion.js'; import { Disclosure } from './motion.js';
import { FoldSummaryText } from './LiveFold.js'; import { FoldSummaryText } from './LiveFold.js';
@ -6,13 +7,13 @@ import { DiffStat } from './DiffPanel.js';
import type { LiveStep } from './live-turn.js'; import type { LiveStep } from './live-turn.js';
/** Keep process counts discoverable after the live-fold presentation retires. */ /** Keep process counts discoverable after the live-fold presentation retires. */
export function ClosedProcessSummary({ steps, open, onChange, controls }: { export function ClosedProcessSummary({ steps, open, onChange, controls, buttonRef }: {
steps: readonly LiveStep[]; open: boolean; onChange: (value: boolean) => void; controls: string; steps: readonly LiveStep[]; open: boolean; onChange: (value: boolean) => void; controls: string; buttonRef?: RefObject<HTMLButtonElement>;
}) { }) {
if (!steps.length) return null; if (!steps.length) return null;
const summary = foldSummary(steps); const summary = foldSummary(steps);
return <div className={`${css.closedProcessSummary} ${css.summaryRow}`} data-reader-closed-summary={summary}> return <div className={`${css.closedProcessSummary} ${css.summaryRow}`} data-reader-closed-summary={summary}>
<Disclosure open={open} onChange={onChange} controls={controls} ariaLabel="本轮过程详情" <Disclosure open={open} onChange={onChange} controls={controls} buttonRef={buttonRef} ariaLabel="本轮过程详情"
label={<FoldSummaryText summary={summary} motion={false} />} /> label={<FoldSummaryText summary={summary} motion={false} />} />
<DiffStat steps={steps} label={summary} /> <DiffStat steps={steps} label={summary} />
</div>; </div>;

View File

@ -12,6 +12,7 @@
must not shrink the lane under that floor. Positive font delta still must not shrink the lane under that floor. Positive font delta still
grows it, or the next sticky band lands on the previous one. */ grows it, or the next sticky band lands on the previous one. */
--reader-lane-block: max(40px, calc(40px + var(--dsh-content-font-delta, 0px))); --reader-lane-block: max(40px, calc(40px + var(--dsh-content-font-delta, 0px)));
--reader-ai-max-width: 90%;
/* Wallpaper themes clear --dsw-alias-bg-base, or leave it only partly /* Wallpaper themes clear --dsw-alias-bg-base, or leave it only partly
opaque. The token and the inner surface paint above Canvas, the page opaque. The token and the inner surface paint above Canvas, the page
surface colour (it follows color-scheme). An opaque stock token covers surface colour (it follows color-scheme). An opaque stock token covers
@ -56,8 +57,29 @@
.userCluster > [data-slot] > :not(.user, .userImages, .userActions) { align-self: stretch; width: 100%; max-width: 100%; min-width: 0; box-sizing: border-box; } .userCluster > [data-slot] > :not(.user, .userImages, .userActions) { align-self: stretch; width: 100%; max-width: 100%; min-width: 0; box-sizing: border-box; }
.userImages { display: flex; flex-direction: column; align-items: flex-end; align-self: flex-end; width: min(100%, 360px); min-width: 0; } .userImages { display: flex; flex-direction: column; align-items: flex-end; align-self: flex-end; width: min(100%, 360px); min-width: 0; }
.userImages .imageFigure { align-self: flex-end; width: 100%; } .userImages .imageFigure { align-self: flex-end; width: 100%; }
.user { align-self: flex-end; width: fit-content; max-width: min(calc(var(--dsh-chat-content-width, 748px) * 0.702), 82%); margin-left: auto; padding: 10px 16px; border-radius: var(--dsw-radius-xl, 22px); background: var(--dsw-specific-bubble); color: var(--dsw-alias-label-primary); font-size: var(--dsh-content-font-size, 14px); line-height: calc(22px + var(--dsh-content-font-delta, 0px)); font-weight: 400; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; box-sizing: border-box; } .user { align-self: flex-end; width: fit-content; max-width: min(calc(var(--dsh-chat-content-width, 748px) * 0.702), 82%); margin-left: auto; padding: 10px 16px; border-radius: 18px 18px 6px 18px; background: var(--dsw-specific-bubble); color: var(--dsw-alias-label-primary); font-size: var(--dsh-content-font-size, 14px); line-height: calc(22px + var(--dsh-content-font-delta, 0px)); font-weight: 400; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; box-sizing: border-box; }
.user .blocks { gap: 10px; } .user .blocks { gap: 10px; }
.answerBubble {
align-self: flex-start;
display: flex;
flex-direction: column;
gap: 12px;
width: fit-content;
max-width: var(--reader-ai-max-width);
min-width: 0;
padding: 10px 16px;
box-sizing: border-box;
border-radius: 18px 18px 18px 6px;
background: var(--dsw-alias-bg-module-platform);
border: 1px solid var(--dsw-alias-border-l1);
overflow-wrap: anywhere;
}
.answerBubble:not(:has(> .flowCell:not([hidden]))) { display: none; }
.answerBubble > .flowCell > .flowCellInner { padding-bottom: 0; }
.answerBubble :global(.md-code-block) {
background: var(--dsw-alias-bg-base);
border: 1px solid var(--dsw-alias-border-l2);
}
.answer { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; } .answer { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.readingText { min-width: 0; } .readingText { min-width: 0; }
.reasonPlain { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; color: inherit; } .reasonPlain { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; color: inherit; }
@ -419,10 +441,11 @@
.historyButton { align-self: center; background: transparent; border: 1px solid var(--dsw-alias-border-l2); border-radius: 8px; padding: 4px 12px; font-size: 12px; color: var(--dsw-alias-label-secondary); } .historyButton { align-self: center; background: transparent; border: 1px solid var(--dsw-alias-border-l2); border-radius: 8px; padding: 4px 12px; font-size: 12px; color: var(--dsw-alias-label-secondary); }
.historyButton:disabled { opacity: .55; cursor: default; } .historyButton:disabled { opacity: .55; cursor: default; }
.empty { padding: 40px 0; color: var(--dsw-alias-label-tertiary); text-align: center; } .empty { padding: 40px 0; color: var(--dsw-alias-label-tertiary); text-align: center; }
.answerActions { display: flex; align-items: center; gap: 8px; margin: 13px 0 0 -6px; min-height: 28px; } .answerActions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: -4px 0 0 -6px; min-height: 28px; max-width: calc(100% + 6px); min-width: 0; }
.userActions { display: flex; align-items: center; align-self: flex-end; justify-content: flex-end; width: fit-content; max-width: 100%; gap: 8px; min-height: 28px; } .userActions { display: flex; flex-wrap: wrap; align-items: center; align-self: flex-end; justify-content: flex-end; width: fit-content; max-width: 100%; gap: 4px 8px; min-height: 28px; }
.messageClock { font-size: 13px; line-height: 24px; color: var(--dsw-alias-label-tertiary); white-space: nowrap; font-variant-numeric: tabular-nums; } .answerActions > .meta:empty, .userActions > .meta:empty { display: none; }
.iconButton { display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 6px; padding: 6px; background: transparent; color: var(--dsw-alias-label-tertiary); } .messageClock { flex: none; font-size: 13px; line-height: 24px; color: var(--dsw-alias-label-tertiary); white-space: nowrap; font-variant-numeric: tabular-nums; }
.iconButton { flex: none; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 6px; padding: 6px; background: transparent; color: var(--dsw-alias-label-tertiary); }
.iconButton svg { fill: none; stroke: currentColor; stroke-width: 1.2; stroke-linecap: round; stroke-linejoin: round; } .iconButton svg { fill: none; stroke: currentColor; stroke-width: 1.2; stroke-linecap: round; stroke-linejoin: round; }
.imageFigure { margin: 0; max-width: 100%; width: min(100%, 360px); box-sizing: border-box; align-self: flex-start; } .imageFigure { margin: 0; max-width: 100%; width: min(100%, 360px); box-sizing: border-box; align-self: flex-start; }
.imageFrame { position: relative; border-radius: 12px; background: var(--dsw-alias-bg-module-platform); border: 1px solid var(--dsw-alias-border-l2); overflow: hidden; max-height: 440px; min-height: 96px; max-width: 100%; box-sizing: border-box; } .imageFrame { position: relative; border-radius: 12px; background: var(--dsw-alias-bg-module-platform); border: 1px solid var(--dsw-alias-border-l2); overflow: hidden; max-height: 440px; min-height: 96px; max-width: 100%; box-sizing: border-box; }
@ -499,10 +522,11 @@
[data-motion=off] .turnStatusLabel { animation: none !important; color: var(--dsw-static-deepseek-500, #4d6bfe) !important; -webkit-text-fill-color: var(--dsw-static-deepseek-500, #4d6bfe) !important; } [data-motion=off] .turnStatusLabel { animation: none !important; color: var(--dsw-static-deepseek-500, #4d6bfe) !important; -webkit-text-fill-color: var(--dsw-static-deepseek-500, #4d6bfe) !important; }
@media (prefers-reduced-motion: reduce) { .turnStatusLabel { animation: none !important; color: var(--dsw-static-deepseek-500, #4d6bfe) !important; -webkit-text-fill-color: var(--dsw-static-deepseek-500, #4d6bfe) !important; } } @media (prefers-reduced-motion: reduce) { .turnStatusLabel { animation: none !important; color: var(--dsw-static-deepseek-500, #4d6bfe) !important; -webkit-text-fill-color: var(--dsw-static-deepseek-500, #4d6bfe) !important; } }
@media (pointer: coarse) { .disclosureButton { min-height: 44px; } } @media (pointer: coarse) { .disclosureButton { min-height: 44px; } }
@media (max-width: 600px) { .root { padding-inline: 20px; } .column { gap: 18px; } .toolbar { font-size: 11px; } } @media (max-width: 600px) { .root { padding-inline: 20px; --reader-ai-max-width: 92%; } .column { gap: 18px; } .toolbar { font-size: 11px; } }
@container (max-width: 480px) { .choreographedFlow { --reader-ai-max-width: 92%; } }
/* Measured flow owns geometry; steps never change React parents when folded. */ /* Measured flow owns geometry; steps never change React parents when folded. */
.choreographedFlow { display: flex; flex-direction: column; min-width: 0; overflow-anchor: none; } .choreographedFlow { display: flex; flex-direction: column; gap: 10px; min-width: 0; overflow-anchor: none; }
.flowCell { min-width: 0; overflow: clip; display: flow-root; } .flowCell { min-width: 0; overflow: clip; display: flow-root; }
.flowCell[hidden] { display: none; } .flowCell[hidden] { display: none; }
.flowCellInner { display: flex; flex-direction: column; min-width: 0; padding-bottom: 16px; } .flowCellInner { display: flex; flex-direction: column; min-width: 0; padding-bottom: 16px; }
@ -511,12 +535,15 @@
.processViewport { .processViewport {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-self: flex-start;
width: 100%;
max-width: var(--reader-ai-max-width);
min-width: 0; min-width: 0;
max-height: min(320px, 45vh); max-height: min(320px, 45vh);
margin-bottom: 16px; margin-bottom: 0;
box-sizing: border-box; box-sizing: border-box;
border: 1px solid var(--dsw-alias-border-l2); border: 1px solid var(--dsw-alias-border-l2);
border-radius: 12px; border-radius: 14px;
background: var(--dsw-alias-bg-module-platform); background: var(--dsw-alias-bg-module-platform);
} }
.processScroll { .processScroll {
@ -525,22 +552,42 @@
overscroll-behavior-y: contain; overscroll-behavior-y: contain;
padding: 0 8px; padding: 0 8px;
} }
.processViewport:not([data-reader-frame-collapsed]) > .processScroll:not([hidden]) {
border-top: 1px solid var(--dsw-alias-border-l1);
}
.processScroll:not(:has(> .flowCell:not([hidden]))), .processScroll:not(:has(> .flowCell:not([hidden]))),
.processViewport:not(:has(> .turnStickyLanes, .flowCell:not([hidden]))) { display: none; } .processViewport:not(:has(> .turnStickyLanes, > .processFrameToggle, .flowCell:not([hidden]))) { display: none; }
.processScroll > .flowCell > .flowCellInner:not(:empty) { padding: 4px 0; } .processScroll > .flowCell > .flowCellInner:not(:empty) { padding: 4px 0; }
.processScroll:focus-visible { outline: 2px solid var(--dsw-alias-state-business-primary); outline-offset: -2px; } .processScroll:focus-visible { outline: 2px solid var(--dsw-alias-state-business-primary); outline-offset: -2px; }
.processViewport > .turnStickyLanes { position: static; flex: none; padding: 4px 8px; } .processViewport > .turnStickyLanes { position: static; flex: none; padding: 4px 10px; }
.root[data-reader-glass] .processViewport { background: transparent; } .root[data-reader-glass] .processViewport {
.processViewport[data-reader-frame-collapsed], background: color-mix(in srgb, var(--dsw-alias-bg-module-platform, rgba(128, 128, 128, .12)) 35%, transparent);
.processViewport:has(.closedProcessSummary, > .processScroll > .flowCell[data-flow-summary]):not(:has(> .processScroll > .flowCell:not([hidden], [data-flow-summary]))) { backdrop-filter: blur(10px);
border: 0; }
background: transparent; .processViewport[data-reader-frame-collapsed] {
width: fit-content;
max-height: none;
border-radius: 999px;
border: 1px solid var(--dsw-alias-border-l1);
background: color-mix(in srgb, var(--dsw-alias-bg-module-platform) 75%, transparent);
margin-bottom: 0; margin-bottom: 0;
} }
.processFrameToggle { flex: none; padding-inline: 8px; } .processViewport[data-reader-frame-collapsed]:hover {
border-color: var(--dsw-alias-border-l2);
background: var(--dsw-alias-bg-module-platform);
}
.processViewport:has(.diffOverlayRow) {
width: 100%;
border-radius: 14px;
}
.processFrameToggle { flex: none; padding: 4px 10px; }
.processViewport[data-reader-frame-collapsed] > .processFrameToggle, .processViewport[data-reader-frame-collapsed] > .processFrameToggle,
.processViewport:not(:has(> .processScroll > .flowCell:not([hidden], [data-flow-summary]))) > :is(.turnStickyLanes, .processScroll) { padding: 0; } .processViewport[data-reader-frame-collapsed] > .turnStickyLanes { padding: 2px 10px; }
.processViewport:not(:has(> .processScroll > .flowCell:not([hidden], [data-flow-summary]))) > .turnStickyLanes > .turnProcessSticky { .processViewport[data-reader-frame-collapsed] .disclosureButton {
font-size: calc(13px + var(--dsh-content-font-delta, 0px));
line-height: calc(22px + var(--dsh-content-font-delta, 0px));
}
.processViewport[data-reader-frame-collapsed] > .turnStickyLanes > .turnProcessSticky {
min-height: 0; min-height: 0;
border: 0; border: 0;
} }
@ -586,6 +633,7 @@
} }
.turnProcessSticky:has(> .closedProcessSummary) > .disclosure { flex: 0 0 auto; } .turnProcessSticky:has(> .closedProcessSummary) > .disclosure { flex: 0 0 auto; }
.closedProcessSummary.summaryRow { flex: 1 1 auto; flex-wrap: nowrap; } .closedProcessSummary.summaryRow { flex: 1 1 auto; flex-wrap: nowrap; }
.closedProcessSummary.summaryRow:has(> .diffOverlayRow) { flex-wrap: wrap; }
/* The same summary row stays in flow until it reaches the measured top lane. */ /* The same summary row stays in flow until it reaches the measured top lane. */
.flowCell[data-flow-summary] { position: sticky; top: calc(var(--reader-toolbar-height, var(--reader-lane-block, 40px)) + var(--reader-status-height, var(--reader-lane-block, 40px))); z-index: 5; overflow: visible; box-sizing: border-box; min-height: var(--reader-lane-block, 40px); padding-block: 4px; background: var(--dsw-alias-bg-base); border-bottom: 0; } .flowCell[data-flow-summary] { position: sticky; top: calc(var(--reader-toolbar-height, var(--reader-lane-block, 40px)) + var(--reader-status-height, var(--reader-lane-block, 40px))); z-index: 5; overflow: visible; box-sizing: border-box; min-height: var(--reader-lane-block, 40px); padding-block: 4px; background: var(--dsw-alias-bg-base); border-bottom: 0; }
/* Keep the official CodeBlock banner's internal z-index inside its wrapper so Reader lanes stay above it. */ /* Keep the official CodeBlock banner's internal z-index inside its wrapper so Reader lanes stay above it. */
@ -709,12 +757,17 @@
font-size: var(--dsh-content-font-size, 14px); font-size: var(--dsh-content-font-size, 14px);
line-height: calc(24px + var(--dsh-content-font-delta, 0px)); line-height: calc(24px + var(--dsh-content-font-delta, 0px));
} }
/* User bubble becomes a sleek translucent frosted pill in skin mode */ /* User & AI bubbles become sleek translucent frosted pills in skin mode */
.root[data-reader-glass] .user { .root[data-reader-glass] .user {
background: color-mix(in srgb, var(--dsw-specific-bubble, rgba(0,0,0,.08)) 25%, transparent); background: color-mix(in srgb, var(--dsw-specific-bubble, rgba(0,0,0,.08)) 25%, transparent);
backdrop-filter: blur(12px); backdrop-filter: blur(12px);
border: 1px solid color-mix(in srgb, var(--dsw-alias-border-l1, rgba(128,128,128,.3)) 30%, transparent); border: 1px solid color-mix(in srgb, var(--dsw-alias-border-l1, rgba(128,128,128,.3)) 30%, transparent);
} }
.root[data-reader-glass] .answerBubble {
background: color-mix(in srgb, var(--dsw-alias-bg-module-platform, rgba(128,128,128,.12)) 55%, transparent);
backdrop-filter: blur(12px);
border: 1px solid color-mix(in srgb, var(--dsw-alias-border-l1, rgba(128,128,128,.3)) 45%, transparent);
}
/* Skin mode paints no plates of the reader's own: cards, panels and frames go /* Skin mode paints no plates of the reader's own: cards, panels and frames go
fully transparent so the skin behind them stays visible. */ fully transparent so the skin behind them stays visible. */
.root[data-reader-glass] :is(.reasonCard, .toolActivity, .processCard) { .root[data-reader-glass] :is(.reasonCard, .toolActivity, .processCard) {

View File

@ -5,10 +5,10 @@ import type { ReactNode, RefObject } from 'react';
import type { ChatConversationViewNode, ChatNode, ChatNodeKind, ChatNodeOwnerProps } from '@deepseek-ai/dsh-client-ui-chat/client'; import type { ChatConversationViewNode, ChatNode, ChatNodeKind, ChatNodeOwnerProps } from '@deepseek-ai/dsh-client-ui-chat/client';
import { createSnapshotStore } from '@deepseek-ai/dsh-client-store'; import { createSnapshotStore } from '@deepseek-ai/dsh-client-store';
import { JsonBlock, MarkdownText } from '@deepseek-ai/dsh-client-ui-primitives'; import { JsonBlock, MarkdownText } from '@deepseek-ai/dsh-client-ui-primitives';
import { BlockBoundary, Blocks, contentBlocks, UserMessageActions } from './Blocks.js'; import { BlockBoundary, Blocks, contentBlocks, CopyAnswer, UserMessageActions } from './Blocks.js';
import { AssistantNode } from './AssistantNode.js'; import { AssistantNode } from './AssistantNode.js';
import { ToolActivity, ToolMedia } from './ToolActivity.js'; import { ToolActivity, ToolMedia } from './ToolActivity.js';
import { OfficialNode, OfficialTail } from './OfficialContent.js'; import { OfficialActions, OfficialNode, OfficialTail } from './OfficialContent.js';
import { OFFICIAL_SEATS, readerGroupAction } from './official-slots.js'; import { OFFICIAL_SEATS, readerGroupAction } from './official-slots.js';
import { preparingLabel, readerFlow } from './tool-activity.js'; import { preparingLabel, readerFlow } from './tool-activity.js';
import { Disclosure, ProcessFragment, RetiringTurns, StatusText, useMotionAllowed, usePinnedSelection, useReadingScroll } from './motion.js'; import { Disclosure, ProcessFragment, RetiringTurns, StatusText, useMotionAllowed, usePinnedSelection, useReadingScroll } from './motion.js';
@ -23,7 +23,7 @@ import { ContextInjectionRow } from './native/ContextInjectionRow.js';
import { TimelineRail } from './TimelineRail.js'; import { TimelineRail } from './TimelineRail.js';
import { landTurn, scrollerOf } from './conversation-scroll.js'; import { landTurn, scrollerOf } from './conversation-scroll.js';
import { mergeTimelineItems, type TimelineItem } from './timeline.js'; import { mergeTimelineItems, type TimelineItem } from './timeline.js';
import { planProcessSeams, presentLiveTurn, segmentLiveTurn } from './live-turn.js'; import { presentLiveTurn, segmentLiveTurn } from './live-turn.js';
import type { LiveStep } from './live-turn.js'; import type { LiveStep } from './live-turn.js';
import { frostedGlassOf } from './fold-intensity.js'; import { frostedGlassOf } from './fold-intensity.js';
import { ChoreographedFlow, useFlowChat } from './ChoreographedFlow.js'; import { ChoreographedFlow, useFlowChat } from './ChoreographedFlow.js';
@ -277,11 +277,7 @@ function subagentCount(snapshot: { nodes: { get(key: string): ChatConversationVi
function GroupStatus({ group, useChat, pending, motion }: Pick<ReaderProps, 'useChat'> & { group: ReaderGroup; motion: boolean; pending: { kind?: string } | undefined }) { function GroupStatus({ group, useChat, pending, motion }: Pick<ReaderProps, 'useChat'> & { group: ReaderGroup; motion: boolean; pending: { kind?: string } | undefined }) {
const text = useChat(snapshot => { const text = useChat(snapshot => {
const turn = group.turn === null ? undefined : snapshot.timeline.turns.get(group.turn); const turn = group.turn === null ? undefined : snapshot.timeline.turns.get(group.turn);
if (turn?.status === 'closed') { if (turn?.status === 'closed') return '执行过程';
if (turn.end?.data.reason.kind !== 'completed') return '执行过程';
const elapsed = turn.start && turn.end ? Math.max(0, Math.round((turn.end.time - turn.start.time) / 1000)) : null;
return elapsed === null ? '执行过程' : elapsed < 60 ? `用时 ${elapsed} 秒` : `用时 ${Math.floor(elapsed / 60)} 分 ${elapsed % 60} 秒`;
}
if (turn?.status !== 'open') return '执行过程'; if (turn?.status !== 'open') return '执行过程';
if (pending !== undefined) return '等待你的操作'; if (pending !== undefined) return '等待你的操作';
const current = turn.steps.at(-1)?.data.get('assistant-step'); const current = turn.steps.at(-1)?.data.get('assistant-step');
@ -499,8 +495,9 @@ const TurnGroup = memo(function TurnGroup({ group, motion, autoFold, pinnedKeys,
() => 'external', () => 'external',
)); ));
const hasProcess = flow.some(item => item.kind === 'tool' || hasProcessContent(nodes.get(item.nodeKey), boundary)); const hasProcess = flow.some(item => item.kind === 'tool' || hasProcessContent(nodes.get(item.nodeKey), boundary));
const showStatusLane = hasProcess && !isAwaitingModel; const processSteps = useMemo(() => steps.filter(step => step.kind !== 'user' && step.kind !== 'body'), [steps]);
const showClosedSummary = boundary.status === 'closed' && hasProcess && autoFold; const showClosedSummary = boundary.status === 'closed' && hasProcess && processSteps.length > 0;
const showStatusLane = hasProcess && !isAwaitingModel && !showClosedSummary;
// Only a real, still-active text selection delays folding. Merely clicking, // Only a real, still-active text selection delays folding. Merely clicking,
// focusing or scrolling the live card does not create a permanent override. // focusing or scrolling the live card does not create a permanent override.
const holdingSelection = selectedProcessKeys.some(key => const holdingSelection = selectedProcessKeys.some(key =>
@ -509,12 +506,6 @@ const TurnGroup = memo(function TurnGroup({ group, motion, autoFold, pinnedKeys,
? item.key === key || item.steps.some(step => step.key === key || ('nodeKey' in step && step.nodeKey === key)) ? item.key === key || item.steps.some(step => step.key === key || ('nodeKey' in step && step.nodeKey === key))
: item.key === key || ('nodeKey' in item.step && item.step.nodeKey === key))); : item.key === key || ('nodeKey' in item.step && item.step.nodeKey === key)));
const expanded = !autoFold || holdingSelection || processExpanded(expansionChoice, boundary); const expanded = !autoFold || holdingSelection || processExpanded(expansionChoice, boundary);
// Seam between narration blocks. Skip a run a live-fold cell already
// covers, and do not drop the previous body's bottom spacing.
const seamPlan = useMemo(
() => planProcessSeams(steps, liveItems, expanded),
[steps, liveItems, expanded],
);
const [foldOpenByKey, setFoldOpenByKey] = useState<Record<string, boolean>>({}); const [foldOpenByKey, setFoldOpenByKey] = useState<Record<string, boolean>>({});
useLayoutEffect(() => { useLayoutEffect(() => {
// Restoring automatic folding also releases live "prior steps" disclosures. // Restoring automatic folding also releases live "prior steps" disclosures.
@ -585,12 +576,32 @@ const TurnGroup = memo(function TurnGroup({ group, motion, autoFold, pinnedKeys,
const stoppedWithoutAnswer = (boundary.reason === 'interrupted' || boundary.reason === 'aborted') && !hasAnswerProse; const stoppedWithoutAnswer = (boundary.reason === 'interrupted' || boundary.reason === 'aborted') && !hasAnswerProse;
const showTerminalNotice = terminal && !hasTurnError const showTerminalNotice = terminal && !hasTurnError
&& (stoppedWithoutAnswer || (boundary.reason !== 'interrupted' && boundary.reason !== 'aborted')); && (stoppedWithoutAnswer || (boundary.reason !== 'interrupted' && boundary.reason !== 'aborted'));
const finalBodyInfo = useMemo(() => {
let lastUserIndex = -1;
for (let i = steps.length - 1; i >= 0; i--) {
if (steps[i]?.kind === 'user') { lastUserIndex = i; break; }
}
const waveBodySteps = steps
.slice(lastUserIndex + 1)
.filter((step): step is Extract<LiveStep, { kind: 'body' }> => step.kind === 'body');
const lastBodyStep = waveBodySteps.at(-1);
const lastNode = lastBodyStep ? nodes.get(lastBodyStep.nodeKey) : undefined;
const finalData = lastNode && isNode(lastNode, 'assistant-step') ? lastNode.data : undefined;
const copyBlocks = waveBodySteps.flatMap(step => step.blocks);
return { finalData, copyBlocks };
}, [steps, nodes]);
const answerFork = useMemo(() => {
const anchor = forkAnchorSeq([finalBodyInfo.finalData?.finalNode, { seq: forkSeq }]);
return props.forkAt && anchor !== undefined ? () => props.forkAt!(anchor) : undefined;
}, [finalBodyInfo.finalData?.finalNode, forkSeq, props.forkAt]);
const showAnswerActions = boundary.status === 'closed'
&& finalBodyInfo.finalData !== undefined
&& finalBodyInfo.finalData.status !== 'running';
const showStopped = finalBodyInfo.finalData?.status === 'interrupted';
const renderStep = (step: LiveStep, folded: boolean) => { const renderStep = (step: LiveStep, folded: boolean) => {
const processOpen = folded || expanded; const processOpen = folded || expanded;
if (step.kind === 'reasoning' || step.kind === 'body') return <BlockBoundary> if (step.kind === 'reasoning' || step.kind === 'body') return <BlockBoundary>
<AssistantNode {...shared} boundary={boundary} nodeKey={step.nodeKey} partStart={step.start} pinned={pinnedKeys.includes(step.nodeKey)} processOpen={processOpen} folded={folded} motion={motion} onRead={pinProcess} returnFocusTo={processButton} <AssistantNode {...shared} boundary={boundary} nodeKey={step.nodeKey} partStart={step.start} pinned={pinnedKeys.includes(step.nodeKey)} processOpen={processOpen} folded={folded} motion={motion} onRead={pinProcess} returnFocusTo={processButton} />
seamSummary={step.kind === 'body' ? seamPlan.before.get(step.key) : undefined}
seamAfter={step.kind === 'body' && seamPlan.after.has(step.key)} />
</BlockBoundary>; </BlockBoundary>;
if (step.kind === 'tool') return <BlockBoundary><ProcessFragment open={processOpen} motion={motion} onRead={pinProcess} returnFocusTo={processButton} nodeKey={step.key} framed> if (step.kind === 'tool') return <BlockBoundary><ProcessFragment open={processOpen} motion={motion} onRead={pinProcess} returnFocusTo={processButton} nodeKey={step.key} framed>
<ToolActivity {...shared} entry={step.entry} motion={motion} turnClosed={boundary.status === 'closed'} onRead={pinProcess} /> <ToolActivity {...shared} entry={step.entry} motion={motion} turnClosed={boundary.status === 'closed'} onRead={pinProcess} />
@ -611,8 +622,8 @@ const TurnGroup = memo(function TurnGroup({ group, motion, autoFold, pinnedKeys,
status={(showStatusLane || showClosedSummary) && <StickyLane kind="status" className={css.turnProcessSticky}> status={(showStatusLane || showClosedSummary) && <StickyLane kind="status" className={css.turnProcessSticky}>
{showStatusLane && <Disclosure open={expanded} onChange={setExpanded} controls={flowId} buttonRef={processButton} {showStatusLane && <Disclosure open={expanded} onChange={setExpanded} controls={flowId} buttonRef={processButton}
label={<GroupStatus group={group} useChat={props.useChat} pending={interaction} motion={motion} />} />} label={<GroupStatus group={group} useChat={props.useChat} pending={interaction} motion={motion} />} />}
{showClosedSummary && <ClosedProcessSummary open={expanded} onChange={setExpanded} controls={flowId} {showClosedSummary && <ClosedProcessSummary open={expanded} onChange={setExpanded} controls={flowId} buttonRef={processButton}
steps={steps.filter(step => step.kind !== 'user' && step.kind !== 'body')} />} steps={processSteps} />}
</StickyLane>} </StickyLane>}
onOpenChange={(key, value) => { pinProcess(); setFoldOpenByKey(current => ({ ...current, [key]: value })); }} renderStep={renderStep} /> onOpenChange={(key, value) => { pinProcess(); setFoldOpenByKey(current => ({ ...current, [key]: value })); }} renderStep={renderStep} />
</div> </div>
@ -620,7 +631,10 @@ const TurnGroup = memo(function TurnGroup({ group, motion, autoFold, pinnedKeys,
{!hasProcess && boundary.status === 'open' && !isAwaitingModel && <div className={css.disclosure} data-reader-status-only> {!hasProcess && boundary.status === 'open' && !isAwaitingModel && <div className={css.disclosure} data-reader-status-only>
<GroupStatus group={group} useChat={props.useChat} pending={interaction} motion={motion} /> <GroupStatus group={group} useChat={props.useChat} pending={interaction} motion={motion} />
</div>} </div>}
{showStopped && <span className={css.stopped}>已停止</span>}
{showDeliverablesRow(boundary.status, deliverables) && <DeliverablesRow deliverables={deliverables} openFile={props.openFile} revealFile={props.revealFile} openMode={openMode} />} {showDeliverablesRow(boundary.status, deliverables) && <DeliverablesRow deliverables={deliverables} openFile={props.openFile} revealFile={props.revealFile} openMode={openMode} />}
{showAnswerActions && <CopyAnswer blocks={finalBodyInfo.copyBlocks} onFork={answerFork} metrics={metrics}
extraActions={<OfficialActions official={official} messageId={finalBodyInfo.finalData?.finalNode?.messageId} />} />}
{boundary.status === 'closed' && <BlockBoundary><OfficialTail official={official} owner={tailOwner} produced={deliverables} /></BlockBoundary>} {boundary.status === 'closed' && <BlockBoundary><OfficialTail official={official} owner={tailOwner} produced={deliverables} /></BlockBoundary>}
{showTerminalNotice && <div className={css.notice} data-reader-terminal>{terminal}</div>} {showTerminalNotice && <div className={css.notice} data-reader-terminal>{terminal}</div>}
</section>; </section>;

View File

@ -1,8 +1,11 @@
.container { .container {
display: inline-flex; display: inline-flex;
flex-wrap: wrap;
align-items: center; align-items: center;
gap: 2px; gap: 4px 2px;
position: relative; position: relative;
max-width: 100%;
min-width: 0;
font-size: 13px; font-size: 13px;
line-height: 24px; line-height: 24px;
color: var(--dsw-alias-label-tertiary); color: var(--dsw-alias-label-tertiary);
@ -11,13 +14,19 @@
.pillButton { .pillButton {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
flex: none;
gap: 5px; gap: 5px;
padding: 2px 8px; height: 24px;
border-radius: 12px; padding: 0 8px;
box-sizing: border-box;
border-radius: 999px;
border: 1px solid var(--dsw-alias-border-l1); border: 1px solid var(--dsw-alias-border-l1);
background: var(--dsw-alias-bg-module-platform); background: var(--dsw-alias-bg-module-platform);
color: var(--dsw-alias-label-tertiary); color: var(--dsw-alias-label-tertiary);
font-size: 11px; font-size: 11px;
line-height: 16px;
font-variant-numeric: tabular-nums;
white-space: nowrap;
cursor: pointer; cursor: pointer;
outline: none; outline: none;
transition: all 140ms ease; transition: all 140ms ease;
@ -33,16 +42,18 @@
.timeButton { .timeButton {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
flex: none;
gap: 4px; gap: 4px;
height: 28px; height: 28px;
padding: 6px 8px; padding: 0 8px;
box-sizing: border-box;
border: none; border: none;
border-radius: 28px; border-radius: 999px;
background: transparent; background: transparent;
color: var(--dsw-alias-label-tertiary); color: var(--dsw-alias-label-tertiary);
font-size: 13px; font-size: 13px;
font-variant-numeric: tabular-nums; font-variant-numeric: tabular-nums;
line-height: 24px; line-height: 20px;
white-space: nowrap; white-space: nowrap;
cursor: pointer; cursor: pointer;
font-family: inherit; font-family: inherit;
@ -64,7 +75,9 @@
position: absolute; position: absolute;
bottom: calc(100% + 8px); bottom: calc(100% + 8px);
left: 0; left: 0;
width: 260px; width: min(260px, calc(100cqw - 24px), calc(100vw - 32px));
max-width: calc(100vw - 32px);
box-sizing: border-box;
padding: 12px 14px; padding: 12px 14px;
border-radius: 10px; border-radius: 10px;
background: var(--dsw-alias-bg-base); background: var(--dsw-alias-bg-base);

View File

@ -1,4 +1,4 @@
import { memo, useEffect, useRef, useState } from 'react'; import { memo, useEffect, useLayoutEffect, useRef, useState } from 'react';
import type { TurnTailChatData } from '@deepseek-ai/dsh-client-ui-chat/client'; import type { TurnTailChatData } from '@deepseek-ai/dsh-client-ui-chat/client';
import { formatRanFor, formatRunDuration } from './message-chrome.js'; import { formatRanFor, formatRunDuration } from './message-chrome.js';
import css from './TurnMetrics.module.css'; import css from './TurnMetrics.module.css';
@ -26,6 +26,32 @@ export const TurnMetrics = memo(function TurnMetrics({
}: TurnMetricsProps) { }: TurnMetricsProps) {
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
const containerRef = useRef<HTMLSpanElement>(null); const containerRef = useRef<HTMLSpanElement>(null);
const popRef = useRef<HTMLDivElement>(null);
useLayoutEffect(() => {
if (!open) return;
const clampPopover = () => {
const container = containerRef.current;
const pop = popRef.current;
if (!container || !pop) return;
pop.style.left = '0px';
const host = container.closest<HTMLElement>('[data-dsh-better-display]') ?? container.closest<HTMLElement>('[data-conversation-scroll]');
const bounds = host?.getBoundingClientRect() ?? { left: 0, right: window.innerWidth };
const popRect = pop.getBoundingClientRect();
const pad = 12;
let shift = 0;
if (popRect.right > bounds.right - pad) {
shift = (bounds.right - pad) - popRect.right;
}
if (popRect.left + shift < bounds.left + pad) {
shift = (bounds.left + pad) - popRect.left;
}
pop.style.left = `${Math.round(shift)}px`;
};
clampPopover();
window.addEventListener('resize', clampPopover);
return () => window.removeEventListener('resize', clampPopover);
}, [open]);
useEffect(() => { useEffect(() => {
if (!open) return; if (!open) return;
@ -92,7 +118,7 @@ export const TurnMetrics = memo(function TurnMetrics({
)} )}
{open && ( {open && (
<div className={css.metricsPop} role="dialog" aria-label="本轮概况"> <div ref={popRef} className={css.metricsPop} role="dialog" aria-label="本轮概况">
<div className={css.popHeader}> <div className={css.popHeader}>
<span>本轮性能与用量概况</span> <span>本轮性能与用量概况</span>
</div> </div>

View File

@ -24,6 +24,15 @@ export type FlowRow =
| { kind: 'summary'; key: string; item: Extract<LiveTurnItem, { kind: 'fold' }> } | { kind: 'summary'; key: string; item: Extract<LiveTurnItem, { kind: 'fold' }> }
| { kind: 'step'; key: string; step: LiveStep; foldKey?: string }; | { kind: 'step'; key: string; step: LiveStep; foldKey?: string };
export type FlowBucket = 'body' | 'process' | 'user' | 'other';
export interface FlowWave<T> {
key: string;
body: T[];
other: T[];
process: T[];
user?: T;
}
/** Keep process cells together, including rows temporarily hidden by a fold. */ /** Keep process cells together, including rows temporarily hidden by a fold. */
export function groupProcessRows<T extends { process: boolean }>(rows: readonly T[]): T[][] { export function groupProcessRows<T extends { process: boolean }>(rows: readonly T[]): T[][] {
const groups: T[][] = []; const groups: T[][] = [];
@ -35,6 +44,38 @@ export function groupProcessRows<T extends { process: boolean }>(rows: readonly
return groups; return groups;
} }
/**
* Partition a turn's flow cells into waves around mid-turn user/steering
* messages. Inside each wave, assistant reply segments merge into one reply
* bubble on top while thinking, tools and records collect into a single
* process frame beneath it.
*/
export function arrangeTurnWaves<T extends { key: string; bucket: FlowBucket }>(rows: readonly T[]): FlowWave<T>[] {
const waves: FlowWave<T>[] = [];
let current: FlowWave<T> | null = null;
let anchor = 'initial';
const ensure = (): FlowWave<T> => {
if (!current) {
current = { key: anchor, body: [], other: [], process: [] };
waves.push(current);
}
return current;
};
for (const row of rows) {
if (row.bucket === 'user') {
waves.push({ key: row.key, body: [], other: [], process: [], user: row });
current = null;
anchor = `after:${row.key}`;
continue;
}
const wave = ensure();
if (row.bucket === 'body') wave.body.push(row);
else if (row.bucket === 'process') wave.process.push(row);
else wave.other.push(row);
}
return waves;
}
/** Each step keeps its React key when its fold membership changes. */ /** Each step keeps its React key when its fold membership changes. */
export function flowRows(items: readonly LiveTurnItem[]): FlowRow[] { export function flowRows(items: readonly LiveTurnItem[]): FlowRow[] {
return items.flatMap((item): FlowRow[] => item.kind === 'fold' return items.flatMap((item): FlowRow[] => item.kind === 'fold'

View File

@ -1,6 +1,6 @@
import { test } from 'vitest'; import { test } from 'vitest';
import assert from 'node:assert/strict'; import assert from 'node:assert/strict';
import { collapseRows, containsNewUser, flowRows, FOLD_TIMING, groupProcessRows, retiringKeys } from '../src/client/fold-choreography.js'; import { arrangeTurnWaves, collapseRows, containsNewUser, flowRows, FOLD_TIMING, groupProcessRows, retiringKeys } from '../src/client/fold-choreography.js';
import { presentLiveTurn } from '../src/client/live-turn.js'; import { presentLiveTurn } from '../src/client/live-turn.js';
import type { LiveStep } from '../src/client/live-turn.js'; import type { LiveStep } from '../src/client/live-turn.js';
const reasoning = (n: number): LiveStep => ({ kind: 'reasoning', key: `r${n}`, nodeKey: `n${n}`, start: 0, blocks: [], step: n }); const reasoning = (n: number): LiveStep => ({ kind: 'reasoning', key: `r${n}`, nodeKey: `n${n}`, start: 0, blocks: [], step: n });
@ -90,3 +90,35 @@ test('one scroll box joins process rows across hidden members and ends before th
['summary', 'folded-record', 'thought', 'tool'], ['answer'], ['next-thought'], ['summary', 'folded-record', 'thought', 'tool'], ['answer'], ['next-thought'],
]); ]);
}); });
test('arrangeTurnWaves merges multi-segment AI replies on top and collects process below, splitting at steering', () => {
const waves = arrangeTurnWaves([
{ key: 'r1', bucket: 'process' },
{ key: 'b1', bucket: 'body' },
{ key: 't1', bucket: 'process' },
{ key: 'b2', bucket: 'body' },
{ key: 'steer', bucket: 'user' },
{ key: 'r2', bucket: 'process' },
{ key: 'b3', bucket: 'body' },
{ key: 'err', bucket: 'other' },
]);
assert.equal(waves.length, 3);
assert.equal(waves[0]?.key, 'initial');
assert.deepEqual(waves[0]?.body.map(r => r.key), ['b1', 'b2']);
assert.deepEqual(waves[0]?.process.map(r => r.key), ['r1', 't1']);
assert.equal(waves[1]?.user?.key, 'steer');
assert.equal(waves[2]?.key, 'after:steer');
assert.deepEqual(waves[2]?.body.map(r => r.key), ['b3']);
assert.deepEqual(waves[2]?.other.map(r => r.key), ['err']);
assert.deepEqual(waves[2]?.process.map(r => r.key), ['r2']);
});
test('arrangeTurnWaves keeps wave key stable when a live-fold summary is inserted ahead of earlier steps', () => {
const before = arrangeTurnWaves([{ key: 'r1', bucket: 'process' }]);
const after = arrangeTurnWaves([
{ key: 'live-fold:r1', bucket: 'process' },
{ key: 'r1', bucket: 'process' },
{ key: 'b1', bucket: 'body' },
]);
assert.equal(before[0]?.key, after[0]?.key);
});

View File

@ -15,6 +15,7 @@ const flow = await readFile(new URL('../src/client/ChoreographedFlow.tsx', impor
const official = await readFile(new URL('../src/client/OfficialContent.tsx', import.meta.url), 'utf8'); const official = await readFile(new URL('../src/client/OfficialContent.tsx', import.meta.url), 'utf8');
const blocks = await readFile(new URL('../src/client/Blocks.tsx', import.meta.url), 'utf8'); const blocks = await readFile(new URL('../src/client/Blocks.tsx', import.meta.url), 'utf8');
const readerCss = await readFile(new URL('../src/client/Reader.module.css', import.meta.url), 'utf8'); const readerCss = await readFile(new URL('../src/client/Reader.module.css', import.meta.url), 'utf8');
const turnMetricsCss = await readFile(new URL('../src/client/TurnMetrics.module.css', import.meta.url), 'utf8');
const markdown = await readFile(new URL('../src/client/markdown/MarkdownText.tsx', import.meta.url), 'utf8'); const markdown = await readFile(new URL('../src/client/markdown/MarkdownText.tsx', import.meta.url), 'utf8');
test('the reader occupies the built-in 对话 View at a shadowing priority', () => { test('the reader occupies the built-in 对话 View at a shadowing priority', () => {
@ -61,8 +62,10 @@ test('short thoughts, tools and folded process summaries keep visible cards', ()
assert.match(readerCss, /\.disclosureButton:has\(\[data-reader-fold-summary\]\)[^{}]*\{[^}]*border:/u); assert.match(readerCss, /\.disclosureButton:has\(\[data-reader-fold-summary\]\)[^{}]*\{[^}]*border:/u);
}); });
test('completed timing and record summary share one measured status lane', () => { test('completed process summary drops duplicate turn duration and keeps one status lane', () => {
assert.match(reader, /<StickyLane kind="status"[^>]*>[\s\S]*?<GroupStatus[\s\S]*?<ClosedProcessSummary[\s\S]*?<\/StickyLane>/u); assert.match(reader, /<StickyLane kind="status"[^>]*>[\s\S]*?<GroupStatus[\s\S]*?<ClosedProcessSummary[\s\S]*?<\/StickyLane>/u);
assert.match(reader, /if \(turn\?\.status === 'closed'\) return '执行过程';/u);
assert.match(reader, /const showStatusLane = hasProcess && !isAwaitingModel && !showClosedSummary;/u);
assert.match(readerCss, /\.closedProcessSummary\.summaryRow \{[^}]*flex-wrap: nowrap/u); assert.match(readerCss, /\.closedProcessSummary\.summaryRow \{[^}]*flex-wrap: nowrap/u);
}); });
@ -81,10 +84,12 @@ test('tool rendering reads a snapshot that survives the plugin context', () => {
assert.match(official, /useSyncExternalStore\(official\.officialHostHome\.subscribe, official\.officialHostHome\.getSnapshot\)/u); assert.match(official, /useSyncExternalStore\(official\.officialHostHome\.subscribe, official\.officialHostHome\.getSnapshot\)/u);
}); });
test('live summaries and visible work share a frame that is removed when folded', () => { test('live summaries and visible work share a bounded process frame beneath the merged AI bubble', () => {
assert.match(flow, /row.kind === 'summary'\) return \{ row, key: row.key, hidden: false, process: true \}/u); assert.match(flow, /row\.kind === 'summary'\) return \{ row, key: row\.key, hidden: false, process: true, bucket: 'process' \}/u);
assert.match(flow, /hidden, process: processOpen && process/u); assert.match(flow, /arrangeTurnWaves\(cells\)/u);
assert.match(readerCss, /\.processViewport \{[^}]*max-height: min\(320px, 45vh\)/u); assert.match(flow, /data-reader-answer-bubble[\s\S]*?data-reader-process-frame/u);
assert.match(readerCss, /\.answerBubble \{[^}]*max-width: var\(--reader-ai-max-width\)/u);
assert.match(readerCss, /\.processViewport \{[^}]*max-width: var\(--reader-ai-max-width\)[^}]*max-height: min\(320px, 45vh\)/u);
assert.match(readerCss, /\.processScroll \{[^}]*overflow: auto/u); assert.match(readerCss, /\.processScroll \{[^}]*overflow: auto/u);
assert.match(reader, /const expanded = !autoFold \|\| holdingSelection \|\| processExpanded\(expansionChoice, boundary\)/u); assert.match(reader, /const expanded = !autoFold \|\| holdingSelection \|\| processExpanded\(expansionChoice, boundary\)/u);
}); });
@ -96,11 +101,20 @@ test('all Reader attachment previews delegate the full reference to the host loa
assert.doesNotMatch(source, /readAttachment\(attachment\.attachmentId\)/u); assert.doesNotMatch(source, /readAttachment\(attachment\.attachmentId\)/u);
}); });
test('the status lane joins the visible process frame and the execution request folds with it', () => { test('the status lane joins the visible process frame below the reply bubble and actions sit outside the bubble', () => {
assert.match(reader, /status=\{\(showStatusLane \|\| showClosedSummary\) && <StickyLane/u); assert.match(reader, /status=\{\(showStatusLane \|\| showClosedSummary\) && <StickyLane/u);
assert.match(flow, /groupProcessRows\(status \? \[header, \.\.\.cells\] : cells\)/u); assert.match(reader, /<CopyAnswer blocks=\{finalBodyInfo\.copyBlocks\}/u);
assert.match(flow, /const hidden = \(trigger && !processOpen\)/u); assert.match(flow, /data-reader-process-frame[^>]*>[\s\S]*?\{hasStatus && <div className=\{css\.turnStickyLanes\} data-flow-process>\{status\}<\/div>\}[\s\S]*?<ProcessScroll hidden=\{scrollHidden\}/u);
assert.match(flow, /data-reader-process-frame[^>]*>[\s\S]*?\{status\}[\s\S]*?<ProcessScroll hidden=\{collapsed\}/u);
assert.match(flow, /className=\{css\.processScroll\} data-reader-process-scroll/u); assert.match(flow, /className=\{css\.processScroll\} data-reader-process-scroll/u);
assert.match(readerCss, /\[data-flow-process\]\[data-flow-summary\] \.disclosureButton \{[^}]*border: 0/u); assert.match(readerCss, /\[data-flow-process\]\[data-flow-summary\] \.disclosureButton \{[^}]*border: 0/u);
}); });
test('answer actions and turn metric pills stay intact when the chat column narrows', () => {
assert.match(readerCss, /\.answerActions \{[^}]*flex-wrap: wrap;/u);
assert.match(readerCss, /\.iconButton \{[^}]*flex: none;/u);
assert.match(readerCss, /\.messageClock \{[^}]*flex: none;[^}]*white-space: nowrap;/u);
assert.match(turnMetricsCss, /\.container \{[^}]*flex-wrap: wrap;[^}]*max-width: 100%;/u);
assert.match(turnMetricsCss, /\.pillButton \{[^}]*flex: none;[^}]*height: 24px;[^}]*white-space: nowrap;/u);
assert.match(turnMetricsCss, /\.timeButton \{[^}]*flex: none;[^}]*height: 28px;[^}]*white-space: nowrap;/u);
assert.match(turnMetricsCss, /\.metricsPop \{[^}]*width: min\(260px,/u);
});