Skip to content

Read PR checks for open PRs only and attach settled PRs by commit - #408

Merged
yansfil merged 4 commits into
mainfrom
fix/pr-list-speed-and-association
Oct 4, 2026
Merged

yansfil merged 4 commits into
mainfrom
fix/pr-list-speed-and-association

Conversation

@yansfil

@yansfil yansfil commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Related: #390 (부모), 같은 영역을 만지는 형제 PR의 이슈 #391 #394 #395

Summary

PR 목록 읽기가 1114초로 15초 한도에 닿던 것을 34초대로 줄이고, 머지·닫힌 PR이 브랜치 이름만 같다는 이유로 새 작업의 워크트리에 붙던 것을 바로잡습니다.

  • gh pr list를 둘로 나눠 동시에 읽습니다: 전체 200건은 statusCheckRollup 없이, 열린 PR만 number,statusCheckRollup으로 읽습니다. 머지·닫힌 PR의 체크는 이전에 읽은 값(번호+head 커밋)이 있으면 쓰고 없으면 unknown(웹은 표시 없음)입니다.
  • 워크트리와 PR을 잇는 규칙을 github::belongs_to_checkout 한 곳에 모았습니다. 열린 PR은 브랜치로, 머지·닫힌 PR은 브랜치와 head 커밋이 모두 맞을 때만 붙고, fork PR은 어디에도 붙지 않습니다.
  • 웹 PRs 탭과 위임 대화상자는 브랜치 이름 대신 row.pull_request.url로 체크아웃을 찾습니다.

Closes #392
Closes #393

gh pr list, 이 저장소, read-only, gh 2.76.2 (초)
before  단일 목록(체크 포함):  13.24  13.19  14.83
after   전체 목록(체크 없음):   3.69   5.57   5.23
after   열린 PR 체크:          1.01   0.99   2.24
after   두 목록 동시:          9.97*  4.87   5.82     (*첫 실행 이상치)
after   실제 list_pull_requests (200건, 열린 5건): 3.34  4.29  4.13  4.38

Review

  • 판단해 주세요: fork PR은 열린 것이든 머지된 것이든 같은 이름의 로컬 브랜치에 붙지 않습니다. fork에서 온 PR을 위임하면 워크트리를 새로 만들려다 눈에 보이게 실패합니다.
  • 판단해 주세요: 머지·닫힌 PR은 워크트리 HEAD가 amend, rebase되었거나 뒤처지면 붙지 않습니다(UI_BEHAVIOR.md에 적음). 열린 PR은 그대로 브랜치로 붙습니다.
  • 판단해 주세요: 머지·닫힌 PR의 체크가 처음 읽기 전에는 표시되지 않습니다(unknown). 값이 없는 칩을 그리지 않는 쪽(디자인 원칙 10)으로 골랐습니다.
  • 조심해서 볼 파일: herdr-core/src/github.rs - gh 두 개를 std::thread::scope로 동시에 돌립니다. 락 밖이며 check-capability-readers-off-lock.sh가 통과합니다. 캐시는 (번호, head)로 키잡고 읽기 실패 때 보존됩니다.
  • 조심해서 볼 파일: herdr-core/src/runtime/projects.rs - ingest_worktrees_answer가 refresh, apply_pull_requests, refresh 순으로 돌아 카탈로그 HEAD가 바뀌면 연결을 다시 정합니다.
  • 조심해서 볼 파일: herdr-core/src/runtime/pull_requests.rs - shown_pull_requests(목록 표시)는 여전히 브랜치 이름 기준이고, 연결 규칙은 belongs_to_checkout입니다.
  • 비용 검토: 읽기당 gh 호출은 1회에서 2회(동시)로 늘지만 총 시간은 줄었습니다. 입력/틱당 작업과 알림 fan-out은 그대로이고, pull_requests.* 진단에 duration_ms가 붙습니다.
  • 형제 PR과 겹침: #391은 github_request 게이트, 작업이 끝난 에이전트 pane이 남은 워크트리는 정리 시트에서 고를 수 없다 #394 #395는 worktree_cleanup.rs와 DiskCleanupSheet.tsx를 만집니다. 이 PR은 github.rs와 runtime/projects.rs를 건드리므로 먼저 머지되는 쪽에 맞춰 리베이스가 필요할 수 있습니다.
  • 질문: 없음.

