Skip to content

fix(status-line): deduplicate PR lookups across instances - #4332

Closed
designinglaunguage wants to merge 1 commit into
Yeachan-Heo:mainfrom
designinglaunguage:fix/status-line-pr-negative-cache
Closed

fix(status-line): deduplicate PR lookups across instances#4332
designinglaunguage wants to merge 1 commit into
Yeachan-Heo:mainfrom
designinglaunguage:fix/status-line-pr-negative-cache

Conversation

@designinglaunguage

Copy link
Copy Markdown
Contributor

Closes #4331.

What changed

  • adds a process-level PR lookup cache keyed by repository identity and branch;
  • caches both positive and negative results for 60 seconds;
  • shares an in-flight promise across status-line instances;
  • preserves the existing instance-level branch/repository invalidation;
  • adds regression tests for negative caching and concurrent deduplication.

Why

The existing instance cache accepts null, but long-lived render/config lifecycles can still produce repeated status-line instances/lookups. In observed use this spawned gh pr view --json number,url 5–28 times per 10 seconds and kept affected idle GJC processes at roughly 45–87% of one CPU core.

Verification

  • focused tests: 31 pass, 0 fail
  • TypeScript check: pass
  • git diff check: pass

Prevent idle render cycles from repeatedly spawning GitHub CLI processes.
@Yeachan-Heo

Copy link
Copy Markdown
Owner

Maintainer intake — owning #4331 / #4332 (sole maintainer lane)

Taking ownership of this issue/PR pair. Exact state at intake:

  • Remote PR head: 9839fbcf55dde5d5f91f812396fc7103db6d9deb (fork designinglaunguage/gajae-code, branch fix/status-line-pr-negative-cache)
  • Submitted base: main@d915ffe58edddba8cb5f9cb9393b1943ebb6cc5c (stale relative to current dev)
  • Current dev: e8af95c8332e588eb878b470dc6543c8645be74e
  • Integrated candidate: e6ea5da32ef63eefd7fed69bd2e68c070be1c805 — your commit replayed onto current dev, verified patch-identical to 9839fbcf, authorship preserved
  • CI: full run 31569177598 on 9839fbcf (still in progress at intake; attribution below covers terminal jobs so far)

CI attribution (run 31569177598):

  • check job 94027314597 — PR-caused: Biome format fails only on packages/coding-agent/test/status-line-gh.test.ts (added multi-line import must collapse to one line). Reproduced locally with repo-pinned Biome 2.5.2 on the integrated candidate. Deterministic and in changed scope; fixing forward.
  • Python SDK 3.10/3.11/3.12/3.13 — identical test_real_session_all_transports_cleanup socket-relay failure on all four; the changed files are TypeScript status-line only, so this is suspected pre-existing/environmental. Being verified against pristine dev before classification.
  • coding-agent shards 3-of-16 and 4-of-16 — lifecycle-race failures outside the changed status-line files; under pristine-dev baseline comparison before classification.

Next: adversarial cache-lifecycle review + maintainer formatting repair, then baseline attribution, then a fresh exact-head CI signal. Review verdict follows.

— gjc maintainer lane (Yeachan-Heo) · worktree gajae-code-pr-4332-status-pr-cache · branch maintainer/pr-4332-status-pr-cache · head 9839fbcf55dde5d5f91f812396fc7103db6d9deb · base d915ffe58edddba8cb5f9cb9393b1943ebb6cc5c · dev e8af95c8332e588eb878b470dc6543c8645be74e · integrated e6ea5da32ef63eefd7fed69bd2e68c070be1c805 · CI run 31569177598

@Yeachan-Heo

Copy link
Copy Markdown
Owner

Maintainer disposition — fixed forward, integrating via #4348

Exact head reviewed: 9839fbcf55dde5d5f91f812396fc7103db6d9deb.

CI attribution on that head (run 31569177598):

  • checkPR-caused: Biome format failure on the added multi-line import in status-line-gh.test.ts (repo-pinned Biome 2.5.2 requires collapsing to one line). Fixed forward with biome check --write, no behavior change.
  • test, four test-shard jobs, Python SDK 3.10-3.13 — pre-existing/environmental, confirmed unrelated to this PR: identical failures reproduce on plain main@d915ffe58e with zero PR changes (CI run 31567860767), and a local check:sdk-closure seam-review failure reproduces identically on the git-stashed (unmodified) worktree.

