Skip to content

feat(ffi): expose bracketed paste and input mode queries over the C ABI - #171

Merged
omarluq merged 3 commits into
mainfrom
feat/ffi-input-modes
Aug 6, 2026
Merged

feat(ffi): expose bracketed paste and input mode queries over the C ABI#171
omarluq merged 3 commits into
mainfrom
feat/ffi-input-modes

Conversation

@omarluq

@omarluq omarluq commented Aug 6, 2026

Copy link
Copy Markdown
Owner

No description provided.

@netlify

netlify Bot commented Aug 6, 2026

Copy link
Copy Markdown

Deploy Preview for termisu canceled.

Name Link
🔨 Latest commit 6d37353
🔍 Latest deploy log https://app.netlify.com/projects/termisu/deploys/6a73e0a504e7370008d4049e

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c5074875-bcd6-4332-a05f-1822230a1444

📥 Commits

Reviewing files that changed from the base of the PR and between ecedf12 and 6d37353.

📒 Files selected for processing (3)
  • spec/termisu/ffi_spec.cr
  • spec/termisu/input/parser_spec.cr
  • src/termisu/input/parser.cr
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/termisu/input/parser.cr
  • spec/termisu/ffi_spec.cr

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added controls to enable and disable bracketed paste mode.
    • Added status queries for mouse, enhanced keyboard, and bracketed paste modes.
    • Exposed these capabilities through the JavaScript API.
  • Bug Fixes

    • Improved input timing so short waits are not rounded down to zero.

Walkthrough

The PR adds bracketed paste controls and mode queries to the C, Crystal, and JavaScript FFI layers. It adds integration and routing tests. The input parser now rounds positive fractional millisecond waits upward and clamps nonpositive waits to zero.

Changes

FFI mode controls

Layer / File(s) Summary
FFI contract and implementation
include/termisu/ffi.h, src/termisu/ffi/core.cr, src/termisu/ffi/exports.cr
The FFI exports bracketed paste controls and UInt8 queries for mouse, enhanced keyboard, and bracketed paste modes.
JavaScript API integration
javascript/core/src/native.ts, javascript/core/src/termisu.ts
Termisu provides bracketed paste controls and boolean mode queries. syncUpdates() uses the shared queryFlag helper.
Mode control validation
javascript/core/tests/termisu.test.ts, spec/termisu/ffi_spec.cr
Tests cover native symbol routing, numeric-to-boolean conversion, and mode transitions.

Input deadline conversion

Layer / File(s) Summary
Parser deadline conversion
src/termisu/input/parser.cr, spec/termisu/input/parser_spec.cr
ms_until uses ceil_ms for positive durations and returns zero for zero or negative durations. Tests cover fractional and exact millisecond values.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Termisu
  participant NativeFFI
  participant TerminalContext
  Termisu->>NativeFFI: query or change input mode
  NativeFFI->>TerminalContext: read or update mode state
  TerminalContext-->>NativeFFI: return status or UInt8 state
  NativeFFI-->>Termisu: return status or boolean state
Loading

Possibly related PRs

Suggested reviewers: hahwul

Poem

A rabbit checks the paste mode bright,
Mouse and keys report their state just right.
The FFI routes each command,
While timers round waits as planned.
Tests confirm each trail,
And expired waits stay at zero.

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive No pull request description was provided, so its relevance to the changeset cannot be confirmed. Add a brief description of the new C ABI functions, input mode queries, and parser rounding changes.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the primary FFI changes for bracketed paste and input mode queries.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/ffi-input-modes

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@spec/termisu/ffi_spec.cr`:
- Around line 200-203: Update the enhanced-keyboard spec around
termisu_disable_enhanced_keyboard to assert that
termisu_enhanced_keyboard(handle) returns 0_u8 after a successful disable
operation. Preserve the existing status and enabled-state assertions.

In `@src/termisu/input/parser.cr`:
- Around line 370-373: Update the deadline conversion near remaining so exact
integer millisecond values remain unchanged while fractional values round up,
without using Float#ceil or an unconditional increment. Add boundary specs
covering 0.25, 1.0, and 1.25 milliseconds.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f1e6765d-5d91-4d14-abb3-9d3a841e1ebf

📥 Commits

Reviewing files that changed from the base of the PR and between df6e907 and ecedf12.

📒 Files selected for processing (8)
  • include/termisu/ffi.h
  • javascript/core/src/native.ts
  • javascript/core/src/termisu.ts
  • javascript/core/tests/termisu.test.ts
  • spec/termisu/ffi_spec.cr
  • src/termisu/ffi/core.cr
  • src/termisu/ffi/exports.cr
  • src/termisu/input/parser.cr

Comment thread spec/termisu/ffi_spec.cr
Comment thread src/termisu/input/parser.cr Outdated
@coderabbitai
coderabbitai Bot requested a review from hahwul August 6, 2026 01:17
@sonarqubecloud

sonarqubecloud Bot commented Aug 6, 2026

Copy link
Copy Markdown

@omarluq
omarluq merged commit 2590112 into main Aug 6, 2026
49 checks passed
@omarluq
omarluq deleted the feat/ffi-input-modes branch August 6, 2026 01:20
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