Evidence

  • 확인한 것: 커밋 순서는 PR 목록 조회가 11 - 14초 걸려 15초 제한에 걸린다 #392(읽기 경로와 github.rs) 다음 머지되거나 닫힌 PR을 브랜치 이름만으로 워크트리에 붙인다 #393(연결 규칙과 웹) 다음 리뷰 반영 다음 e2e 픽스처입니다.
  • 확인한 것: scripts/verify-cargo.sh lint와 test(2092 통과, 0 실패), scripts/verify-web.sh(typecheck, lint, test 944), 웹 빌드, check-capability-readers-off-lock.sh를 최신 origin/main(#404까지) 위에서 통과했습니다.
  • 확인한 것: pnpm e2e overview-prs.spec.ts는 debug hided로 1건 통과했습니다. 가짜 gh가 head 커밋을 알려주지 않아 머지 PR의 정리 버튼이 사라지던 것은 픽스처에 headRefOid를 넣어 고쳤습니다(마지막 커밋).
  • 확인한 것: 새로 쓰거나 바꾼 테스트(github::tests, request_view::tests, runtime::tests::pull_requests, runtime::tests::projects, 120건)를 연속 20회 돌려 20/20 통과했습니다. 실제 네트워크와 gh, sleep은 쓰지 않습니다.
  • 확인한 것: 심은 결함으로 의미를 확인했습니다 - 옛 projectBoard.ts는 새 웹 테스트를 실패시키고, ingest_worktrees_answer에서 apply_pull_requests를 빼면 task_key 테스트가 실패합니다.
  • 확인한 것: 실제 저장소에 읽기 전용 gh로 위 시간표를 쟀습니다.
  • 확인하지 못한 것: 설치된 앱이나 운영자의 hided로는 확인하지 않았습니다(건드리지 않기로 한 범위). 격리한 네이티브 후보 앱의 화면 캡처도 없습니다.
  • 확인하지 못한 것: GithubReader::read()가 known을 캐시에서 꺼내 넘기는 배선은 테스트하지 않았고(list_pull_requests와 read_root 단위로만), 실제 gh 한 건으로 시간만 쟀습니다.
  • 확인하지 못한 것: 이 머신에서 hide-platform의 ipc burst 테스트가 간헐적으로 실패한 적이 있습니다. main이 #396으로 격리한 것이며 이 변경과 무관하고 최종 전체 실행에서는 통과했습니다.

The pull request list asked GitHub for the checks of all 200 listed pull
requests, merged and closed ones included, which took 11 - 14 seconds
against the 15-second limit. The read is now two lists asked at the same
time: every pull request without its checks, and the open ones with only
their checks. A merged or closed pull request keeps the checks read for its
number and head commit while it was open, and otherwise reads Unknown.
Either list failing fails the project's read, and the read diagnostics carry
duration_ms. The list also keeps each pull request's head commit and whether
it comes from a fork.

Refs #392
A branch name used again for new work showed the old merged pull request on
the new worktree. One rule now decides which pull request belongs to a
checkout: an open one by head branch unless it comes from a fork, a merged or
closed one only while the checkout is on exactly the pull request's head
commit, open before merged before closed and newest first among equals. The
sidebar row, the worktree catalog, the agent request block, the link and
hand-off actions and the PRs view all use it, and a worktree read that moves
a HEAD decides the connection again.

Closes #392
Closes #393
A pull request from a fork never belongs to a local branch of the same name, merged or open. An open pull request takes its checks only from the open list, never from a remembered commit. The list order of preferred_per_branch keeps recency over state precedence.
@yansfil
yansfil force-pushed the fix/pr-list-speed-and-association branch from d23fc47 to ada93f4 Compare October 4, 2026 17:34
@yansfil
yansfil merged commit cc99d75 into main Oct 4, 2026
54 of 57 checks passed
@yansfil
yansfil deleted the fix/pr-list-speed-and-association branch October 4, 2026 17:55
yansfil added a commit that referenced this pull request Oct 4, 2026
…nswer across restarts (#407)

Closes #391 (part of #390). Rebased over #408 (two-call PR query,
head-commit linking); this PR does not change the query or the linking
rule.

## Summary

After a daemon restart the sidebar drew every worktree as a plain branch
until Overview or the palette asked for that project, because the core
read GitHub only for the focused project and a memory-only set those
screens filled, and kept nothing on disk.
Now the core reads GitHub for every local Git project on its own once a
window is attached, asks again five minutes after a project's last
answer, and saves the last successful answer to `github-snapshot.json`
in the state folder.
A restart restores that file as stale, so the first frame already draws
the previous run's pull requests, muted, until the first read replaces
them.
A failed read still keeps the last value, now across a restart too.
No UI change: the same icons appear without the screens that used to be
needed to ask for them.

```
before: restart -> rows show branch glyph (no answer, nothing on disk) until Overview / palette asks
after:  restart -> rows show pull request glyph, muted as stale; first read replaces it; gh down keeps it
```

## Review

- **Please judge**: the cap of 64 projects read
(`GITHUB_PROJECT_LIMIT`). Past it the project in front is read first,
then projects a screen named with `github_request`/`overview_refresh`,
then the rest by path; the count is logged as `projects.over_limit`. A
project left out shows no PR icon.
- **Please judge**: the five minutes count from a project's answer, not
from the ask. Counted from the ask, a pass over many slow projects would
be overtaken by its own next ask (the answer is dropped when its request
moved) and never land. A project whose ask is unanswered is not asked
again.
- **Files to watch**: `herdr-core/src/github_store.rs` - the file keeps
what the wire omits (`head_oid`, `cross_repository`, created/closed
times) so a settled pull request reconnects to its worktree after a
restart; a new `skip_serializing` field on `PullRequestSnapshot` must be
added there (the round-trip test builds the type literally, so it fails
to compile). New off-lock writer: one thread, one pending slot,
`hide_platform::fs` atomic replace, joined on drop; a file that is
unreadable, damaged or of another schema version is discarded with a
`snapshot.discarded` diagnostic.
- **Files to watch**: `herdr-core/src/runtime/projects.rs` -
`github_request`, `reread_stale_github`, `ingest_github_answer`. An
empty answer to an empty request is ignored so a navigator that has not
arrived cannot erase the restored answer or its file.
- **Files to watch**: `herdr-core/src/handle.rs` - the file is read
before the runtime lock is taken; no I/O under `Mutex<Runtime>`
(`check-capability-readers-off-lock.sh` passes).
- **Cost review**: no new thread besides the store's. Per coordinator
wake the added work is a comparison of at most 64 instants under the
lock, and one snapshot clone after an answer that changed something; a
`gh` pass happens per due project every 5 minutes only while a window is
attached (the reader stays in the UI-attached block). Ledger row added
to `docs/PERFORMANCE_TESTING.md`.
- **Known gap**: if a first answer lands while only part of the
navigator exists, projects not yet there drop out of the saved file
until their next read. Only a wholly empty request is guarded.

## Evidence

- **Confirmed**: `lint` and `test` for the whole workspace pass on the
rebased head (herdr-core lib 1267 passed); the
capability-readers-off-lock, workstation-identity and harness-anchor
gates pass; `web lint`, `typecheck` and `build` pass.
- **Confirmed**: the 16 new Rust tests (`runtime/tests/github_reads.rs`,
`github_store.rs`) ran 20 times in a row with no failure; they use
injected `Instant`s, a temp folder and no `gh`, network or sleep. One of
them covers #408's rule: a merged pull request plus a worktree on its
head commit, saved, restored in a new runtime, attaches to the worktree,
and stops attaching when the head moves. They cover the request set
(local Git only, path order), the five-minute cycle including the
unanswered-ask case, the cap, `loading` ending for a project the reader
returns nothing for, restore as stale with `last_success_at_unix_ms`
kept, a failed read keeping the restored value, and damaged or
other-version files.
- **Confirmed**: new `web/e2e/sidebar-pr-start.spec.ts` ran 20 times in
a row, no failure, on an isolated pinned Herdr and hided with a fake
`gh` that answers both of the reader's `pr list` calls (two
repositories, neither the project in front). Each start resumes on a
Workspace with the right panel on Explorer; no Overview, project
Overview or palette opens, and the page's wire carries only terminal and
usage-hint events, asserted as zero `github_request` and zero
`overview_refresh`. Start 1: both rows draw their lifecycle. Start 2
(`gh` down): both draw muted as stale. Start 3 (`gh` back): both replace
it, all without any screen asking. With the snapshot file deleted before
the restart the spec fails.
- **Confirmed**: the new cap-priority tests (project in front,
screen-named project, a named project that is no longer registered) are
part of the 20 repeated runs of the Rust tests, 10 in `github_reads.rs`,
5 in `github_store.rs` and 1 in `runtime/tests/pull_requests.rs`.
- **Not confirmed**: real `gh` against this repository and a packaged
app. The e2e uses a fake `gh` and an isolated daemon;
`/Applications/hide.app` and the operator's daemon were not touched.
- **Not confirmed**: a first pass over many slow projects publishes only
when the whole pass finishes, so a large first pass can take a while to
fill the sidebar; no timing was measured.

