Commit Graph
35 Commits
Author SHA1 Message Date
Yichen Jiang ef22fbe7d3 fix(forge): report unconfirmed writes and harden the overview actions
- ForgeActionFailure gains `unknown` for an answer that does not confirm
  the outcome; the GitHub provider passes it on instead of `failed`, the
  panel Remote refuses with `forgePanel/action-unknown`, a viewed mark
  stays, and the other actions ask the reader to check the browser.
- Reruns skip workflow runs with a pending check, try every finished run,
  and report the refused ones together; the card offers a rerun only when
  a failed check's run has finished.
- Review requests resolve users and teams to node ids and call
  `requestReviews`, which GitHub Enterprise Server 3.19 and 3.20 have;
  bots still go through `requestReviewsByLogin`.
- Viewed marks are kept per change request and head, so a reread at the
  same head keeps writes in flight and their locks, and paths named after
  object properties read only their own entries.
- The reviewer search never chooses from the listing of an earlier query.
- Documentation states the unknown code, the branch update evidence, and
  the `canBeRebased` approximation, and drops stray blank lines.
2026-11-09 20:56:46 +08:00
Yichen Jiang a71553a3fd feat(forge-github): sync viewed files and read and act on the pull request overview
Status reads add review requests, latest reviews, closing issue
references, and whether the viewer may update or rebase the head.
Viewed files are read through the files listing, bounded by the new
maxViewedFiles, and set with markFileAsViewed or unmarkFileAsViewed after
a head check. Failed GitHub Actions runs are rerun through the REST API,
reviews are requested with requestReviewsByLogin, and branches are
updated with expectedHeadOid. Every mutation goes through the sender
review writes use, now in mutation.ts.
2026-11-09 17:12:50 +08:00
Yichen Jiang 28df6c3117 Merge remote-tracking branch 'origin/feat/forge-review-threads' into feat/forge-review-writes
# Conflicts:
#	docs/config-catalog.md
#	docs/config-catalog.zh.md
#	packages/experimental/client-ui-forge/README.i18n.yaml
#	packages/experimental/client-ui-forge/src/client/ChangesTab.tsx
#	packages/experimental/forge-github/README.i18n.yaml
#	packages/experimental/forge-github/README.md
#	packages/experimental/forge-github/README.zh.md
#	packages/experimental/forge/README.i18n.yaml
#	packages/experimental/forge/src/index.ts
#	packages/extensions/tool-cordis/src/api-catalog.ts
2026-11-09 14:53:18 +08:00
Yichen Jiang dacbc37209 Merge remote-tracking branch 'origin/master' into feat/forge-review-threads
# Conflicts:
#	docs/config-catalog.md
#	docs/config-catalog.zh.md
#	packages/experimental/client-ui-forge/README.i18n.yaml
#	packages/experimental/client-ui-forge/README.md
#	packages/experimental/client-ui-forge/README.zh.md
#	packages/experimental/client-ui-forge/src/client/ChangesTab.tsx
#	packages/experimental/client-ui-forge/src/client/DiffFile.tsx
#	packages/experimental/forge-github/README.i18n.yaml
#	packages/experimental/forge-github/README.md
#	packages/experimental/forge-github/README.zh.md
#	packages/experimental/forge/README.i18n.yaml
#	packages/experimental/forge/src/index.ts
#	packages/extensions/tool-cordis/src/api-catalog.ts
2026-11-09 14:28:39 +08:00
Yichen Jiang 6e882cd6e3 fix(forge): confine review writes to the bound pull request and reconcile unknown submissions
A write to a thread or comment now reads, in the head check, the pull
request that holds it and is refused without a mutation when that is
another pull request. Submitting the pending review keeps the
submission to reconcile, so an unknown outcome blocks a second review.
GraphQL errors count as refusals only when every type names one, so a
GitHub timeout reports an unknown outcome. Pending reviews are found
by viewerDidAuthor among up to 100, without the unused commit field. A
resolved thread stays open while the reader writes in it, unsupported
writes no longer poll, and the docs state the partial two-step write.
2026-11-09 14:08:22 +08:00
Yichen Jiang 9f875cf44d Merge remote-tracking branch 'origin/feat/forge-review-threads' into feat/forge-review-writes
# Conflicts:
#	apps/web/tests/forge-panel.e2e.ts
#	docs/config-catalog.md
#	docs/config-catalog.zh.md
#	docs/subsystems/forge.i18n.yaml
#	docs/subsystems/forge.md
#	docs/subsystems/forge.zh.md
#	packages/experimental/client-ui-forge/README.i18n.yaml
#	packages/experimental/client-ui-forge/README.md
#	packages/experimental/client-ui-forge/README.zh.md
#	packages/experimental/client-ui-forge/src/client/ChangesTab.tsx
#	packages/experimental/client-ui-forge/src/client/mount.ts
#	packages/experimental/client-ui-forge/src/client/thread-state.ts
#	packages/experimental/client-ui-forge/src/index.ts
#	packages/experimental/client-ui-forge/tests/changes-tab.client.spec.tsx
#	packages/experimental/client-ui-forge/tests/mount.client.spec.ts
#	packages/experimental/client-ui-forge/tests/review-cache.host.spec.ts
#	packages/experimental/client-ui-forge/tests/review.host.spec.ts
#	packages/experimental/forge-github/README.i18n.yaml
#	packages/experimental/forge-github/src/threads.ts
#	packages/experimental/forge-github/tests/threads.spec.ts
#	packages/experimental/forge/src/types.ts
#	packages/experimental/forge/tests/registry.spec.ts
#	packages/extensions/tool-cordis/src/api-catalog.ts
2026-11-09 13:03:22 +08:00
Yichen Jiang 1ba5977691 fix(forge-panel): address the review thread findings
- A jump to a thread centered its card on every later jump to the same file, since the jump target outlived the jump.
  The scroll target now carries the card to center and is cleared when the jump ends; unfolding still follows the
  latest thread jump.