Cache-lifecycle review of the diff itself: the in-flight lookup dedup and TTL cache with insert-time expired-entry sweep are correct — bounded process-lifetime memory, correct repo/branch key isolation, and correct clearCurrentPrCache drop-and-restart semantics, all covered by the added tests (13/13 passing locally, Biome clean after the format fix).

Integrated candidate targeting dev with the format fix on top, replayed with your authorship preserved: #4348. Closing this PR once #4348 lands; thank you for the fix.


[repo owner's gaebal-gajae (clawdbot) 🦞]

Yeachan-Heo added a commit that referenced this pull request Aug 12, 2026
)

* fix(status-line): deduplicate PR lookups

Prevent idle render cycles from repeatedly spawning GitHub CLI processes.

* fmt(status-line): collapse gh test import to satisfy biome

CI `check` job failed on the exact PR head because the added
lookupCurrentPrCached/lookupCurrentPr/clearCurrentPrCache import spans
three lines; repo-pinned biome 2.5.2 requires a single-line import at
this length. Auto-fixed with `biome check --write`, no behavior change.

Lore-id: pr4332-biome-fmt
Constraint: keep the PR diff scoped to status-line PR-lookup dedup only
Rejected: reformat unrelated packages/natives/native/index.d.ts drift | out of PR scope, reverted to origin content
Confidence: high
Scope-risk: narrow
Reversibility: trivial
Tested: bun test packages/coding-agent/test/status-line-gh.test.ts (13 pass); bunx biome check (clean)

* fix(status-line): bound prCache memory and skip gh spawn without pr segment

The process-lifetime prCache map had no eviction path: expired entries
accumulated indefinitely across many repos+branches within one process.

Gate the status snapshot so #lookupPr() is never called when the user's
segment layout has no pr segment. The pr segment renders nothing on null,
so suppressing the spawn is behavior-identical.

Lore-id: pr4332-evict-gate
Constraint: eviction must run on insert, not on a timer (no background work in TUI)
Constraint: pr-segment gating must not change visible status when pr is absent
Tested: bun test status-line-gh.test.ts — 13 pass including eviction + clear tests
Tested: biome check + tsc --noEmit clean
Confidence: high
Scope-risk: narrow
Reversibility: trivial

---------

Co-authored-by: juns <juns@local>
Co-authored-by: gaebal-gajae (clawdbot) <clawdbot@gaebal-gajae.local>
@Yeachan-Heo

Copy link
Copy Markdown
Owner

Integration complete — merged to dev via #4348

This PR was integrated, repaired, and merged into dev as PR #4348.

Merge commit: 9fd5f5ab1146262c990fe092198fb8fcad499407 on dev
Merged head: 5cfcf54b9dcb45f4941c0eda8636d82b23ea28f5

What was integrated from the original PR

  • lookupCurrentPrCached with in-flight dedup + positive/negative TTL cache (60s) in gh.ts
  • clearCurrentPrCache for test isolation
  • Call-site switch in tool-status-header.ts to the cached lookup with repoId\0branch cache key
  • 6 targeted cache lifecycle tests in status-line-gh.test.ts

Maintainer repairs on top (preserving original authorship)

  1. Biome format fix: collapsed the multi-line test import to a single line (repo-pinned Biome 2.5.2 requirement). This was the sole PR-caused CI failure.
  2. Bounded eviction: expired prCache entries are swept on every insert, bounding process-lifetime memory to keys seen within one TTL window.
  3. PR-segment gating: #lookupPr() is no longer called when the status-line layout has no pr segment, eliminating an unnecessary gh spawn with no visible behavior change.

Contributor credit

Original cache design, in-flight dedup, and lifecycle tests by @designinglaunguage (commit 9e48240db1 / original fork head 9839fbcf5). All three PR commits retain the original authorship; maintainer repairs are in the third commit.

CI on the merged head

Dev CI run 31592802446 on 5cfcf54b9d (base bc2492af38): 22 success, 5 skipped, 0 failures.

Closing this PR as superseded by the merged #4348.


[repo owner's gaebal-gajae (clawdbot) 🦞]

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.

Status line repeatedly spawns gh pr view and consumes high idle CPU

2 participants