Skip to content

Fix GUI chat parser and lifecycle state - #362

Merged
TraderSamwise merged 3 commits into
masterfrom
fix/gui-chat-smoke-stability
Jul 13, 2026
Merged

Fix GUI chat parser and lifecycle state#362
TraderSamwise merged 3 commits into
masterfrom
fix/gui-chat-smoke-stability

Conversation

@TraderSamwise

@TraderSamwise TraderSamwise commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • clean GUI chat transcript parsing for Claude/Codex startup noise, action/status rows, and submitted prompt normalization
  • render chat image references as bounded previews and keep terminal output behind the explicit terminal surface
  • tighten GUI lifecycle/create/action states, loop/overseer state, and transient error handling
  • add PNA preflight headers plus host read/stream project targeting and shim retry coverage

Smoke testing

  • Claude and Codex GUI chat send/receive, image attachment rendering, terminal/transcript toggle, back/re-enter, lifecycle stop/resume, label, loop, and overseer flows
  • local browser console stayed clean for app-owned code after fixes

Verification

  • yarn vitest run src/agent-output-parser.test.ts src/agent-prompt-delivery.test.ts src/daemon.test.ts src/installed-shim.test.ts src/metadata-server.test.ts
  • yarn --cwd app test MessageBlock.test.ts heartbeat.test.ts api.test.ts parsed-transcript.test.ts
  • yarn typecheck
  • yarn --cwd app typecheck
  • yarn --cwd app lint
  • yarn lint
  • yarn build
  • pre-push: yarn typecheck && yarn lint && yarn test (171 files, 2463 tests)

Summary by CodeRabbit

  • New Features

    • Images now render inline within conversation messages when available.
    • Added --project path support for agent output capture and streaming.
    • Dashboard sessions now include loop and overseer status.
    • Private-network browser preflight requests are supported for CORS.
  • Bug Fixes

    • Transient request failures no longer clutter error messages across panels and chat.
    • Agent creation now consistently uses the latest tool and worktree selections.
    • Improved transcript parsing to better filter startup noise and handle flattened image attachments.
    • Agent output capture now retries temporary transport failures.

@vercel

vercel Bot commented Jul 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
app Ready Ready Preview, Comment Jul 13, 2026 3:13pm

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b9d6b265-653b-4312-a39b-a3c8a4ce2535

📥 Commits

Reviewing files that changed from the base of the PR and between ea9ab8c and 6b93083.

📒 Files selected for processing (2)
  • src/metadata-server.test.ts
  • src/metadata-server.ts

📝 Walkthrough

Walkthrough

The pull request updates agent UI rendering and error handling, session loop metadata, transcript parsing and prompt normalization, host-agent retries, private-network CORS responses, and project-scoped host command routing.

Changes

Agent UI and session state

Layer / File(s) Summary
Image reference rendering
app/components/MessageBlock.tsx
Image parts resolve service URLs and render inline images when resolvable.
Transient error visibility
app/components/agent-actions.tsx, app/components/service-actions.tsx, app/components/teammate-panel.tsx, app/components/workflow-actions.tsx, app/components/worktree-management-panel.tsx
Transient request errors are excluded from stored and displayed component errors.
Agent controls and session state
app/components/agent-create-panel.tsx, app/components/agent-management-panel.tsx, app/components/screens/AgentChatScreen.tsx, app/lib/desktop-state.ts, src/dashboard/index.ts, src/multiplexer/dashboard-model.ts
Agent selection uses refs, loop and overseer metadata flows through session models, and chat relies on relay readiness plus output polling.

Transcript parsing and prompt normalization

Layer / File(s) Summary
Parsed transcript attachment handling
app/lib/parsed-transcript.ts, app/lib/parsed-transcript.test.ts
Flattened attached-image text is parsed into text and image-reference parts, with added startup-content coverage.
Agent output classification
src/agent-output-parser.ts, src/agent-output-parser.test.ts, src/agent-output-parser-audit.test.ts
Codex and Claude startup artifacts, status lines, runtime noise, and status-only transcripts receive updated classifications and fixtures.
Submitted prompt normalization
src/agent-prompt-delivery.ts, src/agent-prompt-delivery.test.ts
Codex and Claude submitted prompts now use consistent whitespace collapsing.

Transport and project routing

Layer / File(s) Summary
Host-agent transport retry
scripts/installed-aimux-shim.sh, src/installed-shim.test.ts
Host-agent reads retry transport failures up to three times without falling back to the Node launcher.
Private-network CORS support
src/daemon.ts, src/daemon.test.ts, src/metadata-server.ts, src/metadata-server.test.ts
Daemon and metadata-server preflights can receive the private-network access header, with metadata-server origin validation.
Project-scoped host commands
src/main.ts
host agent-read and host agent-stream accept --project and route through the selected project service.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately captures the main themes: GUI chat parsing and lifecycle state updates.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/gui-chat-smoke-stability

Comment @coderabbitai help to get the list of available commands.

@TraderSamwise

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@TraderSamwise

Copy link
Copy Markdown
Owner Author

