Skip to content

refactor(flterm): harden the adapter and expose OSC 52 writes - #100

Closed
adonm wants to merge 8 commits into
elias8:mainfrom
adonm:refactor/flterm-thin-adapter
Closed

refactor(flterm): harden the adapter and expose OSC 52 writes#100
adonm wants to merge 8 commits into
elias8:mainfrom
adonm:refactor/flterm-thin-adapter

Conversation

@adonm

@adonm adonm commented Jul 14, 2026

Copy link
Copy Markdown

Summary

  • delegate terminal mode defaults, cursor-key encoding, and size reporting to libghostty or cached layout state instead of mirroring/consuming terminal render state in flterm
  • make TerminalRenderPipeline the single owner of the atlas lease, frame buffers, painters, Kitty placement/image state, paint order, and terminal dirtiness
  • remove one-use adapter types (TerminalRenderObserver, TerminalPainterStack, TerminalPainter, and TerminalRawGestureDetector)
  • preserve tracked pointer identity and coordinates across mouse buttons, hover, cancellation, wheel input, and touch/stylus scrolling
  • keep the previous same-sized Kitty texture drawable while replacements decode, and coalesce rapid retransmissions to the newest queued frame
  • expose throttled screen-reader semantics for visible, non-concealed terminal text, including focus actions and scrollback updates
  • expose write-only OSC 52 requests as a typed libghostty/flterm callback on native and WASM targets; clipboard read queries remain disabled

Why

flterm should translate Flutter lifecycle, input, paint, accessibility, and host effects at the UI boundary while libghostty remains authoritative for terminal behavior. The removed state and pass-through abstractions created synchronization paths without adding a stable boundary.

The input and rendering fixes close issues found while integrating the adapter in a remote-shell client: fabricated (0, 0) wheel positions, lost mouse-button identity, dirty state consumed by terminal size queries, blank frames during Kitty image replacement, and custom-painted terminal content being unavailable to assistive technologies.

The OSC 52 callback lets embedders apply their own trust policy, payload limits, decoding, foreground-tab checks, and platform clipboard write. It deliberately exposes the raw selector and base64 payload rather than granting clipboard access inside libghostty.

Compatibility and scope

  • changes span packages/flterm and packages/libghostty; the pinned Ghostty commit remains 91f66da24527fa02d92b5fd0b41cd020f553a64c
  • the Ghostty C option is appended at value 26, preserving existing option values
  • the pinned Ghostty source receives a packaged patch during source, CI, native, and WASM builds; the patch hash participates in source cache keys
  • Terminal.onClipboardWrite and TerminalController.onClipboardWrite are additive optional callbacks
  • OSC 52 clipboard read queries (?) are ignored before the callback boundary
  • the package:flterm/flterm.dart entrypoint is unchanged
  • TerminalView.semanticsLabel and TerminalView.semanticsHint are additive optional parameters; semanticsLabel: null lets an embedding application provide its own accessible surface
  • the custom atlas renderer and the newer KittyPlacementCache remain intact

Verification

  • targeted libghostty-vt Zig tests for OSC 52 stream and C callbacks pass
  • dart analyze packages/flterm passes with the three pre-existing info-level lints in terminal_frame_builder_test.dart
  • packages/libghostty/test/hook/ghostty_source_test.dart: 12 tests passed
  • native packages/libghostty/test/impl/terminal/terminal_test.dart: 71 tests passed
  • packages/flterm/test/widgets/terminal_controller_test.dart: 60 tests passed
  • patched wasm32-freestanding library compiles successfully; CI runs the Chrome WASM suite
  • libghostty and flterm publish dry-runs include the expected source patch/API files, with only the expected dirty-worktree warning before commit

@adonm adonm changed the title refactor(flterm): thin the Flutter adapter refactor(flterm): simplify and harden the Flutter adapter Jul 14, 2026
@adonm adonm changed the title refactor(flterm): simplify and harden the Flutter adapter refactor(flterm): harden the adapter and expose OSC 52 writes Jul 15, 2026
@adonm
adonm force-pushed the refactor/flterm-thin-adapter branch 2 times, most recently from 75264d5 to 7bb1817 Compare July 15, 2026 02:31
@adonm

adonm commented Jul 15, 2026

Copy link
Copy Markdown
Author

Superseded by #101 after renaming the head branch to refactor/flterm-adapter.

@adonm adonm closed this Jul 15, 2026
@adonm
adonm deleted the refactor/flterm-thin-adapter branch July 15, 2026 02:34
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.

1 participant