Skip to content

fix(staged): strip ANSI escape codes before regex matching in run detection - #629

Merged
matt2e merged 6 commits into
mainfrom
is-regex-working-for-goose2
Apr 15, 2026
Merged

fix(staged): strip ANSI escape codes before regex matching in run detection#629
matt2e merged 6 commits into
mainfrom
is-regex-working-for-goose2

Conversation

@matt2e

@matt2e matt2e commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Strip ANSI escape codes from terminal output before applying regex matching in the run detector, fixing cases where color/style codes prevented readiness patterns from matching
  • Improve the autodetect AI prompt to prefer server/framework readiness messages (e.g., Vite's "Local: http://localhost:PORT/") over application-level log output
  • Add strip-ansi-escapes crate dependency

Test plan

  • Verify run detection works for apps that emit colored terminal output (e.g., Vite, Next.js)
  • Confirm autodetect correctly identifies server readiness lines over application log lines
  • Check that regex matching still works for apps with plain (non-ANSI) output

🤖 Generated with Claude Code

matt2e and others added 5 commits April 15, 2026 13:42
…lines

The AI prompt for regex autodetection was matching browser/webview console
logs instead of the actual server readiness line. Add guidance to prefer
server/framework readiness messages over application-level log output and
pick the earliest readiness signal.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Log when regex_matcher and autodetect_poller are started (with execution
ID, action name, command/pattern), when each AI poll fires (with line
count), and what the AI decides (status, regex, has_endpoint_capture).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…match

When the AI-generated regex doesn't match any output line, log sample
lines containing "local" with debug escaping so we can see ANSI codes
or other hidden characters causing the mismatch.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ection

Terminal output contains ANSI colour/style codes (e.g. \x1b[1mLocal\x1b[22m)
which prevented AI-generated regexes from matching. Use the
strip-ansi-escapes crate to clean lines before sending to the AI and
before applying regex matches in both spawn_regex_matcher and
spawn_autodetect_poller.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…estigation

Remove the info-level startup/poll/response logs and sample-line debug
logging from spawn_regex_matcher and spawn_autodetect_poller, keeping
only the pre-existing warn/error/info logs for actionable states.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@matt2e
matt2e requested review from baxen and wesbillman as code owners April 15, 2026 04:56

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 803a160062

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

let matched_line = lines.iter().find(|line| re.is_match(line));
// Validate that the regex matches at least one line in the current
// output (using the already-stripped lines).
let matched_line = clean_lines.iter().find(|line| re.is_match(line));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Match AI regex against full output buffer

The new validation step only checks clean_lines, which is built from tail (last ~200 lines), while previously it searched the full lines buffer. In runs that emit a lot of logs after startup, the readiness line can scroll out of the last 200 lines before this poll executes, so a correct readiness regex gets rejected and autodetect can loop until timeout/NoDetection. This regression is introduced by narrowing validation scope at this line; the check should still consider the full buffered output (after ANSI stripping) to avoid missing earlier readiness lines.

Useful? React with 👍 / 👎.

The AI-generated regex is tested against each output line individually,
but the prompt didn't mention this constraint. Add explicit guidance so
the AI knows to produce patterns that match within a single line.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@matt2e
matt2e merged commit 42c80b2 into main Apr 15, 2026
5 checks passed
@matt2e
matt2e deleted the is-regex-working-for-goose2 branch April 15, 2026 05:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant