refactor(define): minimize custom terminal FFI - #33
Merged
Conversation
Move the widget definition TUI terminal boundary into the internal glendix/internal/define/terminal_control module. Delegate size queries to the term_size package and successful process termination to plinth, while retaining only the TTY probe, raw-mode control, stdin lifecycle, and non-blocking key polling as documented custom FFI. Preserve the 80x24 fallback, raw-mode error messages, key decoding, queued input, and one-shot timeout behavior. Add contract coverage for every retained key sequence, raw-mode success and error paths, polling, and terminal-size tuple conversion without exposing a new public package API. Refs #18
GG-O-BP
force-pushed
the
refactor/term-size-terminal-ffi-issue-18
branch
from
September 7, 2026 12:29
a62f126 to
3e76e20
Compare
6 tasks
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
Resolves the issue #18 spike by minimizing the widget-definition TUI's custom
terminal FFI. Terminal-capability and raw-input FFI previously lived in a single
src/glendix/define_ffi.mjsadapter; this change delegates everything with areliable ecosystem equivalent to a package and keeps only the irreducible
custom residue, moved to an internal boundary module.
Closes #18
Changes
term_sizepackage (term_size.get()),converting the package's
#(rows, columns)result into the TUI's existing#(columns, rows)contract. The conventional80x24fallback is preserved,including independent fallback for non-positive dimensions.
plinth/node/process.exitdependency instead of a custom zero-argument FFI export.
src/glendix/define_ffi.mjsinto the internalmodule
glendix/internal/define/terminal_control(+terminal_control_ffi.mjs),so no new public package API is introduced.
terminal-ffi-spike.mdrecords the full evaluation and rationale.Intentionally retained custom FFI
No evaluated package safely provides these, so they remain custom and are
documented as intentional residue:
is_tty)raw mode")
Tests
Added contract coverage in
test/glendix/internal/define/terminal_control_test.gleam:80x24fallback (including non-positive dims)Verification
./scripts/verify.sh inner glendix— pass (Glendix: 106 passed, no failures)./scripts/verify.sh shared glendix— pass (family gates, all standaloneconsumers, widget
.mpkbuild)./scripts/verify.sh final— run via the mandatory child pre-push hook(family gates + Lustre and Mendix end-to-end)
Dependency contract
glendix -> mendrawkeeps its currently declared Hex dependency source form.