feat(tui): hidden experiments section with per-tab prompt drafts - #41862
Draft
kitlangton wants to merge 2 commits into
Draft
feat(tui): hidden experiments section with per-tab prompt drafts#41862kitlangton wants to merge 2 commits into
kitlangton wants to merge 2 commits into
Conversation
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.
What
Adds a hidden Experiments surface to the TUI: an opt-in home for in-flight features on any channel, reachable only by typing
/experiments(it is deliberately absent from the ctrl+p command palette). Each experiment is a registry entry with a title and description; toggling writesexperimental.<id>to the TUI config. Graduating or killing an experiment means deleting one registry entry plus its gated branch.Ships one experiment to give the surface a real tenant:
Per-tab prompt drafts (
tab_drafts) — today an unsent prompt draft is a single global slot that follows focus across session tabs. With the experiment on, drafts stay on the tab where they were written, and<leader>n(new session) moves the current draft into the new session instead of leaving a copy behind.1. Draft on tab two
2. Switch to tab one — draft stays behind
3. Switch back — draft restored
4.
<leader>n— draft moves to the new sessionTab two's composer is now empty (moved, not copied).
How
packages/tui/src/config/index.tsx— adds anexperimentalstruct to the TUI config schema (experimental.tab_drafts).packages/tui/src/component/dialog-experiments.tsx— new experiment registry +DialogExperiments(aDialogSelectthat togglesexperimental.<id>viaconfig.update).packages/tui/src/app.tsx— registersopencode.experimentswithpalette: undefined+slash: { name: "experiments" }, so it is typeable but not listed;session.newmoves the in-progress draft into the home route's prompt seed when the experiment is on.packages/tui/src/component/prompt/index.tsx— the module-level draft stash gains aMapkeyed by tab (sessionID, orhome) when the experiment is on. Two subtleties:props.sessionIDlazily would observe the next route duringonCleanupand stash the draft under the wrong tab (the draft would follow you, one tab behind)reset(), becausereset()merges an empty prompt into the same underlying store object thatunwrapexposesDefault behavior (experiment off) is byte-identical to today: one global stash slot.
Scope
/settings— the section is intentionally separate and unlisted. Happy to surface it differently if we want more/less discoverability.Testing
bun typecheckinpackages/tui— clean.--dev): created two sessions, enabled the experiment through/experiments, verified the draft stays on its tab, restores on return, moves on<leader>n, and the source tab's composer is empty afterwards. Also verifiedexperimental.tab_drafts: truelands in the config file.Demo
Real end-to-end run recorded with opencode-drive (simulated model, real TUI from this branch): creates two sessions, opens
/experiments, toggles the experiment on, writes a draft on tab two, clicks between tabs to show the draft staying put, thenctrl+x nmoving it into a new session.experiments-demo.mp4