Skip to content

feat(grid): add embeddable select grid component - #89

Merged
fx merged 5 commits into
mainfrom
feat/embeddable-select-grid
Oct 18, 2026
Merged

fx merged 5 commits into
mainfrom
feat/embeddable-select-grid

Conversation

@fx

@fx fx commented Oct 18, 2026

Copy link
Copy Markdown
Owner

Summary

Adds SelectGrid to the grid capability: the driven grid as a component a host plugin renders inside its own Ink render session, taking the shared embedded props { request, width, height, isActive, onSubmit, onCancel }. It is the request select presents, drawn as the dialogs' embeddable Select, and onSubmit receives exactly the selection select resolves with.

This is the second and final task of change 0038, so the change is marked complete. print, Grid, and select are unchanged.

Spec: Grid: Embeddable Selection · Change: 0038

Changes

  • plugins/grid/contract.ts: SelectGridProps<T, A> built from EmbeddedProps<GridSelection<T, A>> (imported type-only from @fx/tx/dialogs) plus request and height, and the SelectGrid member typed as returning unknown
  • plugins/grid/select.ts: embeddedSelectGrid, which on mount reads the dialogs capability (throwing with the provider count when there is not exactly one), maps the request with selectRequest once, renders dialogs.Select with the host's width, height, and isActive, and maps the submitted choice back through selection; host callbacks are read through a ref so fresh closures each render are honoured
  • plugins/grid/index.ts: the component created once at registration and exposed as SelectGrid
  • test/grid-embedded.test.ts: a host session on its own keyboard and screen drives grid.SelectGrid read from the registry: acting on a row, a row with no actions, Escape, inactive then active, height and width bounds, and an absent or repeated dialogs provider
  • test/plugin-consumer.test.ts: the packed consumer fixture types SelectGridProps, resolving the grid contract through the dialogs contract, and builds a SelectGrid element
  • test/plugin-boundary.test.ts, test/demo*.test.ts: the contract type-name list gains SelectGridProps; stub grid providers gain SelectGrid
  • docs/manual/plugins.md: documents SelectGrid in the grid section with a host example
  • docs/specs/grid/index.md, docs/changes/0038-*.md, docs/index.yml, docs/index.md: Embeddable Selection marked implemented with a changelog row; change 0038 complete

Test plan

  • bun run check passes (Biome, TypeScript, all tests, 100% statement/function/line coverage, build)
  • bun test test/grid-embedded.test.ts passes, including the the embeddable selecting grid suite
  • bun test test/plugin-consumer.test.ts passes against the packed tarball
  • bun test test/plugin-boundary.test.ts passes with SelectGridProps in the contract type-name list
  • bun test test/grid-select.test.ts test/grid-plugin.test.ts pass with no assertion changed

fx added 4 commits October 18, 2026 19:08
Expose `SelectGrid` on the grid capability: the driven grid as a
component a host plugin renders inside a render session of its own. On
mount it reads the dialogs capability, failing that render with an error
naming the count when there is not exactly one provider, and maps its
request with `selectRequest` once. It renders the dialogs' embeddable
`Select` with the host's `width`, `height`, and `isActive`, and maps a
submitted choice back through `selection`, so `onSubmit` receives
exactly what `select` resolves with. It is created once at registration
so every read yields the same component.

The contract gains `SelectGridProps<T, A>`, built over `EmbeddedProps`
imported type-only from `@fx/tx/dialogs`, and the `SelectGrid` member,
typed as returning `unknown`. The demo tests' stub providers gain the
member, and the boundary test's exact list of contract type names gains
`SelectGridProps`.
Render `grid.SelectGrid`, read from the registry, inside a host session
on a keyboard and screen of its own while the command's streams stay
captured. Cover acting on a row, a row offering no actions, cancelling
with Escape, an inactive grid taking no keys until activated, the
host's height and width bounding what it draws, and the render failing
with the provider count when the dialogs provider is absent or repeated.
…tract

The packed consumer fixture types `SelectGridProps`, which resolves the
grid contract through the dialogs contract in the tarball, and builds a
`grid.SelectGrid` element with the injected React, cast at
`createElement` as the contract requires of a host.
Document `SelectGrid` in the plugin guide's grid section: the shared
embedded props it takes, the select it is drawn as, what `onSubmit`
receives, the dialogs lookup on mount, and the cast at `createElement`,
with a host example. Mark the grid spec's embeddable selection
implemented, add a changelog row, tick the second task of change 0038,
and set the change complete in the docs index.
Copilot AI lite review requested due to automatic review settings October 18, 2026 19:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The contract, implementation, tests, and documentation changes are consistent with the stated spec and are backed by targeted end-to-end coverage for the new embeddable component.

No open issues 🎉

What changed in this PR

This PR adds an embeddable SelectGrid component to the @fx/tx/grid capability so host plugins can render the driven selecting grid inside their own Ink render session, using the shared dialogs embedded-props pattern, and marks change 0038 as complete.

Changes:

  • Extend the grid contract with SelectGridProps<T, A> (built atop dialogs EmbeddedProps) and the SelectGrid capability member.
  • Implement embeddedSelectGrid and expose a single, stable SelectGrid function per capability instance.
  • Add comprehensive host-session tests for the embeddable selecting grid and update docs/spec/change tracking to reflect implementation.
File Description
test/​plugin-consumer.test.ts Ensures packed consumer fixture can type SelectGridProps and build a SelectGrid element.
test/​plugin-boundary.test.ts Extends contract type-name allowlist to include SelectGridProps.
test/​grid-embedded.test.ts Adds end-to-end host-session tests for grid.SelectGrid behavior and error cases.
test/​demo.test.ts Updates demo stub grid provider to include SelectGrid.
test/​demo-scenarios.test.ts Updates scenario stubs to include SelectGrid.
plugins/​grid/​select.ts Implements embeddedSelectGrid composing dialogs’ embeddable Select and mapping selection results.
plugins/​grid/​index.ts Creates and registers a stable SelectGrid component once during capability setup.
plugins/​grid/​contract.ts Publishes SelectGridProps and the SelectGrid member on the grid capability contract.
docs/​specs/​grid/​index.md Updates spec status to reflect SelectGrid now implemented; adds changelog row.
docs/​manual/​plugins.md Documents SelectGrid usage, props, and a host example.
docs/​index.yml Marks change 0038 status as complete.
docs/​index.md Marks change 0038 status as complete in the index table.
docs/​changes/​0038-add-embeddable-grid-components.md Checks off SelectGrid task list and marks the change document complete.

Review effort: Lite

@fx
fx merged commit 5b3e3ad into main Oct 18, 2026
1 check passed
@fx
fx deleted the feat/embeddable-select-grid branch October 18, 2026 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants