coder / coder/ghostty-web

Ghost cursor appears at top-left (0,0) on initialization

Open
#122 4 comments 0 reactions 0 assignees View on GitHub
bug status:could-not-reproduce triage:done
Dominant language
TypeScript
Stars
2.8k
Forks
172
PR merge metrics
No merged PRs in 30d

Description

## Description

When initializing a Terminal instance, a ghost cursor is rendered at the top-left corner (coordinates 0,0) in addition to the actual cursor position. This cursor persists and doesn't disappear even when the terminal receives content.

## Steps to Reproduce

1. Create a new Terminal instance with cursor enabled
2. Call `terminal.open(container)`
3. Observe that a cursor appears at the top-left corner (0,0)
4. The ghost cursor remains even after terminal content is rendered

## Expected Behavior

Only one cursor should be visible at the actual cursor position, not at (0,0).

## Actual Behavior

Two cursors are visible:
1. The correct cursor at the actual position
2. A ghost cursor at the top-left corner (0,0)

## Root Cause Analysis

After investigating the minified source code, the issue appears to be in `CanvasRenderer`:

1. **Initialization**: `lastCursorPosition` is initialized to `{ x: 0, y: 0 }` (around line 1337)
2. **Rendering**: The cursor rendering logic at line 1561-1578 checks `g === 0 && I.visible && this.cursorVisible && this.renderCursor(I.x, I.y)`
3. **Problem**: When the cursor moves to a new position, the old position (0,0) is not properly cleared, leaving a ghost cursor

## Workaround

TBD

## Environment

- ghostty-web version: 0.4.0
- Browser: Chrome (tested)
- OS: macOS

## Suggested Fix

The `CanvasRenderer` should either:
1. Not render the cursor until a valid position is set
2. Properly clear the initial (0,0) position when the cursor moves
3. Initialize `lastCursorPosition` to a sentinel value that prevents initial rendering

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.