@deepseek-ai/dsh-client-ui-chat 0.2.2-rc.5 → 0.2.3-alpha.2

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.
Files changed (91) hide show
  1. package/README.i18n.yaml +13 -10
  2. package/README.md +19 -5
  3. package/README.zh.md +19 -5
  4. package/lib/client.js +7 -6
  5. package/lib/client.js.map +1 -1
  6. package/lib/types/client/apply.d.ts.map +1 -1
  7. package/lib/types/client/apply.js.map +1 -1
  8. package/lib/types/client/chat/AssistantMarkdown.js.map +1 -1
  9. package/lib/types/client/chat/ChatAside.d.ts +10 -0
  10. package/lib/types/client/chat/ChatAside.d.ts.map +1 -0
  11. package/lib/types/client/chat/ChatAside.js.map +1 -0
  12. package/lib/types/client/chat/ChatView.d.ts.map +1 -1
  13. package/lib/types/client/chat/ChatView.js.map +1 -1
  14. package/lib/types/client/chat/CommandNodeView.d.ts +3 -2
  15. package/lib/types/client/chat/CommandNodeView.d.ts.map +1 -1
  16. package/lib/types/client/chat/CommandNodeView.js.map +1 -1
  17. package/lib/types/client/chat/CommandStatusRow.d.ts +16 -0
  18. package/lib/types/client/chat/CommandStatusRow.d.ts.map +1 -0
  19. package/lib/types/client/chat/CommandStatusRow.js.map +1 -0
  20. package/lib/types/client/chat/CompactionCommandCard.d.ts +3 -1
  21. package/lib/types/client/chat/CompactionCommandCard.d.ts.map +1 -1
  22. package/lib/types/client/chat/CompactionCommandCard.js.map +1 -1
  23. package/lib/types/client/chat/CompactionItem.d.ts +12 -3
  24. package/lib/types/client/chat/CompactionItem.d.ts.map +1 -1
  25. package/lib/types/client/chat/CompactionItem.js.map +1 -1
  26. package/lib/types/client/chat/GenericCommandCard.d.ts.map +1 -1
  27. package/lib/types/client/chat/GenericCommandCard.js.map +1 -1
  28. package/lib/types/client/chat/MessageItem.d.ts +5 -2
  29. package/lib/types/client/chat/MessageItem.d.ts.map +1 -1
  30. package/lib/types/client/chat/MessageItem.js.map +1 -1
  31. package/lib/types/client/chat/compaction-preview.d.ts +10 -0
  32. package/lib/types/client/chat/compaction-preview.d.ts.map +1 -0
  33. package/lib/types/client/chat/compaction-preview.js.map +1 -0
  34. package/lib/types/client/chat/register-node-renderers.d.ts.map +1 -1
  35. package/lib/types/client/chat/register-node-renderers.js.map +1 -1
  36. package/lib/types/client/contract/slots.d.ts +19 -2
  37. package/lib/types/client/contract/slots.d.ts.map +1 -1
  38. package/lib/types/client/conversation-nodes/chat-snapshot-builder.d.ts.map +1 -1
  39. package/lib/types/client/conversation-nodes/chat-snapshot-builder.js.map +1 -1
  40. package/lib/types/client/conversation-nodes/command.d.ts.map +1 -1
  41. package/lib/types/client/conversation-nodes/command.js.map +1 -1
  42. package/lib/types/client/conversation-nodes/compaction.d.ts +14 -2
  43. package/lib/types/client/conversation-nodes/compaction.d.ts.map +1 -1
  44. package/lib/types/client/conversation-nodes/compaction.js.map +1 -1
  45. package/lib/types/client/conversation-nodes/inherited-history.d.ts +20 -0
  46. package/lib/types/client/conversation-nodes/inherited-history.d.ts.map +1 -0
  47. package/lib/types/client/conversation-nodes/inherited-history.js.map +1 -0
  48. package/lib/types/client/conversation-nodes/process-activity.js.map +1 -1
  49. package/lib/types/client/conversation-nodes/register.d.ts.map +1 -1
  50. package/lib/types/client/conversation-nodes/register.js.map +1 -1
  51. package/lib/types/client/file-path.d.ts.map +1 -1
  52. package/lib/types/client/file-path.js.map +1 -1
  53. package/lib/types/client/index.d.ts +1 -0
  54. package/lib/types/client/index.d.ts.map +1 -1
  55. package/lib/types/client/index.js.map +1 -1
  56. package/lib/types/client/locale.d.ts +40 -16
  57. package/lib/types/client/locale.d.ts.map +1 -1
  58. package/lib/types/client/locale.js.map +1 -1
  59. package/package.json +44 -43
  60. package/src/client/apply.ts +39 -22
  61. package/src/client/chat/AssistantMarkdown.module.css +7 -4
  62. package/src/client/chat/AssistantMarkdown.tsx +1 -1
  63. package/src/client/chat/ChatAside.tsx +15 -0
  64. package/src/client/chat/ChatGroupSeat.module.css +3 -3
  65. package/src/client/chat/ChatView.module.css +34 -0
  66. package/src/client/chat/ChatView.tsx +9 -4
  67. package/src/client/chat/CommandNodeView.tsx +6 -3
  68. package/src/client/chat/CommandStatusRow.tsx +60 -0
  69. package/src/client/chat/CompactionCommandCard.tsx +4 -2
  70. package/src/client/chat/CompactionItem.tsx +67 -37
  71. package/src/client/chat/GenericCommandCard.tsx +4 -51
  72. package/src/client/chat/MessageIconActions.module.css +4 -4
  73. package/src/client/chat/MessageItem.module.css +53 -55
  74. package/src/client/chat/MessageItem.tsx +31 -5
  75. package/src/client/chat/TurnNavigator.module.css +8 -7
  76. package/src/client/chat/compaction-preview.ts +76 -0
  77. package/src/client/chat/register-node-renderers.ts +7 -3
  78. package/src/client/contract/slots.ts +16 -2
  79. package/src/client/conversation-nodes/README.i18n.yaml +4 -4
  80. package/src/client/conversation-nodes/README.md +2 -2
  81. package/src/client/conversation-nodes/README.zh.md +2 -2
  82. package/src/client/conversation-nodes/chat-snapshot-builder.ts +3 -1
  83. package/src/client/conversation-nodes/command.ts +0 -8
  84. package/src/client/conversation-nodes/compaction.ts +29 -5
  85. package/src/client/conversation-nodes/inherited-history.ts +41 -0
  86. package/src/client/conversation-nodes/process-activity.ts +1 -1
  87. package/src/client/conversation-nodes/register.ts +2 -0
  88. package/src/client/file-path.ts +2 -6
  89. package/src/client/index.ts +1 -0
  90. package/src/client/locale.ts +40 -16
  91. /package/src/client/chat/{GenericCommandCard.module.css → CommandStatusRow.module.css} +0 -0
@@ -145,7 +145,7 @@
145
145
  flex-direction: column;
146
146
  }
147
147
  .content > * { flex-shrink: 0; }
148
- .content > :not([hidden]):not(:empty) ~ :not([hidden]):not(:empty) {
148
+ .content > :not([hidden]):not(:empty) ~ [data-chat-flow-key]:not([hidden]):not(:empty) {
149
149
  margin-top: var(--dsh-chat-flow-gap, 4px);
150
150
  }
151
151
  .expandedBody {
@@ -155,12 +155,12 @@
155
155
  }
156
156
 
157
157
  /* Member spacing changes share the closing body's timing. */
158
- :global([data-chat-motion]) .content > :not([data-chat-motion]) {
158
+ :global([data-chat-motion]) .content > [data-chat-flow-key]:not([data-chat-motion]) {
159
159
  transition: margin-top 160ms cubic-bezier(0.4, 0, 0.2, 1);
160
160
  }
161
161
 
162
162
  @media (prefers-reduced-motion: reduce) {
163
- :global([data-chat-motion]) .content > :not([data-chat-motion]) {
163
+ :global([data-chat-motion]) .content > [data-chat-flow-key]:not([data-chat-motion]) {
164
164
  transition: none;
165
165
  }
166
166
  }
@@ -356,6 +356,40 @@
356
356
 
357
357
  /* Floating controls sit outside the clipped transcript. A standalone Chat
358
358
  anchors them to its frame; the shared host supplies the sticky scrollport. */
359
+ /* The aside layer: zero height at the frame's top, sticky in a shared
360
+ scrollport so its occupant stays put while the transcript scrolls and
361
+ inherits the scrollport's --dsh-composer-height and
362
+ --dsh-conversation-viewport-height. Above the turn rail (7) and the
363
+ back-to-bottom control (8). It publishes the end gutter, the inline space
364
+ between the transcript column and the frame's end edge, for the
365
+ occupant's inline sizes: the percentage resolves against the layer in an
366
+ element whose containing block is the layer, as it does in the
367
+ back-to-bottom control's padding below. The Conversation body's end
368
+ reserve narrows the frame by --dsh-chat-end-inset; the layer reaches back
369
+ across it to the scrollport's end edge, and the gutter counts it. The
370
+ margin follows the body's --dsh-chat-end-reserve-transition, as the
371
+ scrollport's padding does, so the layer's end edge stays put while the
372
+ inset animates. */
373
+ .asideSlot {
374
+ position: absolute;
375
+ top: 0;
376
+ right: 0;
377
+ left: 0;
378
+ z-index: 9;
379
+ height: 0;
380
+ margin-inline-end: calc(-1 * var(--dsh-chat-end-inset, 0px));
381
+ transition: margin-inline-end var(--dsh-chat-end-reserve-transition, 0s);
382
+ pointer-events: none;
383
+ --dsh-chat-aside-gutter: calc(
384
+ var(--dsh-chat-end-inset, 0px)
385
+ + max(0px, (100% - var(--dsh-chat-end-inset, 0px) - var(--dsh-chat-content-width, 100%)) / 2)
386
+ );
387
+ }
388
+
389
+ :global([data-conversation-scroll]) .asideSlot {
390
+ position: sticky;
391
+ }
392
+
359
393
  .toBottomSlot {
360
394
  position: absolute;
361
395
  right: 0;
@@ -16,10 +16,12 @@ import type { ChatFlowHookContext, ChatViewSlotProps, OpenFileOptions } from '..
16
16
  import type { ChatSnapshot } from '../contract/snapshot.ts'
17
17
  import { markdownLabels } from '../markdown-labels.ts'
18
18
  import { TurnNavigator } from './TurnNavigator.tsx'
19
+ import { ChatAside } from './ChatAside.tsx'
19
20
  import { mergeTurnRailItems } from './turn-rail-items.ts'
20
21
  import { useTextInteraction } from './text-interaction.ts'
21
22
  import { useChatScroll } from './use-chat-scroll.ts'
22
23
  import { fileMediaUrl, resolveWorkspacePath, sessionFileAddress } from '@deepseek-ai/dsh-util-workspace-path'
24
+ import { selectSessionDirectory } from '@deepseek-ai/dsh-api-session-controller/client/directories'
23
25
  import css from './ChatView.module.css'
24
26
 
25
27
  /** Host/OS refusal text for the file-open dialog; empty throws keep a locale fallback. */
@@ -99,15 +101,17 @@ export function ChatView({
99
101
  const inbox = useProjection('inbox') as InboxState | undefined
100
102
  // Workspace root off the session list row: path summaries display relative to it.
101
103
  const cwd = useSessions(s => s.byId[sessionId]?.cwd)
104
+ // The directory the Session works in now: a relative image target resolves from it, as a relative link does.
105
+ const directory = useSessions(s => selectSessionDirectory(s, sessionId))
102
106
  const fileImages = useMemo(() => ({
103
107
  fileDrag,
104
- resolve: (path: string) => fileMediaUrl(document.baseURI, resolveWorkspacePath(cwd, path)),
105
- resourceAddress: (path: string) => sessionFileAddress(sessionId, resolveWorkspacePath(cwd, path)),
108
+ resolve: (path: string) => fileMediaUrl(document.baseURI, resolveWorkspacePath(directory, path)),
109
+ resourceAddress: (path: string) => sessionFileAddress(sessionId, resolveWorkspacePath(directory, path)),
106
110
  labels: {
107
111
  open: t('image.open'), loading: t('image.loading'), failed: t('image.failed'),
108
112
  dialog: t('image.dialog'), close: t('image.close'),
109
113
  },
110
- }), [cwd, t, fileDrag, sessionId])
114
+ }), [directory, t, fileDrag, sessionId])
111
115
  const codeLabels = useMemo(() => markdownLabels(t).code, [t])
112
116
  // Every fence in the flow dispatches by language; the content is the plain
113
117
  // code block, so a language without a layer renders as code without diff rows.
@@ -239,6 +243,7 @@ export function ChatView({
239
243
  t={t}
240
244
  />
241
245
  )}
246
+ <ChatAside renderSlot={renderSlot} />
242
247
  <div className={css.root} data-chat-following-tail={scroll.followingTail ? '' : undefined}>
243
248
  <div ref={scroll.listRef} className={css.scroll}>
244
249
  <div ref={scroll.columnRef} className={css.column} data-chat-flow=""
@@ -306,7 +311,7 @@ export function ChatView({
306
311
  aria-label={t('chat.toBottom')}
307
312
  onClick={scroll.returnToBottom}
308
313
  >
309
- <IconChevronDownOutlineRegular />
314
+ <IconChevronDownOutlineRegular size={16} />
310
315
  </button>
311
316
  </div>
312
317
  )}
@@ -1,5 +1,6 @@
1
+ import type { CompactionRowInjected } from './CompactionItem.tsx'
1
2
  import { memo, useMemo } from 'react'
2
- import type { PropsRenderSlots } from '@deepseek-ai/dsh-client-ui-slots'
3
+ import type { InjectFace, PropsRenderSlots } from '@deepseek-ai/dsh-client-ui-slots'
3
4
  import type {
4
5
  ChatNodeViewProps, CommandRowOwnerProps,
5
6
  } from '../contract/slots.ts'
@@ -25,14 +26,16 @@ export const CommandNodeView = memo(function CommandNodeView({ node, renderSlot,
25
26
 
26
27
  /** One integrated `/compact` command and compaction transaction renderer. */
27
28
  export const ManualCompactionNodeView = memo(function ManualCompactionNodeView({
28
- node, t,
29
- }: ChatNodeViewProps<'manual-compaction'>) {
29
+ node, openCompaction, useCompactionPreview, t,
30
+ }: ChatNodeViewProps<'manual-compaction'> & InjectFace<CompactionRowInjected>) {
31
+ const available = useCompactionPreview(value => value)
30
32
  const data = node.data
31
33
  return (
32
34
  <div className={css.callRow}>
33
35
  <CompactionCommandCard
34
36
  node={data.command}
35
37
  {...data.compaction === null ? {} : { compaction: data.compaction }}
38
+ openCompaction={available ? openCompaction : undefined}
36
39
  t={t}
37
40
  />
38
41
  </div>
@@ -0,0 +1,60 @@
1
+ import { memo, useCallback, useMemo, useState } from 'react'
2
+ import type { ChatViewSlotProps } from '../contract/slots.ts'
3
+ import { DisclosureRow, IconApiOutlineRegular, TextShimmer } from '@deepseek-ai/dsh-client-ui-primitives'
4
+ import a11yCss from './accessibility.module.css'
5
+ import css from './CommandStatusRow.module.css'
6
+
7
+ type CommandRowState = 'running' | 'ok' | 'error'
8
+
9
+ const COMMAND_ICON = <IconApiOutlineRegular size={14} />
10
+
11
+ interface CommandStatusRowProps {
12
+ title: string
13
+ state: CommandRowState
14
+ summary: string
15
+ body: string | null
16
+ t: ChatViewSlotProps['t']
17
+ }
18
+
19
+ /** Render a running or settled status with optional multiline details.
20
+ * @param props - localized labels, status, and expandable content.
21
+ * @returns the status row.
22
+ */
23
+ export const CommandStatusRow = memo(function CommandStatusRow({ title, state, summary, body, t }: CommandStatusRowProps) {
24
+ const [expanded, setExpanded] = useState(false)
25
+ const running = state === 'running'
26
+ const open = expanded && body !== null
27
+ const toggle = useCallback(() => { setExpanded(value => !value) }, [])
28
+ const collapsedContent = useMemo(() => (
29
+ <>
30
+ <span className={css.separator} data-shimmer-decoration aria-hidden />
31
+ <span className={css.summary} data-error={state === 'error' || undefined}>
32
+ <TextShimmer>{summary}</TextShimmer>
33
+ </span>
34
+ </>
35
+ ), [state, summary])
36
+ const content = useMemo(() => open
37
+ ? <pre className={css.body} data-error={state === 'error' || undefined}>{body}</pre>
38
+ : undefined, [body, open, state])
39
+ return (
40
+ <div className={css.root} data-variant="others" data-state={state}>
41
+ {state === 'running' && <span className={a11yCss.visuallyHidden}>{t('row.running')}</span>}
42
+ {state === 'error' && <span className={a11yCss.visuallyHidden}>{t('row.failed')}</span>}
43
+ <DisclosureRow
44
+ leadingClassName={css.leading}
45
+ titleClassName={css.title}
46
+ icon={COMMAND_ICON}
47
+ title={title}
48
+ running={running}
49
+ open={open}
50
+ expandable={body !== null}
51
+ expandOnRowClick
52
+ keepContentWhenOpen
53
+ onToggle={toggle}
54
+ collapsedContent={collapsedContent}
55
+ >
56
+ {content}
57
+ </DisclosureRow>
58
+ </div>
59
+ )
60
+ })
@@ -2,19 +2,21 @@
2
2
  // retain the command's complete settlement text.
3
3
 
4
4
  import type { ChatViewSlotProps, CommandRowOwnerProps } from '../contract/slots.ts'
5
- import { CompactionItem } from './CompactionItem.tsx'
5
+ import { CompactionItem, type CompactionRowInjected } from './CompactionItem.tsx'
6
6
  import { GenericCommandCard } from './GenericCommandCard.tsx'
7
7
 
8
8
  interface CompactionCommandCardProps extends CommandRowOwnerProps {
9
+ openCompaction: CompactionRowInjected['openCompaction'] | undefined
9
10
  t: ChatViewSlotProps['t']
10
11
  }
11
12
 
12
13
  /** Render one manual compaction lifecycle without duplicating its checkpoint marker. */
13
- export function CompactionCommandCard({ node, compaction, t }: CompactionCommandCardProps) {
14
+ export function CompactionCommandCard({ node, compaction, openCompaction, t }: CompactionCommandCardProps) {
14
15
  if (compaction !== undefined) {
15
16
  return (
16
17
  <CompactionItem
17
18
  node={compaction}
19
+ openCompaction={openCompaction}
18
20
  title={t('message.compaction.commandTitle')}
19
21
  fallbackSummary={node.outcome?.text ?? null}
20
22
  t={t}
@@ -1,19 +1,25 @@
1
- // A compaction marker does not replace shadowed transcript rows. It is
2
- // expandable only when the current window includes its cited summary.
1
+ // The marker stays at the checkpoint position and opens the associated summary.
3
2
 
4
- import { memo, useMemo, useState } from 'react'
3
+ import { memo, useEffect, useRef, useState } from 'react'
5
4
  import {
6
5
  IconApiOutlineRegular,
7
- IconChevronDownOutlineRegular,
8
6
  IconChevronRightOutlineRegular,
9
- MarkdownText,
7
+ Tooltip,
10
8
  } from '@deepseek-ai/dsh-client-ui-primitives'
9
+ import type { ObservableSnapshot } from '@deepseek-ai/dsh-client-store'
11
10
  import type { ChatViewSlotProps } from '../contract/slots.ts'
12
- import { markdownLabels } from '../markdown-labels.ts'
13
11
  import type { CompactionSummaryNode } from '../contract/snapshot.ts'
12
+ import a11yCss from './accessibility.module.css'
14
13
  import css from './MessageItem.module.css'
15
14
 
15
+ /** Session-bound checkpoint navigation for manual and automatic compaction rows. */
16
+ export interface CompactionRowInjected {
17
+ hooks: { compactionPreview: ObservableSnapshot<boolean> }
18
+ openCompaction: (seq: number, signal: AbortSignal) => Promise<string | null>
19
+ }
20
+
16
21
  interface CompactionItemProps {
22
+ openCompaction: CompactionRowInjected['openCompaction'] | undefined
17
23
  node: CompactionSummaryNode
18
24
  /** Optional command title for a manual compaction folded into this marker. */
19
25
  title?: string
@@ -25,52 +31,76 @@ interface CompactionItemProps {
25
31
 
26
32
  /**
27
33
  * Renders the model-history compaction marker.
28
- * @param props - the marker node off the snapshot cache.
29
- * @returns the marker row, with the summary disclosure when one is available.
34
+ * @param props - the marker node off the snapshot cache and the Sidebar opener.
35
+ * @returns the marker row; disabled while no Sidebar tab type opens checkpoints.
30
36
  */
31
37
  export const CompactionItem = memo(function CompactionItem({
32
38
  node,
39
+ openCompaction,
33
40
  title,
34
41
  fallbackSummary,
35
42
  t,
36
43
  }: CompactionItemProps) {
37
- const [expanded, setExpanded] = useState(false)
38
- const labels = useMemo(() => markdownLabels(t), [t])
39
- const expandable = node.summary !== null
40
- const open = expandable && expanded
44
+ const summarySeq = node.summaryEventSeq
45
+ const available = openCompaction !== undefined && summarySeq !== null
46
+ const pending = useRef<AbortController | null>(null)
47
+ const [opening, setOpening] = useState(false)
48
+ const [failure, setFailure] = useState<string | null>(null)
49
+ useEffect(() => {
50
+ pending.current = null
51
+ setOpening(false)
52
+ setFailure(null)
53
+ return () => { pending.current?.abort() }
54
+ }, [node.seq, summarySeq, openCompaction])
55
+ const open = async (): Promise<void> => {
56
+ if (!available || pending.current !== null) return
57
+ const controller = new AbortController()
58
+ pending.current = controller
59
+ setOpening(true)
60
+ setFailure(null)
61
+ try {
62
+ const result = await openCompaction(summarySeq, controller.signal)
63
+ if (!controller.signal.aborted) setFailure(result)
64
+ } catch (error) {
65
+ if (!controller.signal.aborted) setFailure(error instanceof Error ? error.message : String(error))
66
+ } finally {
67
+ if (pending.current === controller) pending.current = null
68
+ if (!controller.signal.aborted) setOpening(false)
69
+ }
70
+ }
41
71
  const summary = node.shadowedItemCount !== null && node.shadowedTokenCount !== null
42
72
  ? t('message.compaction.completed', {
43
73
  items: node.shadowedItemCount,
44
74
  tokens: node.shadowedTokenCount,
45
75
  })
46
- : fallbackSummary
47
- ?? (expandable ? t('message.compaction.expand') : t('message.compaction.unavailable'))
76
+ : fallbackSummary ?? t('message.compaction.landed')
77
+ const action = t('message.compaction.open')
48
78
  return (
49
79
  <div className={css.compactionRow}>
50
- <button
51
- type="button"
52
- className={css.compactionButton}
53
- disabled={!expandable}
54
- aria-expanded={expandable ? open : undefined}
55
- onClick={() => { setExpanded(value => !value) }}
56
- >
57
- <span className={css.compactionLeading} aria-hidden>
58
- <span className={css.compactionContextIcon} data-compaction-icon="context">
59
- <IconApiOutlineRegular />
60
- </span>
61
- <span
62
- className={css.compactionDisclosureIcon}
63
- data-compaction-disclosure={open ? 'expanded' : 'collapsed'}
64
- >
65
- {open ? <IconChevronDownOutlineRegular /> : <IconChevronRightOutlineRegular />}
80
+ <Tooltip label={action} side="top" portal delayMs={200} disabled={!available}>
81
+ <button
82
+ type="button"
83
+ className={css.compactionButton}
84
+ disabled={!available || opening}
85
+ aria-busy={opening}
86
+ data-compaction-seq={node.seq}
87
+ onClick={() => { void open() }}
88
+ >
89
+ <span className={css.compactionLeading} aria-hidden>
90
+ <span className={css.compactionContextIcon} data-compaction-icon="context">
91
+ <IconApiOutlineRegular />
92
+ </span>
93
+ <span className={css.compactionOpenIcon} data-compaction-icon="open">
94
+ <IconChevronRightOutlineRegular />
95
+ </span>
66
96
  </span>
67
- </span>
68
- <span className={css.compactionTitle}>{title ?? t('message.compaction')}</span>
69
- <span className={css.compactionSep} aria-hidden />
70
- <span className={css.compactionSummary}>{summary}</span>
71
- </button>
72
- {open && node.summary !== null
73
- && <div className={css.compactionBody}><MarkdownText text={node.summary} labels={labels} /></div>}
97
+ <span className={css.compactionTitle}>{title ?? t('message.compaction')}</span>
98
+ <span className={css.compactionSep} aria-hidden />
99
+ <span className={css.compactionSummary}>{summary}</span>
100
+ {available && <span className={a11yCss.visuallyHidden}>{action}</span>}
101
+ </button>
102
+ </Tooltip>
103
+ {failure !== null && <p role="alert">{failure}</p>}
74
104
  </div>
75
105
  )
76
106
  })
@@ -1,18 +1,6 @@
1
- import { memo, useCallback, useMemo, useState } from 'react'
1
+ import { memo } from 'react'
2
2
  import type { ChatViewSlotProps, CommandRowOwnerProps } from '../contract/slots.ts'
3
- import { DisclosureRow, IconApiOutlineRegular, TextShimmer } from '@deepseek-ai/dsh-client-ui-primitives'
4
- import a11yCss from './accessibility.module.css'
5
- import css from './GenericCommandCard.module.css'
6
-
7
- type CommandRowState = 'running' | 'ok' | 'error'
8
-
9
- const COMMAND_ICON = <IconApiOutlineRegular size={14} />
10
-
11
- /** Node state → row state semantic (running while unsettled; outcome kind after). */
12
- function stateOf(outcome: CommandRowOwnerProps['node']['outcome']): CommandRowState {
13
- if (outcome === null) return 'running'
14
- return outcome.kind === 'error' ? 'error' : 'ok'
15
- }
3
+ import { CommandStatusRow } from './CommandStatusRow.tsx'
16
4
 
17
5
  /** Card props: the owner payload plus the render site's locale seat (plain prop). */
18
6
  export interface GenericCommandCardProps extends CommandRowOwnerProps {
@@ -27,7 +15,6 @@ export interface GenericCommandCardProps extends CommandRowOwnerProps {
27
15
  * @returns the command disclosure.
28
16
  */
29
17
  export const GenericCommandCard = memo(function GenericCommandCard({ node, t, runningSummary }: GenericCommandCardProps) {
30
- const [expanded, setExpanded] = useState(false)
31
18
  const text = node.outcome?.text
32
19
  const summary = node.outcome === null
33
20
  ? runningSummary ?? t('command.running')
@@ -35,41 +22,7 @@ export const GenericCommandCard = memo(function GenericCommandCard({ node, t, ru
35
22
  // The summary already carries the settlement text, so the title is the bare
36
23
  // command name.
37
24
  const title = node.name ?? t('command.title')
38
- const state = stateOf(node.outcome)
39
- const running = state === 'running'
25
+ const state = node.outcome === null ? 'running' : node.outcome.kind === 'error' ? 'error' : 'ok'
40
26
  const body = text !== undefined && text.includes('\n') ? text : null
41
- const open = expanded && body !== null
42
- const toggle = useCallback(() => { setExpanded(value => !value) }, [])
43
- const collapsedContent = useMemo(() => (
44
- <>
45
- <span className={css.separator} data-shimmer-decoration aria-hidden />
46
- <span className={css.summary} data-error={state === 'error' || undefined}>
47
- <TextShimmer>{summary}</TextShimmer>
48
- </span>
49
- </>
50
- ), [running, state, summary])
51
- const content = useMemo(() => open
52
- ? <pre className={css.body} data-error={state === 'error' || undefined}>{body}</pre>
53
- : undefined, [body, open, state])
54
- return (
55
- <div className={css.root} data-variant="others" data-state={state}>
56
- {state === 'running' && <span className={a11yCss.visuallyHidden}>{t('row.running')}</span>}
57
- {state === 'error' && <span className={a11yCss.visuallyHidden}>{t('row.failed')}</span>}
58
- <DisclosureRow
59
- leadingClassName={css.leading}
60
- titleClassName={css.title}
61
- icon={COMMAND_ICON}
62
- title={title}
63
- running={running}
64
- open={open}
65
- expandable={body !== null}
66
- expandOnRowClick
67
- keepContentWhenOpen
68
- onToggle={toggle}
69
- collapsedContent={collapsedContent}
70
- >
71
- {content}
72
- </DisclosureRow>
73
- </div>
74
- )
27
+ return <CommandStatusRow title={title} state={state} summary={summary} body={body} t={t} />
75
28
  })
@@ -74,16 +74,16 @@
74
74
  cursor: pointer;
75
75
  }
76
76
 
77
- /* Action glyphs follow the same px delta as the text they serve; the
78
- assistant completion row gives them two extra pixels. */
77
+ /* Action glyphs follow the content font-size delta. */
79
78
  .action svg {
80
79
  width: calc(15px + var(--dsh-content-font-delta, 0px));
81
80
  height: calc(15px + var(--dsh-content-font-delta, 0px));
82
81
  }
83
82
 
84
83
  .actions[data-clock='end'] .action svg {
85
- width: calc(17px + var(--dsh-content-font-delta, 0px));
86
- height: calc(17px + var(--dsh-content-font-delta, 0px));
84
+ flex: none;
85
+ width: calc(16px + var(--dsh-content-font-delta, 0px));
86
+ height: calc(16px + var(--dsh-content-font-delta, 0px));
87
87
  }
88
88
 
89
89
  @media (hover: hover) {
@@ -28,13 +28,56 @@
28
28
  padding: 2px 0;
29
29
  }
30
30
 
31
+ /* Inherited-history divider: a hairline split by a centered caption. The
32
+ bottom padding approaches the inter-turn space above it, so the divider
33
+ does not read as the next message's header. */
34
+ .inheritedHistoryRow {
35
+ display: flex;
36
+ align-items: center;
37
+ gap: 12px;
38
+ padding: 2px 0 20px;
39
+ }
40
+
41
+ .inheritedHistoryLine {
42
+ flex: 1 1 0;
43
+ min-width: 16px;
44
+ border-top: 0.5px solid var(--dsw-alias-border-l2);
45
+ }
46
+
47
+ /* Glyph and label share one caption and its tertiary ink. The 6px gap matches
48
+ a flow row's glyph-to-label gap; without the flow row's 16px leading box the
49
+ label starts 20px in rather than 22px. */
50
+ .inheritedHistoryCaption {
51
+ flex: 0 1 auto;
52
+ display: flex;
53
+ align-items: center;
54
+ gap: 6px;
55
+ min-width: 0;
56
+ color: var(--dsw-alias-label-tertiary);
57
+ }
58
+
59
+ /* The 14px flow-row glyph edge shared with DisclosureRow's leading icon: the
60
+ CSS edge overrides the svg's own width/height so the glyph follows the font
61
+ delta. */
62
+ .inheritedHistoryIcon {
63
+ flex: none;
64
+ width: calc(14px + var(--dsh-content-font-delta, 0px));
65
+ height: calc(14px + var(--dsh-content-font-delta, 0px));
66
+ }
67
+
68
+ .inheritedHistoryLabel {
69
+ flex: 0 1 auto;
70
+ min-width: 0;
71
+ overflow: hidden;
72
+ font-size: var(--dsh-content-font-size-secondary, 13px);
73
+ line-height: calc(24px + var(--dsh-content-font-delta, 0px));
74
+ text-overflow: ellipsis;
75
+ white-space: nowrap;
76
+ }
77
+
31
78
  /* Compaction marker: one 24px row with a context icon at rest and a
32
- hover/focus disclosure for the summary body. */
79
+ hover/focus chevron for opening the checkpoint in the right Sidebar. */
33
80
  .compactionRow {
34
- /* The toggle's line, and the band a pinned toggle occupies. The button's
35
- height and the offset that holds a summary's code banner below that band
36
- are the same measurement, so both read it from here. */
37
- --dsh-compaction-header-height: calc(24px + var(--dsh-content-font-delta, 0px));
38
81
  padding: 2px 0;
39
82
  }
40
83
 
@@ -42,7 +85,7 @@
42
85
  display: flex;
43
86
  align-items: center;
44
87
  width: 100%;
45
- height: var(--dsh-compaction-header-height);
88
+ height: calc(24px + var(--dsh-content-font-delta, 0px));
46
89
  min-width: 0;
47
90
  padding: 0;
48
91
  border: none;
@@ -54,43 +97,6 @@
54
97
  text-align: left;
55
98
  }
56
99
 
57
- /* The summary body flows uncapped with the page, so a long checkpoint summary
58
- carries this toggle off the top of the viewport. Pin it to the conversation
59
- scroll container's top while the row is open (the body is a sibling rendered
60
- only when expanded); the base background masks the prose scrolling under it.
61
- The square corners apply for as long as the row is open, pinned or not: the
62
- fill is what masks the prose, and rounded corners would leave that prose visible
63
- in the corners. z-index outranks the markdown code block's own sticky banner
64
- (z-index 6 in CodeBlock.module.css); that banner itself stops below this
65
- toggle (rule below), so a summary's fenced code block never puts a control
66
- inside the toggle's band. */
67
- .compactionRow:has(.compactionBody) .compactionButton {
68
- position: sticky;
69
- top: 0;
70
- z-index: 7;
71
- border-radius: 0;
72
- background: var(--dsw-alias-bg-base);
73
- }
74
-
75
- /* A fenced code block in the summary pins its banner at the scrollport top,
76
- where this pinned toggle already sits, and the toggle's band covers the
77
- banner's Copy control. Stop the banner below the toggle instead, on the same
78
- measurement the toggle's own height uses. This rule beats CodeBlock's
79
- `.bannerWrap { top: 0 }` by specificity (0,2,0 against 0,1,0), not by
80
- declaration order: the two sheets load in their own packages. */
81
- .compactionBody :has(> [data-code-block-banner]) {
82
- top: var(--dsh-compaction-header-height);
83
- }
84
-
85
- /* Pinned, the toggle needs an opaque hover fill: the default translucent hover
86
- token below would let the scrolling prose show through the moment the pointer
87
- lands on the toggle to collapse it. */
88
- @media (hover: hover) {
89
- .compactionRow:has(.compactionBody) .compactionButton:hover {
90
- background: var(--dsw-alias-interactive-bg-hover-solid);
91
- }
92
- }
93
-
94
100
  .compactionButton:not(:disabled) {
95
101
  cursor: pointer;
96
102
  }
@@ -123,14 +129,14 @@
123
129
  }
124
130
 
125
131
  .compactionContextIcon,
126
- .compactionDisclosureIcon {
132
+ .compactionOpenIcon {
127
133
  display: inline-flex;
128
134
  grid-area: 1 / 1;
129
135
  align-items: center;
130
136
  justify-content: center;
131
137
  }
132
138
 
133
- .compactionDisclosureIcon {
139
+ .compactionOpenIcon {
134
140
  opacity: 0;
135
141
  }
136
142
 
@@ -144,12 +150,12 @@
144
150
  }
145
151
  }
146
152
 
147
- .compactionButton:not(:disabled):focus-visible .compactionDisclosureIcon {
153
+ .compactionButton:not(:disabled):focus-visible .compactionOpenIcon {
148
154
  opacity: 1;
149
155
  }
150
156
 
151
157
  @media (hover: hover) {
152
- .compactionButton:not(:disabled):hover .compactionDisclosureIcon {
158
+ .compactionButton:not(:disabled):hover .compactionOpenIcon {
153
159
  opacity: 1;
154
160
  }
155
161
  }
@@ -181,14 +187,6 @@
181
187
  white-space: nowrap;
182
188
  }
183
189
 
184
- .compactionBody {
185
- /* Indent under the title, which starts at leading (16 + delta) + gap 6. */
186
- padding: 4px 0 4px calc(22px + var(--dsh-content-font-delta, 0px));
187
- color: var(--dsw-alias-label-tertiary);
188
- font-size: var(--dsh-content-font-size-secondary, 13px);
189
- line-height: calc(24px + var(--dsh-content-font-delta, 0px));
190
- }
191
-
192
190
  .retryRow {
193
191
  color: var(--dsw-alias-label-tertiary);
194
192
  font-size: var(--dsh-content-font-size-secondary, 13px);