@cueloop/client 0.1.0-alpha.63 → 0.1.0-alpha.65

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 (68) hide show
  1. package/package.json +7 -6
  2. package/src/App.autoclose.test.tsx +2 -2
  3. package/src/App.export.test.tsx +2 -2
  4. package/src/App.plan-review.test.tsx +76 -247
  5. package/src/App.readonly.test.tsx +80 -35
  6. package/src/App.rendering.test.tsx +5 -6
  7. package/src/App.review-panel.test.tsx +29 -32
  8. package/src/App.submit-confirm.test.tsx +27 -12
  9. package/src/App.test.tsx +73 -49
  10. package/src/App.toast.test.tsx +34 -22
  11. package/src/App.tree.test.tsx +224 -0
  12. package/src/App.tsx +134 -87
  13. package/src/app-screens.tsx +27 -1
  14. package/src/app-view-model.ts +7 -109
  15. package/src/components/AnnotationCard.tsx +2 -2
  16. package/src/components/DiffSheet.scroll.test.tsx +5 -2
  17. package/src/components/DiffSheet.tsx +1 -6
  18. package/src/components/KeybindsDialog.tsx +61 -17
  19. package/src/components/PrototypeSheet.tsx +5 -9
  20. package/src/components/ReviewPanel.stories.tsx +14 -0
  21. package/src/components/ReviewRail.stories.tsx +14 -0
  22. package/src/components/ReviewRail.tsx +15 -6
  23. package/src/components/ThreadView.selection.test.tsx +812 -0
  24. package/src/components/ThreadView.stories.tsx +26 -0
  25. package/src/components/ThreadView.tsx +1620 -0
  26. package/src/components/TreePane.stories.tsx +106 -0
  27. package/src/components/TreePane.tsx +156 -0
  28. package/src/components/__snapshots__/stories.test.tsx.snap +120 -172
  29. package/src/components/primitives/Tabs.tsx +1 -1
  30. package/src/components/story-fixtures.ts +6 -2
  31. package/src/components/story.ts +16 -4
  32. package/src/components/syntax-highlight.ts +10 -2
  33. package/src/components/terminal-pane.test.tsx +1 -1
  34. package/src/components/terminal-pane.ts +7 -1
  35. package/src/config.ts +112 -99
  36. package/src/diff-hunk-curate.ts +4 -104
  37. package/src/editor.ts +5 -1
  38. package/src/ghostty-terminal.test.ts +1 -1
  39. package/src/herdr.ts +10 -2
  40. package/src/index.ts +1 -0
  41. package/src/intent-dispatch.test.ts +235 -55
  42. package/src/intent-dispatch.ts +104 -34
  43. package/src/key-bindings.test.ts +1 -1
  44. package/src/key-bindings.ts +16 -7
  45. package/src/keymap.test.ts +9 -11
  46. package/src/keymap.ts +14 -7
  47. package/src/kitty-image.test.ts +3 -3
  48. package/src/prototype-browser.ts +7 -6
  49. package/src/serve.ts +1 -1
  50. package/src/session-controller.curate.test.ts +106 -4
  51. package/src/session-controller.share.test.ts +220 -70
  52. package/src/session-controller.tree.test.ts +228 -0
  53. package/src/session-controller.ts +370 -94
  54. package/src/share.ts +117 -17
  55. package/src/test-support.test.ts +193 -1
  56. package/src/test-support.ts +69 -1
  57. package/src/theme-presets.ts +9 -2
  58. package/src/thread-chords.test.ts +154 -0
  59. package/src/thread-chords.ts +144 -0
  60. package/src/thread-selection.test.ts +210 -0
  61. package/src/thread-selection.ts +243 -0
  62. package/src/tree-view.test.ts +128 -0
  63. package/src/tree-view.ts +148 -0
  64. package/src/view-diff.ts +1 -4
  65. package/src/view-plan.ts +35 -19
  66. package/src/components/PlanSheet.stories.tsx +0 -113
  67. package/src/components/PlanSheet.tsx +0 -422
  68. package/src/components/plan-sheet-run-style.ts +0 -90
