Repository navigation
feat(grid): add embeddable select grid component - #89
Merged
Merged
Conversation
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.
There was a problem hiding this comment.
🟢 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 dialogsEmbeddedProps) and theSelectGridcapability member. - Implement
embeddedSelectGridand expose a single, stableSelectGridfunction 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
SelectGridto 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 requestselectpresents, drawn as the dialogs' embeddableSelect, andonSubmitreceives exactly the selectionselectresolves with.This is the second and final task of change 0038, so the change is marked complete.
print,Grid, andselectare unchanged.Spec: Grid: Embeddable Selection · Change: 0038
Changes
plugins/grid/contract.ts:SelectGridProps<T, A>built fromEmbeddedProps<GridSelection<T, A>>(imported type-only from@fx/tx/dialogs) plusrequestandheight, and theSelectGridmember typed as returningunknownplugins/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 withselectRequestonce, rendersdialogs.Selectwith the host'swidth,height, andisActive, and maps the submitted choice back throughselection; host callbacks are read through a ref so fresh closures each render are honouredplugins/grid/index.ts: the component created once at registration and exposed asSelectGridtest/grid-embedded.test.ts: a host session on its own keyboard and screen drivesgrid.SelectGridread 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 providertest/plugin-consumer.test.ts: the packed consumer fixture typesSelectGridProps, resolving the grid contract through the dialogs contract, and builds aSelectGridelementtest/plugin-boundary.test.ts,test/demo*.test.ts: the contract type-name list gainsSelectGridProps; stub grid providers gainSelectGriddocs/manual/plugins.md: documentsSelectGridin the grid section with a host exampledocs/specs/grid/index.md,docs/changes/0038-*.md,docs/index.yml,docs/index.md: Embeddable Selection marked implemented with a changelog row; change 0038 completeTest plan
bun run checkpasses (Biome, TypeScript, all tests, 100% statement/function/line coverage, build)bun test test/grid-embedded.test.tspasses, including thethe embeddable selecting gridsuitebun test test/plugin-consumer.test.tspasses against the packed tarballbun test test/plugin-boundary.test.tspasses withSelectGridPropsin the contract type-name listbun test test/grid-select.test.ts test/grid-plugin.test.tspass with no assertion changed