mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-08 16:39:42 +02:00
feat: enable local echo overlay for OpenCode sessions
Use a cursor-based prompt finder for OpenCode's Bubble Tea TUI: - Custom finder locates ┃ (U+2503) border on the cursor's row - Offset 3 skips "┃ " to reach the text input start position - Prompt finder is swapped dynamically when switching between Claude (❯ character) and OpenCode (┃ border) sessions - Added setPrompt() method to ZerolagInputAddon for runtime updates Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
+31
-4
@@ -2005,6 +2005,8 @@ class ZerolagInputAddon {
|
|||||||
resetBufferDetection() { this._bufferDetectDone = false; }
|
resetBufferDetection() { this._bufferDetectDone = false; }
|
||||||
undoDetection() { this._flushedOffset = 0; this._flushedText = ''; this._bufferDetectDone = false; }
|
undoDetection() { this._flushedOffset = 0; this._flushedText = ''; this._bufferDetectDone = false; }
|
||||||
suppressBufferDetection() { this._bufferDetectDone = true; }
|
suppressBufferDetection() { this._bufferDetectDone = true; }
|
||||||
|
/** Update the prompt finder at runtime (e.g., when switching between Claude and OpenCode sessions) */
|
||||||
|
setPrompt(finder) { this._options.prompt = finder; this._lastPromptPos = null; }
|
||||||
findPrompt() {
|
findPrompt() {
|
||||||
if (!this._terminal) return null;
|
if (!this._terminal) return null;
|
||||||
return _zl_findPrompt(this._terminal, this._options.prompt ?? _ZL_DEFAULT_PROMPT);
|
return _zl_findPrompt(this._terminal, this._options.prompt ?? _ZL_DEFAULT_PROMPT);
|
||||||
@@ -3622,14 +3624,39 @@ class ClaudemanApp {
|
|||||||
const settings = this.loadAppSettingsFromStorage();
|
const settings = this.loadAppSettingsFromStorage();
|
||||||
const session = this.activeSessionId ? this.sessions.get(this.activeSessionId) : null;
|
const session = this.activeSessionId ? this.sessions.get(this.activeSessionId) : null;
|
||||||
const echoEnabled = settings.localEchoEnabled ?? MobileDetection.isTouchDevice();
|
const echoEnabled = settings.localEchoEnabled ?? MobileDetection.isTouchDevice();
|
||||||
// Disable local echo for OpenCode sessions — Bubble Tea TUI has no '>' prompt
|
const shouldEnable = !!(echoEnabled && session);
|
||||||
// for the overlay to anchor to, so keystrokes buffer invisibly
|
|
||||||
const isOpenCode = session?.mode === 'opencode';
|
|
||||||
const shouldEnable = !!(echoEnabled && session && !isOpenCode);
|
|
||||||
if (this._localEchoEnabled && !shouldEnable) {
|
if (this._localEchoEnabled && !shouldEnable) {
|
||||||
this._localEchoOverlay?.clear();
|
this._localEchoOverlay?.clear();
|
||||||
}
|
}
|
||||||
this._localEchoEnabled = shouldEnable;
|
this._localEchoEnabled = shouldEnable;
|
||||||
|
|
||||||
|
// Swap prompt finder based on session mode
|
||||||
|
if (this._localEchoOverlay && session) {
|
||||||
|
if (session.mode === 'opencode') {
|
||||||
|
// OpenCode (Bubble Tea TUI): find the ┃ border on the cursor's row.
|
||||||
|
// The input area is "┃ <text>" — the ┃ is the anchor, offset 3 skips "┃ ".
|
||||||
|
// We use the cursor row (cursorY) to find the right line, then scan for ┃.
|
||||||
|
this._localEchoOverlay.setPrompt({
|
||||||
|
type: 'custom',
|
||||||
|
offset: 3,
|
||||||
|
find: (terminal) => {
|
||||||
|
try {
|
||||||
|
const buf = terminal.buffer.active;
|
||||||
|
const row = buf.cursorY;
|
||||||
|
const line = buf.getLine(buf.viewportY + row);
|
||||||
|
if (!line) return null;
|
||||||
|
const text = line.translateToString(true);
|
||||||
|
const idx = text.indexOf('\u2503'); // ┃ (BOX DRAWINGS HEAVY VERTICAL)
|
||||||
|
if (idx >= 0) return { row, col: idx };
|
||||||
|
return null;
|
||||||
|
} catch { return null; }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// Claude Code: scan for ❯ prompt character
|
||||||
|
this._localEchoOverlay.setPrompt({ type: 'character', char: '\u276f', offset: 2 });
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user