mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-08 08:29:42 +02:00
fix: read a row-addressed repaint as lines in the preview
Measured against a live Claude pane: an Ink TUI paints by ROW and emits
almost no newlines, so dropping cursor-position sequences collapsed a whole
screen into one unreadable line, and a tail cut mid-sequence printed the
remains of it (";1H") as text. Now a jump to column 1 starts a display line,
a jump inside a row moves the write position (capped, since a stream may
address a column no terminal has), and a severed CSI head is dropped before
parsing.
The preview is readable against a real session as a result: tool calls, the
working line and the composer all land where they belong.
Also drop the repeated session name from a search row, whose snippet opens
with the name the row already shows in its first column.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
+13
-2
@@ -217,6 +217,16 @@ const SEARCH_GROUP_LABELS: Record<SearchSourceType, string> = {
|
||||
* has a session id too, but selecting it would move the cursor to a row that is
|
||||
* not on the list.
|
||||
*/
|
||||
/**
|
||||
* A session snippet opens with the session's own name (`w1-alpha — /tmp/alpha`),
|
||||
* which the row already shows in its first column. Dropping the repeat is what
|
||||
* keeps a result row from reading as a stutter.
|
||||
*/
|
||||
function withoutLabelPrefix(snippet: string, label: string): string {
|
||||
const rest = snippet.startsWith(label) ? snippet.slice(label.length) : snippet;
|
||||
return rest === snippet ? snippet : rest.replace(/^\s*(?:[—:-]\s*)?/, '');
|
||||
}
|
||||
|
||||
export function buildSearchEntries(
|
||||
groups: readonly SearchResultGroup[],
|
||||
isLive: (sessionId: string) => boolean
|
||||
@@ -227,10 +237,11 @@ export function buildSearchEntries(
|
||||
entries.push({ kind: 'header', text: SEARCH_GROUP_LABELS[group.type] ?? group.type.toUpperCase() });
|
||||
for (const result of group.results) {
|
||||
const live = result.jumpTo.kind === 'session' && isLive(result.sessionId);
|
||||
const label = result.jumpTo.relativePath ?? result.sessionName ?? result.sessionId.slice(0, 8);
|
||||
entries.push({
|
||||
kind: 'result',
|
||||
text: result.jumpTo.relativePath ?? result.sessionName ?? result.sessionId.slice(0, 8),
|
||||
detail: result.snippet,
|
||||
text: label,
|
||||
detail: withoutLabelPrefix(result.snippet, label),
|
||||
sessionId: result.sessionId,
|
||||
live,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user