@@ -1,422 +0,0 @@
1
- /**
2
- * The plan document sheet: header chrome, the reconciliation banner, and the
3
- * scrollable block flow. Each prose block renders as one natively wrapped
4
- * text (wrapMode "word") beside a marker gutter, so wrapping is the
5
- * renderer's job; the sheet keeps the rendered/work offset mapping per block
6
- * and exposes an imperative selection surface - the keyboard span drives the
7
- * native selection, and a mouse drag reads back as an exact work-text range,
8
- * which keeps quote anchors char-precise.
9
- */
10
-
11
- import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from "react";
12
- import { useRenderer } from "@opentui/react";
13
- import { type ScrollBoxRenderable, type TextRenderable } from "@opentui/core";
14
- import type { ReviewSession } from "@cueloop/schema";
15
- import {
16
- blockRuns,
17
- displayText,
18
- overlayMarks,
19
- renderedOffsetAtOrAfter,
20
- renderedOffsetAtOrBefore,
21
- safeLinkHref,
22
- workRangeForRendered,
23
- type DisplayBlock,
24
- type Mark,
25
- type SpanState,
26
- type StyleRun,
27
- } from "../view-plan";
28
- import type { Theme } from "../theme";
29
- import { useComponentTheme } from "./theme-context";
30
- import { CodeBlock } from "./CodeBlock";
31
- import { AnnotationCard, type AnnotationDraft } from "./AnnotationCard";
32
- import { MarkerPopover, type MarkerPopoverProps } from "./MarkerPopover";
33
- import { FRAME_BORDER_STYLE } from "./primitives/frame";
34
- import { runStyle } from "./plan-sheet-run-style";
35
-
36
- /** The popover toolbar card is 3 rows tall and sits flush above the marked words. */
37
- const POPOVER_ROWS_ABOVE = 3;
38
- /** Widest toolbar row ("comment · cut · actions · [x]") plus border and padding. */
39
- const POPOVER_TOOLBAR_COLUMNS = 33;
40
-
41
- export interface PlanSelection {
42
- displayIndex: number;
43
- start: number;
44
- end: number;
45
- }
46
-
47
- export interface PlanSheetHandle {
48
- /** Work-text range of the current native (mouse) selection, if any. */
49
- /** The current native selection; `preferredIndex` (the mouse-up block) re-anchors a fresh drag. */
50
- readSelection(preferredIndex?: number): PlanSelection | null;
51
- /** Anchor/extend the renderer's native selection from keyboard span offsets. */
52
- driveSpanSelection(span: SpanState): void;
53
- clearSelection(): void;
54
- revealBlock(displayIndex: number): void;
55
- }
56
-
57
- export interface PlanComposeState {
58
- kind: "comment";
59
- displayIndex: number;
60
- quote: string;
61
- draft: AnnotationDraft;
62
- }
63
-
64
- /** The marker-actions popover, rendered inline at its block while span mode is live. */
65
- export interface PlanPopoverState extends MarkerPopoverProps {
66
- displayIndex: number;
67
- }
68
-
69
- export interface PlanSheetProps {
70
- session: ReviewSession;
71
- display: DisplayBlock[];
72
- marks: Map<number, Mark[]>;
73
- cursor: number;
74
- /** Extra selection-style paint on one block (keyboard span or compose anchor). */
75
- activeSpan: { displayIndex: number; start: number; end: number } | null;
76
- compose: PlanComposeState | null;
77
- /** The marker-actions popover for the span's block; null when not in span mode. */
78
- popover: PlanPopoverState | null;
79
- editOrphanCount: number;
80
- onLineActivate: (displayIndex: number) => void;
81
- /**
82
- * Fires on any mouse release inside the sheet. A drag released outside a
83
- * block's text (the gutter, past a line end, a gap between blocks) never
84
- * reaches a block's own handler, so this fallback lets the app still turn
85
- * the finished drag's native selection into a span.
86
- */
87
- onSelectionRelease?: () => void;
88
- theme?: Theme;
89
- }
90
-
91
- interface BlockRef {
92
- renderable: TextRenderable;
93
- runs: StyleRun[];
94
- }
95
-
96
- /** Screen position of a rendered-text offset inside a wrapped text. */
97
- function positionOfRenderedOffset(
98
- renderable: TextRenderable,
99
- renderedOffset: number,
100
- ): { x: number; y: number } {
101
- const info = renderable.lineInfo;
102
- let lineIndex = 0;
103
-
104
- for (let index = 0; index < info.lineStartCols.length; index++) {
105
- if (info.lineStartCols[index]! <= renderedOffset) lineIndex = index;
106
- else break;
107
- }
108
-
109
- return {
110
- x: renderable.x + renderedOffset - (info.lineStartCols[lineIndex] ?? 0),
111
- y: renderable.y + lineIndex,
112
- };
113
- }
114
-
115
- export const PlanSheet = forwardRef<PlanSheetHandle, PlanSheetProps>(function PlanSheet(
116
- {
117
- display,
118
- marks,
119
- cursor,
120
- activeSpan,
121
- compose,
122
- popover,
123
- editOrphanCount,
124
- onLineActivate,
125
- onSelectionRelease,
126
- theme,
127
- }: PlanSheetProps,
128
- handleRef,
129
- ): React.ReactNode {
130
- const tokens = useComponentTheme(theme);
131
- const renderer = useRenderer();
132
- const blockRefs = useRef(new Map<number, BlockRef>());
133
- const scrollRef = useRef<ScrollBoxRenderable | null>(null);
134
-
135
- useImperativeHandle(handleRef, () => ({
136
- readSelection: (preferredIndex?: number): PlanSelection | null => {
137
- if (!renderer?.hasSelection) return null;
138
- const readBlock = (displayIndex: number): PlanSelection | null => {
139
- const blockRef = blockRefs.current.get(displayIndex);
140
-
141
- if (!blockRef) return null;
142
- const selection = blockRef.renderable.getSelection();
143
-
144
- if (!selection || selection.end <= selection.start) return null;
145
- const range = workRangeForRendered(blockRef.runs, selection.start, selection.end);
146
-
147
- return range ? { displayIndex, ...range } : null;
148
- };
149
-
150
- // the block the mouse released on wins, so a fresh drag re-anchors the span
151
- // (one marker at a time) instead of sticking to the topmost prior selection
152
- if (preferredIndex !== undefined) {
153
- const preferred = readBlock(preferredIndex);
154
-
155
- if (preferred) return preferred;
156
- }
157
- for (const displayIndex of [...blockRefs.current.keys()].sort(
158
- (left, right) => left - right,
159
- )) {
160
- const found = readBlock(displayIndex);
161
-
162
- if (found) return found;
163
- }
164
-
165
- return null;
166
- },
167
- driveSpanSelection: (span: SpanState): void => {
168
- if (!renderer) return;
169
- const blockRef = blockRefs.current.get(span.displayIndex);
170
-
171
- if (!blockRef) return;
172
- // a span over an emphasized word starts/ends on concealed markers with
173
- // no rendered cell; snap to the visible characters inside them
174
- const renderedStart = renderedOffsetAtOrAfter(blockRef.runs, span.start);
175
- const renderedEnd = renderedOffsetAtOrBefore(blockRef.runs, span.end - 1);
176
-
177
- if (renderedStart === null || renderedEnd === null || renderedEnd < renderedStart) return;
178
- const startPosition = positionOfRenderedOffset(blockRef.renderable, renderedStart);
179
- const endPosition = positionOfRenderedOffset(blockRef.renderable, renderedEnd);
180
-
181
- renderer.startSelection(blockRef.renderable, startPosition.x, startPosition.y);
182
- renderer.updateSelection(blockRef.renderable, endPosition.x + 1, endPosition.y);
183
- },
184
- clearSelection: (): void => {
185
- renderer?.clearSelection();
186
- },
187
- revealBlock: (displayIndex: number): void => {
188
- try {
189
- scrollRef.current?.scrollChildIntoView(`plan-block-${displayIndex}`);
190
- } catch {
191
- // reveal is best-effort; selection state is already correct
192
- }
193
- },
194
- }));
195
-
196
- // the popover sits flush above the marked words, anchored to the
197
- // selection start mapped through the wrap geometry (line + column, not the
198
- // block's linear offset). It renders as the LAST child of the scrollbox in
199
- // content coordinates: content coordinates are scroll-invariant so the card
200
- // tracks its block, and the last sibling paints over every block it floats
201
- // across. Flips below when the line sits too near the viewport top.
202
- const [popoverTop, setPopoverTop] = useState(0);
203
- const [popoverLeft, setPopoverLeft] = useState(2);
204
- // a terminal resize rewraps every block; re-run the anchor math against the
205
- // new geometry instead of leaving the card at its pre-resize cell
206
- const [resizeEpoch, setResizeEpoch] = useState(0);
207
-
208
- useEffect(() => {
209
- if (!renderer) return;
210
- const onResize = (): void => setResizeEpoch((epoch) => epoch + 1);
211
-
212
- renderer.on("resize", onResize);
213
-
214
- return () => void renderer.off("resize", onResize);
215
- }, [renderer]);
216
- useEffect(() => {
217
- if (!popover) return;
218
- const blockRef = blockRefs.current.get(popover.displayIndex);
219
- const scrollbox = scrollRef.current;
220
-
221
- if (!blockRef || !scrollbox) return;
222
- const renderedStart =
223
- activeSpan && activeSpan.displayIndex === popover.displayIndex
224
- ? (renderedOffsetAtOrAfter(blockRef.runs, activeSpan.start) ?? 0)
225
- : 0;
226
- const startPosition = positionOfRenderedOffset(blockRef.renderable, renderedStart);
227
- const content = scrollbox.content;
228
- const anchorLeft = startPosition.x - content.x;
229
- const anchorTop = startPosition.y - content.y;
230
- // clamp so the toolbar card never runs past the content's right edge
231
- const maxLeft = Math.max(0, content.width - POPOVER_TOOLBAR_COLUMNS);
232
-
233
- setPopoverLeft(Math.min(anchorLeft, maxLeft));
234
- // only the toolbar (3 rows) + gap must fit above; the dropdown flows down
235
- const lineViewportRow = startPosition.y - scrollbox.y;
236
-
237
- setPopoverTop(anchorTop + (lineViewportRow < POPOVER_ROWS_ABOVE ? 1 : -POPOVER_ROWS_ABOVE));
238
- }, [popover, activeSpan, display, cursor, resizeEpoch]);
239
-
240
- const registerBlock = (
241
- displayIndex: number,
242
- renderable: TextRenderable | null,
243
- runs: StyleRun[],
244
- ): void => {
245
- if (renderable) blockRefs.current.set(displayIndex, { renderable, runs });
246
- else blockRefs.current.delete(displayIndex);
247
- };
248
-
249
- // stale refs must not survive a shrinking display list
250
- useEffect(() => {
251
- for (const displayIndex of blockRefs.current.keys()) {
252
- if (displayIndex >= display.length) blockRefs.current.delete(displayIndex);
253
- }
254
- }, [display]);
255
-
256
- const children: React.ReactNode[] = [];
257
-
258
- for (let displayIndex = 0; displayIndex < display.length; displayIndex++) {
259
- const block = display[displayIndex]!;
260
- const isCursor = displayIndex === cursor;
261
- const gap = topGap(display[displayIndex - 1], block);
262
-
263
- if (block.kind === "code") {
264
- children.push(
265
- <CodeBlock
266
- key={displayIndex}
267
- id={`plan-block-${displayIndex}`}
268
- language={(block.work ?? block.base)?.lang}
269
- content={displayText(block)}
270
- isCursor={isCursor}
271
- marginTop={gap}
272
- isAnnotated={(marks.get(displayIndex) ?? []).length > 0}
273
- changeTag={showsChangeTag(block) ? tagLabel(block) : undefined}
274
- cut={block.type === "del"}
275
- theme={theme}
276
- />,
277
- );
278
- } else {
279
- const blockMarks = [...(marks.get(displayIndex) ?? [])];
280
-
281
- if (activeSpan && activeSpan.displayIndex === displayIndex) {
282
- blockMarks.push({ start: activeSpan.start, end: activeSpan.end, role: "kspan" });
283
- }
284
- const runs = overlayMarks(blockRuns(block, true), blockMarks);
285
- // the change tag participates in the rendered text but carries no offsets;
286
- // a cut block shows no tag (its strikethrough already reads as removed)
287
- const mappedRuns: StyleRun[] = showsChangeTag(block)
288
- ? [...runs, { text: ` [${tagLabel(block)}]`, role: "plain", start: null }]
289
- : runs;
290
-
291
- children.push(
292
- <box
293
- key={displayIndex}
294
- id={`plan-block-${displayIndex}`}
295
- style={{ flexDirection: "row", marginTop: gap }}
296
- >
297
- <text selectable={false}>
298
- <span fg={isCursor ? tokens.accent : tokens.textDim}>{isCursor ? "▎ " : " "}</span>
299
- <span fg={tokens.textDim}>{marker(block)}</span>
300
- </text>
301
- <text
302
- bg={isCursor ? tokens.cursorBackground : undefined}
303
- selectable
304
- selectionBg={tokens.accent}
305
- selectionFg={tokens.accentInk}
306
- style={{ wrapMode: "word", flexGrow: 1, flexShrink: 1 }}
307
- ref={(renderable: TextRenderable | null) =>
308
- registerBlock(displayIndex, renderable, mappedRuns)
309
- }
310
- onMouseUp={() => onLineActivate(displayIndex)}
311
- >
312
- {runs.map((run, runIndex) => {
313
- const url = run.role === "link" ? safeLinkHref(run.href) : undefined;
314
-
315
- return (
316
- <span
317
- key={runIndex}
318
- {...runStyle(run, block, tokens)}
319
- {...(url ? { link: { url } } : {})}
320
- >
321
- {run.text}
322
- </span>
323
- );
324
- })}
325
- {showsChangeTag(block) ? (
326
- <span fg={tagColor(block, tokens)}> [{tagLabel(block)}]</span>
327
- ) : null}
328
- </text>
329
- </box>,
330
- );
331
- }
332
- if (compose && compose.displayIndex === displayIndex) {
333
- children.push(
334
- <AnnotationCard
335
- key={`compose-${displayIndex}`}
336
- kind={compose.kind}
337
- quote={compose.quote}
338
- draft={compose.draft}
339
- theme={theme}
340
- />,
341
- );
342
- }
343
- }
344
- if (popover) {
345
- // last child on purpose: later siblings paint on top, so the floating card
346
- // covers every block it overlaps regardless of scroll position
347
- children.push(
348
- <box
349
- key="marker-popover"
350
- style={{
351
- position: "absolute",
352
- left: popoverLeft,
353
- top: popoverTop,
354
- flexDirection: "column",
355
- }}
356
- >
357
- <MarkerPopover {...popover} theme={theme} />
358
- </box>,
359
- );
360
- }
361
-
362
- return (
363
- <box style={{ flexGrow: 1, flexDirection: "column" }} onMouseUp={onSelectionRelease}>
364
- <box
365
- style={{
366
- flexGrow: 1,
367
- flexDirection: "column",
368
- border: true,
369
- borderStyle: FRAME_BORDER_STYLE,
370
- borderColor: tokens.text,
371
- }}
372
- >
373
- {editOrphanCount > 0 ? (
374
- <box style={{ height: 1, backgroundColor: tokens.markCommentBackground, paddingLeft: 1 }}>
375
- <text fg={tokens.red}>
376
- {editOrphanCount} annotation{editOrphanCount === 1 ? "" : "s"} no longer match - the
377
- passage was removed.
378
- </text>
379
- </box>
380
- ) : null}
381
- <scrollbox
382
- ref={scrollRef}
383
- style={{ flexGrow: 1, paddingLeft: 1, paddingTop: 0 }}
384
- focused={false}
385
- >
386
- {children}
387
- </scrollbox>
388
- </box>
389
- </box>
390
- );
391
- });
392
-
393
- /** Vertical rhythm: gaps live ABOVE blocks so boundaries never collapse. */
394
- function topGap(previous: DisplayBlock | undefined, current: DisplayBlock): number {
395
- if (!previous) return 0;
396
- const tightPair =
397
- (current.kind === "li" && previous.kind === "li") ||
398
- (current.kind === "oli" && previous.kind === "oli");
399
-
400
- return tightPair ? 0 : 1;
401
- }
402
-
403
- function marker(block: DisplayBlock): string {
404
- if (block.kind === "li") return "- ";
405
- if (block.kind === "oli") return `${block.orderedItemNumber ?? 1}. `;
406
- if (block.kind === "quote") return "▏ ";
407
-
408
- return "";
409
- }
410
-
411
- /** An added or edited block earns a tag; a cut block relies on its strikethrough. */
412
- function showsChangeTag(block: DisplayBlock): boolean {
413
- return block.type === "add" || block.type === "mod";
414
- }
415
-
416
- function tagLabel(block: DisplayBlock): "new" | "edited" {
417
- return block.type === "add" ? "new" : "edited";
418
- }
419
-
420
- function tagColor(block: DisplayBlock, tokens: Theme): string {
421
- return block.type === "add" ? tokens.green : tokens.accent;
422
- }
@@ -1,90 +0,0 @@
1
- import { createTextAttributes } from "@opentui/core";
2
- import type { DisplayBlock, StyleRun } from "../view-plan";
3
- import type { Theme } from "../theme";
4
-
5
- /** A cut block reads as removed: struck through and grayed, never red. */
6
- const CUT_ATTRIBUTES = createTextAttributes({ strikethrough: true, dim: true });
7
-
8
- /** Inline-emphasis attributes, reused per run so the render loop allocates none. */
9
- const STRONG_ATTRIBUTES = createTextAttributes({ bold: true });
10
- const EM_ATTRIBUTES = createTextAttributes({ italic: true });
11
- const STRIKE_ATTRIBUTES = createTextAttributes({ strikethrough: true });
12
- const LINK_ATTRIBUTES = createTextAttributes({ underline: true });
13
- /** Block-level base attributes: headings read bold, blockquotes read italic. */
14
- const HEADING_ATTRIBUTES = createTextAttributes({ bold: true });
15
- const QUOTE_ATTRIBUTES = createTextAttributes({ italic: true });
16
-
17
- interface BlockBaseStyle {
18
- baseFg: string;
19
- baseAttributes: number;
20
- }
21
-
22
- function isHeadingBlock(block: DisplayBlock): boolean {
23
- return block.kind === "h1" || block.kind === "h2" || block.kind === "h3";
24
- }
25
-
26
- // headings are all bold; level reads from descending brightness alone (a
27
- // terminal cannot scale font size), leaving the salmon accent to annotations
28
- function headingForeground(block: DisplayBlock, tokens: Theme): string | undefined {
29
- if (block.kind === "h1") return tokens.text;
30
- if (block.kind === "h2") return tokens.textMuted;
31
- if (block.kind === "h3") return tokens.textDim;
32
-
33
- return undefined;
34
- }
35
-
36
- function blockBaseStyle(block: DisplayBlock, tokens: Theme): BlockBaseStyle {
37
- const isHeading = isHeadingBlock(block);
38
- const isQuote = block.kind === "quote";
39
- const headingFg = headingForeground(block, tokens);
40
- // block-level base: headings bold, quotes muted italic; inline roles compose on top
41
- const baseFg = headingFg ?? (isQuote ? tokens.textMuted : tokens.text);
42
- const baseAttributes = (isHeading ? HEADING_ATTRIBUTES : 0) | (isQuote ? QUOTE_ATTRIBUTES : 0);
43
-
44
- return { baseFg, baseAttributes };
45
- }
46
-
47
- function inlineRoleStyle(
48
- run: StyleRun,
49
- base: BlockBaseStyle,
50
- tokens: Theme,
51
- ): { fg?: string; bg?: string; attributes?: number } {
52
- const { baseFg, baseAttributes } = base;
53
- const withBase = (roleAttributes: number): number => baseAttributes | roleAttributes;
54
-
55
- switch (run.role) {
56
- case "ins":
57
- return { fg: tokens.insertedForeground, attributes: baseAttributes || undefined };
58
- case "del":
59
- return { fg: tokens.deletedForeground };
60
- case "mark-comment":
61
- return { fg: tokens.text, bg: tokens.markCommentBackground };
62
- case "mark-focus":
63
- return { fg: tokens.accentInk, bg: tokens.accent };
64
- case "kspan":
65
- return { fg: tokens.accentInk, bg: tokens.accent };
66
- case "strong":
67
- return { fg: baseFg, attributes: withBase(STRONG_ATTRIBUTES) };
68
- case "em":
69
- return { fg: baseFg, attributes: withBase(EM_ATTRIBUTES) };
70
- case "code":
71
- return { fg: tokens.text, bg: tokens.elevated };
72
- case "strike":
73
- return { fg: tokens.textMuted, attributes: withBase(STRIKE_ATTRIBUTES) };
74
- case "link":
75
- return { fg: tokens.blue, attributes: withBase(LINK_ATTRIBUTES) };
76
- default:
77
- return { fg: baseFg, attributes: baseAttributes || undefined };
78
- }
79
- }
80
-
81
- export function runStyle(
82
- run: StyleRun,
83
- block: DisplayBlock,
84
- tokens: Theme,
85
- ): { fg?: string; bg?: string; attributes?: number } {
86
- // a cut block reads as removed: every run struck through and grayed, never red
87
- if (block.type === "del") return { fg: tokens.textDim, attributes: CUT_ATTRIBUTES };
88
-
89
- return inlineRoleStyle(run, blockBaseStyle(block, tokens), tokens);
90
- }