Skip to content

Fix path resolution leading slash stripping & preserve plaintext agent stream formatting - #134

Open
Spagles wants to merge 7 commits into
nexu-io:mainfrom
Spagles:main
Open

Fix path resolution leading slash stripping & preserve plaintext agent stream formatting#134
Spagles wants to merge 7 commits into
nexu-io:mainfrom
Spagles:main

Conversation

@Spagles

@Spagles Spagles commented Jul 31, 2026

Copy link
Copy Markdown

This PR fixes two issues:

  1. Prevents findCommonPath from stripping leading slashes on Unix systems when computing common directory roots.
  2. Preserves whitespace and empty lines for plaintext streaming agents (aider, codewhale, deepseek-tui) so code blocks and HTML formatting aren't corrupted during streaming.

Changes

  • Path Resolution (cli/src/collision-resolve.ts, cli/src/index.ts, cli/src/__tests__/collision-resolve.test.ts):

    • Removed .filter(Boolean) on path.sep splits in findCommonPath so the root slash isn't lost on Unix systems.
    • Updated collision-resolve test assertions to expect resolved absolute paths.
  • Stream Parsing (cli/src/agents-invoke.ts, next/src/lib/agents/invoke.ts, next/src/lib/agents/argv.ts):

    • Removed the if (!line) continue check in the stream processing loops.
    • Preserved raw line content (including leading spaces and blank lines) for plain-text streaming agents instead of trimming them.

Testing

  • Ran unit tests for path collision resolution.
  • Verified stream outputs for plain-text agents preserve indentation and newlines.

@lefarcen
lefarcen requested a review from nettee July 31, 2026 03:02
@lefarcen lefarcen added size/S Small change: 20-99 changed lines risk/medium Medium risk change type/bugfix Bug fix labels Jul 31, 2026

@nettee nettee left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found one non-blocking follow-up around regression coverage for the plaintext streaming fix. I reviewed the changed ranges on this head and the runtime change looks directionally right, but the new whitespace-preservation path still needs explicit tests so it doesn't regress quietly later.🔁 Powered by Looper · runner=reviewer · agent=codex · An autonomous AI dev team for your GitHub repos.

// go to stderr, which is forwarded as `stderr` events, not parsed here).
if (agent === "aider" || agent === "codewhale" || agent === "deepseek-tui") {
return [{ kind: "delta", text: trimmed.endsWith("\n") ? trimmed : trimmed + "\n" }];
return [{ kind: "delta", text: line + "\n" }];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes the Next-side parser to preserve raw whitespace for aider / codewhale / deepseek-tui, but the regression still isn't covered anywhere in the test suite. next/src/lib/agents/__tests__/argv.test.ts currently only exercises opencode and bob, and the PR also doesn't add a blank-line / indentation case to cli/src/__tests__/agents-invoke.test.ts even though the CLI loop changed in parallel. That matters because the old bug was exactly a line-splitting/parsing detail: a future reintroduction of trim() or if (!line) continue would silently corrupt code blocks and HTML again while the current tests stay green. Please add focused cases for leading spaces, whitespace-only lines, interior blank lines, and a trailing partial line for these plaintext agents in both the Next parser tests and the CLI invoke tests.🔁 Powered by Looper · runner=reviewer · agent=codex · An autonomous AI dev team for your GitHub repos.

@lefarcen

Copy link
Copy Markdown

Hey @Spagles — thanks for the focused fix here.

@nettee's latest review is the main follow-up on this head: the runtime change looks right, but the plaintext streaming path still needs explicit regression coverage so leading spaces, blank lines, and trailing partial lines for aider, codewhale, and deepseek-tui don't quietly break again later. Once those focused tests are in, this should be in a much better spot for the next pass.

💡 To drive this PR to merge hands-free, paste this to your AI coding agent (Claude Code / Codex / opencode / Cursor …):
Take over nexu-io/html-anything#134 until it merges — read https://raw.githubusercontent.com/nexu-io/looper/main/skills/pr-takeover/SKILL.md and follow it.

@lefarcen

Copy link
Copy Markdown

Hey @Spagles — the current runtime/path fix looks directionally right, and @nettee left one non-blocking follow-up on this head that’s worth tightening before the next pass.

The missing piece is focused regression coverage for the plaintext streaming path: tests should explicitly cover leading spaces, whitespace-only lines, interior blank lines, and a trailing partial line for the plaintext agents in both the Next parser tests and the CLI invoke tests, so this whitespace-preservation fix can’t quietly regress later.

💡 To drive this PR to merge hands-free, paste this to your AI coding agent (Claude Code / Codex / opencode / Cursor …):
Take over nexu-io/html-anything#134 until it merges — read https://raw.githubusercontent.com/nexu-io/looper/main/skills/pr-takeover/SKILL.md and follow it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk/medium Medium risk change size/S Small change: 20-99 changed lines type/bugfix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants