Repository navigation
mac: drain the helper's stderr on termination, so an abnormal exit says why - #683
Merged
Merged
Conversation
…ys why
Both `LineProcessClient` and `PreviewControllerClient` cleared the stderr
readability handler in the termination handler and then drained stdout only,
so a helper's last words -- the panic message, the failed open -- went out
with the pipe. Every abnormal helper exit in this app has been discarding its
own explanation.
Both now drain stderr the way they already drain stdout, and the controller
carries the last line onto the exit:
helper exited (1): thread 'main' panicked at ...
Every consumer matches on the `helper exited` prefix, so appending a reason
changes no decision; the new test in `PreviewControllerTests` pins that.
This is the Swift half of #659, split out so it can land now: #659 also adds
a `SNAPSHOT_ARTIFACTS` upload step to `.github/workflows/ci.yml`, and the
authenticated token on this machine lacks the `workflow` scope, so the
combined PR cannot be merged here. The CI half stays on #659 for an
operator with that scope. No behaviour in this commit depends on it.
Motivation is immediate: `IMECompositionTests
.testCancelledCompositionLeavesTheHelperAndLedgerUntouched` deterministically
aborts the Mac suite (#681), and that test drives a real helper subprocess.
Whatever the helper is saying as it dies is currently being thrown away.
Implementation-Agent: Claude Opus 5 (orchestrator-astra, linux-primary)
Commit-Executor: Claude Opus 5 via Claude Code (direct-agent Git execution
under the observed-Cursor-limit user override)
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
Two defects in the rebased change, both in PreviewControllerClient: - `maxStderrTailBytes` is named in bytes and the overflow check reads `utf8.count`, but the trim used `String.suffix(n)`, which counts grapheme clusters. A helper logging non-ASCII could hold several times the stated bound. Trim on the UTF-8 view instead; decoding repairs a scalar split at the new start, which is fine for an evidence tail. - The new members were inserted between `deliver`'s doc comment and `deliver`, so the comment had silently become the documentation for `recentStderr`. Implementation-Agent: claude-opus-5 (export-consolidation lane) Commit-Executor: claude-opus-5 direct git (Cursor usage limit) Co-authored-by: GoKubar <[email protected]>
GoKubar
force-pushed
the
agent/astra/helper-stderr-swift
branch
from
September 16, 2026 04:08
da44b28 to
87a0cd7
Compare
`handleController` opens with `guard let controller else { return }`, so inside
the function `controller` is a non-optional `PreviewControllerClient` shadowing
the optional property — which is also why the same block writes `self.controller
= nil` explicitly. The new `recentStderr` reads used `controller?.`, which does
not compile:
error: cannot use optional chaining on non-optional value of type
'PreviewControllerClient'
This was a genuine defect in the change, not (as first thought) a contaminated
worktree: it reproduces on a clean build of the rebased branch at 87a0cd7.
Implementation-Agent: claude-opus-5 (export-consolidation lane)
Commit-Executor: claude-opus-5 direct git (Cursor usage limit)
Co-authored-by: GoKubar <[email protected]>
d-q222
added a commit
that referenced
this pull request
Sep 16, 2026
#659 re-added stderr-tail draining that #683 already merged into main independently. The merge concatenated both insertions with no conflict markers (each patch's context didn't overlap enough for git to flag it), leaving two declarations of the same members -- 'ambiguous use of recentStderr' at the build step. Kept #659's version (UTF-8-safe trim, avoids splitting a multi-byte scalar at the truncation boundary); removed #683's plain grapheme-count .suffix() version, and reattached its orphaned doc comment to deliver(), where it belongs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Split out of #659 so it can land without the
workflowtoken scope.The bug
LineProcessClientandPreviewControllerClientboth cleared the stderr readability handler inside the termination handler and then drained stdout only. A helper's last words — the panic message, the failed open — were discarded along with the pipe. So every abnormal helper exit in this app has been throwing away its own explanation, leaving callers with a barehelper exited (1).Both now drain stderr the way they already drain stdout, and the controller carries the last line onto the exit:
Every consumer matches on the
helper exitedprefix, so appending a reason changes no decision — the new test inPreviewControllerTestspins exactly that, so a future refactor cannot quietly turn the message into a behavioural dependency.Why now
IMECompositionTests.testCancelledCompositionLeavesTheHelperAndLedgerUntoucheddeterministically aborts the Mac suite (#681) — confirmed identical across three unrelated branches, always at that same test, right afterHostedWindowSupportTests.testTheCompletionPopupFollowsItsHostOffScreenpasses. That test drives a real helper subprocess and awaitsholds(...),helperDocument()andhistoryLabels(). Whatever the helper is saying as it dies is currently being thrown away, which is a large part of why the abort has been so hard to characterise.This change does not fix #681. It makes #681 diagnosable.
Relationship to #659
#659 remains open for its other half: a
SNAPSHOT_ARTIFACTSupload step in.github/workflows/ci.ymlplus the.gitignoreentry. The authenticated token on this machine carriesgist, read:org, repobut notworkflow, so GitHub refuses to merge any PR touching.github/workflows/**from here:Nothing in this commit depends on that half. Credit for the original diagnosis and implementation belongs to #659's author; this is the same Swift diff, taken verbatim onto current main.