Skip to content
Open
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: 3 additions & 2 deletions docs/agents/create-projection.md
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,8 @@ is its framework-free half, `/kit/react` its React components and hooks, and
`/kit/react.css` their styles. Use it rather than your own markup and CSS: the
kit already meets the checks the host holds every renderer to. The starter has
no stylesheet: compose views from the kit's components (`ContentView`, `Group`,
`CardGrid`, `EntityCard`, `Fields`, `Stack`, `Inline`, `Text`) and their props,
`CardGrid`, `EntityCard`, `Fields`, `Stack`, `Inline`, `Text`, `Chip`, `Chips`)
and their props,
and for an inline style they don't cover use `token` (`token.space(2)`). For
items with comparable properties (a row per item, a column per property), use
the kit's `DataTable` rather than hand-built table markup: sortable headings
Expand Down Expand Up @@ -661,7 +662,7 @@ them in the kit's shell, along with that module's `options` (`nouns`, `facts`,
- Accent and focus colors are only for focus and selection; change colors only
for change status. For domain meaning that isn't a change (a tool that only
reads, a privileged write), use the kit's `tone` (`quiet` or `flag`) on
`Text` and `DataTable` rows, or `toneAttributes`, rather than a change color,
`Text`, `Chip` and `DataTable` rows, or `toneAttributes`, rather than a change color,
a dashed edge or opacity. No horizontal scrolling at 390 px. No network: the
sandbox blocks it, so bundle every asset.
- Never nest change colors: only the innermost changed elements are colored. A
Expand Down
42 changes: 40 additions & 2 deletions docs/guides/renderer-kit-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,8 @@ for domain meaning that isn't a change between revisions:
removed item's text stays muted).
- `default` is everything else, and adds nothing.

