Skip to content

feat: refactor-inputpanel-usecursor — replace custom cursor with Ink's useCursor hook#266

Open
avoidwork wants to merge 8 commits into
mainfrom
feat/refactor-inputpanel-usecursor
Open

feat: refactor-inputpanel-usecursor — replace custom cursor with Ink's useCursor hook#266
avoidwork wants to merge 8 commits into
mainfrom
feat/refactor-inputpanel-usecursor

Conversation

@avoidwork

@avoidwork avoidwork commented Jun 15, 2026

Copy link
Copy Markdown
Owner

Description

Refactor the InputPanel cursor from a cosmetic Unicode block character (█) rendered as part of the text output to Ink's built-in useCursor hook for real terminal cursor positioning.

Type of Change

  • Bugfix (non-breaking change which fixes an issue)
  • Refactor (no functional changes)

Testing

  • Updated 4 existing cursor tests to reflect the new useCursor-based implementation
  • Added 4 new tests: wide character positioning, cursor hide on empty input, cursor show on text input, Blink component removal verification
  • All 1130 tests pass (1130/1130)
  • Lint: 0 warnings, 0 errors

Coverage

  • 100% line coverage maintained

Checklist

  • npm run lint passes
  • Tests pass with 100% line coverage
  • No forbidden patterns used
  • Conventional Commit style applied

Files Changed

  • src/tui/inputPanel.js — Removed Blink component, added useCursor hook with string-width positioning
  • src/tui/app.js — Removed cursorChar/cursorColor props from InputPanel usage
  • src/config/schemas.js — Removed cursorChar and blinkTimeout from TUI schema
  • package.json / package-lock.json — Added string-width dependency
  • tests/unit/tui.test.js — Updated cursor tests + 4 new tests
  • tests/unit/config_loader.test.js — Updated schema validation tests
  • openspec/specs/input-cursor/spec.md — Updated spec to reflect new cursor behavior

@avoidwork

Copy link
Copy Markdown
Owner Author

Implementation Audit Results: refactor-inputpanel-usecursor

Goal Fulfillment

Goal 1: Replace Custom Block Cursor with Ink's useCursor Hook

  • ✅ Blink component removed from inputPanel.js
  • useCursor hook imported and used in InputPanel
  • ✅ Cursor x position computed using stringWidth("> " + inputText)
  • ✅ Cursor y position set to totalRows - 1 (last row)
  • ✅ Cursor hidden when input is empty (passes undefined to setCursorPosition)
  • string-width added as production dependency
  • cursorChar prop removed from InputPanel API
  • cursorColor prop removed from InputPanel API
  • ✅ Prompt prefix > rendered correctly

Goal 2: Ensure Proper Cursor Visibility State

  • ✅ Cursor shows when input has text
  • ✅ Cursor hides when input is empty
  • ✅ Cursor position updates on every render (via useCursor hook)

Spec Compliance

All requirements in specs/input-cursor/spec.md are implemented:

  • ✅ REMOVED: Blinking Input Cursor requirement
  • ✅ REMOVED: Configurable Cursor Character requirement
  • ✅ REMOVED: Configurable Blink Interval requirement
  • ✅ ADDED: Real terminal cursor via useCursor
  • ✅ ADDED: Wide character handling via string-width
  • ✅ ADDED: Cursor hidden when input is empty
  • ✅ ADDED: Prompt prefix rendering
  • ✅ ADDED: Blink component removed
  • ✅ ADDED: cursorChar prop removed
  • ✅ ADDED: string-width dependency added

Task Completion

All 17 tasks completed:

  • Setup: 2/2 ✅
  • Refactor InputPanel: 7/7 ✅
  • Update App Component: 3/3 ✅
  • Tests: 5/5 ✅
  • Verification: 5/5 ✅

Quality Check

  • Tests: 1130/1130 passing ✅
  • Lint: 0 warnings, 0 errors ✅
  • No forbidden patterns: No console.log, no empty catch blocks, no hardcoded secrets ✅
  • DRY: Changes are minimal and focused ✅
  • KISS: Simple, readable implementation ✅

Deviations from Plan

None. Implementation followed the design document and specs exactly.

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