- In a commit range view, a thread on a file the chosen commits do not change opened on the host instead of choosing
  all commits; a thread the chosen commits do not hold now always chooses all commits first.
- A quote of an old-side thread named the head as the commit its lines number. It now says the lines number the file
  before the change and names the head only as where the diff ends, and ForgeAnchor documents the same.
- Refresh reads review threads from the host past the panel's cache (`changeRequestReview` takes `fresh`), so a thread
  resolved since shows without waiting for `reviewRefreshMs`; `maxCachedReviewBytes` defaults to 16 MiB, at least
  one read under forge-github's default `maxOutputBytes`.
- Picking a thread from a list that covers the files moves the focus to the thread's card.
- `ForgeReviewData.viewer`, its GraphQL field, `ThreadActions.viewer`, and `ThreadReadState.unsupported` had no
  consumer and are removed.
- A quoted outdated thread is named by the lines it was written on; a missing pull request or repository makes a
  review read `not-found`; a truncated read that kept no thread still offers the thread list.
2026-11-09 12:50:33 +08:00
Yichen Jiang b02529e520 feat(forge): write review threads and the pending review through the provider
ForgeProvider gains an optional writeReview for replies, resolution,
comment edits and deletions, and the viewer's pending review, which
review reads now report with the viewer's permissions. The GitHub
provider checks the head and the pending review in one query, then
sends one GraphQL mutation on stdin and never retries it; a reply at
once is refused while a pending review exists, since GitHub adds it
to that review. The forge panel Remote changeRequestReviewWrite drops
the kept threads after every write, because resolving a thread does
not move a pull request's updatedAt.
2026-11-09 11:21:00 +08:00
Yichen Jiang d6208abfca docs(forge-github): state how review reads bound the first page and which pages re-check the head
A first review thread page whose output alone passes maxOutputBytes fails the read as too-large through gh's output
limit, rather than ending it as truncated as the README and the ReviewLimits documentation said; only a later page
that would pass the limit truncates the read. Thread pages after the first re-check the head, while a thread's comment
pages do not. A test pins the first-page failure.
2026-11-07 18:21:08 +08:00
Yichen Jiang 508b078373 fix(forge-github): keep the status when GitHub reports no full base commit
The base commit only gives the diff read a head start, so a missing or
malformed baseRefOid now leaves baseSha out instead of failing the status.
2026-11-07 18:09:08 +08:00
Yichen Jiang 9b456b4e93 perf(forge): compare from the recorded base while confirming the head
Status snapshots carry the base commit the host recorded with the head
(baseSha). ForgeService.diff passes it to the provider when the latest
status names the requested head, and forge-github starts the compare read
from it while its GraphQL read confirms the head; a stale head or another
base cancels and joins the early read.
2026-11-07 16:22:24 +08:00
Yichen Jiang f11daf3ad3 docs(forge): document review thread reads, the thread overlay, and the unsupported failure
The forge subsystem page documents ctx.forge.readReview, its thread
types, and the panel's changeRequestReview cache; the package READMEs
describe the GitHub thread mapping, the overlay and thread list, and the
new panel Config fields. An upgrade guide covers the unsupported
ForgeFailure code. The Web e2e overlays scripted threads, opens them from
the thread list, and sends a quoted thread through a replayed turn.
2026-11-07 14:31:30 +08:00
Yichen Jiang 256e1ae370 feat(forge): read pull request review threads at the displayed head
ForgeProvider gains the optional readReview(ref, headSha, signal), which
returns ForgeReviewData only when the read names headSha as the head and
a stale failure otherwise. Each thread carries a current position on the
head and the original position it was written at; ForgeFailure gains the
unsupported code that ctx.forge.readReview returns for a provider
without review reads.

forge-github reads the threads, the head, and the viewer in one GraphQL
query, pages threads up to maxReviewThreads and comments to their end,
re-checks the head on every following thread page, and bounds all pages
by maxOutputBytes. A thread is placed at the head only when GitHub keeps
it current and its first comment is on the head commit.

The forge panel adds the changeRequestReview Remote, cached per change
request by head and update time and read again after reviewRefreshMs,
since resolving a thread does not change a pull request's updatedAt.
2026-11-07 14:28:39 +08:00
Yichen Jiang ef34a844de fix(forge-panel): refuse commit runs off the first-parent line and harden review state
- Shift-chosen commits must follow each other as first parents; the picker
  says why it keeps a run that leaves the line, and the Host refuses one with
  forgePanel/commits-not-linear for the Branch scope and change requests.
- The Branch scope lists its newest maxCommits commits with
  --no-show-signature, so log.showSignature cannot corrupt the listing.
- Viewed marks merge with the stored entry on each write and follow the
  storage event, so tabs of one Session keep each other's marks.
- .gitattributes patterns follow Git's wildmatch rules, checked against
  git check-attr; change digests include file mode lines.
- GitHub commit pagination refuses a repeated cursor or a changed count;
  commits validates the repository before its host like the other reads.
- The commit list is read once per head, base, or refresh; the lens menu
  hides the count of the disabled Tests lens.
2026-11-07 12:56:23 +08:00
Yichen Jiang fb637c2bfd Merge remote-tracking branch 'origin/master' into feat/forge-review-viewed-lenses
# Conflicts:
#	apps/web/tests/forge-panel.e2e.ts
#	docs/config-catalog.md
#	docs/config-catalog.zh.md
#	docs/subsystems/forge.i18n.yaml
#	docs/subsystems/forge.md
#	docs/subsystems/forge.zh.md
#	packages/experimental/client-ui-forge/README.i18n.yaml
#	packages/experimental/client-ui-forge/README.md
#	packages/experimental/client-ui-forge/README.zh.md
#	packages/experimental/client-ui-forge/src/client/ChangesTab.tsx
#	packages/experimental/client-ui-forge/src/index.ts
#	packages/experimental/client-ui-forge/tests/controller.host.spec.ts
#	packages/experimental/forge-github/README.i18n.yaml
#	packages/experimental/forge-github/README.md
#	packages/experimental/forge-github/README.zh.md
#	packages/experimental/forge-github/src/index.ts
#	packages/experimental/forge-github/src/provider.ts
#	packages/experimental/forge-github/tests/plugin.spec.ts
#	packages/experimental/forge-github/tests/provider.spec.ts
#	packages/experimental/forge-github/tests/review.spec.ts
#	packages/experimental/forge/README.i18n.yaml
#	packages/extensions/tool-cordis/src/api-catalog.ts
2026-11-07 12:13:56 +08:00
Yichen Jiang c9997e03c7 fix(forge): read commit ranges like the pinned pull request diff
The compare read now takes the same arguments as the comparison helper of the
pinned-diff change: explicit commits, the diff media type, and
--allow-escape-sequences, which gh 2.97 and newer requires to print a patch
whose files hold terminal escape sequences. HTTP 406, GitHub's refusal to
render a diff over its limits, reads as too-large.
2026-11-06 18:18:51 +08:00
Yichen Jiang e07b170d77 fix(forge): address review of pinned diffs and thread counting
- forge-github: repeat a compare read without --allow-escape-sequences when
  a gh older than 2.97 rejects the option; such a gh prints escape sequences
  unchanged, so every version reads every diff (checked with gh 2.96.0 and
  2.100.0 on a pull request whose patch holds an ESC byte).
- client-ui-forge: a stale refusal now re-runs the read effect, so a status
  that arrived during the read, including a failed poll that keeps the
  earlier head, starts the next read at once instead of leaving the changes
  view loading.
- forge: ctx.forge.diff polls at once only for the first stale read at a head
  commit; later stale reads at it wait for the regular poll, which bounds the
  read-poll loop while GitHub's answers briefly disagree.