`Text` and `DataTable` (`tone={item => …}`, from the version a row shows) take a
`tone`. Anything else spreads `toneAttributes(tone)` (from
`Text`, `Chip` and `DataTable` (`tone={item => …}`, from the version a row
shows) take a `tone`. Anything else spreads `toneAttributes(tone)` (from
`@githubnext/projections/kit`), which sets `data-projections-tone` on an HTML
element or SVG text. A tone stays neutral: it never uses a change hue, a dashed
edge, or opacity, so it never reads as added, removed, or modified. Change
Expand All @@ -335,6 +335,44 @@ its own colors inside a toned item.
A table cell carries the tone of each version it lays out, so a column's
reserved width holds when a row's tone changes between revisions.

## Chips

A chip is one small item as a pill: a tool, a binary, a tag. `Chip` draws an
optional category `dot` (a CSS color, such as a palette's color for the item's
category), its `label` (monospace as an identifier by default; `font="text"` for
words), trailing content as its children (a count, a note), and a
[tone](#tones). `Chips` lays chips out as a wrapping list (`label` names it).

- **Change.** `change` is the chip's own change (`added`, `removed`, `modified`,
`renamed`). A changed chip is painted in its hue, a removed one struck through
and muted, all fading with `emphasis` (or, left out, the `--emphasis` of the
item around it), so a chip at an endpoint reads plain. Assistive technology
hears the change in words. `sign` adds the diff's `+`, `−` or `~` before the
label. Set `paint={false}` 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.
- **Status tab.** `status` hangs a `StatusTab` of that change under the chip,
fading with `emphasis`. The chip reserves the tab's width at every frame, so
it is never narrower than its tab and never changes width; put such chips in
`<Chips tabs>`, which keeps the tab's room under every line.
- **Selection.** With `id` and `onSelect` a chip is a button that selects the
item. It is a part (`pk-part`) of the unit around it, or, with `unit`, a ring
unit of its own.

```tsx
<Chips label="Tools" tabs>
{tools.map(tool => (
<Chip key={tool.id} id={tool.id} onSelect={props.onSelect} label={tool.name} dot={kindColor(tool.kind)}
change={classifyChange(tool)} status={tool} emphasis={props.emphasis(tool)} tone={tool.readOnly ? 'quiet' : 'default'}>
{tool.calls}
</Chip>
))}
</Chips>
```

`ChangePills` is a `Chips` list of signed chips for a list whose items arrive,
leave or change.

## Data tables

When your entities share comparable properties, reach for `DataTable` instead of
Expand Down
6 changes: 3 additions & 3 deletions docs/guides/renderer-kit.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,9 @@ Building a solid diff mode takes seven steps:
arrow) the new value in an added pill, read to assistive tech as "was …,
now …". `SvgValueChange` provides the SVG single-line equivalent
(`pk-svg-was`, `pk-svg-arrow`, `pk-svg-now`).
- `ChangePills({items, label, onSelect?, selectedId?})` renders added and
removed list items as `+` / `−` pills with worded changes alongside plain
unchanged items for context. Pills with an `entityId` are selectable parts.
- `ChangePills({items, label, onSelect?, selectedId?})` renders changed list
items as `+` / `−` / `~` chips (`Chip`), worded, beside plain unchanged
ones. Pills with an `entityId` are selectable parts.
- `fieldChanges(before, after, {fields})` and
`fieldLines(row, {fields, exclude, object})` extract differing fields
(`formatValue` formats values as extracted; `sameValue` compares
Expand Down
56 changes: 51 additions & 5 deletions docs/reference/renderer-kit.md
Original file line number Diff line number Diff line change
Expand Up @@ -3767,10 +3767,9 @@ endpoints and with highlighting off.
ChangePills(__0: { "className"?: string; "items": Array<PillItem>; "label": string; "onSelect"?: undefined | { (id: string): void }; "selectedId"?: null | string | undefined }): Element
```

A list whose items arrive and leave, as pills: added ones with `+` in the
added hue, removed ones with `−` struck through in the removed hue, and
unchanged ones plain, for context. Each says its change to assistive
technology. Pills with an `entityId` are buttons that select it.
A list whose items arrive, leave or change, as chips (`Chip`): added ones with `+` in the added hue, removed ones
with `−` struck through in the removed hue, modified ones with `~` in the modified hue, and unchanged ones plain, for
context. Each says its change to assistive technology. Pills with an `entityId` are buttons that select it.

### `ChangeStatus`

Expand All @@ -3782,6 +3781,53 @@ A change-status cell of fixed width, for table-like rows that keep their
status in a column: reserved on every row, filled while the change is
emphasized. `width` defaults to room for one part (`~ Modified`).

### `Chip`

```ts
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.

### `ChipProps`

```ts
interface ChipProps
```

Props of `Chip`.

| Member | Signature | Description |
|---|---|---|
| `change` | `"change"?: "added" \| "modified" \| "removed" \| "renamed" \| "unchanged" \| undefined` | The chip's own change. Unchanged (the default) draws it plain. |
| `children` | `"children"?: Iterable<ReactNode, any, any> \| Promise<Iterable<ReactNode, any, any> \| ReactElement<unknown, string \| { (props: any): Iterable<ReactNode, any, any> \| Promise \| Promise<ReactNode> \| ReactElement<unknown, recursive> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined } \| { new (props: any, context: any): Component<any, any, any> }> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined> \| ReactElement<unknown, string \| { (props: any): Iterable<ReactNode, any, any> \| Promise<Iterable<ReactNode, any, any> \| ReactElement<unknown, recursive> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined> \| Promise<ReactNode> \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined } \| { new (props: any, context: any): Component<any, any, any> }> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined` | What follows the label: a count, a note. |
| `className` | `"className"?: string \| undefined` | More classes on the chip. |
| `description` | `"description"?: string \| undefined` | Extra words for assistive technology, after the label. |
| `dot` | `"dot"?: string \| undefined` | A category's color (a CSS color, such as a palette's color for the item's category), as a dot before the label. |
| `emphasis` | `"emphasis"?: number \| undefined` | How strongly the change is shown (`RendererProps.emphasis`), 0 to 1: the hue and the status tab fade with it. Left out, the chip follows the `--emphasis` of the item around it (fully shown when there is none). |
| `font` | `"font"?: "code" \| "text" \| undefined` | `code` (the default) sets the label in the monospace font as an identifier; `text` keeps the UI font. |
| `id` | `"id"?: string \| undefined` | Makes the chip a button that selects this ID (`data-entity-id`), with `onSelect`. |
| `label` | `"label": Iterable<ReactNode, any, any> \| Promise<Iterable<ReactNode, any, any> \| ReactElement<unknown, string \| { (props: any): Iterable<ReactNode, any, any> \| Promise \| Promise<ReactNode> \| ReactElement<unknown, recursive> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined } \| { new (props: any, context: any): Component<any, any, any> }> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined> \| ReactElement<unknown, string \| { (props: any): Iterable<ReactNode, any, any> \| Promise<Iterable<ReactNode, any, any> \| ReactElement<unknown, recursive> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined> \| Promise<ReactNode> \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined } \| { new (props: any, context: any): Component<any, any, any> }> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined` | What the chip names. |
| `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. |
| `status` | `"status"?: undefined \| { "renamed"?: false \| true \| undefined; "status": "added" \| "modified" \| "removed" \| "unchanged"; "varied"?: Array<Varied> \| undefined }` | A status tab hanging under the chip (`StatusTab`), for its change in words; keep its room with `<Chips tabs>`. |
| `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. |

### `Chips`

```ts
Chips(__0: { "children": Iterable<ReactNode, any, any> | Promise<Iterable<ReactNode, any, any> | ReactElement<unknown, string | { (props: any): Iterable<ReactNode, any, any> | Promise | Promise<ReactNode> | ReactElement<unknown, recursive> | ReactPortal | bigint | false | null | number | string | true | undefined } | { new (props: any, context: any): Component<any, any, any> }> | ReactPortal | bigint | false | null | number | string | true | undefined> | ReactElement<unknown, string | { (props: any): Iterable<ReactNode, any, any> | Promise<Iterable<ReactNode, any, any> | ReactElement<unknown, recursive> | ReactPortal | bigint | false | null | number | string | true | undefined> | Promise<ReactNode> | ReactElement | ReactPortal | bigint | false | null | number | string | true | undefined } | { new (props: any, context: any): Component<any, any, any> }> | ReactPortal | bigint | false | null | number | string | true | undefined; "className"?: string | undefined; "label": string; "tabs"?: false | true | undefined }): Element
```

Chips in a wrapping list, each a list item. `tabs` keeps a status tab's room under every line, so nothing moves
when a chip's status appears.

### `ContentView`

```ts
Expand Down Expand Up @@ -4279,7 +4325,7 @@ One pill of a `ChangePills` list.

| Member | Signature | Description |
|---|---|---|
| `change` | `"change"?: "added" \| "removed" \| "unchanged"` | Added and removed pills carry a + or − sign and their hue; unchanged ones are plain. |
| `change` | `"change"?: "added" \| "modified" \| "removed" \| "unchanged"` | Changed pills carry a sign (+, − or ~) and their hue; unchanged ones are plain. |
| `entityId` | `"entityId"?: string` | Makes the pill a selectable part (`data-entity-id`), activated with `onSelect`. |
| `key` | `"key": string` | React key for the pill: unique within the list and stable across renders. |
| `label` | `"label": Iterable<ReactNode, any, any> \| Promise<Iterable<ReactNode, any, any> \| ReactElement<unknown, string \| { (props: any): Iterable<ReactNode, any, any> \| Promise \| Promise<ReactNode> \| ReactElement<unknown, recursive> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined } \| { new (props: any, context: any): Component<any, any, any> }> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined> \| ReactElement<unknown, string \| { (props: any): Iterable<ReactNode, any, any> \| Promise<Iterable<ReactNode, any, any> \| ReactElement<unknown, recursive> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined> \| Promise<ReactNode> \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined } \| { new (props: any, context: any): Component<any, any, any> }> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined` | The pill's content. |
Expand Down
5 changes: 0 additions & 5 deletions eslint-suppressions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2495,11 +2495,6 @@
"count": 1
}
},
"packages/renderers/kit/src/react/diff-components.tsx": {
"@typescript-eslint/no-non-null-assertion": {
"count": 1
}
},
"packages/renderers/kit/src/react/drag-pan.ts": {
"@typescript-eslint/no-non-null-assertion": {
"count": 2
Expand Down
5 changes: 3 additions & 2 deletions packages/cli/templates/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,8 @@ is its framework-free half, `/kit/react` its React components and hooks, and
`/kit/react.css` their styles. Use it rather than your own markup and CSS: the
kit already meets the checks the host holds every renderer to. The starter has
no stylesheet: compose views from the kit's components (`ContentView`, `Group`,
`CardGrid`, `EntityCard`, `Fields`, `Stack`, `Inline`, `Text`) and their props,
`CardGrid`, `EntityCard`, `Fields`, `Stack`, `Inline`, `Text`, `Chip`, `Chips`)
and their props,
and for an inline style they don't cover use `token` (`token.space(2)`). For
items with comparable properties (a row per item, a column per property), use
the kit's `DataTable` rather than hand-built table markup: sortable headings
Expand Down Expand Up @@ -634,7 +635,7 @@ them in the kit's shell, along with that module's `options` (`nouns`, `facts`,
- Accent and focus colors are only for focus and selection; change colors only
for change status. For domain meaning that isn't a change (a tool that only
reads, a privileged write), use the kit's `tone` (`quiet` or `flag`) on
`Text` and `DataTable` rows, or `toneAttributes`, rather than a change color,
`Text`, `Chip` and `DataTable` rows, or `toneAttributes`, rather than a change color,
a dashed edge or opacity. No horizontal scrolling at 390 px. No network: the
sandbox blocks it, so bundle every asset.
- Never nest change colors: only the innermost changed elements are colored. A
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ 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-change-pill[data-change="removed"]')).toContainText('skills/check-links')
await expect(section('repos').locator('.pk-change-pill[data-change="added"]')).toHaveText(/octo-org\/docs-site/u)
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.
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-change-pill[data-change="removed"]')).toHaveText(/2,000/u)
await expect(section('budgets').locator('.pk-change-pill[data-change="added"]')).toHaveText(/5,000/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)
// 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 +106,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-change-pill')).not.toContainText(['check-links'])
await expect(card.locator('.pk-pill-sign').first()).toBeHidden()
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 renderer.seek(1, {highlighting: 0})
await expect(card.locator('.aw-direction')).toHaveCount(0)
})
Expand All @@ -118,7 +118,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-change-pill[data-change="added"]').first()).toBeVisible()
await expect(card.locator('.pk-chip[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
6 changes: 3 additions & 3 deletions packages/renderers/agentic-workflows/src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +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-pill-sign {
.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. */
Expand Down Expand Up @@ -63,12 +63,12 @@
* In a pill the lock is the label: its words are one (`pk-label`), and its icon centres beside them, both on whole
* pixels, so the pill's own label holds the lock's box rather than trimming a line around it.
*/
.pk .pk-pill-label.pk-label:has(> .aw-lock) {
.pk .pk-chip-label.pk-label:has(> .aw-lock) {
display: flex;
text-box: none;
padding-block: 0;
}
.pk-pill-label > .aw-lock {
.pk-chip-label > .aw-lock {
align-items: center;
}
.aw-lock:not([data-lock='current']) {
Expand Down
1 change: 1 addition & 0 deletions packages/renderers/kit/react.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
@import './styles/generated.css';
@import './styles/graph.css';
@import './styles/diff.css';
@import './styles/chips.css';
@import './styles/layout.css';
@import './styles/scope.css';
@import './styles/table.css';
Loading
Loading