fix(tui): complete TUI feature — interactive demo, expected outputs, Windows link#131
Closed
MelbourneDeveloper wants to merge 11 commits into
Closed
fix(tui): complete TUI feature — interactive demo, expected outputs, Windows link#131MelbourneDeveloper wants to merge 11 commits into
MelbourneDeveloper wants to merge 11 commits into
Conversation
- spawn with a non-constant captured arg (record/runtime value): spill captures through per-spawn globals so the fiber closure reloads them instead of referencing out-of-scope parent SSA values. - discriminated union construction: heap-allocate (malloc) instead of stack alloca so a union returned from a function no longer dangles (garbage int payload / string-payload segfault). - m[key] on a runtime-built map (Map()/mapSet): route through the C runtime get (osprey_map_contains/get) instead of the flat-literal array reader, which segfaulted on the opaque OspreyMap* handle. Covered by examples/tested/basics/knownbugs/bug1..bug4.
Completes the TUI work that did not make it into the squash of #130: - examples/tui/api_browser.osp: interactive colored arrow-key API browser. - jit_executor.go: link only the libs the Windows core build provides (fiber + winpthreads), prefer MinGW gcc; Mac/Linux link args unchanged. - select-based Result wrap, \e/\xHH escapes, lowercase example types.
The expectedoutput files for tui_repo_table and http_response_handle were empty (generated earlier from the wrong working dir), which failed TestHTTPExamples with "MISSING expected output". Regenerate them with real content and drop the nonexistent --sandbox-http flag from the api_browser run instructions.
MelbourneDeveloper
added a commit
that referenced
this pull request
Jun 1, 2026
…eap fix (#132) ## Colored HTTP/JSON TUI — Phases 1–4 of `docs/plans/tui-http-app.md` Lands the "write a colored TUI in Osprey that calls an HTTP API and renders the response" capability, plus the core codegen fix that makes string-wrapper helpers usable. Supersedes the closed #131 (rebuilt cleanly on top of `main`). ### Core codegen fix `generateInterpolatedString` built every interpolated string into a **stack** `alloca` and returned that pointer. The value dangled the moment it escaped the frame — a function returning an interpolated string, or a nested/subsequent interpolation reusing the frame — producing empty or garbage output. It only looked fine when consumed immediately by `print`. Now the buffer is **heap-allocated** (`malloc`), matching `generateIntToString`. This is what makes pure ANSI colour helpers (`fn red(s) = "\e[31m${s}\e[0m"`) work when their result is stored in a `let` or re-interpolated. ### Runtime & examples - **`http_server_runtime.c`** — server "listening"/request diagnostics now go to **stderr**, so tested-example stdout is deterministic. - **`examples/tested/http/tui_repo_table.osp`** (+ golden) — local server → `httpResponseBody` → `jsonParse`/`jsonGet`/`jsonLength` → colored, aligned table. Proves the end-to-end pitch. `[HTTP-RESPONSE-HANDLE]`, `[BUILTIN-JSON]`. - **`examples/tested/http/http_response_handle.osp`** (+ golden) — full handle lifecycle: status, body, header, missing-header error, free, and a double-free that reports `Error` (no crash). `[HTTP-RESPONSE-HANDLE]`. - **`examples/tui/api_browser.osp`** — interactive arrow-key repo browser (raw mode, `termReadKey`, `termClear`, colored render, detail view). `[BUILTIN-TERM]`. - Regenerated the two `.expectedoutput` golden files that had previously been committed empty (the cause of the earlier red CI). ### Verification - `make test` (lint + integration + unit + coverage threshold) passes locally with no regressions; the interpolation change is exercised across the suite. - `tui_repo_table` / `http_response_handle` / `http_server_example` goldens match real program output. - `api_browser.osp` compiles and renders the colored frame (verified by a scripted non-interactive run).
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.
Follow-up to #130 — complete the TUI feature
PR #130 merged the core runtime (HTTP response handles, JSON parser, terminal control) to
main, but a few pieces did not make it into the squash (they were untracked/empty at merge time) andmain'stui_repo_table.ospshipped without a valid.expectedoutput. This PR completes and corrects it.What this adds / fixes
examples/tui/api_browser.osp— the interactive colored arrow-key API browser (the showcase demo). Runs withosprey examples/tui/api_browser.osp --run..expectedoutputfortui_repo_table.ospand a new testedhttp_response_handle.osp(status/body/header/missing-header/free/double-free). These were empty before, failingTestHTTPExampleswith "MISSING expected output".jit_executor.go,compilation.go) — the JIT/run linker unconditionally linked-lhttp_runtime,-lssl,-lcrypto,-ldl,-lm, none of which exist on the Windows core build, so even a pure-fiber program failed to link. Link the minimal set (fiber + winpthreads) on Windows and prefer MinGW gcc there. Mac/Linux link args are unchanged.builder_literals.go/runtime_builtins_generation.go—\e/\xHHstring escapes for ANSI colors, named hex constants (mnd lint), and select-based Result wrapping (no extra basic blocks).Verification
TestHTTPExamplesandTestFiberExamplespass locally.api_browser.ospruns end-to-end (driven by a scripted key sequence): renders, navigates, opens detail, exits cleanly.