Skip to content

fix(sentry): restore guards lost in the main reset and quiet expected poll failures - #1311

Open
pedramamini wants to merge 2 commits into
mainfrom
fix/sentry-main-restore-lost-guards-poll-noise
Open

fix(sentry): restore guards lost in the main reset and quiet expected poll failures#1311
pedramamini wants to merge 2 commits into
mainfrom
fix/sentry-main-restore-lost-guards-poll-noise

Conversation

@pedramamini

@pedramamini pedramamini commented Jul 26, 2026

Copy link
Copy Markdown
Collaborator

Field-crash triage against the channel:stable (main) population on release 0.17.3.

The headline finding: two merged PRs are no longer on main

main was reset after the accidental rc promotion (see the ci(guard): block the rc line from reaching main commits). That reset also took two legitimately-merged main-line PRs with it:

PR Merge commit Reachable from origin/main?
#1213 dbc371eb2 no
#1246 fab1daae2 no

Both still show MERGED on GitHub, so the issues they closed looked handled while the code was gone. Confirmed against the source: sentryFilters.ts had only the EPIPE: broken pipe spelling, stats.ts had the isReady() guard on record-shortcut-usage only, and isExpectedGroomingFailure did not exist. All three issues are live again on 0.17.3.

Both PRs are restored here byte-for-byte (git apply of their own diffs, plus cherry-pick of the 6d3d22766 regex follow-up) so the eventual rc -> main merge converges without conflict.

Restored

  • MAESTRO-1G (29 events/14d) - the filter only matched the libuv fs spelling EPIPE: broken pipe; Node emits a bare write EPIPE for stream/socket writes to a dead pipe, so the rule never fired.
  • MAESTRO-2S / MAESTRO-2Z - stats:record-session-created / -closed threw Database not initialized when an agent was restored on boot ahead of the stats DB. Both callers are fire-and-forget and ignore the return value.
  • MAESTRO-V5 - sessions:setMany / setAll EACCES on maestro-sessions.json.
  • MAESTRO-KA - isExpectedGroomingFailure() for the group-chat groom path, including the follow-up that scopes the regex to Agent ... is not available.

New this round

  • MAESTRO-JS (53 occ) and MAESTRO-K7 - extend isExpectedGroomingFailure() to cover a groom process that would not launch (context-groomer.ts:393, reached from groupChat.ts) and revoked provider credentials. Both are user-environment conditions that resetContext already recovers from by starting a fresh session. Only the group-chat call site suppresses - the user-initiated groom paths in context.ts and director-notes.ts still surface, as in fix(sentry): don't report expected group-chat grooming failures (MAESTRO-KA) #1246.
  • MAESTRO-RR (478 occ - the noisiest app-code issue on stable) - the codex quota sampler carved out 401/403 but still reported http 503. The sampler runs on a timer, so a single ChatGPT outage reports once per tick per install. Now skips 408/429/5xx as well; a 4xx implying we sent a malformed request still reports, because that would be our bug.
  • MAESTRO-KE (70 occ) - isGitHubConnectivityError matched socket-level failures but not GitHub-side 5xx, so HTTP 504: 504 Gateway Timeout (https://api.github.com/graphql) paged Sentry on every Cue poll tick for the duration of a GitHub outage. The poller already retries on its own schedule.
  • MAESTRO-W9 - the getGlobalStats incremental loops report EACCES on transcripts under ~/.claude/projects that belong to the agent CLI and that we merely discovered on disk. Extends the existing RangeError carve-out to expected fs error codes, mirroring EXPECTED_FS_ERROR_CODES in shared-history-manager.ts.

Deliberately not touched

  • MAESTRO-RS (616 events, the largest) - GLIBC_2.38 for better-sqlite3. Build/CI glibc target, not app code. rc PR ci(release): build Linux x64 on ubuntu-22.04 and guard the glibc floor #1290 (build Linux x64 on ubuntu-22.04 and guard the glibc floor) is the real fix.
  • MAESTRO-BC (326 events) and its cascade W2/W7/WA/WB/W6 - Preload script error is a corrupt install (dist\main\preload.js not found in ...app.asar); window.maestro is then undefined and every unguarded call site throws. Optional chaining would mask a broken install across ~40 call sites.
  • MAESTRO-TX / W1 / WP - tagged channel:stable but their release is the Electron version (41.6.0) and the paths are AppData\Roaming\Electron, i.e. unpackaged dev runs, not the stable release line. TX and W1 are already fixed on rc in fix(sentry): stop paging on expected sidecar, bridge, and signal conditions #1247.
  • MAESTRO-CT / NM - spawn codex ENOENT with no app frames in the stack. Genuine spawn failures are real signal.
  • MAESTRO-Q2 - deferred for the fifth time; still needs a human call on maestro-p exit semantics.
  • Native/GPU crashes (SG/1F/QG/4V/9K/5A/TF/RD/VX/23/T2/1J/XQ/MA/WN/SA/62).

Validation

  • 27 regression tests added, each verified to fail against the unfixed source (git stash push of the source files only, re-run, 27 red, restore, 206 green).
  • The pre-existing codex sampler test asserting HTTP 500 is reported was intentionally retargeted to 400, since 5xx is now an expected upstream condition.
  • npm run lint: 112 errors, identical to clean main (missing @codemirror/lang-* optional deps); zero in any changed file.
  • Full suite: 59 failing files with these changes vs 60 on clean main - no new failures.

Summary by CodeRabbit

  • Bug Fixes
    • Reduced unnecessary error/telemetry reporting during expected upstream outages, GitHub 5xx/connectivity issues, session transcript read failures, and known grooming failures.
    • Improved handling of broken-pipe (EPIPE) and permission-related background errors to avoid false alarms.
    • Prevented session statistics updates from failing when the stats database isn’t ready at startup.
  • Tests
    • Expanded automated coverage for expected-error filtering, IPC/session grooming classification, and early-start database readiness behavior.

… poll failures

`main` was reset after the accidental rc promotion, which took PR #1213 and
PR #1246 with it - their merge commits are no longer reachable, so three
already-fixed field issues went live again on 0.17.3. Restores both byte-for-byte
so the eventual rc->main merge converges, then addresses the remaining stable-channel
noise.

Restored (regressed off main):

- MAESTRO-1G (29 events/14d): `shouldDropSentryEvent` only matched the libuv fs
  spelling `EPIPE: broken pipe`. Node emits a bare `write EPIPE` for stream and
  socket writes to a dead pipe, so the rule never fired.
- MAESTRO-2S / MAESTRO-2Z: `stats:record-session-created` and `-closed` threw
  "Database not initialized" when an agent was restored on boot ahead of the
  stats DB. Both callers are fire-and-forget and ignore the return.
- MAESTRO-V5: `sessions:setMany` / `setAll` EACCES on maestro-sessions.json.
- MAESTRO-KA: `isExpectedGroomingFailure()` for the group-chat groom path,
  including the follow-up that scopes the regex to `Agent ... is not available`.

New:

- MAESTRO-JS (53 occ) and MAESTRO-K7: extend `isExpectedGroomingFailure()` to
  cover a groom process that would not launch and revoked provider credentials.
  Both are user-environment conditions that `resetContext` already recovers from
  by starting a fresh session. Only the group-chat call site suppresses; the
  user-initiated groom paths in context.ts and director-notes.ts still surface.
- MAESTRO-RR (478 occ, the noisiest app-code issue on stable): the codex quota
  sampler carved out 401/403 but still reported `http 503`. The sampler runs on a
  timer, so one ChatGPT outage reports once per tick per install. Skip 408/429/5xx
  too; a 4xx that implies we sent a malformed request still reports.
- MAESTRO-KE (70 occ): `isGitHubConnectivityError` missed GitHub-side 5xx, so
  `HTTP 504: Gateway Timeout` paged Sentry on every Cue poll tick during a GitHub
  outage. The poller already retries on its own schedule.
- MAESTRO-W9: the getGlobalStats incremental loops report EACCES on transcripts
  under ~/.claude that the agent CLI owns and we merely discovered. Extends the
  existing RangeError carve-out to expected fs error codes.

Adds 27 regression tests, each verified to fail against the unfixed source.
Copilot AI review requested due to automatic review settings July 26, 2026 14:22
@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR expands expected-error classification across Codex usage sampling, GitHub polling, session parsing, grooming, stats initialization, and shared Sentry filters, with tests covering suppressed and reportable error paths.

Changes

Expected upstream failures

Layer / File(s) Summary
Upstream status classification
src/main/agents/codex-usage-sampler.ts, src/main/cue/cue-github-poller.ts, src/__tests__/main/agents/codex-usage-sampler.test.ts, src/__tests__/main/cue/cue-github-poller.test.ts
Codex 408, 429, and 5xx responses and GitHub API 5xx failures are excluded from Sentry reporting, while HTTP 400 remains reportable. Tests cover both paths.

IPC error handling

Layer / File(s) Summary
Session and grooming error classification
src/main/ipc/handlers/agentSessions.ts, src/main/ipc/handlers/groupChat.ts, src/__tests__/main/ipc/handlers/agentSessions.test.ts, src/__tests__/main/ipc/handlers/groupChat.test.ts
Expected filesystem session-read and grooming failures now log or follow fallback handling without Sentry capture; unexpected failures remain reportable. Helper classification tests cover expected, unexpected, and non-Error inputs.

Startup and shared filtering

Layer / File(s) Summary
Stats startup guards
src/main/ipc/handlers/stats.ts, src/__tests__/main/ipc/handlers/stats.test.ts
Session-created and session-closed stats handlers return early when the database is not ready and avoid database writes and broadcasts.
Sentry filter expansion
src/shared/sentryFilters.ts, src/__tests__/shared/sentryFilters.test.ts
Bare stream/socket EPIPE errors and selected sessions persistence permission errors are suppressed, while unrelated sessions:setMany failures remain unsuppressed.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

Suggested reviewers: copilot, reachrazamair

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 77.78% 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 accurately summarizes the main change: restoring Sentry guards and suppressing expected polling failures after the reset.
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/sentry-main-restore-lost-guards-poll-noise

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.

❤️ Share

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

@greptile-apps

greptile-apps Bot commented Jul 26, 2026

Copy link
Copy Markdown

Greptile Summary

Restores readiness and expected-error guards while reducing Sentry noise from recoverable environment and upstream failures.

  • Skips session lifecycle writes while the stats database is unavailable.
  • Suppresses expected grooming, transcript filesystem, quota endpoint, GitHub outage, broken-pipe, and session persistence errors.
  • Adds focused regression coverage for each restored or expanded classification.

Confidence Score: 5/5

The PR appears safe to merge, with the new guards preserving existing recovery behavior and focused tests covering the expanded classifications.

The changes primarily narrow telemetry reporting for explicitly recoverable conditions, while unexpected errors continue through existing reporting paths and operational retries or fallbacks remain intact.

Important Files Changed

Filename Overview
src/main/ipc/handlers/groupChat.ts Classifies known recoverable grooming failures while preserving fresh-session fallback behavior and reporting unmatched faults.
src/main/ipc/handlers/stats.ts Adds readiness guards to fire-and-forget session lifecycle handlers, consistent with the existing shortcut analytics guard.
src/main/ipc/handlers/agentSessions.ts Avoids reporting expected transcript filesystem failures while continuing incremental aggregation.
src/main/cue/cue-github-poller.ts Treats GitHub HTTP 5xx responses as retryable connectivity failures without changing polling behavior.
src/main/agents/codex-usage-sampler.ts Suppresses telemetry for throttling, timeout, and upstream server statuses while retaining error snapshots for consumers.
src/shared/sentryFilters.ts Extends narrowly scoped filters for Node EPIPE spellings and expected session persistence permission failures.

Reviews (1): Last reviewed commit: "fix(sentry): restore guards lost in the ..." | Re-trigger Greptile

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR restores and extends Sentry-noise guards that were lost during a main reset, and adds additional filtering for known expected, user-environment failures so stable-channel crash triage reflects actionable defects.

Changes:

  • Expand Sentry drop filters for common broken-pipe (write/read EPIPE) and IPC persistence permission (EACCES) noise.
  • Guard stats IPC “record session created/closed” writes during early startup when the stats DB is not ready.
  • Suppress expected operational failures from group-chat grooming, Codex usage sampling, GitHub Cue polling, and global transcript scans, with targeted regression tests.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/shared/sentryFilters.ts Broaden Sentry noise filtering for EPIPE variants and IPC write EACCES cases.
src/main/ipc/handlers/stats.ts Skip fire-and-forget lifecycle stats writes when the stats DB is not initialized yet.
src/main/ipc/handlers/groupChat.ts Centralize “expected grooming failures” predicate and use it to avoid Sentry reporting in resetContext recovery.
src/main/ipc/handlers/agentSessions.ts Treat expected filesystem read failures during transcript scans as non-Sentry noise while keeping local warnings.
src/main/cue/cue-github-poller.ts Treat GitHub-side HTTP 5xx as connectivity noise for Cue polling.
src/main/agents/codex-usage-sampler.ts Treat throttling/degraded-upstream HTTP statuses as expected for periodic quota sampling.
src/tests/shared/sentryFilters.test.ts Add regression tests for EPIPE stream spelling and sessions:setMany EACCES filtering.
src/tests/main/ipc/handlers/stats.test.ts Add coverage for stats lifecycle handlers skipping when DB is not ready.
src/tests/main/ipc/handlers/groupChat.test.ts Add coverage for the expanded expected grooming failure predicate.
src/tests/main/ipc/handlers/agentSessions.test.ts Add coverage for expected transcript read error classification.
src/tests/main/cue/cue-github-poller.test.ts Add coverage ensuring GitHub 5xx does not report to Sentry during polling.
src/tests/main/agents/codex-usage-sampler.test.ts Update expectations for which HTTP statuses should and should not trigger Sentry reporting.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/main/ipc/handlers/agentSessions.ts Outdated
Comment on lines +64 to +66
* Windows. These are environmental, never a Maestro bug, so we keep the local
* warn but skip Sentry to avoid telemetry noise (MAESTRO-W9). Mirrors the
* EXPECTED_FS_ERROR_CODES carve-out in shared-history-manager.ts.

@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)
src/__tests__/main/ipc/handlers/stats.test.ts (1)

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