Independent review finding resolved: app/lib/parsed-transcript.ts only parsed the first flattened attachment item. Fixed in ea9ab8c by scanning every item after the Attached image files header and adding a two-image regression test.

@TraderSamwise

Copy link
Copy Markdown
Owner Author

Independent review finding resolved: active loop goals could not be updated from the GUI. Fixed in ea9ab8c by allowing Save when the active goal differs from the current server goal.

@TraderSamwise

Copy link
Copy Markdown
Owner Author

Independent review finding resolved: loop goal input could stay stale after session metadata refresh. Fixed in ea9ab8c by syncing refreshed server goal state unless the user has diverged with an in-progress edit.

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🧹 Nitpick comments (1)
app/components/agent-actions.tsx (1)

128-128: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Redundant re-classification on already-filtered state; consider a shared hook.

error can only ever hold a non-transient message (the catch at Lines 113-115 already discards transient errors before calling setError). Re-running isTransientRequestError on the stringified message here is dead weight — isTransientRequestError classifies by error.name === "AbortError" and message regex on the original error object; once stringified, the name check is lost and only the (already-passed) message regex re-runs, so the result can never differ from true.

The same set-then-recheck pattern is duplicated nearly verbatim in teammate-panel.tsx, worktree-management-panel.tsx, agent-create-panel.tsx, and agent-management-panel.tsx. Extracting a small hook (e.g. useActionError() returning { error, visibleError, setError, catchError }) would remove the redundant computation and centralize the classification logic so future changes to transient-error rules don't need updating in five places.

♻️ Sketch of a shared hook
// app/lib/use-action-error.ts
import { useCallback, useState } from "react";
import { isTransientRequestError } from "`@/lib/request-errors`";

export function useActionError() {
  const [error, setErrorState] = useState<string | null>(null);
  const setError = useCallback((e: unknown | null) => {
    if (e === null) return setErrorState(null);
    if (!isTransientRequestError(e)) {
      setErrorState(e instanceof Error ? e.message : String(e));
    }
  }, []);
  return { error, setError };
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/components/agent-actions.tsx` at line 128, Extract the duplicated
transient-error classification into a shared useActionError hook and update
agent-actions.tsx plus the corresponding teammate, worktree, agent-create, and
agent-management panels to use it. Have the hook expose the stored error and
setter/catch behavior, classify the original unknown error before stringifying
it, and remove each component’s redundant visibleError re-check while preserving
null handling and existing display behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/lib/parsed-transcript.ts`:
- Around line 60-95: Update partsFromFlattenedAttachmentText to isolate the
section beginning at the “Attached image files:” header, normalize whitespace
only within that attachment segment, and parse the header plus subsequent
attachment entries without requiring the header for each match. Preserve text
before and after the attachment block, including paragraph breaks, when
constructing HistoryPart[].

In `@src/metadata-server.ts`:
- Around line 2191-2195: Restrict the Access-Control-Allow-Private-Network
response in the metadata server CORS handling to trusted origins or
authenticated requests, rather than enabling it alongside the wildcard origin;
reuse the existing trusted-origin policy if available. Preserve normal CORS
behavior for untrusted requests without returning the PNA header, and add a
regression test covering an untrusted origin.

---

Nitpick comments:
In `@app/components/agent-actions.tsx`:
- Line 128: Extract the duplicated transient-error classification into a shared
useActionError hook and update agent-actions.tsx plus the corresponding
teammate, worktree, agent-create, and agent-management panels to use it. Have
the hook expose the stored error and setter/catch behavior, classify the
original unknown error before stringifying it, and remove each component’s
redundant visibleError re-check while preserving null handling and existing
display behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b46429cd-c79c-4f44-a6a6-65ed25611706

📥 Commits

Reviewing files that changed from the base of the PR and between 4383645 and aef4b97.

📒 Files selected for processing (26)
  • app/components/MessageBlock.tsx
  • app/components/agent-actions.tsx
  • app/components/agent-create-panel.tsx
  • app/components/agent-management-panel.tsx
  • app/components/screens/AgentChatScreen.tsx
  • app/components/service-actions.tsx
  • app/components/teammate-panel.tsx
  • app/components/workflow-actions.tsx
  • app/components/worktree-management-panel.tsx
  • app/lib/desktop-state.ts
  • app/lib/parsed-transcript.test.ts
  • app/lib/parsed-transcript.ts
  • scripts/installed-aimux-shim.sh
  • src/agent-output-parser-audit.test.ts
  • src/agent-output-parser.test.ts
  • src/agent-output-parser.ts
  • src/agent-prompt-delivery.test.ts
  • src/agent-prompt-delivery.ts
  • src/daemon.test.ts
  • src/daemon.ts
  • src/dashboard/index.ts
  • src/installed-shim.test.ts
  • src/main.ts
  • src/metadata-server.test.ts
  • src/metadata-server.ts
  • src/multiplexer/dashboard-model.ts

Comment thread app/lib/parsed-transcript.ts
Comment thread src/metadata-server.ts Outdated
@TraderSamwise
TraderSamwise merged commit 585b92a into master Jul 13, 2026
3 checks passed
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