Change request panel and worktree Sessions
变更请求面板与 worktree Session
[Session change request bindings](2026-10-09-session-change-request-bindings.md) give each Session a list of change requests, but nothing shows it. A user who asks the agent to open change requests needs their checks, reviews, and mergeability without leaving the conversation, and wants a new Session's edits and commits kept out of the current checkout. Git must run where the Session's commands run, which can be a re
English
Problem
Session change request bindings give each Session a list of change requests, but nothing shows it. A user who asks the agent to open change requests needs their checks, reviews, and mergeability without leaving the conversation, and wants a new Session's edits and commits kept out of the current checkout. Git must run where the Session's commands run, which can be a remote or confined execution world; inspection must not change the repository, and a worktree must exist before the model's first action.
Decision
dsh-experimental-client-ui-forge is a two-face package. Its Host half, the forgePanel Remote, assembles everything the panel shows for one Session into one streamed state; the forge registry and the binding service keep only their domain operations. Its Client half is a Change requests section, checkout and local changes rows, and an attention mark in the Session panel, a changes view, a New Session option, a creation card above the composer, a toast, and the Session list icons and hover card section. Every surface calls a bound item a change request, the forge registry's term, whatever its code host calls it. The forge bundle ships the panel, the forge registry, the GitHub provider, the bindings, the worktree model tool, and an isolated worktree service for the panel as one default-disabled Plugins page entry.
Review and worktree controls serve one code-change workflow. One Plugins entry lets users enable that workflow without having to distinguish the underlying package split. Packages and the two worktree services remain independent so each owns its before-Session or in-conversation creation flow.
The Remote inspects the checkout through the Session's subprocess provider under its resolved permissions and query restrictions, so it reads what the Session's commands see. Inspection reads the top-level, Git, and common Git directories, the branch or the abbreviated HEAD commit, the upstream, the remotes, and the size of the branch's changes against its fork point. It runs when a Session is followed, after each workspace-root/change, tool/result, and sandbox/mode event, and on refresh, one at a time with one trailing rerun.
Status polling follows panel subscriptions: a Session's bindings are watched only while one of its surfaces is mounted, and the registry stops polling change requests nobody watches. Each card keeps the last snapshot a poll returned, so a transient failure keeps the title and number visible. A Session's only open change request starts expanded, and with several every card starts collapsed; the user's first toggle replaces this default.
An expanded card marks a draft ready for review and merges a change request the host would merge now. The forge seam carries both as provider actions that return a typed failure, and every snapshot says whether the host would merge the change request now for the signed-in user and which methods the repository allows, so the panel offers only actions that can succeed. A merge carries the head commit the card showed, and the host refuses it once new commits arrived. The panel acts only on change requests bound to the Session.
A new Session starts in a worktree through a request, not an immediate creation. Checking the option in the New Session row, a conversation.hero.options entry, appends a plugin:client-ui-forge/worktree record with the base branch; changing the base or clearing the option appends another, and nothing touches the repository until the user sends. The option is offered only where creation can succeed: under workspace-write, the checkout and its common Git directory must lie inside the writable root, which excludes a project that is itself a linked worktree. The worktree must exist before the first message's turn starts, so the turn runs there and its first request already names the new directory. When the message enters the Session's inbox, the panel's agent/inbox/inserted listener starts maintenance of the Agent before the delivery wakes it; the Agent latches the wake until the maintenance ends, and the panel creates and enters the worktree inside it. The creation's stage streams to a card above the composer, where Cancel stops the attempt. After a stopped or failed attempt the message keeps waiting in the inbox, and the card keeps the failure and offers another attempt with a new branch name or Continue without a worktree, which withdraws the request and lets the message go on. An agent/pre-step listener still creates the worktree at the first step proposal of a Session whose request is open, because a message that enters while the Agent runs a turn or other maintenance gets no hold; it moves the working-directory notice into the proposed messages, and a failure ends the turn. The forgeWorktree projection ignores requests after the first turn/start and creations after the first step/start, so a running Session never moves. The tab's first row names the branch the Session works on, and the Session list marks a Session that works in its created worktree.
The worktree a Session works in can be removed outside it. Each inspection checks whether the created worktree's directory still exists, and every message that enters while the Agent is idle starts a hold that checks again, so the message waits without starting its turn while the directory is missing. The check must come before the turn: while it assembles a step's context, the working-directory service moves a Session whose directory is gone back to its project, before any pre-step listener runs. Restore checks the branch out again at the recorded directory, or creates the branch again at its base commit when it is gone; Continue in the project moves the Session to the source checkout. Either runs inside the hold and lets the waiting message go on.
The panel does not move a Session between existing worktrees. Removing a change request appends a dismiss record, and its toast offers Undo through track.
The panel also shows the changes behind a Session's work in a changes view, a resource tab type of this package. The Remote parses every diff on the Host into files and hunks, so the browser draws them without a patch parser, and bounds each read with maxDiffBytes and maxUntrackedFiles. Local changes come from git diff using the Session's permissions and execution world, in a scope the user picks: the branch against its fork point by default, or the uncommitted, unstaged, or staged changes; untracked files are read through the Session's filesystem and shown as new files. A change request's changes come from its code host at the head of the binding's latest status, through two provider reads the forge seam gained, diff and fileText. The Host keeps the patch it read last for each change request, keyed by the head commit and base branch and bounded by maxCachedDiffBytes, so reopening, refreshing, and navigating at the same head download nothing again; a host or provider that refuses an answer over its size limit reports the forge failure too-large, and the view then offers the change request's web page instead of a retry. Unchanged lines between hunks expand from the file's new side, which is the working tree, the index, or the head commit, and only while that text still matches the hunks. Each inspection also sizes the branch's changes for a local changes card, shown while no open change request carries the checked-out branch; its Create change request sends the Session a user message, so the Agent creates the change request with its own tools and the binding follows from gh pr create as for any other.
The changes view also writes the checkout, on whole files: the Unstaged scope stages and restores, and the Staged scope unstages. A reader of an Agent's work keeps the accepted part in the index and discards the rest, and without these writes that meant leaving the application. The reader's press is the authorization, as archiving is for the worktree service's removal of a checkout, so the writing commands run without the Session's sandbox policy: that policy bounds what the Agent does, and the reader stages in a read-only Session or from a Session directory below the checkout's root. Staging and restoring name each file with the digest of the change the reader saw, and the Remote refuses the write when the unstaged scope, read again, shows another change: the Agent can edit a file between the reader's look and the press. The undo of staging and unstaging returns the index entries to a tree written before the write. Restoring has no undo, so it asks first.
The local changes view reads more than the Session's own checkout. A menu at the start of its header chooses another local or remote-tracking branch of the repository. A branch that a worktree of the repository has checked out is read in that worktree with every scope, which shows what a subagent changed in its own worktree, uncommitted files included; a branch that no worktree has checked out shows committed content only. A local scope names the choice as an optional head instead of the view gaining a second kind of source, so every read, the lens request, the viewed-mark key, and the key of the loaded data carry it through the scope they already take; the Session's own checkout names none, so the viewed marks and comment records a browser holds for it keep their identities. The page sends a branch ref and never a path: the Host verifies the ref, asks Git which worktree has the branch checked out, confirms by inspection that a checkout of the same repository has it checked out there, and runs Git there under the reading Session's sandbox policy. Without a chosen base, another branch is compared with the Session's own HEAD, not with the remote's default branch as the Session's own checkout is: a reader of a subagent's branch asks what it changed since it left the Session's work, and that comparison also exists in a repository without a remote and leaves out commits the Session made before it delegated. Another head is read-only, and plugin slots and line annotations stay with the Session's own checkout, so ctx.forgeChanges, the face other plugins use, is unchanged. The Session panel's local changes row shows in every Git checkout, with an empty size when nothing changed, so the view and its menu open from a Session whose own checkout is clean while its subagents work in worktrees.
Review comments capture the file, side, range, complete hunk, and reviewed head when the user selects code. Agent references enter the existing composer quote mechanism, so the user controls batching and the sent message records exactly what the model receives. GitHub writes belong to the optional forge provider operation: preflight checks the current head, the write addresses that commit, and an ambiguous outcome blocks another write until the user reconciles it. Inline records of Agent references and published comments, and the review summary, belong to a browser tab occurrence, not to the Session log; a pull request comment kept for a later review goes to the code host's pending review, as the pending review decision records. Switching Sessions retains that occurrence; closing it discards the local state and rejects late write completions. Published GitHub comments remain external records.
Deferred
The left-navigation review page this section deferred is implemented as the code review page; its lists come from an optional provider capability and its page reads change requests by URL, so this package's Session surfaces did not change.
The changes view offers no scope for one commit or for the last turn yet; both would be further ForgeLocalScope kinds read through localDiff.
Alternatives considered
Per-host nouns. Calling items pull requests on GitHub and merge requests on GitLab would need each provider to declare its noun and every string to take it; GitHub is the only provider, and one term keeps the copy fixed.
Merging through gh pr merge. It enables auto-merge while required checks are pending and joins a merge queue when the base requires one, so a click could schedule a later merge instead of merging. The REST merge endpoint merges at once or refuses.
Deleting the head branch after a merge. The Session's worktree can be on that branch.
A Host service package for Git inspection. No second consumer needs checkout facts yet; a model tool can move them into a shared service when it exists.
Running Git as a Host process. Remote and confined execution worlds would show the Host's files instead of the Session's, and the Host would read directories the Session cannot.
Creating the worktree when the option is checked. Every toggle or base change would create and abandon a checkout, and the Session would move before the user decided to send.
Carrying the option in the Session creation request. The Session controller owns a closed request; a plugin record keeps the option inside this package and survives a reload of the blank Session.
Switching between existing worktrees from the panel. A switched Session keeps the sandbox root of its project, so a worktree outside the project stays read-only, and moving mid-conversation splits the model's view of the files. Starting a Session in its worktree avoids both.
The option in the composer tool row. The tool row stays after the first message, when the option no longer applies; the New Session row disappears once the Session starts. The row offered only single slots, so ui-conversation gained the list slot conversation.hero.options.
Creating the worktree within the first turn. The turn has started when the first step proposal runs: its context was assembled for the old directory, a failure can only end the turn and drop the claimed message, and the working-directory service has already moved a Session out of a removed worktree. It remains the fallback for a message no hold took.
Holding the message at Agent admission. An agent-controller/admission stage would hold a message before it enters the inbox, so the composer keeps it until the worktree exists and a failure returns it for editing. It needs a controller service in front of every sender's delivery, a core addition that one panel does not justify; a hold at inbox insertion uses the existing inbox event and maintenance, and covers every sender.
Returning a waiting message to the composer. Once the Host accepted a message the composer cannot take it back without a new public API in the conversation package for one plugin; the message keeps waiting with the card's actions instead.
A submit gate in the Web composer. The browser held the message before the Host saw it, so every check needed a Remote call, the stage of a refused message lived only in the browser, and other senders bypassed it. A hold at inbox insertion keeps the message where it enters the Agent and the failure in the panel state.
The creation card in the transcript. Transcript nodes accept no plugin kinds; the input dock above the composer is the nearest list slot, and it renders on the New Session screen.
Manual URL tracking. It duplicated the bindings the Session's own commands record. Bindings come from gh pr create, the gh pr commands that act on one change request, pushes, and the branch the checkout tracks, and track remains for Undo.
Parsing patches in the browser. The Remote would carry unbounded patch text, and the browser would need a patch parser; the Host bounds the read and parses it once.
Reusing the review tab's file comparison. It belongs to another plugin, which this package may not import at run time, and moving it into the shared primitives would change a shared package for one consumer; the view is built from the shared highlighter, menu, tooltip, and diff color tokens instead.
Reading a change request's diff from the local repository. The checked-out branch can be ahead of or behind the host, and the base may not be fetched; the host's diff is what reviewers see. The view says when the checked-out branch has commits beyond the head instead.
Recognizing a too-large diff from the failure message in the panel. The message belongs to the provider and its host and changes with them; a failure code lets each provider report its own limits, and the panel branches on the code.
Creating the change request from the card. The panel would need to push the branch and compose the title and description; a message lets the Agent do both with its tools and the user's instructions, and keeps one way to bind change requests.
Sending each line comment immediately to the Agent. It starts a turn before the user can collect related comments or add a shared instruction; composer references preserve that choice.
Keeping review drafts after their tab closes. Reopening the same PR would restore abandoned review state. A tab occurrence gives closing a clear discard meaning while preserving Session switching.
Staging hunks or lines. Whole files cover keeping and discarding a file of the Agent's work with four Git commands and one staleness rule. A hunk write applies a patch to the index and needs its own rule for a hunk that moved; it is left for a later change.
Running a reader's write under the Session's sandbox policy. The first version did, because git add, git reset, and git restore run the repository's filters, which the Session can configure. The buttons then failed wherever the index lies outside the Session's writable directory: a Session below its checkout's root, a linked worktree the Host did not create, and a read-only Session. None of eight peer products surveyed on 2026-11-25 confines a person's own Git write, and this repository's archive cleanup already runs Git on the user's authorization.
Emptying the repository's filter drivers for a write. Codex's worktree code, Reasonix, and Pi empty them for each command, as this package does for reads. A staged file would then hold unfiltered content wherever the repository itself configures the filter, such as Git LFS installed for one repository, so files using one would have to be refused. The two peers with the same buttons, MiniMax Code and ZCode, run the commands without such a guard; the three guard other Git operations. A Session that can edit the repository's configuration can also run commands itself, so the guard would take a working feature away without removing an ability.
Unstaging as the undo of staging. A file with an edit staged earlier would lose that edit from the index too. A tree of the index before the write restores exactly the entries the write changed.
Writes in the Uncommitted and Branch scopes. Both compare the working tree, so staging changes nothing they show, and a file staged in part would give no sign of which part.
Staged and unstaged files as two groups of one list. A file with edits on both sides would be listed twice, while viewed marks, expansion, the file tree, and navigation identify a file by its path.
Restoring a file the index tracks without content. git restore replaces it with the empty index entry, and deleting it would discard a file the user chose to track; the view offers no restoration for it.
Automatically retrying a review write. A lost response does not mean that GitHub rejected the request. Retaining the outgoing request and requiring reconciliation prevents a transport failure from silently duplicating comments.
A separate view type for another branch. Each read, the lens request, the viewed-mark key, and the data key would need a second case. An optional head on the local scope reaches all of them through the value they already take.
A menu group of the Sessions delegated from the reading one. Each row named a delegated Session's checkout by Session id. Every listing then read the subagent catalogs and each delegated Session's records, several Sessions in one checkout needed one label, and a Session that moved to another directory kept its row under the old name. Git's worktree list reaches the same working trees through the branch a reader searches for, without a dependency on the subagent service.
Committed content only for every other branch. Reading a branch that another worktree has checked out from its commits alone hides the edits a subagent has not committed yet, which a reader checks while that subagent works.
Writes and plugin entries on another head. The slots, the annotations, and ctx.forgeChanges address the Session's own local changes; another head stays read-only and without those entries, which leaves that face as it is.
Consequences
The panel shows current status only while it is open; checks that finish while nothing is mounted produce no notification. Changes made outside the Session appear after Refresh or the next tool result. A local write is not recorded in the Session and the model is not told about it; the Agent meets the result the next time it reads the checkout. A local write runs the clean and smudge filters named in the repository's configuration with the Host's permissions, measured for git add and git reset, and a Session that can write its checkout can add one. Every inspection spawns up to twelve short Git processes in the Session's execution world with one remote, and two more for each further remote it tries for a fork point. A worktree exists only for a Session that requested it before its first step, and a failed or cancelled attempt can leave its branch or checkout behind. A message that enters while the Agent runs a turn or other maintenance gets no hold, so its worktree is created within the first turn and a removed worktree is not checked. While a message waits, the Agent stays idle in maintenance: the composer offers no stop, and callers waiting for the Agent to become idle wait as well. Restoring loses changes that were never committed. A base branch that requires a merge queue cannot merge from the panel. The bundle mounts two independent worktree services; the model's tool never sees the panel's service. A local or change request diff over maxDiffBytes, or one the host refuses, shows no files. Expanding unchanged lines of a change request reads each file from the code host once. The head menu finds only worktrees of the Session's repository, by branch: work a delegated Session does in a plain directory or in another repository does not show, and a worktree shows under its branch name, not under the Session that works there. Another head is read again when the Session's own checkout is, on Refresh or after its own changes, not after each edit in the other worktree.
中文
Problem
Session 变更请求绑定为每个 Session 提供了变更请求列表,但没有地方展示。让 agent 开变更请求的用户需要在不离开对话的情况下看到它们的检查、评审与能否合并,也希望新 Session 的修改和提交不影响当前检出。Git 必须在 Session 命令运行的地方执行,这可能是远程或受限的执行环境;检查不能改动仓库,而且 worktree 必须在模型第一次动作之前就存在。
Decision
dsh-experimental-client-ui-forge 是一个双端包。宿主端的 forgePanel Remote 把面板为一个 Session 展示的全部内容组装成一条流式状态;forge 注册表与绑定服务只保留各自的领域操作。客户端包括会话面板中的“变更请求”分栏、检出行与本地变更行和提醒标记,以及一个变更视图、一个新会话选项、一张位于输入框上方的创建卡片、一个 toast,以及会话列表中的图标与悬浮卡片部分。所有界面都把已绑定的条目称为变更请求(forge 注册表的术语),不随代码托管平台的叫法变化。forge 套件把面板、forge 注册表、GitHub 提供方、绑定服务、工作树模型工具与面板使用的一个隔离 worktree 服务作为插件页中默认禁用的一个条目发布。
评审与工作树控件服务于同一个代码修改流程。统一插件入口让用户可以一次启用这些能力,无需根据底层包的拆分判断应该开启哪张卡片。包与两套工作树服务仍保持独立,分别负责会话开始前和对话中创建工作树的流程。
Remote 通过 Session 的子进程提供方,按其解析出的权限与查询限制检查检出,因此它读到的与 Session 命令看到的相同。检查读取顶层目录、Git 目录与公共 Git 目录、分支或缩写的 HEAD 提交、上游与远端,以及分支相对于其分叉点的变更规模。它在 Session 被关注时、每个 workspace-root/change、tool/result 与 sandbox/mode 事件之后以及刷新时运行,一次只运行一个,最多再追加一次。
状态轮询跟随面板订阅:只有该 Session 的某个界面挂载时才监听其绑定,注册表停止轮询无人监听的变更请求。每张卡片保留最近一次轮询得到的快照,因此短暂的失败不会让标题与编号消失。Session 只有一个打开的变更请求时,它的卡片默认展开;有多个时全部折叠;用户第一次展开或收起卡片后,以用户的选择为准。
展开的卡片可以把草稿标记为可评审,也可以合并主机现在就会合并的变更请求。forge seam 把两者作为提供方操作承载,失败时返回带类型的结果;每个快照都说明主机现在是否会为已登录用户合并该变更请求、仓库允许哪些合并方式,因此面板只提供能够成功的操作。合并带上卡片显示的 head 提交,有新提交到达后主机会拒绝。面板只操作绑定到该 Session 的变更请求。
新 Session 通过请求而不是立即创建来以 worktree 开始。勾选新会话那一行中的选项(一个 conversation.hero.options 条目)会追加一条带基准分支的 plugin:client-ui-forge/worktree 记录;更换基准或取消勾选会再追加一条;用户发送之前不会改动仓库。只有创建能够成功时才提供该选项:在 workspace-write 下,检出及其公共 Git 目录必须位于可写根之内,这排除了本身就是链接 worktree 的项目。worktree 必须在第一条消息的这一轮开始之前就存在,这样这一轮才会在其中运行,第一次请求也已经写明新目录。消息进入 Session 的收件箱时,面板的 agent/inbox/inserted 监听器在这次投递唤醒 Agent 之前启动 Agent 的维护任务;Agent 会暂存唤醒直到维护任务结束,面板在维护任务内创建并进入 worktree。创建的阶段以流的形式推送给输入框上方的卡片,卡片上的“取消”停止这次尝试。尝试被停止或失败后,消息继续在收件箱中等待,卡片保留失败信息,并提供用新分支名再试一次,或“不使用工作树”:撤回请求并让消息继续。一个 agent/pre-step 监听器仍会在请求未完成的 Session 的第一个步骤提议中创建 worktree,因为 Agent 正在运行一轮或其他维护任务时进入的消息不会被暂留;它把工作目录通知移入本步提议的消息,失败时这一轮结束。forgeWorktree 投影忽略第一个 turn/start 之后的请求以及第一个 step/start 之后的创建,因此运行中的 Session 永远不会移动。标签页顶部一行写出 Session 所在的分支,会话列表标出在所创建 worktree 中工作的 Session。
Session 所在的 worktree 可能在 Session 之外被删除。每次检查都会确认所创建 worktree 的目录是否还在;Agent 空闲时进入的每条消息都会启动一次暂留并再确认一次,目录缺失期间消息等待、不开始这一轮。这次确认必须发生在这一轮之前:组装一个步骤的上下文时,工作目录服务会把目录已不存在的 Session 移回其项目,而这发生在任何 pre-step 监听器运行之前。“恢复”在记录的目录重新检出分支;分支也已删除时,在其基准提交重新创建分支。“在项目目录继续”把 Session 移回源检出。两者都在暂留内运行,之后放行等待中的消息。
面板不在现有 worktree 之间移动 Session。移除变更请求会追加一条 dismiss 记录,它的 toast 通过 track 提供“撤销”。
面板还通过变更视图展示 Session 工作背后的变更;变更视图是本包的一个资源标签页类型。Remote 在宿主上把每个 diff 解析成文件与 hunk,因此浏览器无需补丁解析器即可绘制,每次读取都受 maxDiffBytes 与 maxUntrackedFiles 约束。本地变更来自使用 Session 权限与执行环境的 git diff,范围由用户选择:默认是分支相对于分叉点的变更,也可以是未提交、未暂存或已暂存的变更;未跟踪文件经 Session 的文件系统读取,显示为新文件。变更请求的变更来自代码托管平台,取自绑定最新状态中的 head,经 forge seam 新增的两个提供方读取操作 diff 与 fileText 获得。Host 为每个变更请求保留最近读到的补丁,按 head 提交与目标分支区分,总量受 maxCachedDiffBytes 约束,因此在同一 head 下重新打开、刷新与导航都不会再次下载;托管平台或提供方因结果超过其大小上限而拒绝时报告 forge 失败 too-large,视图随之提供变更请求的网页而不是重试。hunk 之间未变更的行从文件的新版本展开,即工作树、暂存区或 head 提交,并且只在该文本仍与 hunk 吻合时展开。每次检查还会为变更卡片统计分支的变更规模;没有打开中的变更请求以当前检出分支为源分支时才显示该卡片。卡片上的“创建变更请求”向 Session 发送一条用户消息,由 Agent 用自己的工具创建变更请求,绑定像其他变更请求一样来自 gh pr create。
变更视图也写 checkout,粒度是整个文件:“未暂存”范围可以暂存和还原,“已暂存”范围可以取消暂存。评审 Agent 工作的人把认可的部分放进暂存区、丢弃其余部分,没有这些写操作就得离开应用去做。读者按下按钮就是授权,正如归档之于 worktree 服务移除 checkout,所以写入命令不受 Session 沙箱策略约束:该策略约束的是 Agent 的行为,读者可以在只读的 Session 里暂存,也可以在目录位于 checkout 根目录之下的 Session 里暂存。暂存和还原为每个文件带上读者所见改动的 digest,Remote 重新读取 unstaged 范围,改动不同就拒绝写入:从读者看到文件到按下按钮之间,Agent 可能又改了它。暂存和取消暂存的撤销,是把暂存区条目恢复到写入之前写出的 tree。还原没有撤销,所以先询问。
本地变更视图读取的不只是 Session 自己的检出。标题栏开头的菜单可以选择仓库的另一个本地分支或远程跟踪分支。仓库里有 worktree 检出的分支在该 worktree 里读取,四个范围都可用,这样就能看到子智能体在自己的 worktree 里改了什么,包括未提交的文件;没有 worktree 检出的分支只显示已提交的内容。本地范围用可选的 head 表示这个选择,而不是给视图增加第二种来源,所以每次读取、透镜请求、已审阅标记的键和已加载数据的键都通过它们本来就接受的范围带上它;Session 自己的检出不带 head,所以浏览器为它保存的已审阅标记和评论记录保持原有标识。页面只发送分支引用,从不发送路径:Host 校验引用,向 Git 询问哪个 worktree 检出了该分支,通过检查确认那里是同一个仓库的检出并且确实检出了它,再以读取方 Session 的沙箱策略在那里运行 Git。没有选择基准时,其他分支与 Session 自己的 HEAD 比较,而不是像 Session 自己的检出那样与远端默认分支比较:查看子智能体分支的人想知道的是它离开 Session 的工作之后改了什么;这种比较在没有远端的仓库里也成立,并且不会把 Session 派出任务之前自己的提交算进去。其他 head 是只读的,插件插槽和行注解只留给 Session 自己的检出,所以其他插件使用的 ctx.forgeChanges 不变。Session 面板的本地变更行在每个 Git 检出内都显示,没有变更时显示空的行数,这样当 Session 自己的检出没有变更、而它的子智能体在 worktree 里工作时,也能打开视图和菜单。
评审评论在用户选择代码时固定文件、侧、行范围、完整 hunk 与所评审的 head。Agent 引用进入既有输入框引用机制,由用户决定批量发送,发送后的消息记录模型实际收到的内容。GitHub 写入属于 forge 提供方的可选操作:预检核对当前 head,写入明确指向该提交;结果不明时阻止再次写入,直到用户核对。Agent 引用与已发布评论的行内记录以及评审总结归浏览器页签实例所有,不进入 Session 日志;留待之后一起提交的 PR 评论写入代码托管平台的待提交评审,见待提交评审决策。切换 Session 保留该实例;关闭时丢弃本地状态并拒绝迟到的写入结果。已发布的 GitHub 评论仍保留在外部平台。
Deferred
本节曾暂缓的左侧导航代码审查页已实现为代码评审页;它的列表来自可选的提供方能力,页面按 URL 读取变更请求,因此本包的会话界面没有改变。
变更视图目前还没有单个提交与上一轮的范围;两者将是经 localDiff 读取的更多 ForgeLocalScope 种类。
Alternatives considered
按平台使用不同名称。 在 GitHub 上称 pull request、在 GitLab 上称 merge request,需要每个提供方声明自己的名称,所有文案也要随之变化;而 GitHub 是唯一的提供方,统一的术语让文案保持不变。
通过 gh pr merge 合并。 必需检查尚未完成时它会启用自动合并,基准分支要求合并队列时它会加入队列,因此一次点击可能安排了一次以后的合并而不是立即合并。REST 合并接口要么立即合并,要么拒绝。
合并后删除 head 分支。 Session 的 worktree 可能就在这个分支上。
为 Git 检查单独建一个宿主服务包。 目前没有第二个使用方需要检出信息;出现模型工具时,可以再把它们移入共享服务。
以宿主进程运行 Git。 远程与受限的执行环境会显示宿主的文件而不是 Session 的文件,宿主还会读取 Session 无法读取的目录。
勾选时立即创建 worktree。 每次切换勾选或更换基准都会创建并丢弃一个检出,而且用户决定发送之前 Session 就已经移动。
在创建 Session 的请求中携带该选项。 这个请求由 Session 控制器拥有,字段是封闭的;插件记录让选项留在本包之内,并且在空白 Session 重新加载后仍然保留。
在面板中切换现有 worktree。 切换后的 Session 仍保留其项目的沙箱根,因此项目之外的 worktree 依然只读;对话中途移动还会让模型对文件的认识前后割裂。让 Session 从一开始就在自己的 worktree 中运行可以同时避免这两点。
把选项放在输入框工具栏。 发出第一条消息后工具栏依然存在,而那时该选项已不再适用;新会话那一行在 Session 开始后就会消失。那一行原先只提供单值 slot,因此 ui-conversation 增加了列表型 slot conversation.hero.options。
在第一轮之内创建 worktree。 第一个步骤提议运行时这一轮已经开始:上下文按旧目录组装,失败只能结束这一轮并丢弃已认领的消息,而工作目录服务已经把 Session 移出被删除的 worktree。它只作为没有被暂留的消息的兜底。
在 Agent 接纳阶段暂留消息。 agent-controller/admission 阶段会在消息进入收件箱之前暂留它,因此 worktree 建好之前消息一直留在输入框里,失败时退回以便编辑。它需要在每个发送方的投递之前加一个控制器服务,单个面板不足以支撑这项核心改动;在收件箱插入时暂留只用现有的收件箱事件与维护任务,并覆盖所有发送方。
把等待中的消息退回输入框。 宿主接收消息之后,输入框没有办法把它收回,除非为一个插件在会话包里新增公共 API;消息改为在卡片的操作下继续等待。
在 Web 输入框里设发送闸门。 浏览器在宿主看到消息之前就拦住它,因此每次检查都要一次 Remote 调用,被拒绝消息的阶段只存在于浏览器中,其他发送方也会绕过它。在收件箱插入时暂留,让消息停在它进入 Agent 的位置,并把失败保留在面板状态中。
把创建卡片放进对话记录。 对话记录的节点不接受插件定义的类型;输入框上方的停靠区是最近的列表型 slot,而且它在新会话页也会渲染。
手动粘贴 URL 跟踪。 它与 Session 自己的命令记录下的绑定重复。绑定来自 gh pr create、操作单个变更请求的 gh pr 命令、推送以及检出所跟踪的分支,track 保留给“撤销”使用。
在浏览器中解析补丁。 Remote 将传输不受限的补丁文本,浏览器也需要补丁解析器;宿主约束读取并只解析一次。
复用代码审查标签页的文件对比。 它属于另一个插件,本包在运行时不能导入;把它移入共享基础组件又会为一个使用方改动共享包。变更视图改用共享的高亮器、菜单、提示与 diff 颜色 token 构建。
从本地仓库读取变更请求的 diff。 当前检出分支可能领先或落后于托管平台,基准分支也可能没有拉取;评审者看到的是托管平台的 diff。视图改为在当前检出分支有超出 head 的提交时给出说明。
在面板里根据失败信息识别 diff 过大。 失败信息属于提供方及其托管平台,会随它们变化;失败代码让每个提供方报告自己的上限,面板只按代码分支。
直接在卡片上创建变更请求。 面板需要推送分支并撰写标题与描述;发送消息让 Agent 用自己的工具和用户的指示完成这两件事,绑定变更请求的方式也只保留一种。
把每条行内评论立即发送给 Agent。 用户还没来得及收集相关评论或补充共同指令,就会开始一轮;输入框引用保留用户的选择。
关闭页签后仍保留评审草稿。 重新打开同一个 PR 会恢复已放弃的评审状态。页签实例让关闭明确表示丢弃,同时保留切换 Session 的状态。
暂存代码块或行。 整个文件已经覆盖“留下或丢弃 Agent 改的某个文件”,只需要四条 Git 命令和一条过期规则。代码块级的写入要把补丁应用到暂存区,还要为位置移动的代码块另定规则;留给以后的变更。
在 Session 的沙箱策略下执行读者的写入。 第一版是这样做的,因为 git add、git reset 和 git restore 会运行仓库的 filter,而 Session 可以配置它们。结果是暂存区位于 Session 可写目录之外时按钮都会失败:目录在 checkout 根目录之下的 Session、不是 Host 创建的 linked worktree,以及只读的 Session。2026-11-25 调研的八个同类产品都不约束用户自己发起的 Git 写入,本仓库的归档清理也已经凭用户的授权直接运行 Git。
为写入置空仓库的 filter driver。 Codex 的 worktree 代码、Reasonix 和 Pi 对每条命令都这样做,本包对读取也这样做。但仓库自己配置了 filter 时(例如只为某个仓库安装的 Git LFS),暂存进去的会是未经 filter 处理的内容,所以使用这类 filter 的文件必须被拒绝。有同样按钮的两个同类产品 MiniMax Code 和 ZCode 执行这些命令时没有这道防护;那三家防护的是其他 Git 操作。能修改仓库配置的 Session 本来就能自己运行命令,所以这道防护会拿走一个可用的功能,却不会去掉任何能力。
用取消暂存作为暂存的撤销。 更早暂存过修改的文件,会连那次修改也一起从暂存区丢掉。写入之前的暂存区 tree 能恰好恢复这次写入改动的条目。
在“未提交”和“分支”范围里写入。 两者比较的都是工作区,所以暂存不会改变它们显示的内容,只暂存了一部分的文件也看不出是哪一部分。
把已暂存和未暂存的文件作为同一列表的两组。 两边都有修改的文件会列出两次,而已审阅标记、展开状态、文件树和跳转都用路径识别文件。
还原暂存区只登记了路径、还没有内容的文件。 git restore 会用空的暂存区条目替换它,而删除它会丢掉用户选择跟踪的文件;视图不为它提供还原。
自动重试评审写入。 丢失响应不代表 GitHub 拒绝了请求。保留发出的请求并要求核对,可以避免传输失败悄悄产生重复评论。
为另一个分支单独设一种视图类型。 每次读取、透镜请求、已审阅标记的键和数据的键都要多一种情况。本地范围上可选的 head 通过它们本来就接受的值到达所有这些地方。
在菜单里按 Session 列出当前 Session 派出的子 Session。 每一行用 Session id 指定一个子 Session 的检出。这样每次列出都要读取子智能体目录和每个子 Session 的记录,同一个检出里的多个 Session 需要合成一个标签,Session 后来换了目录时它的行还留在旧名称下。Git 的 worktree 列表通过读者搜索的分支就能到达同样的工作树,不依赖子智能体服务。
其他分支一律只显示已提交的内容。 对另一个 worktree 检出的分支只按提交读取,会看不到子智能体尚未提交的修改,而读者正是在子智能体工作时查看这些修改。
在其他 head 上提供写操作和插件条目。 插槽、注解和 ctx.forgeChanges 面向的是 Session 自己的本地变更;其他 head 保持只读、不带这些条目,这个接口就不用改。
Consequences
面板只在打开时显示当前状态;没有任何界面挂载时检查结束不会有通知。Session 之外的改动要等到刷新或下一个工具结果才会出现。本地写操作不记录到 Session,也不告知模型;Agent 下次读取 checkout 时才看到结果。本地写操作会以 Host 的权限运行仓库配置里指定的 clean 和 smudge filter(已对 git add 和 git reset 实测),而能写自己 checkout 的 Session 可以添加这样的 filter。只有一个远端时,每次检查最多在 Session 的执行环境中启动十二个短暂的 Git 进程;为寻找分叉点每多尝试一个远端,就多启动两个。只有在第一步之前提出请求的 Session 才会有 worktree,失败或被取消的尝试可能留下它的分支或检出。Agent 正在运行一轮或其他维护任务时进入的消息不会被暂留,因此它的 worktree 在第一轮之内创建,已删除的 worktree 也不会被检查。消息等待期间,Agent 以空闲状态处于维护任务中:输入框不提供停止,等待 Agent 空闲的调用方也会一并等待。恢复会丢失从未提交的修改。要求合并队列的基准分支无法从面板合并。组合包挂载两个互不影响的 worktree 服务;模型的工具看不到面板的服务。本地或变更请求的 diff 超过 maxDiffBytes,或被托管平台拒绝时,不显示任何文件。展开变更请求中未变更的行时,每个文件只从托管平台读取一次。查看分支的菜单只能按分支找到 Session 所在仓库的 worktree:子 Session 在普通目录或另一个仓库里做的工作不会出现,worktree 以它的分支名出现,而不是以在其中工作的 Session 出现。其他 head 在 Session 自己的检出重新读取时才重新读取(点击“刷新”或它自己的变更变化之后),而不是在另一个 worktree 每次修改之后。