Repository navigation
Commit b12845f
committed
feat(tui): paint an editable home prompt before the TUI loads
`opencode` used to show a blank terminal for seconds while it loaded the
CLI, the server worker, plugins and providers, and keys typed meanwhile
were echoed by the tty and lost or turned into stray Enters. The home
screen with a working prompt is now on screen within about 100 ms.
boot.ts, the new compiled entrypoint, calls InstantPrompt.start() before
it imports the CLI. For the plain TUI (and `--mini`) it puts the tty in
raw mode, reads tui.json with plain file I/O, paints the home screen
from the startup cache, and hands stdin to a worker thread
(instant/worker.ts). The main thread cannot service stdin while it
evaluates the rest of the CLI, which takes 0.3-1.7 s; the worker reads
and paints keys as they are typed. Just before the renderer claims the
terminal, the TUI awaits handover(): the worker stops and returns the
prompt state and unparsed bytes, which are unshifted onto stdin.
A box on the renderer root (component/instant-screen.ts) keeps drawing
the same frame, independent of the providers that render nothing until
they load, and the renderer feeds keys back in until the home Prompt
mounts and claim()s the text, caret and selection (placed through cell
offsets, instant/caret.ts).
The prompt is a real editor (instant/editor.ts): every input_* keybind,
including tui.json overrides, word-wrap layout, click-to-caret, drag
selection, paste and undo. Its actions are checked against opentui's
own TextareaRenderable from every caret position (editor.test.ts).
Enter while loading queues the submit with a white "still loading"
notice; once the TUI has resolved the agent, model and variant it
submits only if they match what the screen showed, otherwise a red
"not submitted" notice asks for Enter again. Without the screen
(`startup.instant_prompt: false`, `--mini`) the same capture runs
invisibly (`startup.early_input`). A line feed in the first read is an
Enter typed before raw mode (ICRNL) and is dropped.
The startup cache (agent, model, variant, colors, shortcuts, branch,
tips height per directory) is written beside the database the process
would open, `<db>.tui-startup.json`, so a different OPENCODE_DB, data
directory or channel never shares it; the loading path does not open
SQLite. DatabaseLocation and GlobalPath split the path logic out of
database.ts and global.ts for that.
Layout numbers the screen depends on moved to constants-only modules
read by both sides: layout.ts (home and prompt geometry, placeholders,
spinner, notices) and config/keybind-definitions.ts (keybind defaults).
Measured with opencode-idle-bench ttp, --pure, desktop at load ~27:
typable 114 ms median (85-145) against 4778 ms (3830-5515) before.
AI-Tool: opencode 1.18.34-vt-128-907b3bc518
AI-Model: anthropic/claude-opus-5-5
AI-Variant: high
AI-Platform: linux
AI-Harness: Vibeterm cfa71a2
AI-Session-ID: ses_eebf9a83fffeIQQwW9gVFo5jaO1 parent 08f08f6 commit b12845f
41 files changed
Lines changed: 3137 additions & 300 deletions
File tree
- packages
- core/src
- database
- opencode
- script
- src
- cli
- cmd/run
- tui
- src
- component
- prompt
- config
- feature-plugins/home
- instant
- routes
- test/instant
- web/src/content/docs
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | 8 | | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
57 | 52 | | |
58 | 53 | | |
59 | 54 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | 1 | | |
3 | | - | |
4 | | - | |
5 | 2 | | |
6 | 3 | | |
7 | 4 | | |
8 | 5 | | |
| 6 | + | |
9 | 7 | | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
| 8 | + | |
16 | 9 | | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
| 10 | + | |
34 | 11 | | |
35 | 12 | | |
36 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
| 160 | + | |
160 | 161 | | |
161 | 162 | | |
162 | 163 | | |
| |||
184 | 185 | | |
185 | 186 | | |
186 | 187 | | |
187 | | - | |
| 188 | + | |
188 | 189 | | |
| 190 | + | |
189 | 191 | | |
190 | 192 | | |
191 | 193 | | |
| |||
195 | 197 | | |
196 | 198 | | |
197 | 199 | | |
| 200 | + | |
198 | 201 | | |
199 | 202 | | |
200 | 203 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
| |||
706 | 708 | | |
707 | 709 | | |
708 | 710 | | |
| 711 | + | |
| 712 | + | |
709 | 713 | | |
710 | 714 | | |
711 | 715 | | |
712 | 716 | | |
713 | 717 | | |
714 | 718 | | |
| 719 | + | |
715 | 720 | | |
716 | 721 | | |
717 | 722 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
178 | 179 | | |
179 | 180 | | |
180 | 181 | | |
| 182 | + | |
181 | 183 | | |
182 | 184 | | |
183 | 185 | | |
| |||
193 | 195 | | |
194 | 196 | | |
195 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
196 | 211 | | |
197 | 212 | | |
198 | 213 | | |
| |||
0 commit comments