Cover the no-broadcast contract in both startup guard tests.

Both tests verify the return value and skipped database write, but a regression that emits stats:updated before returning would still pass.

  • src/__tests__/main/ipc/handlers/stats.test.ts#L530-L543: assert that the session-created path does not broadcast.
  • src/__tests__/main/ipc/handlers/stats.test.ts#L560-L568: assert that the session-closed path does not broadcast.
🤖 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 `@src/__tests__/main/ipc/handlers/stats.test.ts` around lines 530 - 543, Update
both startup guard tests in src/__tests__/main/ipc/handlers/stats.test.ts (lines
530-543 and 560-568) to assert that the stats:updated broadcast is not emitted
when the stats database is uninitialized. Add the no-broadcast assertion to the
session-created test and the session-closed test while preserving their existing
return-value and skipped-write checks.
🤖 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 `@src/__tests__/main/cue/cue-github-poller.test.ts`:
- Around line 983-989: Add an assertion after advancing timers and before
inspecting Sentry calls that verifies mockExecFile received the expected `pr
list` invocation, confirming the injected failure path executed. Keep the
existing zero-cue:github:doPoll Sentry assertion unchanged.

In `@src/main/cue/cue-github-poller.ts`:
- Around line 100-104: Update resolveRepo() so failures from gh repo view that
represent GitHub connectivity outages or rate limits are re-thrown instead of
converted to null. This must allow doPoll() to pass them through
isGitHubConnectivityError so the outer handler suppresses expected GitHub 5xx
and rate-limit failures, while preserving null for non-connectivity
repository-discovery failures.