- forge-github: review thread pages share the byte budget of a complete
  check read.
- client-ui-forge: a truncated count shows its "+" even when it is zero.
- READMEs: document the batch deadline and rewritten-base limitations.
2026-11-06 18:17:04 +08:00
Yichen Jiang 38b59a84bc feat(forge): read pull request commits and commit ranges
ForgeProvider gains optional commits and compare methods, which a provider
implements together. The forge service returns undefined from commits and an
unavailable failure from compare when either is missing. The GitHub provider
lists commits through GraphQL pages pinned to one head, bounded by the new
maxCommits setting, and reads ranges through the compare API in diff form.
2026-11-06 17:50:54 +08:00
Yichen Jiang 7dc864a931 fix(forge-github): read pinned diffs through the compare API
The GitHub provider now reads headRefOid and baseRefOid in one GraphQL query,
returns `stale` when the head moved, and reads the patch from
`compare/<baseRefOid>...<headSha>` instead of bracketing `gh pr diff` with two
head reads. Both ends are fixed commits. The compare read lives in the internal
`readComparison` helper so commit-range diffs can reuse it.

For every open and merged pull request measured, the compare patch is
byte-identical to `gh pr diff`. Unlike the pull request diff, it returns diffs
over 300 files, so such a pull request now shows its complete diff; only output
over `maxOutputBytes` or GitHub's HTTP 406 / `too_large` refusal is
`too-large`. The read passes `--allow-escape-sequences`, which gh 2.97 and
newer require to print patches whose files contain terminal escape sequences.
2026-11-06 17:05:05 +08:00
Yichen Jiang 94336c6b3d fix(forge): pin change request diffs to the polled head and count every review thread
ForgeProvider.diff now takes the head commit it must describe. The GitHub
provider reads headRefOid before and after `gh pr diff` and returns the new
ForgeFailure code `stale` when either read names another commit, so the
forge panel never caches a patch under a head it does not describe. A stale
read polls the change request at once, and the changes view waits for the
next status before reading again.

Status polling pages reviewThreads up to the new `maxReviewThreads` setting
(default 1,000) instead of counting only the first 100, and sets
ChangeRequestSnapshot.threadsTruncated when the count is a lower bound.
2026-11-06 16:15:24 +08:00
dsh-ci-bot 4a8727ee5f test(forge-github): exec the fake gh sleep so deadline cases settle
The fixture's sleep ran as a child of dash. Killing the wrapper shell left the child holding stdout/stderr, so execa's close waited for the sleep itself to exit (about 5025ms) and both deadline cases hit vitest's 5000ms budget on Linux. exec makes the killed process the one that owns the pipes, so a timed-out or cancelled invocation rejects immediately.
2026-11-05 22:52:28 +08:00
Yichen Jiang f08ad306cc fix(forge): load complete checks on demand per pull request 2026-10-29 11:10:35 +08:00
Yichen Jiang 2d709ab5be fix(forge): address check states and review accessibility 2026-10-28 17:45:32 +08:00
Yichen Jiang 2cb769b430 fix(forge): deduplicate checks and improve review navigation 2026-10-28 16:38:40 +08:00
Yichen Jiang 822aef2804 test(forge): cover review interactions and failure recovery 2026-10-28 12:32:47 +08:00
Yichen Jiang bd1c30cd81 feat(forge): add file tree and inline review comments 2026-10-28 11:42:45 +08:00
Yichen Jiang bbb031654e Merge remote-tracking branch 'origin/worktree/forge-change-request-bindings' into worktree/forge-pr-worktree-panel
# Conflicts:
#	docs/config-catalog.md
#	docs/config-catalog.zh.md
#	docs/event-producer-consumer.md
#	docs/event-producer-consumer.zh.md
#	packages/experimental/forge-github/README.i18n.yaml
#	packages/experimental/forge-github/README.md
#	packages/experimental/forge-github/README.zh.md
#	packages/experimental/forge-github/src/provider.ts
#	packages/experimental/forge-session/README.i18n.yaml
#	packages/experimental/forge-session/README.md
#	packages/experimental/forge-session/README.zh.md
#	packages/experimental/forge-session/src/index.ts
#	packages/experimental/forge/README.i18n.yaml
#	packages/experimental/forge/README.md
#	packages/experimental/forge/README.zh.md
#	packages/experimental/forge/src/index.ts
2026-10-26 18:14:53 +08:00
Yichen Jiang 4bef9db77e fix(forge-github): validate byte budgets separately from timeouts 2026-10-26 17:49:52 +08:00
Yichen Jiang 1ebb31915b fix(forge-github): preserve HTTP remote ports 2026-10-26 17:49:24 +08:00
Yichen Jiang ae40382197 fix(forge-github): distinguish HTTP errors from GraphQL results 2026-10-26 17:45:20 +08:00
Yichen Jiang fbcfd80e21 fix(forge-github): enforce configured hosts before queries 2026-10-26 17:42:35 +08:00
Yichen Jiang d0fc1f6458 feat(forge): show the changes of a Session and of its change requests
The forge panel opens a changes view in the right sidebar for the
checkout's local changes and for the diff of each change request.