- **CI note**: `e2e/overview-modal.spec.ts:7` failed in the first CI run
(`toBeFocused` after the Overview modal closes). Under the same CPU load
(6 busy loops, 3 workers, `--retries 0`) `origin/main` failed 6/30 and
this branch 7/30; an earlier smaller run was 1/15 on main and 3/15 here.
Failures are focus-handoff steps (lines 92 and 100) and several failing
pages show the shell `reconnecting`. It reproduces on main, so this
change is not its cause; it is not fixed here.
- `hide-platform`
`a_burst_is_bounded_and_ends_in_an_overflow_rather_than_silence` and
`only_a_guarded_launch_returns_startup_proof` failed in local full runs
while other jobs loaded the machine; this PR does not touch
`hide-platform`.

<details><summary>Verification record</summary>

- Review subagent, Fix now: a re-read counted from the ask could starve
a slow pass; per-project read state was never pruned; four doc sentences
contradicted the code; a stale e2e comment. All fixed. Follow-up not
done: a drop guard for a panicking save worker, an `Arc` instead of a
clone under the lock, partial-navigator saves.

</details>
yansfil added a commit that referenced this pull request Oct 4, 2026
…uest reattaches at once (#410)

Related: Follow-up to #391, part of #390

## Summary

재시작 직후 머지된 PR이 사이드바 행에 다시 붙기까지 최대 1분이 걸렸다. 머지된 PR은 체크아웃 HEAD가 PR의 head
커밋과 같을 때만 붙는데(#408), `CheckoutSnapshot::head_sha()`가 느린 worktree 카탈로그 값만
읽었기 때문이다.

- `hide-project`의 `Repository::head_oid`가 Git 파일만으로 HEAD 커밋을 읽는다(분리된
HEAD, loose ref, `packed-refs`, linked worktree의 common dir). 프로세스 없음, 못
읽으면 `None`.
- 카탈로그를 만들 때(`build_catalog`, 락 밖) 브랜치 이름을 채우는 자리에서 core 전용 `head_oid`를
같이 채운다.
- 카탈로그 값이 있으면 그것이, 없을 때만 파일 값이 `head_sha()`가 된다.

실측(이전 동작, main 16e4f7c, 격리 Herdr+hided, 실제 gh, worktree 59개, PR 200개):

- 첫 실행: 56행이 규칙에 맞음 (merged 31, open 2, draft 1, branch 22).
- gh를 끈 재시작: open/draft 3개는 바로 흐리게 보이고 merged 31개는 30초간 branch 아이콘.
- gh가 돌아온 재시작: 새 읽기는 14초에 도착했지만 카탈로그가 답하는 약 60초까지 merged 0, 그 뒤 31개가 붙음.

## Review

- **판단해 주세요**: 카탈로그 값이 파일 값을 이긴다. 카탈로그는 HEAD/ref 변경 때 다시 읽고, 파일 값은 행을
마지막으로 만든 때까지만 신선하다. 반대로 하면 HEAD가 움직인 직후 오래된 값이 이긴다.
- **조심해서 볼 파일**: `hide-project/src/lib.rs` - 새 파일 읽기(ref 이름 검증,
`packed-refs` 8 MiB 상한, 한 줄씩 읽기).
- **조심해서 볼 파일**: `herdr-core/src/workspace.rs` - `build_catalog`는 코디네이터가
락 밖에서 돌린다. 락 아래에 남는 호출(픽스처 경로, 등록 안 된 루트의 임시 행, 시작)은 이미 같은 HEAD를 읽던 자리다.
- **조심해서 볼 파일**: `herdr-core/src/model.rs` - `head_sha()` 우선순위, wire로
나가지 않는 필드(`skip_serializing`).
- **비용 검토**: 체크아웃당 파일 1-2개 읽기가 카탈로그 재구성(입력이 바뀔 때, 최대 30초마다)에만 붙는다. 틱당
작업, 알림 fan-out, 새 스레드 없음.

## Evidence

- **확인한 것**: `hide-project` 단위 테스트 11개(loose ref, packed-refs만, loose가
packed를 이김, 분리된 HEAD, linked worktree, 없는 ref, `..` 로 저장소를 벗어나는 ref) 20회
반복 통과.
- **확인한 것**: 호출자 관점 회귀 테스트(`github_reads`, 카탈로그가 답하기 전): 복원된 merged PR이
head가 같은 체크아웃에는 붙고 다른 커밋의 체크아웃에는 붙지 않음, 카탈로그 값이 파일 값을 이김. 15개 20회 반복 통과.
`head_oid` 대체를 빼면 attach 테스트가 실패하는 것을 확인.
- **확인한 것**: `sidebar-pr-start` e2e에 head 커밋을 가진 merged PR을 추가(재시작 직후와
gh 중단 중 흐린 merged 글리프, 화면이 `github_request`/`overview_refresh`를 보내지 않음).
실패 2회를 뺀 로컬 반복은 아래 항목을 보세요.
- **확인한 것**: `verify-cargo.sh lint`, `test --no-fail-fast`(2123개 통과),
`build -p hided`, web typecheck/lint/build,
`check-capability-readers-off-lock`, `check-no-workstation-identity`,
`check-harness-ignore-anchor`.
- **확인하지 못한 것**: e2e의 저장소는 작아 worktree 리더가 몇 ms에 답하므로 e2e는 최종 상태만 증명한다.
"카탈로그를 기다리지 않는다"는 단위 테스트가 증명한다.
- **확인하지 못한 것**: 59 worktree 실제 gh 재측정은 하지 않았다(격리 라이브 확인 없음). 이전 동작의 숫자는
위 실측이다.
- **확인하지 못한 것**: `sidebar-pr-start` e2e가 로컬에서 2회 실패했다. 둘 다 첫 재시작(gh 정상)
뒤 `feature/alpha` 행이 30초 동안 `branch`로 남았고, 수정하지 않은 open PR 경로다. 원인은 확정하지
못했다: 로그를 남기기 전에 일어났고, 진단을 붙여 돌린 뒤로 재현되지 않았다. 두 번 모두 cargo 빌드/테스트와 겹친
시점이라 부하가 의심되며, 후보는 부하 속에서 첫 `gh` 읽기가 실패하면 다음 읽기가 5분 뒤라는 #407의 동작이다.
- **확인한 것**: 실패 이후 같은 코드로 진단을 붙여 40회, 25회, 부하 없이 15회 통과했고, 코어 수만큼 busy
loop를 돌린 부하 아래에서 20회 모두 통과했다(총 100회 통과, 실패 0).

<details><summary>추가 증거</summary>

코드 리뷰 subagent의 Fix now 4건(경로 이탈 테스트가 가드 없이도 통과, `packed-refs` 무제한 읽기,
우선순위 테스트 부재, e2e가 타이밍을 증명하지 못함)을 반영했다.

</details>
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.

머지되거나 닫힌 PR을 브랜치 이름만으로 워크트리에 붙인다 PR 목록 조회가 11 - 14초 걸려 15초 제한에 걸린다

1 participant