fix: stabilize notes and reasoning replay

This commit is contained in:
Peter Steinberger
2026-01-11 04:36:16 +01:00
parent edb3651c32
commit eeae5ce7fd
5 changed files with 29 additions and 19 deletions

View File

@@ -639,8 +639,10 @@ describe("doctor", () => {
([message, title]) =>
title === "Sandbox" &&
typeof message === "string" &&
message.includes('agents.list (id "work") sandbox docker') &&
message.includes('scope resolves to "shared"'),
message
.replace(/\s+/g, " ")
.includes('agents.list (id "work") sandbox docker') &&
message.replace(/\s+/g, " ").includes('scope resolves to "shared"'),
),
).toBe(true);
});

View File

@@ -1,10 +1,7 @@
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import {
intro as clackIntro,
outro as clackOutro,
} from "@clack/prompts";
import { intro as clackIntro, outro as clackOutro } from "@clack/prompts";
import {
resolveAgentWorkspaceDir,
resolveDefaultAgentId,
@@ -39,8 +36,8 @@ import { runGatewayUpdate } from "../infra/update-runner.js";
import { runCommandWithTimeout } from "../process/exec.js";
import type { RuntimeEnv } from "../runtime.js";
import { defaultRuntime } from "../runtime.js";
import { stylePromptTitle } from "../terminal/prompt-style.js";
import { note } from "../terminal/note.js";
import { stylePromptTitle } from "../terminal/prompt-style.js";
import { sleep } from "../utils.js";
import {
DEFAULT_GATEWAY_DAEMON_RUNTIME,

View File

@@ -1,12 +1,7 @@
import { note as clackNote } from "@clack/prompts";
import { visibleWidth } from "./ansi.js";
import { stylePromptTitle } from "./prompt-style.js";
const ANSI_ESCAPE = /\u001b\[[0-9;]*m/g;
function visibleLength(value: string): number {
return Array.from(value.replace(ANSI_ESCAPE, "")).length;
}
function splitLongWord(word: string, maxLen: number): string[] {
if (maxLen <= 0) return [word];
const chars = Array.from(word);
@@ -25,8 +20,8 @@ function wrapLine(line: string, maxWidth: number): string[] {
const content = match?.[3] ?? "";
const firstPrefix = `${indent}${bullet}`;
const nextPrefix = `${indent}${bullet ? " ".repeat(bullet.length) : ""}`;
const firstWidth = Math.max(10, maxWidth - visibleLength(firstPrefix));
const nextWidth = Math.max(10, maxWidth - visibleLength(nextPrefix));
const firstWidth = Math.max(10, maxWidth - visibleWidth(firstPrefix));
const nextWidth = Math.max(10, maxWidth - visibleWidth(nextPrefix));
const words = content.split(/\s+/).filter(Boolean);
const lines: string[] = [];
@@ -36,7 +31,7 @@ function wrapLine(line: string, maxWidth: number): string[] {
for (const word of words) {
if (!current) {
if (visibleLength(word) > available) {
if (visibleWidth(word) > available) {
const parts = splitLongWord(word, available);
const first = parts.shift() ?? "";
lines.push(prefix + first);
@@ -50,7 +45,7 @@ function wrapLine(line: string, maxWidth: number): string[] {
}
const candidate = `${current} ${word}`;
if (visibleLength(candidate) <= available) {
if (visibleWidth(candidate) <= available) {
current = candidate;
continue;
}
@@ -59,7 +54,7 @@ function wrapLine(line: string, maxWidth: number): string[] {
prefix = nextPrefix;
available = nextWidth;
if (visibleLength(word) > available) {
if (visibleWidth(word) > available) {
const parts = splitLongWord(word, available);
const first = parts.shift() ?? "";
lines.push(prefix + first);

View File

@@ -11,13 +11,13 @@ import {
text,
} from "@clack/prompts";
import { createCliProgress } from "../cli/progress.js";
import { note as emitNote } from "../terminal/note.js";
import {
stylePromptHint,
stylePromptMessage,
stylePromptTitle,
} from "../terminal/prompt-style.js";
import { theme } from "../terminal/theme.js";
import { note as emitNote } from "../terminal/note.js";
import type { WizardProgress, WizardPrompter } from "./prompts.js";
import { WizardCancelledError } from "./prompts.js";