src/pull-requests.ts: maps each workspace to its GitHub repository, reads the pull request list with onegh api graphqlcall per repository, and reads one pull request's details with one more.branchPullRequestasks onegh api graphqlcall, outside GitHub's search, for the newest open or merged pull request a branch heads, forsrc/session-facts.ts.mergedPullRequestsasks onegh api graphqlcall for the newest pull request from each of a repository's branches, with one alias per branch, and keeps the merged ones with their merge time, forsrc/worktrees.ts.loadPullRequestTitlereads only a linked PR's title through a separate 30-second cache, without loading its details.src/github.ts'srepoOfkeeps each workspace's repository, or its lack of one, for ten minutes in acreateCachefromsrc/cache.ts, and runs at most eightgit remotelookups at once through alimitgate fromsrc/map-limit.ts. A row'sconflictsis true when GraphQL'smergeableisCONFLICTING. The list leaves out a pull request whose own state says closed, which the open searches still return for up to a minute after a close, since GitHub's search index lags it. A row and the details readchecks,conflicts, andunresolvedfrom the same GraphQL fields, soreadyToMergeinsrc/shared/moves.tstakes either; the details countunresolvedfrom the threads they keep, so their counts and threads agree. The details also read the last 100 commits with the pull requests GitHub links each to, and keep a commit linked to none or to this one, since a branch that merged its trunk lists the trunk's commits too.src/git.ts: the git checkout of a directory, the worktree a directory is in (worktreeAt), the branch a worktree had checked out at a given time (headHistory,branchAt), and the worktree a new session's branch runs in. It also holds the git helpers thatsrc/worktrees.tsshares:git,canonical,commonDir,worktreesOf, which parsesgit worktree list --porcelain -z, andholderOf, the worktree that has a branch checked out, which the pull request checkout and rebase use too.src/worktrees.ts: the worktree inventory and the checks before a checkout is removed;Worktrees.startandWorktrees.removeorder starts against removals;removeCheckoutremoves the linked worktree a directory is in, or returnsnullfor a main checkout or a directory outside git, waiting up to 15 seconds for a session that just ended to leave it: it polls only which live sessions occupy the checkout, then runs the full preview once.releaseBranchremoves the linked worktree that has a branch checked out throughremoveCheckoutwithout that wait, and answers aBranchReleasefromsrc/shared/git.ts, forPUT /api/worktree/release.deleteMergedBranchdeletes a local branch only while its commit is the one its pull request merged, or one that commit contains, and no worktree has it checked out, for the cleanup after a merge.inUsenames the directories live sessions and the server run in, which keep an isolation sandbox, andbeneathtells whether one holds another. The inventory and the snapshot of what uses the checkouts resolve each distinct directory once, and run those realpaths and the per-directory and per-repository git probesPROBE_PARALLEL(16) at a time. The inventory then reads every repository's checkouts from one queue, four at a time, with onegit rev-parsefor their identity, andpreviewAllpreviews several targets from one snapshot of what uses them, four at a time;src/map-limit.tsholdsmapLimit, the ordered, boundedPromise.allthey share, andlimit, a gate that bounds tasks arriving one by one. A preview reports a path that git no longer lists as a worktree with theunregisteredblocker, whichWorktreestells apart from other failures by itsUnregisteredWorktreeerror class. The inventory marks each linked checkout'smerged:git merge-base --is-ancestoragainstrefs/remotes/origin/HEADfor each distinct commit, then onemergedPullRequestscall per repository, through theWorktreesEnvseam that tests fake, for the branches the default branch lacks. A merged pull request counts only when the branch's last commit is no newer than the merge, read with onegit log --no-walkcall.previewAll(targets, true), for Remove merged, runs the same check and adds theunmergedblocker to each target it cannot show merged; removal needs no second check, since the confirmation pins the branch and commit.src/local-file.ts: finds a file that agent text names by absolute path, by the real path's extension and outside the sign-in and config directories inDENIED_DIRS:readTextFilereads a text file forGET /api/file, within the size and encoding that route allows, andfindMediaFilean image or video forGET /api/media.src/worktrees-shared.tsholds the shapes the page and the routes share.src/changes.ts: the session changes dialog's reads forGET /api/changesandGET /api/changes/file, a session's checkout diff merged with its own changed files, the last scan of each place kept for three seconds so that reading a file does not list every change again, and each session transcript folded into its changed files once, by the lines it gained since;src/shared/changes.tsholds the shapes the page shares,parseFullDiff, which numbers the rows of a whole-file diff, andpatchRows, which fills GitHub's patch out to the whole file.src/pull-request-files.ts: the Code tab's REST file and blob reads, optional commit scope, and paginated GraphQL viewed-state read.src/pull-request-order.tsorders the list: sources after the files they import, then tests in their sources' order, then generated files.src/pull-request-stack.tsreads the stack forGET /api/pull-request/stack.src/pull-request-edit.tssaves titles, descriptions, labels, review requests, states, branch updates, and conversation changes forPUT /api/pull-request, and viewed files forPUT /api/pull-request/viewed. It also lists picker choices forGET /api/pull-request/optionsand appends images withattachToPullRequest.src/pull-request-checkout.tschecks out a pull request forPUT /api/pull-request/checkout: withgh pr checkoutin a checkout, or on its head branch in a worktree with a new session that the route's starter opens there.src/pull-request-rebase.tsrebases a pull request's branch onto its base forPUT /api/pull-request/rebase, in the worktree that has the branch or a temporary one, and force-pushes it with a lease through the repository's pre-push hook, one repository at a time. Both read the pull request's head and base branches throughheadOfinsrc/pull-request-head.ts, and refuse a workspace of another repository throughassertWorkspaceOfthere.src/pull-request-merge.tsholdsGITHUB_MERGES, the merge and its steps, including merge or rebase branch updates, and the status reads.src/pull-requests.tsaddsbehindBywith one REST base-to-head comparison per detail read.src/pull-request-review.tsholds a review draft's side of GitHub:readReviewTarget, the head and the lines each file's diff shows, the viewer's login, the reviews and their comments a retry compares, andpostReview, onePOSTof the review throughghRestPostinsrc/github.ts.src/github-media.ts:GET /api/github-media, authenticated reads of allowlisted GitHub images and videos with redirect validation, a streamed size cap, and a bounded private cache.src/server/merge-queue.ts:MergeQueue, every merge the dashboard makes, kept inmerges.jsonand stepped only by the server that holds the owner lock,nextStep, which picks a merge's next step from where its pull request stands, andstackOrder, which orders a stack of one repository bottom first;src/shared/merge-queue.tsholdsQueuedMerge,MergeQueueChange,MergeQueueAnswer, andqueuedMergeOf, which the page shares; see Merges, and the cleanup after one.src/server/review-drafts.ts:ReviewDrafts, the Review session'ssave_review_drafthost tool, bound to its pull request throughjoinand theReviewers it keeps, and the preview and post of a draft, which takes a matching review already on GitHub instead of posting twice;src/server/review-drafts-file.tskeeps the drafts and reviewers inreview-drafts.jsonbeside the access token;src/shared/review-drafts.tsholdsReviewDraft,ReviewFinding,ReviewDraftEdit,applyReviewDraft,reviewPayload, which builds the review from the accepted findings and the diff's lines, andpostRefusal, which the page shares; see Review drafts.src/server/merge-cleanup.ts:MergeCleanup, which marks the live sessions linked to a pull request that merged while it watched, and ends each once it is idle and not held for a continue with every pull request merged or closed, with its worktree and its merged branch, trying a failed or refused end again at the next look.src/server/isolation-sweep.ts:IsolationSweep, which once a day, on the owner's minute tick, removes each of omp's isolation sandboxes whose omp exited and whose checkout is clean, unlocked, and unused;src/omp/isolation.tssupplies omp's directory, its owner marker and liveness check, and its teardown of a retained mount; see Isolation sandboxes.src/source-control.ts: Settings › Source control providers on the server:gh's andgt's sign-in, the automatic pull setting and the cleanup after a merge insource-control.json, andpullDefaultBranch; see HTTP API.src/shared/source-control.tsholds the shapes the page shares, the merge methods and their labels,applySourceControl, andstartingMethod, which picks the method the merge button starts with.src/settings-sync.ts: Settings › Sync on the server:SettingsSyncruns one sync at a time againstSyncRepo,readLocalandapplyLocalread and write this machine's side,planSyncandmergeFilemerge three ways,portableText,portablePath, andlocalPathcarry home paths as~, andsourceControlStoresyncsSourceControl's settings through its store; see Settings sync.src/sync-repo.tsholdsSyncRepo, the git commands on the bare repository under the data directory, run without prompts;src/shared/settings-sync.tsholds the registry,SYNC_ITEMSandNEVER_SYNCED, the shapes the page shares, andparseSyncSettings.src/server/self-update.ts: Update dashboard:SelfUpdatereads the build the server runs at startup, counts origin's new commits for the bell, and fast-forwards the checkout, installs whenbun.lockchanged, and has the server restart;fastForwardrefuses rather than stash, reset, or merge; see Updating the dashboard.src/shared/dashboard-update.tsholds whatGETandPUT /api/dashboard/updateanswer.