---

Nitpick comments:
In `@src/__tests__/main/ipc/handlers/stats.test.ts`:
- Around line 530-543: Update both startup guard tests in
src/__tests__/main/ipc/handlers/stats.test.ts (lines 530-543 and 560-568) to
assert that the stats:updated broadcast is not emitted when the stats database
is uninitialized. Add the no-broadcast assertion to the session-created test and
the session-closed test while preserving their existing return-value and
skipped-write checks.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 22110f74-7cba-411d-bca2-dc6d86015890

📥 Commits

Reviewing files that changed from the base of the PR and between a277af4 and 0cd6fb3.

📒 Files selected for processing (12)
  • src/__tests__/main/agents/codex-usage-sampler.test.ts
  • src/__tests__/main/cue/cue-github-poller.test.ts
  • src/__tests__/main/ipc/handlers/agentSessions.test.ts
  • src/__tests__/main/ipc/handlers/groupChat.test.ts
  • src/__tests__/main/ipc/handlers/stats.test.ts
  • src/__tests__/shared/sentryFilters.test.ts
  • src/main/agents/codex-usage-sampler.ts
  • src/main/cue/cue-github-poller.ts
  • src/main/ipc/handlers/agentSessions.ts
  • src/main/ipc/handlers/groupChat.ts
  • src/main/ipc/handlers/stats.ts
  • src/shared/sentryFilters.ts