- ForgePanelController reads local diffs in the branch, uncommitted,
  unstaged, and staged scopes through Git in the Session's read-only
  sandbox, change request diffs through the forge provider, and the text
  of a changed file to expand unchanged lines. Change request patches stay
  cached by head commit and base branch within maxCachedDiffBytes. A local
  diff over maxDiffBytes fails as forgePanel/diff-too-large, and a provider
  read over its output limit fails as too-large, which the view explains
  with a link to the code host; a gh timeout fails as unavailable.
- forge adds the diff, fileText, and fileUrl provider methods and the
  too-large failure code, and forge-github implements them with gh.
- The panel shows a local changes card that opens the view and asks the
  Agent for a change request. The view collapses files past a line
  budget, draws lines side by side or in one column with optional
  wrapping, expands unchanged lines on request, and collapses or expands
  every file from its toolbar; file headers use a bare chevron.
- The checkout row copies the worktree or project directory path, the
  refresh glyph turns while a refresh runs, change request cards keep
  their actions while collapsed, and the header entry uses the shared
  compact button.
- client-ui-forge classifies changeRequestKey and FsError as
  peer-required Host imports, which keeps forge and dsh-fs as its peers.
2026-10-20 13:34:27 +08:00
Yichen Jiang 80254034c7 feat(forge): mark change requests ready and merge them from the panel
An expanded card now marks a draft ready for review and merges a change
request that the host would merge now:

- The forge seam gains provider actions `markReady` and `merge`, which
  return a typed `ForgeActionFailure`; the registry polls a watched change
  request at once after either settles. Snapshots carry `mergeReady` and
  the `mergeMethods` the repository allows, the user's usual one first.
- GitHub marks ready with `gh pr ready` and merges through the REST merge
  endpoint with the head SHA the card showed, so new commits refuse the
  merge; it never enables auto-merge, joins a merge queue, or deletes the
  head branch.
- The panel Remote acts only on visible bindings of the Session, and the
  card offers 标记为可评审 for drafts and a 合并 menu with the allowed
  methods and a confirmation, reporting each outcome in a toast.
- The forge panel e2e replaces the worktree branch before the ARIA
  capture normalizes durations, so a random suffix no longer breaks it.
2026-10-20 11:50:10 +08:00
Yichen Jiang fc43a2d507 feat(forge): add the pull request panel and worktree Sessions
The forge panel shows the pull requests a Session created or pushed in a
right-sidebar tab, with a Session header button and branch label, and lets
a new Session start in its own Git worktree from the New Session options
row. The forge bundle ships the panel with the forge registry, the GitHub
provider, the Session bindings, and an isolated worktree service.

The panel listens to the agent-controller/admission stage. It holds the
first message of a Session with a worktree request while it creates and
enters the worktree as Agent maintenance, and refuses messages while the
worktree the Session works in is gone. A failed or stopped creation
returns the message to the composer: the card above the composer shows the
failure, sending again retries with a new branch name, and Continue
without a worktree withdraws the request. A removed worktree can be
checked out again or left for the source checkout. A message that enters
without admission still gets its worktree at the first step proposal.
2026-10-20 11:49:51 +08:00
Yichen Jiang dcbfd8079a feat(experimental): bind code host change requests to Sessions
Add the experimental forge capability seam:

- dsh-experimental-forge: provider-neutral repository and change request
  references, a provider registry, and shared status polling. Watchers of
  one change request share one loop; each forge has one batched fetch in
  flight, and the cadence follows check, mergeability, and lifecycle state.
- dsh-experimental-forge-github: GitHub provider that runs the GitHub CLI
  on the host with a scrubbed environment and reads every due pull request
  of a host in one GraphQL query.
- dsh-experimental-forge-session: a host-only projection derives Session
  bindings from gh pr create and git push shell results and from
  plugin:forge-session/binding records; push results trigger head-branch
  discovery of open pull requests, and Session watchers poll bound change
  requests through ctx.forge.
2026-10-20 11:49:25 +08:00