The side chat inherited none of the main pane's reading behaviour and could not say where it forked off. This change brings it in line and keeps the upstream v0.30.1 release intact. Work details follow the main conversation's setting (transcriptView + collapseTiming): settled turns fold behind the host's own "Completed in Ns" line, running turns stay open, verbose never folds. The transcript now names its origin: the events route reports the fork point, and the block above the first row renders the inherited question as an ordinary user bubble and the inherited answer as ordinary assistant prose, bracketed by two divider lines and carried verbatim. Reading the thread got cheaper and calmer: only the tail is mounted with a step-wise reveal, scroll-follow answers an explicit intent, and the composer guards IME composition, key repeat and the submit-gesture choice while send and stop stay independent controls. Everything visual rides the host's own surface: content-size and code font axes, the host's markdown surface for reasoning, host cards for search/web/ terminal/diff results, compaction and retry rows, and host-defined design tokens (six borders and eleven colours had referenced tokens the host never defines, so they never painted). Thread creation became reliable: a stored parent is resumed through the session controller, the create budget is a deployment setting instead of a hard-coded 15 seconds, and the child attaches at the parent's workspace cwd while its tools keep running in the reader's current directory. Upstream v0.30.1 brings side-chat images, clickable quote chips, editor draft backup, the settings icon slot and the 0.2.2 model seam; its per-thread draft owner and image projection replace the hand-written paths this branch used to carry, so only one implementation of each survives.
57 lines
2.7 KiB
TypeScript
57 lines
2.7 KiB
TypeScript
/** Keep the host Markdown renderer as the default; a registered consumer may
|
|
* enhance only this real row root while it is visible and durably identified. */
|
|
import { useLayoutEffect, useRef } from 'react'
|
|
import { MarkdownText, type MarkdownFileMentions } from '@deepseek-ai/dsh-client-ui-primitives'
|
|
import { markdownTextProps, type MarkdownCopyLabels } from './markdown-labels.tsx'
|
|
import { attachSidechatSurface, isSidechatSurfaceIdentity } from './sidechat-surface.ts'
|
|
import type { SidechatTranscriptRow } from './sidechat-transcript.ts'
|
|
import css from './SideChatView.module.css'
|
|
|
|
export interface SidechatRowSurfaceBinding {
|
|
service: object | undefined
|
|
threadId: string | undefined
|
|
visible: boolean
|
|
sendPrompt: (text: string) => Promise<void>
|
|
}
|
|
|
|
export function SidechatAssistantRow(props: {
|
|
row: Extract<SidechatTranscriptRow, { kind: 'assistant' }>
|
|
labels: MarkdownCopyLabels
|
|
/** The view's row-level prose pass (image destinations first, then local
|
|
* links) — takes the ROW so an unchanged row reuses its cached rewrite. */
|
|
rewrite: (row: Extract<SidechatTranscriptRow, { text: string }>) => string
|
|
/** The thread's inline-code file-mention vocabulary (see
|
|
* sidechat-mentions.ts); absent leaves every token inert code. */
|
|
fileMentions?: MarkdownFileMentions | undefined
|
|
surface: SidechatRowSurfaceBinding
|
|
}): React.ReactNode {
|
|
const rootRef = useRef<HTMLDivElement | null>(null)
|
|
const { row, labels, rewrite, fileMentions, surface } = props
|
|
const { service, threadId, visible, sendPrompt } = surface
|
|
const renderedText = rewrite(row)
|
|
useLayoutEffect(() => {
|
|
const root = rootRef.current
|
|
if (!visible || !row.settled || root === null || threadId === undefined
|
|
|| row.contentBlockIndex === undefined
|
|
|| !isSidechatSurfaceIdentity(threadId, row.seq, row.contentBlockIndex)) return
|
|
return attachSidechatSurface(service, {
|
|
root,
|
|
source: 'dsh-better-sidebar/sidechat',
|
|
threadId,
|
|
eventSeq: row.seq,
|
|
contentBlockIndex: row.contentBlockIndex,
|
|
text: row.text,
|
|
sendPrompt,
|
|
})
|
|
}, [service, threadId, visible, sendPrompt, row.settled, row.seq, row.contentBlockIndex, row.text, renderedText])
|
|
return (
|
|
<div ref={rootRef} className={css.sidechatAssistant} data-genui-surface="dsh-better-sidebar/sidechat">
|
|
{/* `streaming` keeps the host's incremental parse across chunks
|
|
instead of restarting it; only the durable (settled) message is
|
|
the final parse. It rides the row's own flag so a superseded
|
|
live row never claims to be settled. */}
|
|
<MarkdownText {...markdownTextProps(renderedText, labels, undefined, fileMentions)} streaming={!row.settled} />
|
|
</div>
|
|
)
|
|
}
|