Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix(ide): stop terminal link detection walking past the buffer end

rubenluetke10-beep04c0f398b66e
diff --git a/jarvis/ui/web/frontend/src/lib/terminalLinks.test.ts b/jarvis/ui/web/frontend/src/lib/terminalLinks.test.ts
index ef67da3519..b2d2626417 100644
--- a/jarvis/ui/web/frontend/src/lib/terminalLinks.test.ts
+++ b/jarvis/ui/web/frontend/src/lib/terminalLinks.test.ts
@@ -178,6 +178,7 @@ describe("terminal links", () => {
const terminal = {
buffer: {
active: {
+ length: 1,
getLine: (row: number) => (row === 0 ? line : undefined),
getNullCell: () => cell,
},
diff --git a/jarvis/ui/web/frontend/src/lib/terminalLinks.ts b/jarvis/ui/web/frontend/src/lib/terminalLinks.ts
index 16fb781239..23fe1d9da8 100644
--- a/jarvis/ui/web/frontend/src/lib/terminalLinks.ts
+++ b/jarvis/ui/web/frontend/src/lib/terminalLinks.ts
@@ -219,12 +219,17 @@ function logicalLineAt(
const chunks: string[] = [];
let row = startRow;
let measured = 0;
- while (measured < MAX_LOGICAL_LINE_CHARS) {
+ // `getLine` past the last row wraps around xterm's scrollback ring instead
+ // of returning undefined, and an empty wrapped row adds no characters — so
+ // the walk is bounded by the buffer's real end as well as by length.
+ const lastRow = buffer.length - 1;
+ while (measured < MAX_LOGICAL_LINE_CHARS && row <= lastRow) {
const current = buffer.getLine(row);
if (!current) break;
const text = current.translateToString(true);
chunks.push(text);
measured += text.length;
+ if (row >= lastRow) break;
const next = buffer.getLine(row + 1);
if (!next?.isWrapped) break;
row += 1;
@@ -245,6 +250,7 @@ function mapStringIndex(
let column = initialColumn;
let remaining = chars;
while (remaining > 0) {
+ if (row >= buffer.length) return undefined;
const line = buffer.getLine(row);
if (!line) return undefined;
for (let index = column; index < line.length; index += 1) {