GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — polish v2: smoothness & delight by anandh8x · Pull Request #484 · Twigpine/zero Conversation
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughAdds error hinting and Gemini OAuth retry wiring, TUI transcript and streaming updates, command and export flows, picker ranking, bash output truncation, agent compaction and guardrail changes, and reconnect/backoff adjustments. ChangesCross-cutting runtime and UI updates
Runtime output and agent control
Estimated code review effort: 4 (Complex) | ~60 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
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 `@internal/errhint/errhint.go`:
- Around line 35-60: The Classify function is matching overly broad substrings,
which can mislabel local failures as provider errors. Tighten the checks in
Classify by either restricting matches to known provider error patterns or
adding a provider-origin gate before returning Auth, RateLimit, ContextOverflow,
ModelNotFound, or Connectivity. Focus on the containsAny cases in Classify and
make sure hints are only attached when the error clearly comes from the
provider.
Fix all unresolved CodeRabbit comments on this PR:
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: e1f5d682-7e37-41a7-8f37-63907617ad0b
internal/errhint/errhint.gointernal/errhint/errhint_test.gointernal/tui/error_hint_test.gointernal/tui/model.gointernal/tui/rendering.gointernal/tui/transcript.go
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
The Gemini provider used providerio.SendWithRetry (429/503/529 only), so an expired OAuth token surfaced as a terminal 'API key not valid' auth error while OpenAI and Anthropic silently recovered via SendWithAuthRetry's force-refresh-and-replay on 401. Plumb OAuthResolver through gemini.Options/Provider and the factory (exactly as the other two providers already do) and switch the stream send to SendWithAuthRetry. With a nil resolver (API-key users) behavior is unchanged.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
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 `@internal/tools/bash.go`:
- Around line 160-181: The bash result handling in Result construction is
dropping truncation state even though budgetBashOutput marks meta["truncated"]
as true. Update the return paths in the bash execution flow in
internal/tools/bash.go so Result.Truncated is set whenever output is truncated,
including both the error and success cases; use the existing budgetBashOutput
and formatBashOutputWithShellHint paths to locate all Result literals and either
copy the meta flag into the struct or have budgetBashOutput return the
truncation boolean directly.
Fix all unresolved CodeRabbit comments on this PR:
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 4cc89ca1-e27c-4c20-8162-b106238a5925
internal/providers/factory.gointernal/providers/gemini/provider.gointernal/providers/gemini/provider_test.gointernal/tools/bash.gointernal/tools/bash_budget_test.go
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Address CodeRabbit review on #1: agentResponseMsg.err can also carry local failures (a tool's 'permission denied', a 'file does not exist', a config error), and broad substrings would have attached a bogus /provider or /model hint to those. Classify now returns Unknown unless the message carries a provider marker the provider layer always attaches (auth error: / rate limit error: / provider error: / provider request error: / provider stream error:). Local errors never draw a provider hint; provider errors sub-classify as before. Added local-failure test cases proving they stay Unknown.
zero exec printed provider failures as a bare '[zero] <raw error>' with no next step. Append a one-line hint (reusing the shared errhint classifier) for recognized provider failures — 'run `zero auth`', 'run `zero doctor`', etc. The provider-origin gate means non-provider codes (sandbox_error, mcp_error) and JSON/stream-json output are untouched.
Address CodeRabbit review on #3: budgetBashOutput recorded truncation in meta["truncated"] but never set the Result.Truncated struct field, so consumers reading the struct (like glob/web_fetch/read_minified do) would miss truncated bash results. Return the bool from budgetBashOutput and set Result.Truncated on every return path.
runAgentWithOptions built a fresh lsp.NewManager per run and shut it down when the run returned, so gopls (and every other language server) cold-started on the first edit of every turn — 200ms-2s of latency the manager's own design (long-lived, reused servers) exists to avoid. Build one manager per session in newModel (cheap: servers start lazily on first Check) and reuse it across runs; the SelfCorrector still gets a fresh checker wrapping the shared manager each run. Torn down with a short deadline in quit(). Runs fall back to a per-run manager when the session manager is absent (cwd unknown, or a directly-built test model).
m.streamingText += msg.delta was O(len) per delta -> O(n²) across a long generation (a 10k-token code gen allocates hundreds of MB of intermediate strings and the UI gets progressively laggier). Accumulate into a []byte with append (O(1) amortized) and read via streamingTextString(). A []byte rather than strings.Builder because the TUI model is copied by value on every Update, which would trip strings.Builder's copy check; []byte is nil-safe and copies cleanly like the other slice fields.
Every OnText delta was its own tea.Msg, so a fast provider (100+ tok/s) drove 100+ full Update->View cycles per second, each re-parsing the growing markdown — visible stutter over SSH and wasted CPU. Batch agentTextMsg deltas at the runtime sink over a ~16ms frame and forward them as a single message, decoupling render rate from token rate. Any non-text message flushes pending text first so ordering with tool-call / reasoning / row messages is preserved; the final agentResponseMsg (a tea.Cmd return, not a sink message) is safe because the model already drops deltas for an inactive runID.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
internal/tui/model.go (1)
268-274: 🚀 Performance & Scalability | 🔵 Trivial | 🏗️ Heavy liftConsider applying the same byte-buffer treatment to
streamingReasoning.
streamingReasoning(line 274) still accumulates via+=on a plainstring(seeagentReasoningMsghandling), which reintroduces the exact O(n²) growth pattern this PR just eliminated forstreamingText. Long chain-of-thought traces from reasoning-heavy models could hit the same wall-time overhead this cohort is meant to fix.♻️ Sketch of the same pattern applied to reasoning
- streamingReasoning string // live provider reasoning for the current segment + streamingReasoning []byte // live provider reasoning for the current segment; see streamingReasoningString()Not blocking this PR, but worth a follow-up given the precedent just set here.
🤖 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 `@internal/tui/model.go` around lines 268 - 274, The `streamingReasoning` field in `internal/tui/model.go` still grows via repeated string concatenation in the `agentReasoningMsg` flow, which brings back the same O(n²) accumulation problem already fixed for `streamingText`. Apply the same byte-buffer approach used for `streamingText`: change `streamingReasoning` to a `[]byte`, add a helper for reading it back as a string, and update the reasoning append path to append bytes instead of using `+=`. Use the existing `streamingText`/`streamingTextString()` pattern as the reference for where to wire this in.internal/tui/coalesce_test.go (1)
37-44: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winPotential CI flakiness: the "still buffered" assertion depends on wall-clock timing.
sendarms a real 16mstime.AfterFuncon the first delta. Line 42'slen(got) != 0check assumes the timer hasn't fired yet — usually true, but a GC/scheduler stall >16ms between the sends andsnapshot()will flush early and fail the assertion nondeterministically. Consider making the coalesce interval injectable (or the timer a test seam) so this path is deterministic.🤖 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 `@internal/tui/coalesce_test.go` around lines 37 - 44, The coalescing test in coalesce_test.go is timing-dependent because agentTextMsg buffering in send() relies on a real time.AfterFunc, so the “still buffered” assertion can fail nondeterministically. Make the coalesce interval or timer behavior injectable through the coalescer/send path and use that test seam in the test so the snapshot assertion is deterministic. Reference the send method and the buffered-delta assertion in the coalesce test when wiring the fix.
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 `@internal/tui/coalesce.go`:
- Around line 41-80: The forwarding path in textCoalescer can race because send
and flush both drain under c.mu but call c.forward after unlocking, allowing
buffered text to overtake a concurrent non-text message. Update
textCoalescer.send and textCoalescer.flush to serialize all forward calls with a
separate lock or equivalent ordering guard, and apply it around the
drain+forward flow so agentTextMsg output from the timer or run switch cannot be
delivered after the intervening non-text msg.
---
Nitpick comments:
In `@internal/tui/coalesce_test.go`:
- Around line 37-44: The coalescing test in coalesce_test.go is timing-dependent
because agentTextMsg buffering in send() relies on a real time.AfterFunc, so the
“still buffered” assertion can fail nondeterministically. Make the coalesce
interval or timer behavior injectable through the coalescer/send path and use
that test seam in the test so the snapshot assertion is deterministic. Reference
the send method and the buffered-delta assertion in the coalesce test when
wiring the fix.
In `@internal/tui/model.go`:
- Around line 268-274: The `streamingReasoning` field in `internal/tui/model.go`
still grows via repeated string concatenation in the `agentReasoningMsg` flow,
which brings back the same O(n²) accumulation problem already fixed for
`streamingText`. Apply the same byte-buffer approach used for `streamingText`:
change `streamingReasoning` to a `[]byte`, add a helper for reading it back as a
string, and update the reasoning append path to append bytes instead of using
`+=`. Use the existing `streamingText`/`streamingTextString()` pattern as the
reference for where to wire this in.
Fix all unresolved CodeRabbit comments on this PR:
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: f493d773-b06e-4728-a786-91a3af324212
internal/tui/coalesce.gointernal/tui/coalesce_test.gointernal/tui/flush_test.gointernal/tui/model.gointernal/tui/model_test.gointernal/tui/rendering_lime_test.gointernal/tui/run.gointernal/tui/syntax_highlight_test.gointernal/tui/transcript_selection.gointernal/tui/working_status_test.go
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
guardrails.go halted a run after 4 consecutive same-error tool failures. A corrective hint fires at 2, and a model iterating on a genuinely tricky edit can legitimately fail a couple more times after the hint while converging — stopping at 4 cut those runs short. Raise to 6; the streak still resets the instant the tool succeeds or hits a different error, so only true same-error loops are affected.
…rrors #19: bump maxStreamReconnects 2->4 and add up-to-50% jitter on the exponential backoff (capped at 8s), so a multi-second network blip is ridden out instead of killing the run on a 2s hiccup, and concurrent runs (swarms, cron fleets) don't reconnect in lockstep. #34: drop the '502'/'503' substring matches from shouldReconnect. 503 already exhausted providerio.SendWithRetry (retrying here is a redundant double-retry) and 502 is non-idempotent by providerio's rule (the POST may have been processed). Only genuine transport failures — where no response was received — reconnect now.
A no-output stream stall is detected only after the full stream idle timeout (~5min) elapses, and each retry can idle again — so 2 retries left an interactive session frozen for ~15min. Drop to 1 retry: keeps the common single-hiccup recovery while bounding the worst case to ~2x the idle timeout.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
internal/agent/reconnect.go (1)
110-129: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winBlock HTTP 504 before the generic timeout match.
Line 112 says 504 must not be retried, but Line 123 still makes
"504 Gateway Timeout"reconnectable via"timeout". Add an HTTP-status guard before the transport substring loop, then update the test expectation.Proposed fix
msg := strings.ToLower(err.Error()) if isContextLimitError(msg) || isImageRejectionError(err) { return false } + for _, needle := range []string{ + "500 internal server error", + "502 bad gateway", + "503 service unavailable", + "504 gateway timeout", + "http 500", + "http 502", + "http 503", + "http 504", + "status 500", + "status 502", + "status 503", + "status 504", + } { + if strings.Contains(msg, needle) { + return false + } + } // Transport-level disconnects only. HTTP 5xx statuses are deliberately NOT🤖 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 `@internal/agent/reconnect.go` around lines 110 - 129, Block HTTP 504 explicitly before the transport substring checks in reconnect logic, since the generic timeout match in the reconnect matcher can still incorrectly treat “504 Gateway Timeout” as reconnectable. Update the reconnect decision path in the reconnect helper so it short-circuits on 504 before the substring loop in the function that scans the needles, then adjust the associated test expectations to assert 504 is not retried.
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@internal/agent/reconnect.go`:
- Around line 110-129: Block HTTP 504 explicitly before the transport substring
checks in reconnect logic, since the generic timeout match in the reconnect
matcher can still incorrectly treat “504 Gateway Timeout” as reconnectable.
Update the reconnect decision path in the reconnect helper so it short-circuits
on 504 before the substring loop in the function that scans the needles, then
adjust the associated test expectations to assert 504 is not retried.
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 05be15ad-178a-4e8c-91e1-e96681c6b673
internal/agent/guardrails.gointernal/agent/reconnect.gointernal/agent/reconnect_test.go
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Address CodeRabbit review on #7: flush() and the run-switch path drained the text buffer under c.mu but called forward() after releasing it, so a timer-fired text flush could race a concurrent non-text send() and land after the tool-call/reasoning message it should precede. Hold c.mu across drain AND forward (drainAndForwardLocked), so whoever holds the lock delivers atomically and the other caller blocks until it is done — text can never overtake a following non-text message. Added a concurrency stress test (timer racing an inline send) that passes under -race.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Went through all ten commits and they hold up. Each one's a real thing: bash was the only tool without an output cap, Gemini was the only OAuth provider that couldn't refresh an expired token (you'd get a dead "API key not valid" while OpenAI/Anthropic silently retry), streamingText really was doing O(n²) string appends, and the per-run LSP manager cold-started gopls on the first edit of every prompt. One commit per item, each with a test, so it's easy to reason about.
A few small things, none blocking:
forward() outside the mutex, so in theory the flush timer and a non-text emit can reorder and render a trailing narration fragment after the tool card it should sit before. The window is nanoseconds wide and the committed transcript comes from result.FinalAnswer, not the streamed buffer, so it's cosmetic — worth a code comment, not worth holding this.Approving — good pass.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Bare /compact already triggers compaction, but /compact now — what users reach for when the context gauge climbs — hit the usage-error branch. Accept the 'now' keyword and advertise it in the command usage.
/retry resends the last prompt; /edit recalls it into the composer to tweak and resend — both read a new lastPrompt field captured verbatim (pre-expansion) in launchPrompt. /copy puts the last answer on the clipboard via the existing copy machinery; /export writes a plain role-prefixed transcript to a file (timestamped default, or a given path). Real gaps for SSH users with no mouse select.
tool_search ranked deferred tools by exact substring, so a model that
typed 'webfetch' (dropping the underscore) matched nothing and looped.
Add a separator-squashing fallback ('web_fetch' -> 'webfetch') scored
below an exact substring match, so precise queries still rank first.
# Conflicts: # internal/tui/commands.go
Empty answers all rendered as '(no answer provided)', so the model couldn't tell a wholesale dismissal (user closed the prompt without answering anything) from one field left blank amid real answers — and might invent a default. FormatAskUserAnswers now flags a full dismissal up front as a skip and marks individual empties '(left blank)' vs '(skipped)'.
The pickers filtered by flat strings.Contains with no ranking, so finding 'sonnet 4.5' among 50+ models meant an exact prefix or scrolling. Rank matches (exact < prefix < contains < subsequence, reusing fuzzySubsequenceGap) so the closest match lands on top, and 'snt45' now matches 'Sonnet 4.5'. Groups stay contiguous — ordered by their best match, never split — so the grouped model picker still renders one header per provider. Covers both /model and /resume (shared commandPicker).
partitionTools re-ran the recursive schema->map conversion (schemaToRuntimeMap) for every tool on every turn — redundant, since a tool's advertised name/description/schema is stable for the run. Add a per-run definition cache keyed by tool name (nil-safe; the plain partitionTools entrypoint and tests pass nil for fresh renders). The partitioning itself (visibility, deferral, ordering) still recomputes every turn — it must, because a tool's deferred state can flip mid-run (swarm tools un-defer once a swarm is active). Only the expensive schema render is memoized. tool_search is excluded by its callers (dynamic description) so it never poisons the cache.
The byte/4 heuristic (ApproxTextTokens) over-counts code-heavy content ~15-20%, so with triggerRatio=0.7 compaction fired at ~60% of true capacity — premature summarizer calls that degrade quality. Each turn now folds (rawEstimate, provider InputTokens) into an EMA calibration ratio, clamped per-sample to a sane band; maybeCompact and the reactive path scale their estimates by it. Turn 1 uses the raw estimate (no data yet); later turns compact near real capacity.
os.WriteFile ignores Unix permission bits on Windows and Stat reports 0666, so the 0o600 assertion failed there. The production 0o600 is honored on Linux/macOS (where it matters); guard the check with runtime.GOOS so Windows smoke passes.
|
@coderabbitai review the commits that u havent checked before |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
✅ Action performedReview finished.
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Zero automated PR reviewVerdict: No blockers found Blockers
Validation
ScopeHead: This deterministic review checks validation status and basic diff hygiene. A human reviewer still owns product judgment and design quality. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
internal/tui/image_attach.go (1)
302-313: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winMinor grammar: "1 staged image(s)" reads awkwardly for singular count.
When exactly one image is staged, the message renders as
⚠ 1 staged image(s) will be dropped — ..., which looks like unfinished pluralization logic in a user-facing warning.✏️ Optional pluralization fix
func (m model) visionDropWarning() string { if len(m.pendingImages) == 0 || m.modelSupportsVisionTUI() { return "" } + noun := "images" + if len(m.pendingImages) == 1 { + noun = "image" + } - return fmt.Sprintf("⚠ %d staged image(s) will be dropped — %s has no vision support.", - len(m.pendingImages), displayValue(m.modelName, "the active model")) + return fmt.Sprintf("⚠ %d staged %s will be dropped — %s has no vision support.", + len(m.pendingImages), noun, displayValue(m.modelName, "the active model")) }🤖 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 `@internal/tui/image_attach.go` around lines 302 - 313, The warning text in visionDropWarning uses awkward pluralization for a single staged image, so update the message formatting to choose singular vs plural based on len(m.pendingImages). Keep the existing logic in model.visionDropWarning and displayValue, but change the user-facing string so it renders naturally for 1 image and multiple images without “image(s)”.
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 `@internal/tui/session.go`:
- Around line 394-401: Windows workspace matching should not fail when the same
path differs only by casing. Update sessionMatchesWorkspace to compare the
cleaned sessionCwd and workspaceCwd case-insensitively on Windows, or normalize
the stored cwd in the session creation path so both values use the same casing
before matching. Use the sessionMatchesWorkspace helper and the cwd values set
from options.Cwd/os.Getwd() to locate the fix.
- Around line 374-388: The latest resumable session shortcut is too permissive
because latestResumableInWorkspace() only checks workspace membership and can
return entries that newSessionPicker() would hide. Update
latestResumableInWorkspace() in model to apply the same resumable filters used
by the picker, skipping zero-event and empty/failed runs before returning a
match, so /resume latest stays aligned with the picker behavior.
---
Nitpick comments:
In `@internal/tui/image_attach.go`:
- Around line 302-313: The warning text in visionDropWarning uses awkward
pluralization for a single staged image, so update the message formatting to
choose singular vs plural based on len(m.pendingImages). Keep the existing logic
in model.visionDropWarning and displayValue, but change the user-facing string
so it renders naturally for 1 image and multiple images without “image(s)”.
Fix all unresolved CodeRabbit comments on this PR:
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: afe4ca59-9ec0-4322-aa9e-6c02e08a06eb
internal/agent/loop.gointernal/errhint/errhint.gointernal/errhint/errhint_test.gointernal/tools/bash.gointernal/tui/command_center.gointernal/tui/image_attach.gointernal/tui/model.gointernal/tui/onboarding.gointernal/tui/onboarding_affordance_test.gointernal/tui/resume_scope_test.gointernal/tui/retry_edit_test.gointernal/tui/session.gointernal/tui/transcript_export.gointernal/tui/transcript_export_test.gointernal/tui/vision_drop_test.go
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
…atch on Windows Address CodeRabbit review on #21: - latestResumableInWorkspace now applies the SAME filters as the picker (skip zero-event metadata and empty/failed runs), so /resume latest can't land on a session the picker intentionally hides. - sessionMatchesWorkspace compares paths case-insensitively on Windows (its filesystem is), so the same workspace spelled with different casing no longer hides resumable sessions; other platforms stay case-sensitive.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I found issues that need to be addressed before this is ready.
[P2] Preserve attachments when retrying the previous prompt
internal/tui/model.go:3952
/retry now relaunches only m.lastPrompt, but lastPrompt stores just the text while the original submit path consumes PDF text (consumePendingDocuments) and passes staged images via turnImages before clearing both attachment queues. If a vision or document-backed prompt fails and the user runs /retry, the retried request silently loses the image/PDF context even though the command is documented as resending the last prompt, so the model answers a different task. Please carry the submitted attachments/document preamble with the remembered prompt, or make /retry refuse/clearly warn when the last prompt depended on attachments.
[P3] Complete CodeRabbit's request to update the OAuthResolver provider comment
internal/providers/factory.go:27
CodeRabbit's earlier request is still valid: this comment says OAuthResolver is applied only to OpenAI and Anthropic, but the current factory also passes it to gemini.New in the Google provider branch. Since this PR is specifically adding Gemini OAuth retry wiring, please update the provider-factory documentation so future auth work does not rely on a stale provider boundary.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
/retry relaunched only lastPrompt's text, but launchPrompt clears the pending image/document queues once a turn is sent. A vision- or PDF-backed prompt that failed would silently retry as text-only and answer a different task. Snapshot the consumed attachments at launch and re-stage them on /retry so launchPrompt rebuilds an identical request (document preamble, images, and the submit-time vision re-check). startNewSession drops the snapshot so a post-/new /retry cannot leak the previous session's attachments. Also correct the OAuthResolver factory comment, which omitted the Gemini provider it is now passed to.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates. I rechecked the changed paths and found issues that still need to be addressed.
[P2] Complete CodeRabbit's request to keep 504 out of reconnect retries
internal/agent/reconnect.go:123
CodeRabbit's 504 reconnect concern is still valid on the current head. The new reconnect comment says HTTP 500/502/504 responses are non-idempotent and must not be replayed because the completion POST may already have been processed, but shouldReconnect still matches the generic "timeout" substring, so an error like 504 Gateway Timeout returns true and reissues the same completion request. Please add an explicit HTTP-status guard before the transport substring loop and update TestShouldReconnectClassification so 504 stays non-reconnectable.
[P2] Preserve attachments when editing and resending the previous prompt
internal/tui/model.go:3974
The /edit command recalls only m.lastPrompt into the composer, while the image/PDF snapshot captured for that same last prompt is left out of the pending attachment queues. After a vision or document-backed prompt, /retry now correctly re-stages m.lastImages/m.lastDocuments, but /edit followed by Enter silently sends a text-only version of the edited prompt. That makes the documented "edit and resend" flow answer a different task whenever the original prompt depended on attachments. Please either re-stage/show the remembered attachments for /edit, or warn/refuse when the previous prompt had attachments that cannot be carried through the edit flow.
[P2] Keep recently re-edited files in the preserved edit summary
internal/agent/compaction_preserve.go:462
The recent-edit preservation cap can drop a file that was just edited again. recentEdits records path order only the first time a file appears, mergeSkillEntries keeps an older preserved path in its old position even when a fresh edit updates its note, and capRecentEdits then keeps only the tail of that old order. In a long editing session, once more than 20 distinct files are tracked, re-editing an early file can still leave it outside the capped tail, so the next compaction omits exactly the file the model most recently touched. Please move paths to the newest position when a fresh edit arrives, and add a regression covering a capped list where an old path is edited again.
[P3] Complete CodeRabbit's request to make the coalescer batching test deterministic
internal/tui/coalesce_test.go:41
The test still starts the real 16ms time.AfterFunc and then asserts that nothing has been forwarded before the manual c.flush(). If the scheduler or GC pauses the test goroutine for longer than that interval between the sends and the snapshot, the timer goroutine can legally flush the buffered text first and make this test fail nondeterministically. Please add a test seam for the coalescer interval/timer or otherwise structure this assertion so it does not depend on beating a wall-clock timer.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…, coalescer test) - reconnect: exclude HTTP 5xx (500/502/503/504) before the transport substring match so "504 Gateway Timeout" no longer slips through on the generic "timeout" needle. A gateway timeout is non-idempotent — the completion POST may already have reached the model — so replaying the connect risked duplicate billable work. Reuses a digit-boundary status matcher exported from errhint (HasStatusCode). Test asserts 504/500 stay non-reconnectable. - tui /edit: re-stage the remembered image/PDF snapshot alongside the recalled prompt text, mirroring the /retry fix — editing a vision- or document-backed prompt no longer silently resends a text-only version. - compaction recent-edits: order edits by LAST edit, not first, and move a re-touched path to the newest position on merge, so the maxRecentEdits tail cap keeps the file the model most recently edited instead of dropping it. Adds mergeRecentEdits (edit-specific) and a capped-list regression. - coalescer test: inject the frame timer via afterFunc so TestCoalescerBatchesDeltas proves buffering deterministically instead of racing the real 16ms wall-clock timer.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates. I rechecked the changed paths and found an issue that still needs to be addressed.
internal/tools/bash.go:127exec.Cmd has already written all stdout/stderr into unbounded bytes.Buffers and after both buffers are converted to strings. A command like cat on a huge file can still grow the Zero process until it stalls or OOMs before budgetBashOutput ever runs, even though the PR description says bash stdout/stderr are capped. Please cap the capture writer or stream through a bounded buffer before handing stdout/stderr to the formatter, so the tool is protected from large output as well as from large model-visible output.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…le text Previously stdout/stderr streamed into unbounded bytes.Buffers and were only truncated to the 96 KiB budget AFTER the command finished, so a runaway command (cat huge.log, yes) could grow Zero's memory until it stalled or OOMed before budgetBashOutput ever ran. Replace the capture with boundedBuffer, an io.Writer that keeps only the head+tail each stream will surface and discards the middle as it arrives, while counting the true total for the truncation marker. Memory is now bounded to ~head+2×tail per stream regardless of output size. truncateHeadTail is refactored onto a total-aware core so the string path (and its tests) are unchanged, and budgetBashCapture reports the true raw_bytes even though only a bounded slice was held. Adds boundedBuffer/capture unit tests and an end-to-end test that streams ~5× the budget and asserts bounded emission with an accurate raw_bytes.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates. I rechecked the previously discussed paths and do not see any remaining actionable issues from my side.
@Vasanthdev2004 LGTM
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Re-approving after the latest round (my earlier approval went stale on the new pushes).
I did an independent pass over the parts that worried me most — the core-loop changes where green CI and unit tests can still hide a hang, a leak, or dropped output. All of it holds up:
[]byte accumulator is copy-on-read, no aliasing.[0.5, 2.0], so a bad turn can't push compaction to fire way early or never; the preserved recent-edits block is hard-capped (20 paths, short notes) with no bypass.#34's narrowing doesn't strand a recoverable stream, and the 4→6 tool-failure stop has no off-by-one.quit(), and cwd is process-fixed so /new and /resume don't point it at the wrong root.On the whole PR: it's a lot to land at once (55 files), but it's the right kind of a lot — every item is its own commit with its own tests, each is a real wall-time or UX win rather than churn, and it's already been through three rounds with jatmn. Worth merging.
One coordination note: the bash output cap here (#3) covers the same ground as #492, so that one can be closed or folded once this lands.
Can't merge it myself — over to kevin.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM — approving. Ran an independent regression pass on top of the existing reviews.
Local gate (checked out polish/v2-smoothness):
go build ./... ✅ · go vet ./... ✅ · gofmt -l clean ✅go test ./... -race → 74 packages, 0 failures, 0 races ✅Deep-dived the streaming coalescer (internal/tui/coalesce.go) since it's the one item with new concurrency + a 16ms buffer. Traced the worst case — the final ≤16ms text batch losing the race to agentResponseMsg and getting dropped as a stale-run delta — and confirmed it's safe: on the success path the final answer is committed from the runtime's complete final rowAssistant in msg.rows, which supersedes the streamed streamingText, so a dropped tail only affects the last live frame. The error path keeps streamingText as a best-effort partial, where a 16ms truncation is immaterial. The mutex-held-across-forward design also correctly prevents streamed text from reordering around non-text (tool/reasoning) messages. The "harmless late flush" comment holds.
Everything else: the reconnect narrowing (502/503/504) and the bash memory-bound cap — the P2s from the earlier rounds — are addressed, and the full race suite passing gives me confidence the core-loop changes are clean. One-commit-per-item plus near-total test coverage made this easy to reason about despite the size.
Nothing blocking from me. The two remaining CodeRabbit inline notes (errhint.go:81, bash.go:181) are minor quick-wins — optional.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.