Skip to content

Move terminal emulator to daScript#3513

Merged
borisbat merged 1 commit into
masterfrom
codex/das-terminal-daslang
Jul 19, 2026
Merged

Move terminal emulator to daScript#3513
borisbat merged 1 commit into
masterfrom
codex/das-terminal-daslang

Conversation

@borisbat

@borisbat borisbat commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • move terminal parsing, screen state, scrollback, UTF-8 handling, input encoding, replies, snapshots, and viewport projection from C++ to daScript
  • keep only the raw OS PTY/process transport in native code
  • expose raw array<uint8> feed/write/reply paths while retaining compatibility string boundaries
  • replace native semantic tests with inspectable daScript coverage and retain a transport-only ConPTY integration test
  • add feed-throughput and snapshot-scaling benchmarks

Performance

For a 154 KB / 2,000-line feed workload:

  • JIT feed: about 42-47 ms -> 9-10 ms
  • transient strings: 300,000 -> 95
  • full snapshot with ~10k history rows: about 133-156 ms -> 8.7 ms
  • viewport projection remains history-independent at roughly 0.3-0.4 ms

The feed benchmark includes terminal creation, parsing, scrollback allocation, and disposal. Viewport projection is cached by terminal revision and scroll offset, so it is rebuilt on updates rather than for idle frames.

Validation

  • in-tree formatter: 6 changed daScript files verified
  • lint: 6 files, 0 issues, 0 errors
  • modules/dasTerminal/tests/snapshot_smoke.das
  • modules/dasTerminal/tests/terminal_semantics.das
  • embedded dasImgui terminal compile-only check
  • transport-only ConPTY test: 8/8 assertions
  • focused Release builds for shared/static terminal modules and tests-cpp-small

Companion UI adaptation: borisbat/dasImgui#228

Deliberately deferred oracle phase

This PR does not select or embed a C++ terminal library. The follow-up sequence is:

  1. audit existing terminal libraries and compare their semantics/features against this implementation;
  2. select the oracle and document gaps/normalization rules;
  3. only then build side-by-side replay for deterministic test streams;
  4. after synthetic parity is understood, compare captured real PTY streams.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the dasTerminal terminal emulator (parsing, state, snapshots, key/paste encoding, and viewport projection) from C++ into daScript, leaving native code as a minimal PTY/process transport layer. It replaces the prior C++ semantic test coverage with daScript tests and adds benchmarks around feed throughput and snapshot scaling.

Changes:

  • Remove the C++ terminal emulator implementation and expose only PTY transport primitives from native code.
  • Implement the terminal emulator, snapshots, and input encoding in modules/dasTerminal/daslib/terminal.das, with new daScript semantic tests.
  • Adjust tests/benchmarks/docs to reflect the new raw-byte transport boundary and daScript-centric validation.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests-cpp/small/test_terminal.cpp Reduces C++ coverage to a PTY transport-only ConPTY integration test, now matching raw-byte behavior.
modules/dasTerminal/tests/terminal_semantics.das Adds daScript semantic coverage for parsing/snapshots/chunk invariance/replies/events/key+paste encoding.
modules/dasTerminal/tests/snapshot_smoke.das Updates smoke test expectations around disposal semantics.
modules/dasTerminal/src/terminal.h Removes the C++ terminal emulator API/types (deleted).
modules/dasTerminal/src/terminal.cpp Removes the C++ terminal emulator implementation (deleted).
modules/dasTerminal/src/dasTerminal.cpp Refactors native bindings to expose PTY-only APIs and a pty_handle managed type.
modules/dasTerminal/src/aot_builtin_terminal.h Replaces TerminalHandle with PtyHandle and updates exported native entrypoints.
modules/dasTerminal/README.md Updates module documentation to describe daScript emulator + native PTY boundary and new test/benchmark locations.
modules/dasTerminal/daslib/terminal.das Introduces the daScript terminal emulator core, snapshots/viewports, and raw-byte reply/event plumbing.
modules/dasTerminal/CMakeLists.txt Removes C++ terminal sources, installs only PTY headers, and registers the new daScript semantic test.
benchmarks/terminal/snapshot_scaling.das Adds a feed-throughput benchmark alongside existing snapshot scaling benchmarks.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests-cpp/small/test_terminal.cpp
Comment thread modules/dasTerminal/daslib/terminal.das
Copilot AI review requested due to automatic review settings July 19, 2026 22:35
@borisbat
borisbat force-pushed the codex/das-terminal-daslang branch from 08fb7fa to e7971e3 Compare July 19, 2026 22:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Comment thread modules/dasTerminal/README.md

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Comment thread modules/dasTerminal/daslib/terminal.das Outdated
Comment thread modules/dasTerminal/daslib/terminal.das
Comment thread modules/dasTerminal/daslib/terminal.das
Copilot AI review requested due to automatic review settings July 19, 2026 22:54
@borisbat
borisbat force-pushed the codex/das-terminal-daslang branch from e7971e3 to 5d2ec3e Compare July 19, 2026 22:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.

@borisbat
borisbat merged commit 7f413f6 into master Jul 19, 2026
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants