Pull requests
Source-control setup
Open Settings → Connections → Source control to see each configured forge, the authenticated account, and the credential source. Recheck credentials reloads the hub’s CLI and environment credentials without restarting ocman.
GitHub uses GITHUB_TOKEN, then GH_TOKEN, then the hub’s GitHub CLI login.
Forgejo and Gitea hosts come from the hub’s tea configuration. Their credentials
use FORGEJO_TOKEN, then GITEA_TOKEN, then the tea login’s token.
You can also save a token for github.com or an explicit Forgejo/Gitea hostname.
Ocman verifies it before saving. A saved token overrides discovered credentials
for that host. Removing it restores discovery. Use repository and pull-request
read access for PR monitoring. Account verification does not prove access to
every private repository.
Tokens are stored in the hub’s private state database, not browser storage, and are never returned by these APIs. Protect database backups as credentials. Setup and PR mutation endpoints require privileged local access. Git fetch and push use the checkout owner’s separate Git authentication; API sign-in does not configure SSH keys or Git credential helpers.
Link a PR to a session
Open the session’s PRs & Issues pane. Under Linked to this session, choose an upstream and enter the PR number. Links are persisted with the session’s platform, owning machine, repository and PR number. Launching a session or worktree from a PR also saves its link. Multiple PRs can be linked to one session.
Project PR rows show Open session for associated sessions on that machine, including sessions in sibling worktrees. If several sessions share a PR, each has its own link. These links preserve the session’s platform and remote owner and support opening in a new tab. Refresh the sidebar to reload associations.
Agents can also link PRs from other repositories through the MCP tool by supplying
the forge host, repo in owner/name format, and PR number. The relationship
stays attached to the originating session without moving it to another project.
The host must be supported by a configured hub forge client.
Unlink removes the relationship and stops its watch. It does not close the PR, delete its branch or archive the session. PRs opened independently by an agent or outside ocman must be linked manually.
Watch checks and feedback
Watch PR asks for confirmation because background follow-ups can use model credits. Ocman records the current checks and comments as a baseline, then checks watched PRs about every two minutes without needing an open browser. Changes queue a session follow-up through the shared delivery queue:
- Newly failing checks or failures on a new head commit.
- All reported checks passing. This is not a merge-readiness decision.
- New or edited comments and review feedback, excluding the current forge user.
- Newly reported merge conflicts.
Quiet PRs with settled checks and known mergeability slow down to roughly five to six minutes after 30 minutes without a metadata update. Feedback is reread when the head or metadata changes, and on the first poll after ten minutes to catch comment edits that do not update the PR timestamp. Missing timestamps keep the full-read behavior. GitHub background reads share the same one-minute response cache as the sidebar and previews.
The linked-PR pane refreshes once per minute while the document is visible.
The sidebar Refresh control refreshes both the PR list and linked PRs,
explicitly revalidating GitHub metadata within the shared request budget.
Reopening the pane uses the cached read path.
If a newly loaded link is missing from its project’s PR list, the pane fetches
that repository’s list once with refresh=1, bypassing the backend cache too.
It waits for any older list request first and keeps the current filters and page.
Watch/status updates and unlinking do not trigger this fetch; rate-limited
lists are not retried automatically.
Active turns and sessions waiting on prompts are not interrupted. Disconnected owners are skipped without falling back to the hub. Read failures preserve the last good snapshot and back off. Eight consecutive failures stop the watch and show an explanation. Ten consecutive comment-only updates also stop it, limiting automated reply loops. A merged or closed PR stops its watch without archiving the session.
Rate limits pause reads until the provider’s retry deadline, with a two-minute minimum pause. They do not count toward the eight-failure limit. Stale responses do not advance the watch snapshot or its feedback watermark.
Watch state and pending notifications survive restarts. A crash after queue acceptance but before the notification receipt is saved can repeat a notice. Stop watching prevents future watch deliveries but does not retract a message already accepted by the session queue. Ocman never automatically merges a PR.
Merge a green linked PR
An open, mergeable linked PR shows Merge when its checks are green. Confirm the action to merge with the forge’s default method. Forgejo uses the repository’s configured default merge style; GitHub uses the authenticated user’s default merge method for that repository. Ocman does not choose a fallback if the default is unavailable or refused.
Before merging, Ocman rereads the PR and checks without using stale results. The head must still match the displayed commit, all checks must pass, and the forge must report the PR as mergeable. The merge request pins that head commit and leaves permission, review and branch-protection enforcement to the forge. It never force-merges or schedules an automatic merge. Success stops the watch and moves the PR into the merged group. This action is dashboard-only, not an MCP tool action.
Prepare a feedback task
Address feedback, Fix failing checks, and Resolve conflicts fetch fresh PR context and open an editable task. Review and copy it into the session when ready. Nothing is sent to the agent or posted to the forge by preparing a task. Review feedback is bounded in the draft; larger discussions direct the agent to the forge for the remaining context. Forge content is explicitly untrusted.
MCP tool
The pull_requests tool exposes these workflows to local agents. Start with
{"action":"help"} for inputs, output descriptions and examples.
upstreams,list,checks,mergeabilityread project forge information. Supply an absolutedirectoryand explicitremote_id, usinglocalfor this machine. Exceptupstreams, also supply the upstreamremotename.checksalso accepts a linked PR’s identity, likewatch: the session identifiers,host,repoandnumber. Ocman reads the PR’s current head commit unlessshais given and returns it assha. Project checks keep requiringsha.launchstarts a PR session or worktree. Supply the project inputs plusnumber,platform,mode(sessionorworktree) andtask(handleorreview). It does not create a PR. Cross-fork fetch confirmation stays in the dashboard.linked,link,unlink,watch,unwatchmanage session PR links and watches. Supplysession_idandplatform, including its remote owner prefix when applicable. Mutations also neednumber;linkaccepts eitherremotefrom the session’s checkout or explicithostandrepo, not both. Use the latter for a PR created in another repository. Other mutations use thehostandreporeturned bylinked.linkedreturns a compact entry per PR (number,title,state,url,remote,watchingand anylastError). Optionalnumber,hostandrepofilter it to matching PRs;detail: truereturns the full saved metadata.feedback,checks_prompt,conflicts_promptreturn unsent task prompts. Supply the session identifiers,host,repoandnumber.
A validation error names every missing field at once.
For example, to attach another repository’s PR to the session that created it:
{"action":"link","platform":"opencode","session_id":"ses_example","host":"github.com","repo":"other/project","number":42}After creating a PR, agents must link it and verify the repository and number
with action: "linked" before reporting completion. Linking does not start a watch.
If the session identity is missing, supply directory with the current checkout’s
absolute path. The tool looks up the session in the same call. Optional platform
and remote_id narrow the lookup. It accepts exactly one exact-directory match,
preserves supplied identity fields, and never picks by recency or status. Failed
reads or disconnected explicit owners stop the action rather than using partial
results. Multiple matches return candidate IDs and exact platforms without
performing the PR action. Confirm a candidate against the conversation using
sessions with action: "get", or ask the user if still ambiguous, then retry.
Never recreate an already-created PR to retry linking.
Launches and watches require user authorization because they can consume model credits. Draft actions do not send messages or post comments. No action merges, force-pushes, archives sessions or changes credentials. Disconnected explicit owners fail closed, just as in the dashboard.
How the PR workflow works
flowchart LR
UI[Setup and session PR pane] --> Setup[sourcecontrol]
UI --> Workflow[prworkflow]
MCP[Agent pull_requests tool] -->|session and optional explicit repository| Workflow
MCP --> Launch
Launch[projectforge lists and launches] --> Workflow
Workflow -->|owner-scoped session references on PR list rows| Launch
UI -->|new link missing from matching list: refresh=1| Launch
Setup --> Credentials[(Private credential overrides)]
Workflow --> Links[(PR links and watch snapshots)]
Links -->|unfinished task counts| UI
Workflow -->|session invalidation: local SSE or owner gRPC to hub SSE| UI
Workflow -->|owner check; checkout upstream when needed| Host[Owning Host]
Workflow -->|cached metadata and checks; selective feedback| Forge[GitHub or Forgejo API]
Workflow -->|confirmed merge: fresh checks, expected head, forge default| Forge
Setup --> Forge
Workflow -->|changed checks or feedback| Queue[Shared session queue]
Queue --> Platform[Owning Platform]
sourcecontrolowns privileged setup routes, verified per-host tokens and live credential resolution for project PR operations, Factory and watches. Saved tokens override CLI/environment discovery without altering Git auth. Discovery itself (sourcecontrol.DiscoverClients:GITHUB_TOKEN/GH_TOKEN,gh,FORGEJO_TOKEN/GITEA_TOKEN, tea logins) and its credential-source labels live there too; the server only resolves remotes through it.prworkflowowns session-qualified links, feedback-task drafts and its joined two-minute watch worker. It persists snapshots and pending notices separately from conversations. The hub reads forge metadata; owner disconnection never routes checkout or session work to another machine.- Project PR lists join durable session links by forge host, repository and PR
number, scoped to the selected machine. The server reads each registered
platform’s reverse index through
prworkflow; remote reads use the owning platform’s authenticated PR-workflow RPC. Only platform and session IDs reach the list response, never watch snapshots or pending prompts. - Explicit
hostandrepolinks resolve through configured hub forge clients without consulting the session checkout’s upstreams. The session retains its owning project and directory; links can refer to multiple other repositories. The linked-PR badge reads checks through a session-qualified endpoint using the saved repository identity, including for links created from an upstream. - Watch reads reuse GitHub’s credential-scoped one-minute transport cache with sidebar and preview reads. Head/metadata timestamps gate feedback pagination, with a ten-minute safety reread. Quiet settled PRs slow to five-minute due times on the two-minute worker. Provider rate limits pause the host without exhausting a watch’s read-failure allowance. Terminal PRs skip checks/feedback.
- Its
pull_requestsMCP tool reuses fixed session HTTP handlers and an injectedprojectforgePR-only handler. MCP authentication precedes dispatch; existing owner checks and validation still apply. Draft actions return prompts without sending them, and cross-fork fetch confirmation remains dashboard-only. Missing session identity can be resolved through a server-injected, uncapped exact-directory lookup using the platform registry’s connection keys. The tool refuses ambiguous or incomplete reads before dispatching a session action. Remote adapters implementplatforms.SessionInventoryReaderthrough the existing inventory RPC without the cached fallback used for browsing. Failed remote inventory reads, including those with an empty cache, block automatic selection. - Successful link/watch saves and removals publish an owner-qualified
ocman.session.changedevent on/api/events. The PR controls and background task notice refresh on matching events and SSE reconnects, alongside the session list. Forwarded mutations notify hub clients after owner acceptance. An authenticated owner-to-hub invalidation stream also carries direct owner mutations and automatic stops, without requiring a browser conversation stream. The hub qualifies identities from its connection, not the payload. Polling remains a backstop for missed events. - Loaded session links also reconcile the matching owner, forge host and repository’s project PR list. A missing new link triggers one fresh list read, not cache warming or a refetch on every session event. Existing rows and unrelated upstreams are left alone.
- Watches are opt-in, deduplicate changes and queue follow-ups rather than running an agent polling loop. Polling continues while a session cannot accept follow-ups, so merged or closed PRs stop their watches. Notification delivery waits until the session is ready. Stop/unlink serializes with delivery. Merging and session archival remain explicit user decisions.
- Session lists add durable watches to native background-task counts, keyed by the full platform and session identity. Active watches and pending nonterminal updates keep the background indicator visible and delay completion-based archive resurfacing without holding foreground execution busy. Stop, unlink, or detecting a merged or closed PR removes that watch’s contribution, even when its final notice still awaits delivery.