Comment thread src/__tests__/main/cue/cue-github-poller.test.ts
Comment on lines +100 to +104
*
* A 5xx from api.github.com counts: `HTTP 504: 504 Gateway Timeout` and friends
* mean GitHub itself is degraded, which is the same "can't reach the API right
* now" condition as a dropped socket. The poller retries on its own schedule, so
* paging Sentry on every tick of a GitHub outage is pure noise (MAESTRO-KE).

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Route repository discovery 5xx failures through this classifier.

When config.repo is unset, resolveRepo() captures a gh repo view 5xx and returns null, so doPoll() never reaches isGitHubConnectivityError. Re-throw connectivity failures with rate limits so the outer handler suppresses expected GitHub outages.

Proposed fix
-			if (isGitHubRateLimitError(err)) {
+			if (isGitHubRateLimitError(err) || isGitHubConnectivityError(err)) {
 				throw err;
 			}

Also applies to: 127-128

🤖 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 `@src/main/cue/cue-github-poller.ts` around lines 100 - 104, Update
resolveRepo() so failures from gh repo view that represent GitHub connectivity
outages or rate limits are re-thrown instead of converted to null. This must
allow doPoll() to pass them through isGitHubConnectivityError so the outer
handler suppresses expected GitHub 5xx and rate-limit failures, while preserving
null for non-connectivity repository-discovery failures.

Addresses PR review findings on #1311.

- `resolveRepo()` runs before the poll and has its own `captureException`, so a
  `gh repo view` 5xx during a GitHub outage still paged Sentry once per tick for
  every auto-detect trigger - the doPoll-side fix alone left MAESTRO-KE half
  covered. Suppresses connectivity failures there too.

  Diverges from the suggested "re-throw alongside rate limits": routing these
  into doPoll's catch would newly drag them through the first-poll seed-marker
  path, which changes event-loss semantics for a telemetry fix. Skipping the
  Sentry call keeps the existing skip-the-poll behavior byte for byte.

- Assert the injected `pr list` failure actually executed in the 5xx test - a
  zero-Sentry assertion would also pass if polling bailed out earlier.

- Drop the claim that the new fs carve-out mirrors EXPECTED_FS_ERROR_CODES in
  shared-history-manager.ts. That helper is on `rc`, not `main`.
Copilot AI review requested due to automatic review settings July 26, 2026 14:32
@pedramamini

Copy link
Copy Markdown
Collaborator Author

All three review findings were valid and are addressed in b0b3587.

CodeRabbit, cue-github-poller.ts:104 (Major) - confirmed, and it was a real gap in my fix. resolveRepo() runs before the poll and has its own captureException at the cue:github:resolveRepo tag, so a gh repo view 5xx during a GitHub outage still paged Sentry once per tick for every auto-detect trigger. The doPoll-side fix alone left MAESTRO-KE only half covered.

I did not take the proposed if (isGitHubRateLimitError(err) || isGitHubConnectivityError(err)) throw err; though. Re-throwing routes these into doPoll's outer catch, which drags them through the first-poll seed-marker path - and that path exists to decide whether existing items count as "already seen". Changing event-loss semantics to quiet telemetry is the wrong trade. Skipping just the captureException keeps the existing skip-the-poll-and-return-null behavior byte for byte. Added a regression test that drives the repo: undefined path and verified it fails without the fix.

CodeRabbit, cue-github-poller.test.ts:989 - fair. The stash-the-source check had already proven the test wasn't vacuous, but the assertion is cheap and guards the future. Added.

Copilot, agentSessions.ts:66 - correct. EXPECTED_FS_ERROR_CODES lives in shared-history-manager.ts on rc, not on main (it arrived in rc PR #1141 and reaches main on promotion). The comment would have sent the next reader to a symbol that isn't there. Reworded to point at the sibling RangeError carve-out in the same function instead.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated no new comments.

@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: 1

🤖 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 `@src/__tests__/main/cue/cue-github-poller.test.ts`:
- Around line 999-1017: Add an assertion in the test case around
createCueGitHubPoller to verify the mocked gh repo view command was invoked,
before inspecting Sentry calls. Keep the existing 503 mock and suppression
assertion unchanged, ensuring the test proves repository auto-detection
executed.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 0fea88d8-5b03-4b05-93d4-08939f624481

📥 Commits

Reviewing files that changed from the base of the PR and between 0cd6fb3 and b0b3587.

📒 Files selected for processing (3)
  • src/__tests__/main/cue/cue-github-poller.test.ts
  • src/main/cue/cue-github-poller.ts
  • src/main/ipc/handlers/agentSessions.ts

Comment on lines +999 to +1017
it('does not report a GitHub-side 5xx during repo auto-detection (MAESTRO-KE)', async () => {
// Repo auto-detection runs before the poll, so a `gh repo view` failure
// short-circuits doPoll entirely and has to suppress on its own.
const config = makeConfig({ repo: undefined });
mockExecFile.mockImplementation((_c, args, _o, cb) => {
if ((args as string[]).includes('--version')) return cb(null, '2.0.0', '');
return cb(new Error('HTTP 503: 503 Service Unavailable (https://api.github.com)'), '', '');
});

const cleanup = createCueGitHubPoller(config);
await vi.advanceTimersByTimeAsync(2100);

const sentryCalls = mockCaptureException.mock.calls.filter(
(c) => (c[1] as { operation: string }).operation === 'cue:github:resolveRepo'
);
expect(sentryCalls).toHaveLength(0);

cleanup();
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Prove that repository auto-detection executed.

The test only checks that no cue:github:resolveRepo Sentry event was captured. If polling exits before gh repo view, the assertion still passes without exercising the injected 503 path. Add an invocation assertion before inspecting Sentry calls.

Proposed fix
 			const cleanup = createCueGitHubPoller(config);
 			await vi.advanceTimersByTimeAsync(2100);
 
+			expect(
+				mockExecFile.mock.calls.some((c) => {
+					const args = c[1] as string[];
+					return args.includes('repo') && args.includes('view');
+				})
+			).toBe(true);
+
 			const sentryCalls = mockCaptureException.mock.calls.filter(
🤖 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 `@src/__tests__/main/cue/cue-github-poller.test.ts` around lines 999 - 1017,
Add an assertion in the test case around createCueGitHubPoller to verify the
mocked gh repo view command was invoked, before inspecting Sentry calls. Keep
the existing 503 mock and suppression assertion unchanged, ensuring the test
proves repository auto-detection executed.

@pedramamini

Copy link
Copy Markdown
Collaborator Author

CI note: the test job is red, but it is red on main too, with the identical failure set.

main @ a277af4 (this PR's base) this PR
Failing files HistoryPanel.test.tsx, DirectorNotes/UnifiedHistoryTab.test.tsx same two
Failing tests 51 51
Passing files 1104 1104

The last three commits on main (a277af4, d2085a0, bbbb0f3) all have a failing CI run. This PR neither adds to nor fixes that.

The failures look environmental rather than logical: every one is a ~1.1s waitFor timeout ending in TestingLibraryElementError: Unable to find an element with the text: Test summary, and both files pass locally (107/107). The shared ingredient is the virtualized history list, which renders no rows when the container reports zero height - a jsdom/CI layout difference, not a behavior change.

Flagging rather than fixing, since it is unrelated to this PR's scope. Worth its own issue.

Local validation for the changes here: 207/207 across the six affected suites, npm run lint at the pre-existing 112-error baseline with zero errors in any changed file.

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.

2 participants