From d316ab7dc85cd27da043683217a238eef4ae4a30 Mon Sep 17 00:00:00 2001 From: agorischek <6295280+agorischek@users.noreply.github.com> Date: Sat, 5 Dec 2026 01:01:59 +0000 Subject: [PATCH 1/5] Kit: side-by-side panes mark their side's changes with the diff's vocabulary A held pane marks only the changes on its side (Before: removed and modified; After: added and modified), with the same status border, band and tint as the diff. Values show their own side's value in the change's hue, with no signs and nothing struck through. The kit's marks read the pane (HeldPane), so renderers drop their own pane special cases. Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- .../renderers/agentic-workflows/src/card.tsx | 19 ++---- packages/renderers/api/src/signature-view.tsx | 30 +++++---- packages/renderers/github-actions/src/job.tsx | 2 +- .../renderers/github-actions/src/matrix.tsx | 38 ++++------- .../renderers/github-actions/src/values.tsx | 34 +++++----- packages/renderers/kit/src/emphasis.ts | 34 +++++++--- packages/renderers/kit/src/react.ts | 2 + packages/renderers/kit/src/react/chip.tsx | 18 +++-- .../kit/src/react/diff-components.tsx | 65 +++++++++++++++++-- packages/renderers/kit/src/react/facts.tsx | 62 +++++++++++------- .../kit/src/react/layout-components.tsx | 26 +++++--- .../renderers/kit/src/react/matrix-grid.tsx | 17 +++-- .../renderers/kit/src/react/shell/document.ts | 3 +- .../renderers/kit/src/react/shell/frame.ts | 12 ++++ .../kit/src/react/shell/kit-renderer.tsx | 8 ++- packages/renderers/kit/styles/chips.css | 5 +- packages/renderers/kit/styles/diff.css | 8 ++- packages/renderers/kit/styles/layout.css | 25 ++----- packages/renderers/kit/styles/matrix.css | 2 +- packages/renderers/kit/styles/nesting.css | 14 ++-- .../renderers/runtime-policy/src/chips.tsx | 3 +- 21 files changed, 270 insertions(+), 157 deletions(-) diff --git a/packages/renderers/agentic-workflows/src/card.tsx b/packages/renderers/agentic-workflows/src/card.tsx index 091644ad2..805b28761 100644 --- a/packages/renderers/agentic-workflows/src/card.tsx +++ b/packages/renderers/agentic-workflows/src/card.tsx @@ -48,11 +48,11 @@ const Words = ({children}: {children: string}) => ( /** * An entry as lines of a section's list. In the diff, arriving or leaving entries take their sign and hue, and one * changed in place reads old → new: the same text at every emphasis, whose hue follows it. A side-by-side pane draws its - * own revision's entries, marked while emphasized, one changed in place in the pane's hue. + * own revision's entries, each in its change's hue (one changed in place in the modified hue), with no signs and + * nothing struck: the kit's `ValueList` draws a held pane so. */ -function items(entry: Entry, side: Side, marked: boolean): ValueItem[] { - const diff = side === 'diff' - if (diff && entry.mark === 'modified' && entry.was !== undefined) { +function items(entry: Entry, side: Side): ValueItem[] { + if (side === 'diff' && entry.mark === 'modified' && entry.was !== undefined) { // Too long to read as old → new on one line: the old entry leaves and the new one arrives, a line each. if (entry.was.length + entry.text.length > inlineChange) { return [ @@ -62,9 +62,7 @@ function items(entry: Entry, side: Side, marked: boolean): ValueItem[] { } return [{key: entry.key, label: {entry.text}, was: {entry.was}, change: 'modified'}] } - const mark = entry.mark === 'modified' && !diff ? (side === 'before' ? 'removed' : 'added') : entry.mark - const change = (diff || marked) && (mark === 'added' || mark === 'removed') ? mark : 'unchanged' - return [{key: entry.key, label: {entry.text}, change}] + return [{key: entry.key, label: {entry.text}, change: entry.mark}] } function SectionRow({section, strength, frame}: {section: Section; strength: number; frame: Frame}) { @@ -80,12 +78,7 @@ function SectionRow({section, strength, frame}: {section: Section; strength: num
{shown.length ? ( - items(entry, frame.side, strength > 0.01))} - label={section.spec.title} - layout="stack" - sign={frame.side === 'diff'} - /> + items(entry, frame.side))} label={section.spec.title} layout="stack" /> ) : ( {section.spec.empty} )} diff --git a/packages/renderers/api/src/signature-view.tsx b/packages/renderers/api/src/signature-view.tsx index d2c8a5094..d8b7e9da5 100644 --- a/packages/renderers/api/src/signature-view.tsx +++ b/packages/renderers/api/src/signature-view.tsx @@ -1,20 +1,22 @@ import {useMemo, type ReactNode} from 'react' import type {Entity} from '@githubnext/projections-schemas' import {identifier, keyed, type EntityChange} from '@githubnext/projections-renderer-sdk/presentation' +import {classifyChange, type ChangeClassification} from '@githubnext/projections-renderer-kit' import {Fact, Facts, Text} from '@githubnext/projections-renderer-kit/react' import {dataChanges} from './model.js' import {signatureLayout, signatureOf, signatureSegments, signatureTokens, type Segment, type Side, type Token} from './signature.js' -type Tone = 'added' | 'removed' -const toneMarks: Record = {added: '+', removed: '−'} +type Tone = Exclude +const toneMarks: Partial> = {added: '+', removed: '−'} -/** One signature line; a toned line carries a `+` or `−` marker in its gutter. */ -function Line({tone, children}: {tone?: Tone | undefined; children: ReactNode}) { +/** One signature line; a diff's added or removed line carries a `+` or `−` marker in its gutter. */ +function Line({tone, signed = true, children}: {tone?: Tone | undefined; signed?: boolean; children: ReactNode}) { + const mark = signed && tone ? toneMarks[tone] : undefined return (
-      {tone && (
+      {mark && (
         
       )}
       {children}
@@ -79,8 +81,10 @@ export function DiffSignature({row}: {row: EntityChange}) {
 
 /**
  * One revision's signature, as a side-by-side pane or an extraction shows it.
- * With emphasis, a changed signature is this side's line of a split diff,
- * marking what the other revision lacks when most of it survives.
+ * With emphasis, a changed signature is tinted in its change's hue (a pane
+ * marks only its side's changes: removed in Before, added in After, modified
+ * in both), with no sign, marking what the other revision lacks when most of
+ * it survives.
  */
 export function RevisionSignature({row, side, emphasized}: {row: EntityChange; side: Side; emphasized: boolean}) {
   const own = signatureOf(row[side]!)
@@ -91,9 +95,13 @@ export function RevisionSignature({row, side, emphasized}: {row: EntityChange{own}
-  return {tokens ?  : own}
+  const change = classifyChange(row)
+  if (!emphasized || otherSignature === own || change === 'unchanged') return {own}
+  return (
+    
+      {tokens ?  : own}
+    
+  )
 }
 
 /** Above this many changed fields, a row lists these and counts the rest. */
diff --git a/packages/renderers/github-actions/src/job.tsx b/packages/renderers/github-actions/src/job.tsx
index 22ab0c51a..f2ad59a43 100644
--- a/packages/renderers/github-actions/src/job.tsx
+++ b/packages/renderers/github-actions/src/job.tsx
@@ -206,7 +206,7 @@ export function JobCard({row, frame}: {row: EntityChange; frame: Frame})
       holdsChanges={changed && row.status === 'modified' && (frame.side === 'diff' || strength > 0.01)}
     >
       
-      {view?.kind === 'grid' && }
+      {view?.kind === 'grid' && }
     
   )
 }
diff --git a/packages/renderers/github-actions/src/matrix.tsx b/packages/renderers/github-actions/src/matrix.tsx
index 27ec71356..3c346f280 100644
--- a/packages/renderers/github-actions/src/matrix.tsx
+++ b/packages/renderers/github-actions/src/matrix.tsx
@@ -33,15 +33,15 @@ function own(cell: GridCell) {
 }
 
 /** One run as a matrix cell: a mark, or what tells it apart, with its whole name for a pointer and screen readers. */
-function cellOf(cell: GridCell | null, frame: Frame, strength: number): MatrixCell | null {
+function cellOf(cell: GridCell | null, frame: Frame): MatrixCell | null {
   if (!cell) return null
   const content = own(cell)
-  return {change: shownMark(cell.mark, frame, strength), title: runName(cell) || 'run', ...(content ? {content} : {})}
+  return {change: shownMark(cell.mark, frame), title: runName(cell) || 'run', ...(content ? {content} : {})}
 }
 
 /** A run `include` adds of its own: what tells it apart, in a quiet cell, its whole name on hover. */
-function Cell({cell, frame, strength}: {cell: GridCell; frame: Frame; strength: number}) {
-  const shown = shownMark(cell.mark, frame, strength)
+function Cell({cell, frame}: {cell: GridCell; frame: Frame}) {
+  const shown = shownMark(cell.mark, frame)
   return (
     
       {own(cell)}
@@ -53,10 +53,10 @@ function Cell({cell, frame, strength}: {cell: GridCell; frame: Frame; strength:
   )
 }
 
-const axisOf = (axis: Axis, frame: Frame, strength: number): MatrixAxis => ({
+const axisOf = (axis: Axis, frame: Frame): MatrixAxis => ({
   name: axis.key,
   code: true,
-  values: axis.values.map(value => ({key: value.text, change: shownMark(value.mark, frame, strength)})),
+  values: axis.values.map(value => ({key: value.text, change: shownMark(value.mark, frame)})),
 })
 
 function Grid({
@@ -64,14 +64,12 @@ function Grid({
   rows,
   columns,
   frame,
-  strength,
   job,
 }: {
   panel: Panel
   rows?: Axis | undefined
   columns?: Axis | undefined
   frame: Frame
-  strength: number
   job: string
 }) {
   // A lone dimension lies as the axes put it: across, in one row under its values, unless it's the runner, whose long
@@ -87,7 +85,7 @@ function Grid({
     if (!rows) return line.get(row) ?? null
     return column === undefined ? ([...line.values()][0] ?? null) : (line.get(column) ?? null)
   }
-  const shown = shownMark(panel.mark, frame, strength)
+  const shown = shownMark(panel.mark, frame)
   const caption =
     panel.title.length > 0 ? (
       
@@ -105,10 +103,10 @@ function Grid({
   return (
      cellOf(find(row, column), frame, strength)}
+      cell={(row, column) => cellOf(find(row, column), frame)}
       vacant="No run: this combination is excluded"
       {...(caption ? {caption} : {})}
     />
@@ -116,22 +114,12 @@ function Grid({
 }
 
 /** A matrix's runs: a grid (or one per combination of its further dimensions), then any runs `include` adds alone. */
-export function Runs({
-  view,
-  frame,
-  strength,
-  job,
-}: {
-  view: Extract
-  frame: Frame
-  strength: number
-  job: string
-}) {
+export function Runs({view, frame, job}: {view: Extract; frame: Frame; job: string}) {
   if (!view.panels.length && !view.extra.length) return null
   return (
     
{view.panels.map(panel => ( - + ))} {view.extra.length > 0 && (
@@ -139,7 +127,7 @@ export function Runs({
    {view.extra.map(cell => (
  • - +
  • ))}
diff --git a/packages/renderers/github-actions/src/values.tsx b/packages/renderers/github-actions/src/values.tsx index a71821373..55f3e5104 100644 --- a/packages/renderers/github-actions/src/values.tsx +++ b/packages/renderers/github-actions/src/values.tsx @@ -1,9 +1,12 @@ // What every card reads (the frame) and how it writes values: plain text, identifiers in monospace, each change in its // hue with its sign, struck through when it leaves, old → new when it changes in place. No pills: a card reads as text. +// A side-by-side pane draws its side's values only, in their hue, with no signs and nothing struck: the kit's marks +// (`ValueMark`, `ValueList`) do that for a held pane, so these take the same props in every mode. import type {ReactNode} from 'react' import {Fact, ValueChange, ValueList, ValueMark, type RendererProps, type ValueItem} from '@githubnext/projections-renderer-kit/react' import type {Entity} from '@githubnext/projections-schemas' import {identifier, type EntityChange} from '@githubnext/projections-renderer-sdk/presentation' +import {paneChange} from '@githubnext/projections-renderer-kit' import type {Entry, Mark, Side} from './model.js' /** What every card reads: the host's props, the revision shown and how strongly a change shows. */ @@ -15,11 +18,8 @@ export interface Frame { strength: (row: EntityChange) => number } -/** A mark as this frame shows it: the diff marks everything; a side-by-side pane tints only while emphasized. */ -export function shownMark(mark: Mark, frame: Frame, strength: number): Mark { - if (frame.side === 'diff') return mark - return strength <= 0.01 ? 'unchanged' : mark -} +/** A mark as this frame shows it: the diff marks everything; a side-by-side pane only its side's (`paneChange`). */ +export const shownMark = (mark: Mark, frame: Frame): Mark => paneChange(mark, frame.props.pane) /** Text as code (an identifier, a path, a value) or as words. */ export const code = (text: string) => ( @@ -33,14 +33,10 @@ const words: Partial> = {added: 'added: ', removed: 'remove /** A shown mark in words, for assistive technology: what color and dashes say. */ export const spoken = (mark: Mark) => (mark === 'unchanged' ? '' : (words[mark] ?? 'changed: ')) -/** How strongly a change shows in this frame: the diff follows the host's highlighting, a pane the job's emphasis. */ -const emphasisIn = (frame: Frame, strength: number) => (frame.side === 'diff' ? frame.props.highlighting : strength) - -/** One value, marked (the kit's `ValueMark`): its sign in the diff (a pane hides it), its change in words. */ -export function Value({mark, frame, strength, children}: {mark: Mark; frame: Frame; strength: number; children: ReactNode}) { - const shown = shownMark(mark, frame, strength) +/** One value, marked (the kit's `ValueMark`): its sign (none in a pane), its change in words, at the job's emphasis. */ +export function Value({mark, strength, children}: {mark: Mark; frame: Frame; strength: number; children: ReactNode}) { return ( - + {children} ) @@ -93,10 +89,11 @@ export function Values({ /** The list's accessible name. */ label: string }) { + // A pane's entries are already its side's; the kit shows a modified item's own value there, old → new in the diff. const values: ValueItem[] = items.map(entry => frame.side === 'diff' && entry.mark === 'modified' && entry.was !== undefined ? {key: entry.key, label: render(entry.text), was: render(entry.was), change: 'modified'} - : {key: entry.key, label: render(entry.text), change: shownMark(entry.mark, frame, strength)}, + : {key: entry.key, label: render(entry.text), change: entry.mark}, ) return ( ) } @@ -126,13 +122,13 @@ export function Single({ before?: string | undefined after?: string | undefined frame: Frame - /** The job's emphasis: a pane tints a value that differs from the other revision only while it's emphasized. */ + /** The job's emphasis, which the value's change follows. */ strength: number render: (text: string) => ReactNode }) { const shown = frame.side === 'before' ? before : after - // A pane tints a value that differs only while the change shows; at rest it reads as with nothing to compare. - if (frame.side !== 'diff' && before !== after && shown !== undefined && strength > 0.01) { + // A pane marks a value that differs from the other revision in its hue: its side's own value, as the kit's marks do. + if (frame.side !== 'diff' && before !== after && shown !== undefined) { const other = frame.side === 'before' ? after : before const mark: Mark = other === undefined ? (frame.side === 'before' ? 'removed' : 'added') : 'modified' return ( @@ -145,7 +141,7 @@ export function Single({ if (before === undefined || after === undefined) { const text = before ?? after ?? '' return ( - + {render(text)} ) diff --git a/packages/renderers/kit/src/emphasis.ts b/packages/renderers/kit/src/emphasis.ts index e2442921e..f90494920 100644 --- a/packages/renderers/kit/src/emphasis.ts +++ b/packages/renderers/kit/src/emphasis.ts @@ -181,6 +181,25 @@ export function edgePresence(edge: EntityChange, progress: number) return entityPresence(edge, progress) } +/** One held pane of side by side or swipe (`RendererProps.pane`): the revision it shows. */ +export type Pane = 'before' | 'after' + +/** + * Whether a held pane marks a change: each pane marks only the changes on its side. Before marks what was removed, + * changed or renamed; After what was added, changed or renamed. Nothing else is marked, and unchanged items are neutral + * in both, so a removed item is marked only in Before and an added one only in After. + */ +export function paneShows(change: ChangeClassification | Classifiable, pane: Pane): boolean { + const classified = typeof change === 'string' ? change : isChanged(change) ? classifyChange(change) : 'unchanged' + if (classified === 'unchanged') return false + return pane === 'before' ? classified !== 'added' : classified !== 'removed' +} + +/** The change a value or item shows in a held pane (`paneShows`), else unchanged; outside a pane, its own change. */ +export function paneChange(change: C, pane: Pane | undefined): C | 'unchanged' { + return pane === undefined || paneShows(change, pane) ? change : 'unchanged' +} + /** Step-scoped emphasis for one row: pass the row, and its row ID when the row object has none. */ export type EmphasisOf = (change: Classifiable & {id?: string}, id?: string) => number @@ -192,19 +211,16 @@ export type EmphasisOf = (change: Classifiable & {id?: string}, id?: string) => * highlighting, which is exactly 0 at both endpoints. Earlier steps never * pre-tint later changes. Rows no step places use the host's highlighting. * A held pane of side by side or swipe (`pane`) is a static comparison, not a - * moment of the transition: every change it shows follows the host's - * highlighting alike, so Before marks its removals as After marks its - * additions. + * moment of the transition, so the neutral endpoints of the animation don't + * apply to it: every change on its side (`paneShows`) follows the host's + * highlighting alike, so Before marks its removals and changes as After marks + * its additions and changes, and the other side's changes show none. */ -export function stepEmphasis( - schedule: readonly ScheduledStep[], - progress: number, - highlighting: number, - pane?: 'before' | 'after', -): EmphasisOf { +export function stepEmphasis(schedule: readonly ScheduledStep[], progress: number, highlighting: number, pane?: Pane): EmphasisOf { const stepOf = new Map() if (!pane) for (const step of schedule) for (const id of [...step.entities, ...step.relationships]) stepOf.set(id, step) return (change, id = change.id) => { + if (pane && !paneShows(change, pane)) return 0 const strength = presentedEmphasis(change, highlighting) return strength && id !== undefined ? strength * emphasisRise(stepOf.get(id), progress) : strength } diff --git a/packages/renderers/kit/src/react.ts b/packages/renderers/kit/src/react.ts index 8f315b91e..3e7498f0e 100644 --- a/packages/renderers/kit/src/react.ts +++ b/packages/renderers/kit/src/react.ts @@ -17,6 +17,8 @@ export { usePaintGate, usePaintHold, useSelectable, + HeldPane, + useHeldPane, } from './react/shell/frame.js' export * from './react/select-control.js' export * from './react/components.js' diff --git a/packages/renderers/kit/src/react/chip.tsx b/packages/renderers/kit/src/react/chip.tsx index d95d7808b..251c39edf 100644 --- a/packages/renderers/kit/src/react/chip.tsx +++ b/packages/renderers/kit/src/react/chip.tsx @@ -2,11 +2,11 @@ // status tab under it, and `Chips`, a wrapping list of them that keeps room for those tabs. import {Children, type ReactNode} from 'react' import {identifier as identifierAttributes} from '@githubnext/projections-renderer-sdk/presentation' -import {classifyChange, describeChange, statusLabels, type ChangeClassification} from '../emphasis.js' +import {classifyChange, describeChange, paneChange, statusLabels, type ChangeClassification} from '../emphasis.js' import type {StatusChange} from '../svg-status.js' import {toneAttributes, type Tone} from '../tone.js' import {StatusTab} from './status-tab.js' -import {useSelectable} from './shell/frame.js' +import {useHeldPane, useSelectable} from './shell/frame.js' const signs: Partial> = {added: '+', removed: '−', modified: '~', renamed: '~'} @@ -23,7 +23,7 @@ export interface ChipProps { * leaves with an item already marked around it, so change colors never nest; its sign and words still say it. */ paint?: boolean | undefined - /** Puts the change's sign (`+`, `−`, `~`) before the label, as a diff does. */ + /** Puts the change's sign (`+`, `−`, `~`) before the label, as a diff does; never in a held pane. */ sign?: boolean | undefined /** * How strongly the change is shown (`RendererProps.emphasis`), 0 to 1: the hue and the status tab fade with it. Left @@ -72,14 +72,15 @@ export interface ChipProps { * One small item as a pill: an optional category dot, its label (monospace by default) and trailing content, in a * neutral edge. A changed chip is painted in its change's hue (fading with `emphasis`), struck through when removed, * and can carry its sign and a status tab; assistive technology hears its change in words. With `id` and `onSelect` - * it is a button that selects the item. + * it is a button that selects the item. In a held pane it is painted only for its side's changes (`paneShows`), with + * no sign and nothing struck through. */ export function Chip({ label, font = 'code', - change = 'unchanged', + change: own = 'unchanged', paint = true, - sign = false, + sign: signed = false, emphasis, status, dot, @@ -93,6 +94,9 @@ export function Chip({ description, className, }: ChipProps) { + const pane = useHeldPane() + const change = paneChange(own, pane) + const sign = signed && !pane const changed = change !== 'unchanged' // What assistive technology hears: the status tab's words when there is one (it is hidden from it), else the change. const said = status && classifyChange(status) !== 'unchanged' ? describeChange(status) : changed ? statusLabels[change] : undefined @@ -104,6 +108,8 @@ export function Chip({ className: classes, ...(painted ? {'data-change': change} : {}), ...(changed ? {'data-chip-change': change} : {}), + // A held pane shows one revision: what it marks is in its hue, never struck through (chips.css). + ...(pane ? {'data-pane': pane} : {}), ...(id !== undefined ? {'data-entity-id': id} : {}), ...(unit ? {'data-projections-unit': ''} : {}), // Without its own emphasis, a chip's status tab fades with the item's around it, as its paint does. diff --git a/packages/renderers/kit/src/react/diff-components.tsx b/packages/renderers/kit/src/react/diff-components.tsx index fdbce8475..4c3d06b14 100644 --- a/packages/renderers/kit/src/react/diff-components.tsx +++ b/packages/renderers/kit/src/react/diff-components.tsx @@ -1,6 +1,20 @@ import type {ReactNode} from 'react' import {identifier as identifierAttributes} from '@githubnext/projections-renderer-sdk/presentation' +import {statusLabels, type ChangeClassification, type Pane} from '../emphasis.js' import {Chip, Chips} from './chip.js' +import {useHeldPane} from './shell/frame.js' + +const present = (value: ReactNode) => value !== undefined && value !== null && value !== false + +/** + * A value change as a held pane shows it: only its side's value, in its change's hue (modified when both sides have + * one, else removed in Before or added in After), or nothing when its side has none. + */ +function paneValue(before: ReactNode, after: ReactNode, pane: Pane): {value: ReactNode; change: ChangeClassification} | undefined { + const value = pane === 'before' ? before : after + if (!present(value)) return undefined + return {value, change: present(before) && present(after) ? 'modified' : pane === 'before' ? 'removed' : 'added'} +} /** * A value that changed: the old one struck through in a removed pill, then @@ -10,7 +24,8 @@ import {Chip, Chips} from './chip.js' * version), in the monospace font. `variant="text"` draws the same change as * text, with no pills: the old value struck through in the removed hue, an * arrow, then the new one in the added hue (always on one line); use it in - * key-value lists and running text, where pills would be loud. + * key-value lists and running text, where pills would be loud. A held pane shows only its side's value, in its + * change's hue (modified when both sides have one), struck through nowhere. */ export function ValueChange({ before, @@ -28,8 +43,23 @@ export function ValueChange({ variant?: 'pills' | 'text' className?: string }) { - const has = (value: ReactNode) => value !== undefined && value !== null && value !== false + const has = present const label = code ? identifierAttributes : {} + const pane = useHeldPane() + if (pane && variant === 'pills') { + const shown = paneValue(before, after, pane) + if (!shown) return null + return ( + + + {statusLabels[shown.change]}: + + {shown.value} + + + + ) + } if (variant === 'text') { const text = (value: ReactNode) => (has(value) ? {value} : undefined) return @@ -113,7 +143,8 @@ export function ChangePills({ * `ValueChange` inside SVG: one text line at `x`, `y` (the baseline) with * the old value struck through in the removed hue, an arrow, then the new * value in the added hue. Pass identifier attributes (the SDK's - * `identifier`) for code values such as versions. + * `identifier`) for code values such as versions. A held pane draws only its + * side's value, in the modified hue. */ export function SvgValueChange({ before, @@ -131,6 +162,16 @@ export function SvgValueChange({ anchor?: 'start' | 'middle' | 'end' className?: string } & Record<`data-${string}`, string>) { + const pane = useHeldPane() + if (pane) { + return ( + + + {pane === 'before' ? before : after} + + + ) + } return ( {before} @@ -142,10 +183,24 @@ export function SvgValueChange({ /** * A value that changed in place, as text: the old one struck through in the removed hue, an arrow, then the new one - * in the added hue, with no pills. `ValueChange variant="text"` is this. + * in the added hue, with no pills. `ValueChange variant="text"` is this. A held pane shows only its side's value, in + * its change's hue (modified when both sides have one), struck through nowhere. */ export function ValueText({before, after, className}: {before?: ReactNode; after?: ReactNode; className?: string}) { - const has = (value: ReactNode) => value !== undefined && value !== null && value !== false + const has = present + const pane = useHeldPane() + if (pane) { + const shown = paneValue(before, after, pane) + if (!shown) return null + return ( + + + {statusLabels[shown.change]}: + {shown.value} + + + ) + } return ( {has(before) && ( diff --git a/packages/renderers/kit/src/react/facts.tsx b/packages/renderers/kit/src/react/facts.tsx index c261d5ff1..08a04cd48 100644 --- a/packages/renderers/kit/src/react/facts.tsx +++ b/packages/renderers/kit/src/react/facts.tsx @@ -2,15 +2,22 @@ // arrive, leave or change, marked inline in their change's hue rather than each drawn as a pill (`ValueList`). import type {ReactNode} from 'react' import {identifier as identifierAttributes} from '@githubnext/projections-renderer-sdk/presentation' -import {statusLabels, type ChangeClassification} from '../emphasis.js' +import {paneChange, statusLabels, type ChangeClassification, type Pane} from '../emphasis.js' import {ValueChange, ValueText} from './diff-components.js' import {Chip, Chips} from './chip.js' -import {useSelectable} from './shell/frame.js' +import {useHeldPane, useSelectable} from './shell/frame.js' const signs: Partial> = {added: '+', removed: '−', modified: '~', renamed: '~'} const hasContent = (value: ReactNode) => value !== undefined && value !== null && value !== false && value !== '' +/** + * The element a changed value is set in: in the diff and a transition, `del` (struck through) when it leaves and `ins` + * when it arrives; in a held pane, which shows one revision, plain text in its change's hue. + */ +const markTag = (change: ChangeClassification, pane: Pane | undefined) => + pane === undefined && change === 'removed' ? 'del' : pane === undefined && change === 'added' ? 'ins' : 'span' + const emphasisStyle = (emphasis: number | undefined) => emphasis === undefined ? undefined : ({'--emphasis': emphasis} as Record) @@ -42,7 +49,8 @@ export function Facts({ /** * One row of `Facts`: its label, its value and, optionally, a muted note after the value (`meta`: "and 8 run steps"), * so a count or a note sits beside a label rather than alone on a line. A row that arrives or leaves as a whole takes - * `change`: its label is marked in the change's hue, struck through when it leaves, and said in words. + * `change`: its label is marked in the change's hue, struck through when it leaves, and said in words. In a held pane + * it is marked only on its side (`paneShows`), and never struck through. */ export function Fact({ label, @@ -58,14 +66,16 @@ export function Fact({ /** How strongly `change` shows, 0 to 1; left out, the row follows the `--emphasis` of the item around it. */ emphasis?: number }) { - const changed = change !== 'unchanged' - const Label = change === 'removed' ? 'del' : change === 'added' ? 'ins' : 'span' + const pane = useHeldPane() + const shown = paneChange(change, pane) + const changed = shown !== 'unchanged' + const Label = markTag(shown, pane) return (
{changed ? ( -
{changed ? ( -
diff --git a/packages/renderers/kit/styles/chips.css b/packages/renderers/kit/styles/chips.css index 67914028d..86e5caf40 100644 --- a/packages/renderers/kit/styles/chips.css +++ b/packages/renderers/kit/styles/chips.css @@ -83,9 +83,10 @@ } /* * Removed: struck through and muted, painted or not, so removal never rests on color alone. Both fade with the - * chip's emphasis, so a removed chip at an endpoint reads plain. + * chip's emphasis, so a removed chip at an endpoint reads plain. A held pane (`data-pane`) shows only Before's chips + * there, which strikes nothing: its removals are in their hue, as Before has them. */ -.pk .pk-chip[data-chip-change='removed'] .pk-chip-label { +.pk .pk-chip[data-chip-change='removed']:not([data-pane]) .pk-chip-label { color: color-mix(in srgb, var(--muted) calc(var(--emphasis, 1) * 100%), var(--text)); text-decoration: line-through color-mix(in srgb, currentColor calc(var(--emphasis, 1) * 100%), transparent); } diff --git a/packages/renderers/kit/styles/diff.css b/packages/renderers/kit/styles/diff.css index 769be6acf..873f7445e 100644 --- a/packages/renderers/kit/styles/diff.css +++ b/packages/renderers/kit/styles/diff.css @@ -2,7 +2,7 @@ * Diff mode (see `diffModel` and `changeMark`). Every item of the union carries `data-change` with its change, whose * hue `changes.css` sets for everything in it. HTML regions use `pk-region`; an SVG item draws its own shape * (`pk-diff-shape`) the same way, dashed when removed. Text of a removed item (`pk-diff-text`) is struck through and - * muted, so removal never rests on color alone. + * muted, so removal never rests on color alone, except in a held pane (`data-pane`), which shows Before as it is. */ .pk [data-change] > .pk-diff-shape { fill: color-mix(in srgb, var(--pk-region-fill) calc(var(--emphasis, 1) * 100%), var(--raised)); @@ -12,7 +12,7 @@ .pk [data-change='removed'] > .pk-diff-shape { stroke-dasharray: 5 3; } -.pk [data-change='removed'] .pk-diff-text { +.pk:not([data-pane]) [data-change='removed'] .pk-diff-text { color: var(--muted); fill: var(--muted); text-decoration: line-through; @@ -83,6 +83,10 @@ .pk-svg-now { fill: var(--green); } +/* A held pane's side of an SVG value change: that side's value alone, in its change's hue, struck through nowhere. */ +.pk-svg-own { + fill: var(--pk-change-ink); +} /* A diff card's field changes (GraphCanvas `changedFields`). */ .node-field-key, .node-field-value { diff --git a/packages/renderers/kit/styles/layout.css b/packages/renderers/kit/styles/layout.css index a129d8926..b9852f0c7 100644 --- a/packages/renderers/kit/styles/layout.css +++ b/packages/renderers/kit/styles/layout.css @@ -188,27 +188,16 @@ border-radius: var(--projections-radius-sm); background: var(--canvas); } -/* A changed card that is a change region (`pk-region`) takes its edge's hue on its own border, one line, not beside it. */ +/* + * A changed card is a change region (`pk-region`) in every mode, the diff's, a transition's and a held pane's alike: its + * edge's hue on its own border, one line, not beside it, and its fill over the card's own, both fading with `--emphasis` + * to the plain card's. + */ .pk .pk-entity-card.pk-region[data-change] { border-color: color-mix(in srgb, var(--pk-region-edge) var(--pk-region-amount), var(--border-strong)); + background-color: color-mix(in srgb, var(--pk-region-fill) var(--pk-region-amount), var(--canvas)); box-shadow: none; } -/* The change's hue on the card's leading edge, drawn inside it, so emphasis never overlaps a neighbour. */ -.pk .pk-entity-card:not(.pk-region) { - box-shadow: inset 3px 0 0 color-mix(in srgb, var(--change) calc(var(--emphasis) * 100%), transparent); -} -.pk .pk-entity-card[data-status='added'] { - --change: var(--green); -} -.pk .pk-entity-card[data-status='removed'] { - --change: var(--red); -} -.pk .pk-entity-card[data-status='modified'] { - --change: var(--amber); -} -.pk .pk-entity-card:is([data-status='renamed'], [data-status='moved'], [data-status='unchanged']) { - --change: var(--violet); -} /* Hover, keyboard focus and selection rings are the renderer SDK's, on the card's own element. */ .pk .pk-entity-card-select { display: flex; @@ -299,7 +288,7 @@ .pk-entity-card:is( .pk-holds-changes, .pk-mixed-change, - :is([data-change], [data-status]):has(:is([data-change]:not(.pk-status-tab), .pk-svg-was, .pk-svg-now)) + :is([data-change], [data-status]):has(:is([data-change]:not(.pk-status-tab), .pk-svg-was, .pk-svg-now, .pk-svg-own)) ) { --pk-region-fill: transparent; --pk-region-edge: var(--border-emphasis); diff --git a/packages/renderers/kit/styles/matrix.css b/packages/renderers/kit/styles/matrix.css index 4a0a6d1ae..1950e6105 100644 --- a/packages/renderers/kit/styles/matrix.css +++ b/packages/renderers/kit/styles/matrix.css @@ -89,7 +89,7 @@ .pk .pk-matrix .pk-matrix-cell.pk-region[data-change='removed'] { box-shadow: inset 0 0 0 var(--stroke) color-mix(in srgb, var(--border) calc((1 - var(--emphasis, 1)) * 100%), transparent); } -.pk .pk-matrix [data-change='removed'] .pk-diff-text { +.pk:not([data-pane]) .pk-matrix [data-change='removed'] .pk-diff-text { color: color-mix(in srgb, var(--muted) calc(var(--emphasis, 1) * 100%), var(--text)); text-decoration: line-through color-mix(in srgb, currentColor calc(var(--emphasis, 1) * 100%), transparent); } diff --git a/packages/renderers/kit/styles/nesting.css b/packages/renderers/kit/styles/nesting.css index 7201b63c1..b8acd1b80 100644 --- a/packages/renderers/kit/styles/nesting.css +++ b/packages/renderers/kit/styles/nesting.css @@ -8,8 +8,8 @@ */ .pk :is( - :is([data-change], [data-status]):has(:is([data-change]:not(.pk-status-tab), .pk-svg-was, .pk-svg-now)), - .graph-node:has(:is([data-change], .pk-svg-was, .pk-svg-now)), + :is([data-change], [data-status]):has(:is([data-change]:not(.pk-status-tab), .pk-svg-was, .pk-svg-now, .pk-svg-own)), + .graph-node:has(:is([data-change], .pk-svg-was, .pk-svg-now, .pk-svg-own)), .pk-holds-changes ) { --pk-region-fill: transparent; @@ -24,12 +24,14 @@ * card changed two ways (`mixedChange`: renamed and changed) is drawn so too, its status words each in their own hue. */ .pk - :is(.graph-node:has(:is([data-change], .pk-svg-was, .pk-svg-now)), .pk-holds-changes, .pk-mixed-change) + :is(.graph-node:has(:is([data-change], .pk-svg-was, .pk-svg-now, .pk-svg-own)), .pk-holds-changes, .pk-mixed-change) > :is(.node-emphasis, .node-footer-rule) { fill: none; stroke: var(--border-emphasis); } -.pk :is(.graph-node:has(:is([data-change], .pk-svg-was, .pk-svg-now)), .pk-holds-changes, .pk-mixed-change) > .node-footer-band { +.pk + :is(.graph-node:has(:is([data-change], .pk-svg-was, .pk-svg-now, .pk-svg-own)), .pk-holds-changes, .pk-mixed-change) + > .node-footer-band { fill: var(--recessed); } /* @@ -41,8 +43,8 @@ } .pk :is( - :is([data-change], [data-status]):has(:is([data-change]:not(.pk-status-tab), .pk-svg-was, .pk-svg-now)), - .graph-node:has(:is([data-change], .pk-svg-was, .pk-svg-now)), + :is([data-change], [data-status]):has(:is([data-change]:not(.pk-status-tab), .pk-svg-was, .pk-svg-now, .pk-svg-own)), + .graph-node:has(:is([data-change], .pk-svg-was, .pk-svg-now, .pk-svg-own)), .pk-holds-changes, .pk-group:has(:is([data-change], [data-status])) ) { diff --git a/packages/renderers/runtime-policy/src/chips.tsx b/packages/renderers/runtime-policy/src/chips.tsx index 854d1145e..1494b87a9 100644 --- a/packages/renderers/runtime-policy/src/chips.tsx +++ b/packages/renderers/runtime-policy/src/chips.tsx @@ -69,7 +69,8 @@ export function Chips({ onSelect={frame.props.onSelect} change={change} paint={filled} - sign={frame.side === 'diff'} + // The kit draws no sign in a held pane. + sign emphasis={change === 'unchanged' ? 0 : strength} font="text" label={ From 92801569404a89644e829a943254bc281317d9df Mon Sep 17 00:00:00 2001 From: agorischek <6295280+agorischek@users.noreply.github.com> Date: Sat, 5 Dec 2026 01:32:41 +0000 Subject: [PATCH 2/5] Checks: neutral endpoints only animate; pane-marks checks each pane's side neutral-endpoints and quiet-endpoints run only for a renderer with animated mode: a side-by-side or swipe pane is a static comparison. status-text expects Before to name its removals and changes and After its additions and changes. The new pane-marks check fails a pane that marks the other side's arrivals or departures, or a changed card whose band and edge disagree (a tinted band on a neutral edge). Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- .../test/agentic-workflows.test.mjs | 15 ++- packages/renderers/api/test/api.test.mjs | 8 +- .../harness/browser/pane-marks.spec.ts | 50 ++++++++ packages/renderers/kit/src/react/facts.tsx | 18 ++- packages/renderers/kit/styles/layout.css | 7 +- packages/renderers/kit/test/facts.test.mjs | 64 +++++++++- packages/renderers/kit/test/group.test.mjs | 3 +- packages/renderers/kit/test/layout.test.mjs | 5 +- packages/renderers/kit/test/status.test.mjs | 25 ++++ .../renderers/testing/src/checks/catalog.ts | 7 +- .../testing/src/checks/comparison.ts | 6 +- .../src/checks/comparison/endpoints.ts | 17 +-- .../testing/src/checks/comparison/panes.ts | 42 +++++++ .../testing/src/checks/comparison/status.ts | 5 +- packages/renderers/testing/src/measure.ts | 1 + .../testing/src/measure/pane-marks.ts | 116 ++++++++++++++++++ packages/renderers/testing/src/probe.ts | 2 + packages/renderers/testing/src/types.ts | 22 ++++ .../renderers/testing/test/helpers.test.mjs | 2 +- 19 files changed, 376 insertions(+), 39 deletions(-) create mode 100644 packages/renderers/harness/browser/pane-marks.spec.ts create mode 100644 packages/renderers/testing/src/checks/comparison/panes.ts create mode 100644 packages/renderers/testing/src/measure/pane-marks.ts diff --git a/packages/renderers/agentic-workflows/test/agentic-workflows.test.mjs b/packages/renderers/agentic-workflows/test/agentic-workflows.test.mjs index 4087907b7..d5a64629d 100644 --- a/packages/renderers/agentic-workflows/test/agentic-workflows.test.mjs +++ b/packages/renderers/agentic-workflows/test/agentic-workflows.test.mjs @@ -4,6 +4,7 @@ import {readFileSync} from 'node:fs' import {createElement} from 'react' import {renderToStaticMarkup} from 'react-dom/server' import {comparisonModel, extractionModel, stepEmphasis} from '@githubnext/projections-renderer-kit' +import {HeldPane} from '@githubnext/projections-renderer-kit/react' import {createRulesRuntime} from '@githubnext/projections-comparator-runtime' import {buildModel, entries, findingsOf} from '../node_modules/.cache/test/model.js' import {agenticWorkflowsFacts} from '../node_modules/.cache/test/summary.js' @@ -247,13 +248,19 @@ test('a card says what changed beyond its entries: engine, strict mode, lock, de for (const text of ['was copilot, now claude', 'was strict mode on, now strict mode off', 'was Lock current, now Lock stale']) { assert.ok(meta.replaceAll('→', '').includes(text), `${text} in ${meta}`) } - // Side by side, an entry changed in place takes its pane's hue while highlighted. + // Side by side, an entry changed in place is its pane's own, in the modified hue in both panes, with no sign. const pane = progress => renderToStaticMarkup( - createElement(AgenticWorkflowsView, props(model, {...init, comparisonMode: 'side-by-side'}, {diff: false, progress})), + createElement( + HeldPane, + {value: progress < 0.5 ? 'before' : 'after'}, + createElement(AgenticWorkflowsView, props(model, {...init, comparisonMode: 'side-by-side'}, {diff: false, progress})), + ), ) - assert.match(pane(0), /data-change="removed"[^>]*>(?:(?!<\/li>).)*timeout/u) - assert.match(pane(1), /data-change="added"[^>]*>(?:(?!<\/li>).)*timeout/u) + for (const progress of [0, 1]) { + assert.match(pane(progress), /data-change="modified"[^>]*>(?:(?!<\/li>).)*timeout/u) + assert.doesNotMatch(pane(progress), /pk-value-sign| { diff --git a/packages/renderers/api/test/api.test.mjs b/packages/renderers/api/test/api.test.mjs index e44527928..e5bc2be8e 100644 --- a/packages/renderers/api/test/api.test.mjs +++ b/packages/renderers/api/test/api.test.mjs @@ -288,7 +288,7 @@ test('without highlighting the diff keeps its content and footers and drops only ) }) -test('side-by-side panes list each revision; with highlighting each marks its side of the changes', async () => { +test("side-by-side panes list each revision; with highlighting each marks its side's changes in their hue", async () => { const model = await comparison() const alone = extraction => render(props(extractionModel(extraction), {comparing: false, highlighting: 0})) const pane = (progress, highlighting) => render(props(model, {progress, highlighting})) @@ -303,14 +303,16 @@ test('side-by-side panes list each revision; with highlighting each marks its si assert.equal(statusOf(end.added), 'Added') assert.match(start.legacy, /class="api-signature pk-label removed"/u) assert.match(end.added, /class="api-signature pk-label added"/u) + // A changed signature is in the modified hue in both panes, with no sign: each its side's own, marking what it adds. assert.match( start.greet, - /class="api-signature pk-label removed" data-change-hue="removed" data-projections-identifier="">.*greet\(<\/span>\): string<\/span>/u, + /class="api-signature pk-label modified" data-change-hue="modified" data-projections-identifier="">greet\(<\/span>\): string<\/span>/u, ) assert.match( end.greet, - /class="api-signature pk-label added" data-change-hue="added" data-projections-identifier="">.*name: string<\/mark>/u, + /class="api-signature pk-label modified" data-change-hue="modified" data-projections-identifier="">.*name: string<\/mark>/u, ) + assert.ok(![start.greet, end.greet, start.legacy, end.added].some(row => row.includes('api-line-mark')), 'a pane draws no sign') assert.ok(!start.parse.includes(' { + test.skip(info.project.name !== 'chromium-desktop', 'One engine shows the probe works; the checks run in every one.') + const stage = await openStage(page, harnessInspector(), { + scenario: 'github-actions/pipeline', + progress: 1, + pane: 'after', + highlighting: 1, + }) + await stage.measure('settle') + const marks = await stage.measure('paneMarks') + // The kit's cards in a held pane: each changed card's edge and band in its own hue, and nothing removed in After. + expect(marks.length).toBeGreaterThan(0) + for (const mark of marks) { + expect(mark.edge, mark.element).toEqual(mark.band) + expect(mark.words, mark.element).not.toContain('Removed') + } + await stage.frame.locator('body').evaluate(body => { + const fixture = document.createElement('div') + const green = 'var(--projections-color-added)' + const band = (tint: string) => + `
Added
` + fixture.innerHTML = ` +
+

stripe

${band(green)} +
+
+

region

${band(green)} +
+
+

holds changes Modified

+
` + body.prepend(fixture) + }) + const fixtures = new Map( + (await stage.measure('paneMarks')).filter(mark => mark.id.startsWith('fixture-')).map(mark => [mark.id, mark]), + ) + expect(fixtures.get('fixture-stripe')).toMatchObject({words: ['Added'], edge: [], band: ['added']}) + expect(fixtures.get('fixture-region')).toMatchObject({words: ['Added'], edge: ['added'], band: ['added']}) + expect(fixtures.get('fixture-badge')).toMatchObject({words: ['Modified'], edge: [], band: []}) +}) diff --git a/packages/renderers/kit/src/react/facts.tsx b/packages/renderers/kit/src/react/facts.tsx index 08a04cd48..3d9348f86 100644 --- a/packages/renderers/kit/src/react/facts.tsx +++ b/packages/renderers/kit/src/react/facts.tsx @@ -2,21 +2,17 @@ // arrive, leave or change, marked inline in their change's hue rather than each drawn as a pill (`ValueList`). import type {ReactNode} from 'react' import {identifier as identifierAttributes} from '@githubnext/projections-renderer-sdk/presentation' -import {paneChange, statusLabels, type ChangeClassification, type Pane} from '../emphasis.js' +import {paneChange, statusLabels, type ChangeClassification} from '../emphasis.js' import {ValueChange, ValueText} from './diff-components.js' import {Chip, Chips} from './chip.js' import {useHeldPane, useSelectable} from './shell/frame.js' const signs: Partial> = {added: '+', removed: '−', modified: '~', renamed: '~'} -const hasContent = (value: ReactNode) => value !== undefined && value !== null && value !== false && value !== '' +/** The element a change is set in outside a held pane: struck through (`del`) when it leaves, `ins` when it arrives. */ +const markTags: Partial> = {removed: 'del', added: 'ins'} -/** - * The element a changed value is set in: in the diff and a transition, `del` (struck through) when it leaves and `ins` - * when it arrives; in a held pane, which shows one revision, plain text in its change's hue. - */ -const markTag = (change: ChangeClassification, pane: Pane | undefined) => - pane === undefined && change === 'removed' ? 'del' : pane === undefined && change === 'added' ? 'ins' : 'span' +const hasContent = (value: ReactNode) => value !== undefined && value !== null && value !== false && value !== '' const emphasisStyle = (emphasis: number | undefined) => emphasis === undefined ? undefined : ({'--emphasis': emphasis} as Record) @@ -69,7 +65,8 @@ export function Fact({ const pane = useHeldPane() const shown = paneChange(change, pane) const changed = shown !== 'unchanged' - const Label = markTag(shown, pane) + // A held pane shows one revision: its changes in their hue, never struck through (`del`) or underlined (`ins`). + const Label = markTags[pane ? 'unchanged' : shown] ?? 'span' return (
@@ -263,7 +260,8 @@ export function ValueMark({ const pane = useHeldPane() const shown = paneChange(change, pane) if (shown === 'unchanged') return <>{children} - const Tag = markTag(shown, pane) + // A held pane shows one revision: its changes in their hue, never struck through (`del`) or underlined (`ins`). + const Tag = markTags[pane ? 'unchanged' : shown] ?? 'span' return ( {statusLabels[shown]}: diff --git a/packages/renderers/kit/styles/layout.css b/packages/renderers/kit/styles/layout.css index b9852f0c7..ea8cae7c9 100644 --- a/packages/renderers/kit/styles/layout.css +++ b/packages/renderers/kit/styles/layout.css @@ -190,12 +190,13 @@ } /* * A changed card is a change region (`pk-region`) in every mode, the diff's, a transition's and a held pane's alike: its - * edge's hue on its own border, one line, not beside it, and its fill over the card's own, both fading with `--emphasis` - * to the plain card's. + * edge's hue on its own border, one line, not beside it, and its tint laid over the card's own surface, both fading with + * `--emphasis` to the plain card's. A card drawn neutral (nesting.css) keeps its surface. */ .pk .pk-entity-card.pk-region[data-change] { + --pk-card-tint: color-mix(in srgb, var(--pk-region-fill) var(--pk-region-amount), transparent); border-color: color-mix(in srgb, var(--pk-region-edge) var(--pk-region-amount), var(--border-strong)); - background-color: color-mix(in srgb, var(--pk-region-fill) var(--pk-region-amount), var(--canvas)); + background: linear-gradient(var(--pk-card-tint), var(--pk-card-tint)) var(--canvas); box-shadow: none; } /* Hover, keyboard focus and selection rings are the renderer SDK's, on the card's own element. */ diff --git a/packages/renderers/kit/test/facts.test.mjs b/packages/renderers/kit/test/facts.test.mjs index 392e3bd4a..1afbd5dbf 100644 --- a/packages/renderers/kit/test/facts.test.mjs +++ b/packages/renderers/kit/test/facts.test.mjs @@ -2,7 +2,7 @@ import {test} from 'node:test' import assert from 'node:assert/strict' import {createElement} from 'react' import {renderToStaticMarkup} from 'react-dom/server' -import {Fact, Facts, Field, Fields, ValueChange, ValueList, ValueMark} from '../dist/react.js' +import {Chip, EntityCard, Fact, Facts, Field, Fields, HeldPane, ValueChange, ValueList, ValueMark} from '../dist/react.js' import {plain} from './markup.mjs' const html = element => renderToStaticMarkup(element) @@ -100,3 +100,65 @@ test('one value marks its own change, or is the value alone', () => { 'Removed: a', ) }) + +test("a held pane shows each value as its side has it, in its change's hue, with no sign and nothing struck through", () => { + const inPane = (pane, element) => html(createElement(HeldPane, {value: pane}, element)) + const items = [ + {key: 'a', label: 'checkout@v5'}, + {key: 'b', label: 'setup-node@v5', change: 'added'}, + {key: 'c', label: 'cache@v3', change: 'removed'}, + {key: 'd', label: 'upload@v4', was: 'upload@v3', change: 'modified'}, + ] + const before = inPane('before', createElement(ValueList, {label: 'Steps', items})) + const after = inPane('after', createElement(ValueList, {label: 'Steps', items})) + for (const markup of [before, after]) assert.doesNotMatch(markup, /Modified: <\/span>upload@v4<\/span>/u) + assert.equal( + inPane('before', createElement(ValueMark, {change: 'removed', sign: true}, 'a')), + 'Removed: a', + ) + assert.equal(inPane('after', createElement(ValueMark, {change: 'removed'}, 'a')), 'a') + assert.equal( + plain(inPane('before', createElement(Fact, {label: 'Container', change: 'removed'}, 'node:22'))), + 'Removed: Containernode:22', + ) + // A changed value shows its side's value only, in the modified hue; a side without one shows nothing. + const text = inPane('before', createElement(ValueChange, {before: '8.x', after: '10.x', variant: 'text'})) + assert.match(text, //u) + assert.equal(plain(text), 'Modified: 8.x') + assert.match( + inPane('after', createElement(ValueChange, {before: '8.x', after: '10.x'})), + //u, + ) + assert.equal(inPane('before', createElement(ValueChange, {after: '10.x'})), '') + const chip = inPane('before', createElement(Chip, {label: 'gone', change: 'removed', sign: true})) + assert.match(chip, /data-change="removed" data-chip-change="removed" data-pane="before"/u) + assert.doesNotMatch(chip, /pk-chip-sign/u) + assert.doesNotMatch(inPane('before', createElement(Chip, {label: 'new', change: 'added'})), /data-change/u) +}) + +test('a changed card is a change region in every mode: the diff, a transition and its side of a held pane', () => { + const card = (change, pane, emphasis = 1) => + html( + createElement( + HeldPane, + {value: pane}, + createElement(EntityCard, {id: 'job', label: 'job', selected: false, onSelect: () => undefined, change, emphasis}), + ), + ) + const added = {status: 'added'} + assert.match( + card(added, 'after'), + /class="pk-entity-card pk-frame pk-region" data-entity-id="job"[^>]* data-status="added" data-change="added"/u, + ) + // A transition's card is the same region, at its step's emphasis: none at an endpoint, so it reads plain there. + assert.match(card(added, undefined, 0), /class="pk-entity-card pk-frame pk-region"[^>]* data-change="added" style="--emphasis:0"/u) + // A pane never marks the other side's change, and an unchanged card is no region. + const opening = markup => /^]*>/u.exec(markup)[0] + assert.doesNotMatch(opening(card({status: 'removed'}, 'after')), /pk-region|data-change/u) + assert.doesNotMatch(opening(card({status: 'unchanged'}, 'after')), /pk-region|data-change/u) + assert.match(card({status: 'modified'}, 'before'), /data-change="modified"/u) +}) diff --git a/packages/renderers/kit/test/group.test.mjs b/packages/renderers/kit/test/group.test.mjs index 725c6a6f7..26e13202c 100644 --- a/packages/renderers/kit/test/group.test.mjs +++ b/packages/renderers/kit/test/group.test.mjs @@ -71,7 +71,8 @@ test('in a comparison the status states the change in proportion to emphasis, an inline(file), ) const css = inline('react.css') - assert.match(css, /\.pk \[data-change='removed'\] \.pk-diff-text \{[^}]*text-decoration: line-through/u) + // Outside a held pane: a pane shows Before as it is, its removals in their hue, struck through nowhere. + assert.match(css, /\.pk:not\(\[data-pane\]\) \[data-change='removed'\] \.pk-diff-text \{[^}]*text-decoration: line-through/u) }) test('a group that presents an item is its unit, and its title is the button that selects it', () => { diff --git a/packages/renderers/kit/test/layout.test.mjs b/packages/renderers/kit/test/layout.test.mjs index 043a4b2f1..e88d61e2d 100644 --- a/packages/renderers/kit/test/layout.test.mjs +++ b/packages/renderers/kit/test/layout.test.mjs @@ -1187,7 +1187,8 @@ test('a card leads with its title, its kind above it, a subtitle under it and an card, /Matrix job<\/span>40 min<\/span><\/span>build<\/span><\/span><\/span>6 runs<\/span>/u, ) - // Given a change, it shows status in a band at its foot, framed; renamed and changed, it is drawn neutral. + // Given a change, it shows status in a band at its foot, framed; renamed and changed, it is drawn neutral (a region + // whose hues `pk-mixed-change` drains). const changed = renderToStaticMarkup( createElement(EntityCard, { id: 'b', @@ -1198,7 +1199,7 @@ test('a card leads with its title, its kind above it, a subtitle under it and an emphasis: 1, }), ) - assert.match(changed, /
  • /u, + ) // A pane never marks the other side's change, and an unchanged card is no region. const opening = markup => /^]*>/u.exec(markup)[0] assert.doesNotMatch(opening(card({status: 'removed'}, 'after')), /pk-region|data-change/u) diff --git a/packages/renderers/runtime-policy/src/chips.tsx b/packages/renderers/runtime-policy/src/chips.tsx index 1494b87a9..854d1145e 100644 --- a/packages/renderers/runtime-policy/src/chips.tsx +++ b/packages/renderers/runtime-policy/src/chips.tsx @@ -69,8 +69,7 @@ export function Chips({ onSelect={frame.props.onSelect} change={change} paint={filled} - // The kit draws no sign in a held pane. - sign + sign={frame.side === 'diff'} emphasis={change === 'unchanged' ? 0 : strength} font="text" label={ diff --git a/packages/renderers/testing/README.md b/packages/renderers/testing/README.md index cfd92b922..b27c014ff 100644 --- a/packages/renderers/testing/README.md +++ b/packages/renderers/testing/README.md @@ -43,8 +43,8 @@ for (const key of scenarioKeys('scenarios.json')) { package whose `package.json` names one in `"projections": {"renderer": "dist"}`. Build the bundle before the tests. The checks: -- `neutral-endpoints`: At progress 0 and 1, every entity is painted as in an - unchanged comparison of that revision. Parts marked +- `neutral-endpoints`: In animated mode, at progress 0 and 1, every entity is + painted as in an unchanged comparison of that revision. Parts marked `data-projections-category=""` paint a categorical colour: a palette ranked over both revisions is allowed, as long as each key keeps one colour from Before to After. @@ -88,10 +88,17 @@ Build the bundle before the tests. The checks: 0.75 and 1 (animated; the endpoints for two-pane modes) and in the diff, every entity has the same box with highlighting on and off. - `status-text`: While a change is emphasized (in the diff, after its step, or - in its endpoint pane), its entity states its status as text (Added, Removed, - Modified, Renamed or Moved), visibly or for assistive technology. -- `quiet-endpoints`: At both endpoints, with the default highlighting, no entity - shows status text. + in a pane that shows it: Before its removals and changes, After its additions + and changes), its entity states its status as text (Added, Removed, Modified, + Renamed or Moved), visibly or for assistive technology. +- `pane-marks`: In each held pane of side by side or swipe, with highlighting, + the pane marks only its side's changes (nothing in Before marked added, + nothing in After removed), and a changed card's edge (anything taller than a + chip or tag), all the way round, and the band behind its status words share + one change hue: never a tinted band on a neutral edge, or a stripe beside the + edge for one. +- `quiet-endpoints`: In animated mode, at both endpoints, with the default + highlighting, no entity shows status text. - `content-top`: The renderer draws no header of its own (the host owns title, schema and counts): its first entity, outermost SVG canvas or region marked `data-projections-content` (content that isn't an entity: an axis, a table @@ -237,12 +244,12 @@ its reason, so a review sees it. The SDK's style lint CSS at build time. Checks follow the comparison modes the renderer declares -(`capabilities.comparisonModes`): `neutral-endpoints` runs when it declares a -progress mode (`animated`, `side-by-side` or `swipe`), `step-holds` and -`highlight-scope` only with `animated`, and the `diff-*` checks only with -`diff`. `affordances`, `rings`, `legend`, `summary` and `selection` present a -comparison in the renderer's default (first) mode; `phone-overflow` checks every -declared mode. +(`capabilities.comparisonModes`): `neutral-endpoints`, `quiet-endpoints`, +`step-holds` and `highlight-scope` run only with `animated` (a held pane is a +static comparison, with no endpoints), `pane-marks` with `side-by-side` or +`swipe`, and the `diff-*` checks only with `diff`. `affordances`, `rings`, +`legend`, `summary` and `selection` present a comparison in the renderer's +default (first) mode; `phone-overflow` checks every declared mode. Entities are elements with `data-entity-id`; emphasis is measured by comparing painted styles, so the checks need no knowledge of your class names. A check diff --git a/packages/renderers/testing/src/checks/catalog.ts b/packages/renderers/testing/src/checks/catalog.ts index 375f2d3f4..ec978ff9b 100644 --- a/packages/renderers/testing/src/checks/catalog.ts +++ b/packages/renderers/testing/src/checks/catalog.ts @@ -132,7 +132,7 @@ export const checkDescriptions: Record = { 'While a change is emphasized, its entity states its status as text (Added, Removed, Modified, Renamed or Moved), visibly or for assistive technology, never by color alone.', 'quiet-endpoints': "In animated mode, at both endpoints, with the host's default highlighting, no entity shows status text.", 'pane-marks': - "In each held pane of side by side or swipe, with highlighting, the pane marks only its side's changes: Before its removals and changes, After its additions and changes, so nothing in Before is marked added and nothing in After removed (in status words, edge or band). A changed card carries its status the diff's way: its edge all the way round and the band behind its status words (and its tint) in one change hue, or all neutral when it holds changes; never a tinted band on a neutral edge, or a stripe beside the edge for one. Use the kit's `EntityCard` (or a graph card), which draws a pane so. Skipped for a renderer without side-by-side or swipe mode.", + "In each held pane of side by side or swipe, with highlighting, the pane marks only its side's changes: Before its removals and changes, After its additions and changes, so nothing in Before is marked added and nothing in After removed (in status words, edge or band). A changed card (taller than a chip or tag) carries its status the diff's way: its edge all the way round and the band behind its status words (and its tint) in one change hue, or all neutral when it holds changes; never a tinted band on a neutral edge, or a stripe beside the edge for one. Use the kit's `EntityCard` (or a graph card), which draws a pane so. Skipped for a renderer without side-by-side or swipe mode.", 'content-top': "The renderer draws no header of its own (the host shows the title, schema and counts): its first entity, canvas or marked content region (data-projections-content) starts within the stage padding of the frame top (the host's stage-inset, else 12 px, or its stage-inset-top where that is more), at full and phone width. A zoomable canvas (a scroll container marked data-zoom) counts as a whole, since it opens fitted (or at the text floor) and centres what it draws.", 'stage-insets': diff --git a/packages/renderers/testing/src/checks/comparison/panes.ts b/packages/renderers/testing/src/checks/comparison/panes.ts index 2f952a868..54352f5e1 100644 --- a/packages/renderers/testing/src/checks/comparison/panes.ts +++ b/packages/renderers/testing/src/checks/comparison/panes.ts @@ -29,7 +29,8 @@ export const paneChecks: Pick = { `${where}, "${mark.id}" is marked ${foreign}: a pane marks only ${own}, so ${foreign} items are marked only in the other pane.`, ) } - if (mark.band.some(family => !mark.edge.includes(family)) || mark.edge.some(family => !mark.band.includes(family))) { + const disagree = mark.band.some(family => !mark.edge.includes(family)) || mark.edge.some(family => !mark.band.includes(family)) + if (mark.card && disagree) { failures.push( `${where}, "${mark.id}" (${mark.element}) says ${mark.words.join(', ')} with its band ${named(mark.band)} but its edge ${named(mark.edge)}: a changed card carries its status border, band and tint in one hue, as in the diff (the kit's EntityCard and graph cards do), or all neutral when it holds changes.`, ) diff --git a/packages/renderers/testing/src/measure/pane-marks.ts b/packages/renderers/testing/src/measure/pane-marks.ts index 45327c053..6928a21c7 100644 --- a/packages/renderers/testing/src/measure/pane-marks.ts +++ b/packages/renderers/testing/src/measure/pane-marks.ts @@ -8,6 +8,8 @@ const statusWords = /\b(?:Added|Removed|Modified|Renamed|Moved)\b/gu const changeFamilies: ReadonlySet = new Set(['added', 'removed', 'modified', 'moved']) /** How far, in CSS px, an edge's box may lie inside or outside its item's and still be that item's edge. */ const edgeSlack = 4 +/** The tallest a chip, pill or tag is, in CSS px (its status tab included): anything taller is a card. */ +const tallestChip = 48 const isChange = (family: AccentFamily): family is ChangeFamily => changeFamilies.has(family) @@ -21,7 +23,8 @@ const sameBox = (a: DOMRect, b: DOMRect) => Math.abs(a.bottom - b.bottom) <= edgeSlack /** - * The hues an element's own edge is drawn in, all the way round: a border of one hue on all four sides, an inset or + * The hues an element's own edge is drawn in, all the way round: a border of one hue on every side it draws (three at + * least, as a table's row leaves its left edge to its first cell), an inset or * outset shadow with no offset (a ring, as `pk-region` draws), or an SVG stroke. A shadow offset to one side (a stripe * along the leading edge) or one side's border is an accent beside the edge, not the edge. */ @@ -31,12 +34,11 @@ function edgeHues(element: Element, style: CSSStyleDeclaration, hues: Map 0) found.push(familyOf(style.stroke, hues)) return found.filter(family => family !== undefined) } - const sides = ['top', 'right', 'bottom', 'left'].map(side => - style.getPropertyValue(`border-${side}-style`) !== 'none' && px(style.getPropertyValue(`border-${side}-width`)) > 0 - ? familyOf(style.getPropertyValue(`border-${side}-color`), hues) - : undefined, - ) - if (sides[0] !== undefined && sides.every(side => side === sides[0])) found.push(sides[0]) + // The sides it draws: a row in a table may leave one to the cell beside it, as the kit's do. + const sides = ['top', 'right', 'bottom', 'left'] + .filter(side => style.getPropertyValue(`border-${side}-style`) !== 'none' && px(style.getPropertyValue(`border-${side}-width`)) > 0) + .map(side => familyOf(style.getPropertyValue(`border-${side}-color`), hues)) + if (sides.length >= 3 && sides[0] !== undefined && sides.every(side => side === sides[0])) found.push(sides[0]) for (const shadow of style.boxShadow === 'none' ? [] : normalizeColors(style.boxShadow).split(/,(?![^(]*\))/u)) { const color = /rgba?\([^)]*\)|#[0-9a-f]{6,8}\b/iu.exec(shadow)?.[0] ?? '' const [x = 0, y = 0, , spread = 0] = shadow @@ -107,6 +109,7 @@ export function paneMarks(): PaneMark[] { marks.push({ id: unit.getAttribute('data-entity-id') ?? '', element: describe(unit), + card: box.height > tallestChip, words: [...new Set(words)], edge: [...edge], band: [...band], diff --git a/packages/renderers/testing/src/types.ts b/packages/renderers/testing/src/types.ts index c9aa058d5..e53999480 100644 --- a/packages/renderers/testing/src/types.ts +++ b/packages/renderers/testing/src/types.ts @@ -320,6 +320,8 @@ export interface PaneMark { id: string /** The item's element, described. */ element: string + /** Whether it is a card, taller than a chip, pill or tag (which may hang its status in a tab of its own). */ + card: boolean /** The status words it shows (Added, Removed, Modified, Renamed, Moved). */ words: string[] /** The change hues its edge is drawn in. */ From a41e6237e5479274aa9c88cd539b956110b41dc4 Mon Sep 17 00:00:00 2001 From: agorischek <6295280+agorischek@users.noreply.github.com> Date: Sat, 5 Dec 2026 03:40:50 +0000 Subject: [PATCH 4/5] Docs: comparison modes in the renderer guides; specs present held panes Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- docs/reference/renderer-kit.md | 98 +++++++++++++++---- .../browser/agentic-workflows.spec.ts | 3 +- packages/renderers/api/browser/api.spec.ts | 12 ++- 3 files changed, 87 insertions(+), 26 deletions(-) diff --git a/docs/reference/renderer-kit.md b/docs/reference/renderer-kit.md index 0f8f8f29a..7de69e122 100644 --- a/docs/reference/renderer-kit.md +++ b/docs/reference/renderer-kit.md @@ -2430,6 +2430,32 @@ How `categoryPalette` assigns colors beyond its defaults. | `distinct` | `"distinct"?: false \| true` | Choose each free slot to be as far as possible from every color already used (OKLab, in both themes), rather than by its preferred slot: for categories with no conventional color, such as entity kinds, so no two look alike. | | `pinned` | `"pinned"?: ReadonlyMap` | Categories whose color is set (a definition's kind colors), by key: they keep it, and the rest keep clear of it. | +### `Pane` + +```ts +type Pane = "after" | "before" +``` + +One held pane of side by side or swipe (`RendererProps.pane`): the revision it shows. + +### `paneChange` + +```ts +paneChange(change: C, pane: "after" | "before" | undefined): "unchanged" | C +``` + +The change a value or item shows in a held pane (`paneShows`), else unchanged; outside a pane, its own change. + +### `paneShows` + +```ts +paneShows(change: "added" | "modified" | "removed" | "renamed" | "unchanged" | { "renamed"?: false | true | undefined; "status": ChangeStatus; "varied"?: Array | undefined }, pane: Pane): false | true +``` + +Whether a held pane marks a change: each pane marks only the changes on its side. Before marks what was removed, +changed or renamed; After what was added, changed or renamed. Nothing else is marked, and unchanged items are neutral +in both, so a removed item is marked only in Before and an added one only in After. + ### `parseStageCover` ```ts @@ -3300,9 +3326,10 @@ it), rises over the start of the window, then follows the host's highlighting, which is exactly 0 at both endpoints. Earlier steps never pre-tint later changes. Rows no step places use the host's highlighting. A held pane of side by side or swipe (`pane`) is a static comparison, not a -moment of the transition: every change it shows follows the host's -highlighting alike, so Before marks its removals as After marks its -additions. +moment of the transition, so the neutral endpoints of the animation don't +apply to it: every change on its side (`paneShows`) follows the host's +highlighting alike, so Before marks its removals and changes as After marks +its additions and changes, and the other side's changes show none. ### `stepEnds` @@ -4105,7 +4132,8 @@ Chip(__0: ChipProps): Element One small item as a pill: an optional category dot, its label (monospace by default) and trailing content, in a neutral edge. A changed chip is painted in its change's hue (fading with `emphasis`), struck through when removed, and can carry its sign and a status tab; assistive technology hears its change in words. With `id` and `onSelect` -it is a button that selects the item. +it is a button that selects the item. In a held pane it is painted only for its side's changes (`paneShows`), with +no sign and nothing struck through. ### `ChipProps` @@ -4130,7 +4158,7 @@ Props of `Chip`. | `onSelect` | `"onSelect"?: undefined \| { (id: string): void }` | Selects the chip's item (`RendererProps.onSelect`). | | `paint` | `"paint"?: false \| true \| undefined` | Paints the change: the chip's edge and fill in its hue (the default). Turn it off for a chip that arrives or leaves with an item already marked around it, so change colors never nest; its sign and words still say it. | | `selected` | `"selected"?: false \| true \| undefined` | Whether the host has selected the chip's item (`RendererProps.selectedId`). | -| `sign` | `"sign"?: false \| true \| undefined` | Puts the change's sign (`+`, `−`, `~`) before the label, as a diff does. | +| `sign` | `"sign"?: false \| true \| undefined` | Puts the change's sign (`+`, `−`, `~`) before the label, as a diff does; never in a held pane. | | `status` | `"status"?: undefined \| { "renamed"?: false \| true \| undefined; "status": ChangeStatus; "varied"?: Array \| undefined }` | A status tab hanging under the chip (`StatusTab`), for its change in words; keep its room with ``. The chip reserves the tab's width from `status`, so the chip's width doesn't change as the tab fades in or out. Pass `status` to every chip in a comparison at every progress, including the endpoints: either the item's change row or `{status: 'unchanged'}` (which reserves nothing and shows no tab). Passing `status` only while a change is visible makes the chip narrow when the tab disappears. | | `tone` | `"tone"?: "default" \| "flag" \| "quiet" \| undefined` | How much the chip asks for attention apart from its change (`Tone`). | | `unit` | `"unit"?: false \| true \| undefined` | Marks the chip as a ring unit of its own (`data-projections-unit`), for a chip that is an item. By default a selectable chip is a part (`pk-part`) of the unit around it. | @@ -4294,8 +4322,10 @@ EntityCard(__0: EntityCardProps): Element One entity as a card: a unit the host rings on hover, focus and selection, a button that selects it, its name and identifier, and (given `change`) its change status in words, in a footer band across its bottom whose space is always -reserved, as a graph card's is. In the progress modes its edge takes -the change's hue as the step emphasizes it; in diff mode (`mark`) it is filled and edged like any kit region. +reserved, as a graph card's is. A changed card is a change region in every mode, as a graph card is: its edge, fill +and band in its change's hue. In diff mode (`mark`) at the host's highlighting; in a transition as its step +emphasizes it (`emphasis`, 0 at both endpoints); in a held pane at the host's highlighting, only for a change on its +side (`paneShows`: Before marks removals and changes, After additions and changes). ### `EntityCardProps` @@ -4308,7 +4338,7 @@ Props of `EntityCard`: one entity's card, its selection and its change. | Member | Signature | Description | |---|---|---| | `aside` | `"aside"?: ReactNode` | A muted fact at the end of the card's first line (the `meta` role), such as a timeout ("40 min"). | -| `change` | `"change"?: { "renamed"?: false \| true \| undefined; "status": ChangeStatus }` | The row, for its change status: stated in words in the footer, in proportion to `emphasis`. | +| `change` | `"change"?: { "renamed"?: false \| true \| undefined; "status": ChangeStatus }` | The row, for its change status: stated in words in the footer, and its edge and fill in its hue, in proportion to `emphasis` (in a held pane, only for a change on its side). | | `children` | `"children"?: ReactNode` | Relationships and fields, below the name. | | `emphasis` | `"emphasis"?: number` | The host's emphasis for this change (`props.emphasis(row)`): 0 at both endpoints and before its step. | | `holdsChanges` | `"holdsChanges"?: false \| true` | Changes are drawn inside it that no `data-change` marks (a nested renderer's frame): the card is drawn neutral (`pk-holds-changes`), so change colors never nest. | @@ -4331,7 +4361,8 @@ Fact(__0: { "change"?: ChangeClassification; "children"?: ReactNode; "emphasis"? One row of `Facts`: its label, its value and, optionally, a muted note after the value (`meta`: "and 8 run steps"), so a count or a note sits beside a label rather than alone on a line. A row that arrives or leaves as a whole takes -`change`: its label is marked in the change's hue, struck through when it leaves, and said in words. +`change`: its label is marked in the change's hue, struck through when it leaves, and said in words. In a held pane +it is marked only on its side (`paneShows`), and never struck through. ### `Facts` @@ -4474,7 +4505,7 @@ Everything but the renderer props is optional; the defaults draw every entity as | `detail` | `"detail"?: undefined \| { (entity: Entity): string \| undefined }` | A short code identifier drawn in monospace at the right of a card's kind line, such as a package version. When it differs between revisions, the two crossfade with the card's own step; in the diff, a modified card shows `was → now`, or, when only one revision has a detail, strikes it where it went away and marks it new where it appeared. | | `diff` | `"diff": false \| true` | Whether the host presents this comparison in `diff` mode: one static frame showing both subjects, with no progress (`progress` stays 1 and `schedule` is empty). Draw the renderer's own static comparison; `highlighting` is the host's change emphasis for it (1 unless the host turned highlighting off). | | `direction` | `"direction": -1 \| 1` | The host's playback direction (`ProgressPayload.direction`): 1 toward After, -1 back toward Before. Always 1 for an extraction and in diff mode. `schedule` is already ordered for the direction the transition presents. | -| `emphasis` | `"emphasis": EmphasisOf` | A change's emphasis now: 0 until its comparison step begins, then the host's highlighting; in a held pane, the host's highlighting (see `stepEmphasis`). Pass the row ID as the second argument when the object passed has none. | +| `emphasis` | `"emphasis": EmphasisOf` | A change's emphasis now: 0 until its comparison step begins, then the host's highlighting; in a held pane, the host's highlighting for a change on its side and 0 for the other side's (see `stepEmphasis`). Pass the row ID as the second argument when the object passed has none. | | `environment` | `"environment": RendererEnvironment` | The host's current theme, motion preference, locale and pane: `init`'s, or a later `environment`'s. | | `filtered` | `"filtered"?: false \| true \| undefined` | Whether the host has said what it shows (its filter, and with it the scope). Until it does, every item is drawn, provisionally: a canvas that moves between layouts of the scope doesn't move from that one, so the first scope the host chooses is drawn at once rather than pared down to. Undefined where no host filter is wired (treat it as said). | | `focus` | `"focus"?: undefined \| { "ids": ReadonlySet; "label": string }` | Entity rows to bring forward, for example what depends on the selection: other cards and relationships recede. `label` says what is highlighted, for people who don't see the graph, in a strip under it. Passing `focus`, as `undefined` while nothing is focused, keeps that strip from the start, so a focus never refits the graph. | @@ -4492,7 +4523,7 @@ Everything but the renderer props is optional; the defaults draw every entity as | `onSelect` | `"onSelect": { (id: null \| string): void }` | Selects an item, as the person activating it: activating the selected item again clears the selection, as an `aria-pressed` toggle does, and `null` clears it. The shell also clears the selection when the person clicks the renderer's background, and toggles an item when they click its element anywhere outside a control. | | `options` | `"options": RendererOptions` | The host's latest `options`, such as `showRelationships`; empty until it sends any. | | `orientation` | `"orientation"?: "horizontal" \| "vertical"` | The layers' direction: `vertical` (the default) runs top to bottom, `horizontal` left to right. | -| `pane` | `"pane": "after" \| "before" \| undefined` | Set while this frame is one held pane of side by side or swipe (`RendererEnvironment.pane`): it shows only that revision, which the host labels, so leave out narration of the transition such as step captions. | +| `pane` | `"pane": "after" \| "before" \| undefined` | Set while this frame is one held pane of side by side or swipe (`RendererEnvironment.pane`): it shows only that revision, which the host labels, so leave out narration of the transition such as step captions. A pane is a static comparison that marks only its side's changes (`paneShows`); the kit's components read it (`useHeldPane`). | | `progress` | `"progress": number` | 0 (before) to 1 (after); always 1 for an extraction. | | `prose` | `"prose"?: undefined \| { (entity: Entity): false \| true }` | Cards whose label is human language rather than an identifier (for example a summary card), drawn in sans. | | `reducedMotion` | `"reducedMotion": false \| true` | Whether the person prefers reduced motion: present each frame without decorative movement. | @@ -4562,6 +4593,16 @@ Props of `Group`: only `title` and `children` are required. | `title` | `"title": ReactNode` | What the group holds, in a few words or as a code name. | | `titleFont` | `"titleFont"?: "code" \| "text"` | The title's font: `code` for a title that is code (a command, a kind, a path or another identifier), drawn in the monospace font and marked as an identifier; `text` (the default) for a title in human words, in the UI font. | +### `HeldPane` + +```ts +HeldPane(props: ProviderProps<"after" | "before" | undefined>): ReactNode +``` + +The held pane of side by side or swipe this frame shows (`RendererProps.pane`), undefined in the diff, an animated +transition or a single extraction. The kit's change marks read it, so a pane marks only its side's changes, each +value as that side has it, in its change's hue, with no signs and nothing struck through. + ### `Icon` ```ts @@ -4655,7 +4696,8 @@ A grid over two axes, as a table: the axes' names in its corner (`os × compiler edge, and each cell what `cell(row, column)` returns: by default a small mark that something is there, with its whole name (or `present`) as a tooltip and for assistive technology, so a cell never repeats its headings. A cell with nothing (`null`) is vacant, on the kit's hatch. A value, row, column or cell that arrives or leaves is a kit change region, struck -through when it leaves, fading with `emphasis` (or the item's around it). Leave out `columns` for a single list of +through when it leaves, fading with `emphasis` (or the item's around it); a held pane marks only its side's changes +(`paneShows`), struck through nowhere. Leave out `columns` for a single list of cells along `rows`: down the side, or with `across`, in one row under the values. `caption` names the grid when several stand together (one per further dimension). @@ -4831,7 +4873,7 @@ Everything a kit renderer component receives for one host state. | `declareNouns` | `"declareNouns": { (nouns: Readonly> \| undefined \| { (kind: string, collection: "entities" \| "relationships"): SummaryKindCount \| SummaryNoun \| false \| undefined }): void }` | Names the document's kinds in the host's summary bar, replacing `MountOptions.nouns` (see `useSummaryNouns`). The shell counts every kind and posts the summary itself; without nouns, the host words kinds from their names. | | `diff` | `"diff": false \| true` | Whether the host presents this comparison in `diff` mode: one static frame showing both subjects, with no progress (`progress` stays 1 and `schedule` is empty). Draw the renderer's own static comparison; `highlighting` is the host's change emphasis for it (1 unless the host turned highlighting off). | | `direction` | `"direction": -1 \| 1` | The host's playback direction (`ProgressPayload.direction`): 1 toward After, -1 back toward Before. Always 1 for an extraction and in diff mode. `schedule` is already ordered for the direction the transition presents. | -| `emphasis` | `"emphasis": EmphasisOf` | A change's emphasis now: 0 until its comparison step begins, then the host's highlighting; in a held pane, the host's highlighting (see `stepEmphasis`). Pass the row ID as the second argument when the object passed has none. | +| `emphasis` | `"emphasis": EmphasisOf` | A change's emphasis now: 0 until its comparison step begins, then the host's highlighting; in a held pane, the host's highlighting for a change on its side and 0 for the other side's (see `stepEmphasis`). Pass the row ID as the second argument when the object passed has none. | | `environment` | `"environment": RendererEnvironment` | The host's current theme, motion preference, locale and pane: `init`'s, or a later `environment`'s. | | `filtered` | `"filtered"?: false \| true \| undefined` | Whether the host has said what it shows (its filter, and with it the scope). Until it does, every item is drawn, provisionally: a canvas that moves between layouts of the scope doesn't move from that one, so the first scope the host chooses is drawn at once rather than pared down to. Undefined where no host filter is wired (treat it as said). | | `focusRequest` | `"focusRequest": RendererFocus \| undefined` | Where the host wants the opening view (`InitPayload.focus`), or a comparison's changes while the host shows changes only; undefined for the renderer's own choice. The shell scrolls the first focused item of a list into view itself; a renderer that places its own view (`useStageZoom`) frames what it names. | @@ -4844,7 +4886,7 @@ Everything a kit renderer component receives for one host state. | `onOpen` | `"onOpen": { (path: string, line?: number \| undefined): void }` | Ask the host to navigate to source evidence; the host decides. | | `onSelect` | `"onSelect": { (id: null \| string): void }` | Selects an item, as the person activating it: activating the selected item again clears the selection, as an `aria-pressed` toggle does, and `null` clears it. The shell also clears the selection when the person clicks the renderer's background, and toggles an item when they click its element anywhere outside a control. | | `options` | `"options": RendererOptions` | The host's latest `options`, such as `showRelationships`; empty until it sends any. | -| `pane` | `"pane": "after" \| "before" \| undefined` | Set while this frame is one held pane of side by side or swipe (`RendererEnvironment.pane`): it shows only that revision, which the host labels, so leave out narration of the transition such as step captions. | +| `pane` | `"pane": "after" \| "before" \| undefined` | Set while this frame is one held pane of side by side or swipe (`RendererEnvironment.pane`): it shows only that revision, which the host labels, so leave out narration of the transition such as step captions. A pane is a static comparison that marks only its side's changes (`paneShows`); the kit's components read it (`useHeldPane`). | | `progress` | `"progress": number` | 0 (before) to 1 (after); always 1 for an extraction. | | `reducedMotion` | `"reducedMotion": false \| true` | Whether the person prefers reduced motion: present each frame without decorative movement. | | `rendererName` | `"rendererName": string` | Definition renderer name the host matched, for example `graph-horizontal`. | @@ -4976,7 +5018,8 @@ SvgValueChange(__0: { "after": string; "anchor"?: "end" | "middle" | "start"; "b `ValueChange` inside SVG: one text line at `x`, `y` (the baseline) with the old value struck through in the removed hue, an arrow, then the new value in the added hue. Pass identifier attributes (the SDK's -`identifier`) for code values such as versions. +`identifier`) for code values such as versions. A held pane draws only its +side's value, in the modified hue. ### `Swatch` @@ -5155,6 +5198,14 @@ The frame's width and the host window's height, CSS px, as the host last reporte until it has. A content-sized frame lies in its host's scrolling page, so the window's height bounds how tall a stage that pans and zooms should ask to be (see `useFitScale`). +### `useHeldPane` + +```ts +useHeldPane(): "after" | "before" | undefined +``` + +The held pane this frame shows (`HeldPane`), or undefined. + ### `useLegend` ```ts @@ -5371,7 +5422,7 @@ and set it. Spread them: ` { +test("side-by-side panes list each revision; with highlighting each marks its own side's changes in their hue, with no sign", async ({ + page, +}) => { for (const [progress, document] of [ [0, before], [1, after], @@ -205,9 +207,9 @@ test('side-by-side panes list each revision; with highlighting each marks its ow highlighting: 1, }) expect(await rows(start.frame.locator('.api-view'))).toEqual([ - {id: 'hello', status: ['Modified'], lines: ['removed:hello(): string'], runs: []}, + {id: 'hello', status: ['Modified'], lines: ['modified:hello(): string'], runs: []}, {id: 'legacy', status: ['Removed'], lines: ['removed:legacy(): void'], runs: []}, - {id: 'parse', status: ['Modified'], lines: ['removed:parse(text: string): Node'], runs: []}, + {id: 'parse', status: ['Modified'], lines: ['modified:parse(text: string): Node'], runs: []}, {id: 'stable', status: [], lines: ['plain:stable(): void'], runs: []}, ]) const end = await openRenderer(page, { @@ -220,7 +222,9 @@ test('side-by-side panes list each revision; with highlighting each marks its ow highlighting: 1, }) const hello = (await rows(end.frame.locator('.api-view'))).find(row => row.id === 'hello') - expect(hello).toEqual({id: 'hello', status: ['Modified'], lines: ['added:hello(name: string): string'], runs: ['mark:name: string']}) + expect(hello).toEqual({id: 'hello', status: ['Modified'], lines: ['modified:hello(name: string): string'], runs: ['mark:name: string']}) + // A pane draws no sign in its gutter. + await expect(end.frame.locator('.api-line-mark')).toHaveCount(0) }) test('selecting a declaration reports it and reflects the host selection', async ({page}) => { From e9d8f417df256b8fcf1723bd48fc9706f4b01da0 Mon Sep 17 00:00:00 2001 From: agorischek <6295280+agorischek@users.noreply.github.com> Date: Sat, 5 Dec 2026 03:53:06 +0000 Subject: [PATCH 5/5] Changelog: side-by-side vocabulary for renderer authors (#417) Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- changelog.d/417-behaviour-changes.md | 5 +++++ changelog.d/417.md | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 changelog.d/417-behaviour-changes.md create mode 100644 changelog.d/417.md diff --git a/changelog.d/417-behaviour-changes.md b/changelog.d/417-behaviour-changes.md new file mode 100644 index 000000000..cf7da5e2c --- /dev/null +++ b/changelog.d/417-behaviour-changes.md @@ -0,0 +1,5 @@ +--- +section: behaviour-changes +--- + +- **`neutral-endpoints` and `quiet-endpoints` run only in animated mode, and a new `pane-marks` check holds side-by-side panes** (#417). A renderer without animated mode now skips both endpoint checks, since a held pane is a static comparison. `status-text` expects Before to name its removals and changes, and After its additions and changes; before, Before was only expected to name removals. The new `pane-marks` check loads each held pane with highlighting. It fails when Before marks something added or After something removed, or when a changed card's border and the band behind its status words aren't in the same hue, such as a tinted band on a neutral border. A custom renderer that draws its own cards can fail it. The kit's `EntityCard` and graph cards pass. diff --git a/changelog.d/417.md b/changelog.d/417.md new file mode 100644 index 000000000..8d1dfdb93 --- /dev/null +++ b/changelog.d/417.md @@ -0,0 +1,5 @@ +--- +section: renderer-authors +--- + +- **A side-by-side or swipe pane marks only its side's changes, with the diff's vocabulary** (#417). Before marks removed and modified items, After added and modified ones, and unchanged items are neutral in both. `props.emphasis(row)` in a held pane is the host's highlighting for a change on its side and 0 for the other side's (`paneShows`, `paneChange`). The kit's components read the held pane (`useHeldPane`, and `data-pane` on the `.pk` root): `EntityCard` draws a changed card as a change region in every mode, with its border, tint and band in its change's hue rather than a leading stripe; and `ValueMark`, `ValueList`, `Fact`, `ValueChange`, `ValueText`, `SvgValueChange`, `Chip` and `MatrixGrid` show only the pane's own value in its change's hue (a modified value in the modified hue in both panes), with no sign and no strikethrough, whatever `sign` says. Pass them the same `change`, `sign` and `emphasis` in every mode, and drop special cases such as `sign={side === 'diff'}` or tinting a pane only while emphasized. See [Comparison modes](docs/guides/change-emphasis.md#comparison-modes).