Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog.d/adopt-typography.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
section: renderers
---

- **Agentic workflows and GitHub Actions switch to plain text**. Agentic workflow sections list entries one per line with added, removed, and changed items marked inline instead of as pills; changes too long for one old → new line split into separate removed and added lines. The GitHub Actions renderer uses the kit's header slots, `Facts`, `ValueList`, and `Slot` for cards, and `MatrixGrid` for its matrix. The custom renderer starter shows a changed field as text instead of two pills.
13 changes: 7 additions & 6 deletions docs/guides/renderer-kit-type.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@ and `Field` are the same list with `labelFont="code"` for raw data keys.
`separator="dot"`) and wrapping between items, or stacked one per line
(`layout="stack"`). Added items appear in the added hue after `+`, removed items
are struck through in the removed hue after `−`, and changed items show the old
value (`was`) struck through, an arrow, and the new value. Marks fade with
`emphasis` (inheriting the surrounding item's when omitted) and are announced in
words. Items are unboxed by default; `display="chips"` renders them as chips
(`ChangePills`) for small or selectable sets. `ValueMark` marks one value the
same way, and `ValueChange variant="text"` renders a single value change without
pills.
value (`was`) struck through, an arrow, and the new value. The hue and
strikethrough fade with `emphasis`, which inherits from the surrounding item
when omitted. At zero emphasis, the sign stays visible in a muted color, as it
does on a chip. Marks are announced in words to assistive technology. Items are
unboxed by default; `display="chips"` renders them as chips (`ChangePills`) for
small or selectable sets. `ValueMark` marks one value the same way, and
`ValueChange variant="text"` renders a single value change without pills.

## Quiet text pieces

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/templates/renderer/src/diff.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export function DiffView(props: RendererProps) {
<Field key={key} name={key}>
{field ? (
<ValueChange
layout="inline"
variant="text"
before={field.before === undefined ? undefined : formatValue(field.before)}
after={field.after === undefined ? undefined : formatValue(field.after)}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,16 @@ test('the diff draws each workflow once in its group, with each section’s dire
const card = renderer.frame.locator(`[data-entity-id="${bot}"]`)
const section = (id: string) => card.locator(`.aw-section[data-section="${id}"]`)
await expect(section('loads').locator('.aw-direction')).toHaveText('Widened')
await expect(section('loads').locator('.pk-chip[data-change="removed"]')).toContainText('skills/check-links')
await expect(section('repos').locator('.pk-chip[data-change="added"]')).toHaveText(/octo-org\/docs-site/u)
// A limit that moves reads old → new: in one pill when short, as the old pill leaving and the new arriving when not.
await expect(section('loads').locator('.pk-value-mark[data-change="removed"]')).toContainText('skills/check-links')
await expect(section('repos').locator('.pk-value-mark[data-change="added"]')).toHaveText(/octo-org\/docs-site/u)
// Entries are text marked inline, each with its sign, not chips.
await expect(section('repos').locator('.pk-value-mark[data-change="added"] .pk-value-sign')).toHaveText('+')
await expect(card.locator('.pk-chip')).toHaveCount(0)
// A limit that moves reads old → new: on one line when short, as the old value leaving and the new arriving when not.
const examples = renderer.frame.locator('[data-entity-id="workflow:.github/workflows/docs-bot-examples.md"]')
await expect(examples.locator('.aw-section[data-section="budgets"] .pk-value-change')).toHaveText(/60 min.*30 min/u)
await expect(section('budgets').locator('.pk-chip[data-change="removed"]')).toHaveText(/2,000/u)
await expect(section('budgets').locator('.pk-chip[data-change="added"]')).toHaveText(/5,000/u)
await expect(section('budgets').locator('.pk-value-mark[data-change="removed"]')).toHaveText(/2,000/u)
await expect(section('budgets').locator('.pk-value-mark[data-change="added"]')).toHaveText(/5,000/u)
// A lock state that changes reads old → new on the card's meta line.
const lock = renderer.frame.locator(`[data-entity-id="${triage}"] .aw-meta .pk-value-change`)
await expect(lock.locator('[data-change="removed"] .aw-lock')).toHaveText('Lock current')
Expand All @@ -106,8 +109,8 @@ test('side by side, each pane draws its own revision without the diff’s signs,
const renderer = await open(page, {comparison, mode: 'after'})
await layout(renderer)
const card = renderer.frame.locator(`[data-entity-id="${bot}"]`)
await expect(card.locator('.aw-section[data-section="loads"] .pk-chip')).not.toContainText(['check-links'])
await expect(card.locator('.pk-chip-sign').first()).toBeHidden()
await expect(card.locator('.aw-section[data-section="loads"] .pk-value-item')).not.toContainText(['check-links'])
await expect(card.locator('.pk-value-sign')).toHaveCount(0)
await renderer.seek(1, {highlighting: 0})
await expect(card.locator('.aw-direction')).toHaveCount(0)
})
Expand All @@ -118,7 +121,7 @@ test('the default comparator still marks every entry, without directions', async
await expect.poll(() => facts(renderer)).toEqual(['1 lock file out of date'])
const card = renderer.frame.locator(`[data-entity-id="${bot}"]`)
await expect(card.locator('.aw-direction')).toHaveCount(0)
await expect(card.locator('.pk-chip[data-change="added"]').first()).toBeVisible()
await expect(card.locator('.pk-value-mark[data-change="added"]').first()).toBeVisible()
})

test('the matrix marks capabilities that arrive and leave, and selects a workflow from its row', async ({page}) => {
Expand Down
33 changes: 18 additions & 15 deletions packages/renderers/agentic-workflows/src/card.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {classifyChange, isChanged} from '@githubnext/projections-renderer-kit'
import {ChangePills, EntityCard, Icon, Prose, ValueChange, type PillItem} from '@githubnext/projections-renderer-kit/react'
import {EntityCard, Icon, Prose, ValueChange, ValueList, type ValueItem} from '@githubnext/projections-renderer-kit/react'
import type {ReactNode} from 'react'
import {dataOf} from './sections.js'
import {asText, facts, lockText} from './facts.js'
Expand Down Expand Up @@ -35,34 +35,32 @@ function Directions({directions, strength}: {directions: readonly Direction[]; s
)
}

/** An entry's text as one run, so its words and code spans wrap together inside a pill. */
/** An entry's text as one run, so its words and code spans wrap together. */
/** The longest old and new text, together, that reads as one old → new line; longer ones read as two lines. */
const inlineChange = 48

const Words = ({children}: {children: string}) => (
<span className="aw-words">
<Prose>{children}</Prose>
</span>
)

/** The longest old and new text, together, that reads as one old → new pill; longer ones read as two pills. */
const inlineChange = 48

/**
* An entry as pills. In the diff, arriving or leaving entries take the pill's sign and hue, and one changed in place
* reads old → new, or, when that is too long for a line, as the old pill leaving and the new one arriving: the same
* pills at every emphasis, whose hue follows it. A side-by-side pane draws its own revision's entries, tinted while
* emphasized, one changed in place in the pane's hue (its pills' signs are hidden, so emphasis never moves anything).
* 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.
*/
function pills(entry: Entry, side: Side, marked: boolean): PillItem[] {
function items(entry: Entry, side: Side, marked: boolean): ValueItem[] {
const diff = side === 'diff'
if (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 [
{key: `${entry.key}|was`, label: <Words>{entry.was}</Words>, change: 'removed'},
{key: entry.key, label: <Words>{entry.text}</Words>, change: 'added'},
]
}
return [
{key: entry.key, label: <ValueChange layout="inline" before={<Words>{entry.was}</Words>} after={<Words>{entry.text}</Words>} />},
]
return [{key: entry.key, label: <Words>{entry.text}</Words>, was: <Words>{entry.was}</Words>, change: 'modified'}]
}
const mark = entry.mark === 'modified' && !diff ? (side === 'before' ? 'removed' : 'added') : entry.mark
const change = (diff || marked) && (mark === 'added' || mark === 'removed') ? mark : 'unchanged'
Expand All @@ -82,7 +80,12 @@ function SectionRow({section, strength, frame}: {section: Section; strength: num
</dt>
<dd className="aw-section-body">
{shown.length ? (
<ChangePills items={shown.flatMap(entry => pills(entry, frame.side, strength > 0.01))} label={section.spec.title} />
<ValueList
Comment thread
agorischek marked this conversation as resolved.
Resolved
items={shown.flatMap(entry => items(entry, frame.side, strength > 0.01))}
label={section.spec.title}
layout="stack"
sign={frame.side === 'diff'}
/>
) : (
<span className="aw-muted">{section.spec.empty}</span>
)}
Expand All @@ -93,7 +96,7 @@ function SectionRow({section, strength, frame}: {section: Section; strength: num

/** One fact of the meta line: in the diff, a fact that changed reads old → new. */
function Fact({was, now}: {was: ReactNode; now: ReactNode}) {
return was === undefined ? <>{now}</> : <ValueChange layout="inline" before={was} after={now} />
return was === undefined ? <>{now}</> : <ValueChange variant="text" before={was} after={now} />
}

/**
Expand Down
5 changes: 1 addition & 4 deletions packages/renderers/agentic-workflows/src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@
color: var(--muted);
}
/* A side-by-side pane tints the entries that differ from the other revision, without the diff's signs. */
.aw-view:not([data-side='diff']) .pk-chip-sign {
display: none;
}
/* An entry's words and code spans wrap as one run inside its pill. */
/* An entry's words and code spans wrap as one run. */
.aw-words {
display: inline;
min-width: 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ test('one revision draws the start, every job and the matrix as a grid of named
const read = await layout(renderer)
expect(read.cards.map(card => card.id).toSorted()).toEqual(['job:analyze', 'job:build', 'trigger:on'])
expect(read.arrows).toBe(2)
const runs = renderer.frame.locator('[data-entity-id="job:build"] .gha-run')
const runs = renderer.frame.locator('[data-entity-id="job:build"] .pk-matrix-cell')
await expect(runs).toHaveCount(6)
await expect(runs.first()).toHaveAttribute('title', 'Build on windows-latest for 10.0 TransparentCompiler')
await expect(renderer.frame.locator('[data-entity-id="trigger:on"]')).toContainText('nightly')
Expand All @@ -74,17 +74,17 @@ test('the diff reads a matrix losing a dimension’s values as columns leaving,
const renderer = await open(page, fixture('matrix/before'), fixture('matrix/after'), 'diff')
await layout(renderer)
const build = renderer.frame.locator('[data-entity-id="job:build"]')
await expect(build.locator('thead .gha-axis-value[data-change="removed"]')).toHaveCount(4)
await expect(build.locator('.gha-run[data-change="removed"]')).toHaveCount(12)
await expect(build.locator('.gha-run:not([data-change])')).toHaveCount(6)
await expect(build.locator('thead .pk-matrix-value[data-change="removed"]')).toHaveCount(4)
await expect(build.locator('.pk-matrix-cell[data-change="removed"]')).toHaveCount(12)
await expect(build.locator('.pk-matrix-cell:not([data-change])')).toHaveCount(6)
const outline = await build
.locator('.gha-run[data-change="removed"]')
.locator('.pk-matrix-cell[data-change="removed"]')
.first()
.evaluate(cell => getComputedStyle(cell).outlineStyle)
expect(outline).toBe('dashed')
// Only removal is dashed: what stays, and an excluded gap, never is.
const kept = await build
.locator('.gha-run:not([data-change])')
.locator('.pk-matrix-cell:not([data-change])')
.first()
.evaluate(cell => getComputedStyle(cell).outlineStyle)
expect(kept).not.toBe('dashed')
Expand All @@ -96,7 +96,7 @@ test('a pipeline’s needs are arrows, and its diff marks the jobs and needs tha
expect(read.cards).toHaveLength(10)
await expect(renderer.frame.locator('[data-entity-id="job:sign"][data-change="added"]')).toHaveCount(1)
await expect(renderer.frame.locator('.gha-arrow[data-change="removed"]')).toHaveCount(2)
await expect(renderer.frame.locator('[data-entity-id="job:test"] .gha-vacant')).toHaveCount(1)
await expect(renderer.frame.locator('[data-entity-id="job:test"] .pk-matrix-cell[data-vacant]')).toHaveCount(1)
await expect(renderer.frame.locator('[data-entity-id="job:build"] .gha-expression')).toContainText('fromJSON')
})

Expand Down
31 changes: 9 additions & 22 deletions packages/renderers/github-actions/src/header.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,13 @@
// A card's header, by role: its kind above, its name as the title, then a muted line of what sums it up.
// A card's subtitle: what sums it up, each part after a middot, for the kit card's `subtitle` slot.
import type {ReactNode} from 'react'

/** The card's label: the kind (muted, small) above the title, as the graph's cards draw kind over name. */
export function Title({kind, children}: {kind: string; children: ReactNode}) {
return (
<>
<span className="gha-kind">{kind}</span>
<span className="gha-title">{children}</span>
</>
)
}

/** What sums the card up, under its title, each part after a middot: `6 runs · fail-fast off · times out after 40 min`. */
export function Subtitle({parts}: {parts: readonly {key: string; node: ReactNode}[]}) {
if (!parts.length) return null
return (
<p className="gha-subtitle">
{parts.map(part => (
<span key={part.key} className="gha-subtitle-part">
{part.node}
</span>
))}
</p>
)
export function subtitle(parts: readonly {key: string; node: ReactNode}[]): ReactNode {
if (!parts.length) return undefined
return parts.map((part, index) => (
<span key={part.key}>
{index > 0 && ' · '}
{part.node}
</span>
))
}
17 changes: 9 additions & 8 deletions packages/renderers/github-actions/src/job.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// its condition, environment, container and services), then its matrix's runs.
import type {ReactNode} from 'react'
import {classifyChange, isChanged} from '@githubnext/projections-renderer-kit'
import {EntityCard} from '@githubnext/projections-renderer-kit/react'
import {EntityCard, Facts as FactList} from '@githubnext/projections-renderer-kit/react'
import type {Entity} from '@githubnext/projections-schemas'
import {identifier, type EntityChange} from '@githubnext/projections-renderer-sdk/presentation'
import {entries, hasExpression, jobData, revision, shortRef, type JobData} from './model.js'
Expand All @@ -12,7 +12,7 @@ import {runnerKey} from './runs.js'
import {Row, Single, Values, type Frame} from './values.js'
import {Spelled, Template} from './text.js'
import {Runs} from './matrix.js'
import {Subtitle, Title} from './header.js'
import {subtitle} from './header.js'
import {MatrixFacts, plural, summary} from './summary-line.js'

interface Item {
Expand Down Expand Up @@ -83,7 +83,7 @@ function Steps({before, after, frame, strength}: {before: JobData; after: JobDat
const words = (count: number) => (count > 0 ? `${items.length ? 'and ' : ''}${plural(count, 'run step', 'run steps')}` : undefined)
return (
<Row title="Steps">
{items.length > 0 && <Values items={items} frame={frame} strength={strength} render={action} />}
{items.length > 0 && <Values items={items} frame={frame} strength={strength} render={action} label="Steps" />}
{counts && (
<span className="gha-note">
<Single before={words(was)} after={words(is)} frame={frame} strength={strength} render={text => text} />
Expand Down Expand Up @@ -112,7 +112,7 @@ function Facts({
const items = entries(read(before), read(after), frame.side)
return items.length ? (
<Row key={title} title={title}>
<Values items={items} frame={frame} strength={strength} {...(render ? {render} : {})} />
<Values items={items} frame={frame} strength={strength} label={title} {...(render ? {render} : {})} />
</Row>
) : null
}
Expand All @@ -125,7 +125,7 @@ function Facts({
) : null
}
return (
<dl className="gha-facts">
<FactList className="gha-facts" label="Job facts">
{single('Calls', job => job.uses, spelled)}
{list('Runs on', runnerItems, runner)}
<Steps before={before} after={after} frame={frame} strength={strength} />
Expand All @@ -137,7 +137,7 @@ function Facts({
{single('Environment', job => job.environment, spelled)}
{single('Container', job => job.container, spelled)}
{list('Services', job => job.services.map(name => ({key: name, text: name})))}
</dl>
</FactList>
)
}

Expand Down Expand Up @@ -177,7 +177,9 @@ export function JobCard({row, frame}: {row: EntityChange<Entity>; frame: Frame})
return (
<EntityCard
id={row.id}
label={<Title kind={kind(shown)}>{name}</Title>}
kind={kind(shown)}
label={name}
subtitle={subtitle(summary(view, before, after, frame, marked))}
{...(entity.label !== key ? {identifier: key} : {})}
selected={frame.props.selectedId === row.id}
onSelect={frame.props.onSelect}
Expand All @@ -188,7 +190,6 @@ export function JobCard({row, frame}: {row: EntityChange<Entity>; frame: Frame})
// A modified job says what changed inside it; while it shows, the card stays neutral so change colors never nest.
holdsChanges={changed && row.status === 'modified' && (frame.side === 'diff' || strength > 0.01)}
>
<Subtitle parts={summary(view, before, after, frame, marked)} />
<Facts before={before} after={after} view={view} frame={frame} strength={marked} />
{view?.kind === 'grid' && <Runs view={view} frame={frame} strength={marked} job={key} />}
</EntityCard>
Expand Down
Loading