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 && (
- {toneMarks[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 ? (
-
+
{children}
) : (
@@ -108,7 +118,9 @@ export interface ValueItem {
* A list of values whose items may arrive, leave or change, as text: comma-separated on a line by default, or one per
* line (`layout="stack"`). An arrived item is in the added hue after a `+`, a removed one struck through in the removed
* hue after a `−`, and a modified one its old value struck through, an arrow, then its new one; each fades with
- * `emphasis` (left out, the `--emphasis` of the item around it) and is said in words. No item is boxed: for a few
+ * `emphasis` (left out, the `--emphasis` of the item around it) and is said in words. A held pane shows each item as
+ * its side has it (a modified item's old value in Before, its new one in After), marks only its side's changes
+ * (`paneShows`) in their hue, and draws no signs and nothing struck through. No item is boxed: for a few
* items a reader picks out or selects, such as tools or services, `display="chips"` draws them as chips instead
* (`ChangePills`), keeping each item's change, sign, previous value and code font.
*/
@@ -146,6 +158,9 @@ export function ValueList({
}) {
// Where nothing can be selected, the items are text, not buttons (a chip sees to its own).
const selectable = useSelectable()
+ const pane = useHeldPane()
+ // A held pane shows each item as its side has it: a modified item's old value in Before, its new one in After.
+ const own = (item: ValueItem) => (pane === 'before' && item.change === 'modified' && item.was !== undefined ? item.was : item.label)
if (display === 'chips') {
// Chips wrap in a row, so `layout` and `separator` don't apply; everything else does.
return (
@@ -157,10 +172,10 @@ export function ValueList({
) : (
- item.label
+ own(item)
)
}
font={code ? 'code' : 'text'}
@@ -184,20 +199,20 @@ export function ValueList({
style={emphasisStyle(emphasis)}
>
{items.map(item => {
- const change = item.change ?? 'unchanged'
+ const change = paneChange(item.change ?? 'unchanged', pane)
const id = item.entityId
const value =
- change === 'modified' && item.was !== undefined ? (
+ change === 'modified' && item.was !== undefined && !pane ? (
// Said in words, as a marked item is: the status, then what it was and is.
<>
{statusLabels.modified}:
>
) : change === 'unchanged' ? (
- text(item.label)
+ text(own(item))
) : (
- {text(item.label)}
+ {text(own(item))}
)
return (
@@ -231,7 +246,8 @@ export function ValueList({
/**
* One value marked with its own change, inline, as `ValueList` marks its items: its change's hue on the text, its sign
* before it (`sign`), struck through when it leaves, said in words, fading with `emphasis` (or the item's around it).
- * Unchanged, it is the value alone.
+ * Unchanged, it is the value alone. In a held pane it is marked only on its side (`paneShows`), in its hue alone: no
+ * sign and nothing struck through, whatever `sign` says.
*/
export function ValueMark({
change = 'unchanged',
@@ -244,14 +260,16 @@ export function ValueMark({
emphasis?: number
children: ReactNode
}) {
- if (change === 'unchanged') return <>{children}>
- const Tag = change === 'removed' ? 'del' : change === 'added' ? 'ins' : 'span'
+ const pane = useHeldPane()
+ const shown = paneChange(change, pane)
+ if (shown === 'unchanged') return <>{children}>
+ const Tag = markTag(shown, pane)
return (
-
- {statusLabels[change]}:
- {sign && signs[change] && (
+
+ {statusLabels[shown]}:
+ {sign && !pane && signs[shown] && (
- {signs[change]}
+ {signs[shown]}
)}
{children}
diff --git a/packages/renderers/kit/src/react/layout-components.tsx b/packages/renderers/kit/src/react/layout-components.tsx
index 8332687dc..220a60af2 100644
--- a/packages/renderers/kit/src/react/layout-components.tsx
+++ b/packages/renderers/kit/src/react/layout-components.tsx
@@ -11,9 +11,9 @@ import {token, type SpaceStep, type IconName} from '@githubnext/projections-rend
import {ChangeFooter, ChangeStatus, Identifier, NameLine} from './components.js'
import {changeMark} from '../diff/model.js'
import {Icon} from './icons.js'
-import {useSelectable} from './shell/frame.js'
+import {useHeldPane, useSelectable} from './shell/frame.js'
import {useSelectControl} from './select-control.js'
-import {mixedChange, type ChangeClassification} from '../emphasis.js'
+import {isChanged, mixedChange, paneShows, type ChangeClassification} from '../emphasis.js'
interface StatusChange {
status: Status
@@ -186,7 +186,10 @@ export interface EntityCardProps {
selected: boolean
/** Selects the entity (the renderer's `onSelect`) with `id`, when the card's button is activated. */
onSelect: (id: string) => void
- /** The row, for its change status: stated in words in the footer, in proportion to `emphasis`. */
+ /**
+ * 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).
+ */
change?: StatusChange
/** The host's emphasis for this change (`props.emphasis(row)`): 0 at both endpoints and before its step. */
emphasis?: number
@@ -206,8 +209,10 @@ export interface EntityCardProps {
/**
* 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).
*/
export function EntityCard({
id,
@@ -227,6 +232,9 @@ export function EntityCard({
children,
}: EntityCardProps) {
const selectControl = useSelectControl()
+ const pane = useHeldPane()
+ // The change the card marks: the diff's `mark`; else its change, in a held pane only on its side.
+ const region = mark ?? (change && isChanged(change) && (pane === undefined || paneShows(change, pane)) ? change : undefined)
const style = {'--emphasis': emphasis, ...(presence < 1 ? {opacity: presence, visibility: presence > 0 ? 'visible' : 'hidden'} : {})}
const name = (
@@ -246,14 +254,16 @@ export function EntityCard({
change && 'pk-frame',
// Renamed and changed: no one hue is right, so the card is neutral and each status word takes its own.
change && mixedChange(change) && 'pk-mixed-change',
- mark !== undefined && 'pk-region',
+ region !== undefined && 'pk-region',
selected && 'selected',
holdsChanges && 'pk-holds-changes',
)}
data-entity-id={id}
data-projections-unit=""
- data-status={mark === undefined && change && emphasis > 0 ? (change.renamed ? 'renamed' : change.status) : undefined}
- {...(mark !== undefined ? changeMark(mark) : {})}
+ data-status={
+ mark === undefined && change && region !== undefined && emphasis > 0 ? (change.renamed ? 'renamed' : change.status) : undefined
+ }
+ {...(region !== undefined ? changeMark(region) : {})}
style={style as CSSProperties}
>