Repository navigation
Workspace & Directory APIs: patch conflicts, overlay search, path removal - #13777
Merged
Merged
Conversation
This was referenced Jul 30, 2026
vito
force-pushed
the
llm-workspace-workspace-apis
branch
from
July 30, 2026 20:53
dde84c0 to
0ce59ce
Compare
vito
force-pushed
the
llm-workspace-workspace-apis
branch
from
July 30, 2026 21:03
0ce59ce to
f4905a1
Compare
vito
force-pushed
the
llm-workspace-workspace-apis
branch
from
July 30, 2026 21:43
f4905a1 to
5f96568
Compare
vito
force-pushed
the
llm-workspace-workspace-apis
branch
2 times, most recently
from
July 30, 2026 22:31
6a84d8a to
d1feb73
Compare
vito
force-pushed
the
llm-workspace-workspace-apis
branch
from
July 31, 2026 17:38
be641c8 to
afbeb29
Compare
Patches recorded during an LLM session get replayed when a saved session is loaded, and by then the workspace content may have drifted: git apply fails outright and the session cannot resume. The new onConflict mode LEAVE_CONFLICT_MARKERS applies with --reject, converts each rejected hunk's .rej into a git-style conflict block inserted at the hunk's recorded position (current content around it, the hunk's intended result inside), removes the .rej, and warns on the span's stderr listing the conflicted files. Placement is best-effort by nature - the content drifted, which is why the hunk rejected - but the markers are labeled and grep-able, which is what a resuming agent needs to resolve them. The default remains FAIL. Signed-off-by: Alex Suraci <[email protected]>
Workspace.search and Workspace.glob on a host-backed workspace ran entirely against the host filesystem, so pending overlay edits were invisible: a file modified through the overlay kept matching its stale host content, and removed or newly created files were missed entirely. Notably, after restoring an LLM session the model could not find its own conflict markers. Both APIs now merge the host results with an in-engine pass over the overlay's delta root, with per-path replacement: the overlay's view wins for every path its edits touch, so modified files serve overlay content, removed paths drop out, and created ones appear, while untouched paths keep serving host results. Explicit search paths apply to the overlay side as a post-filter since the sparse delta lacks host-only paths, and the limit caps the merged, sorted set. Signed-off-by: Alex Suraci <[email protected]>
Workspace could add and modify paths through the overlay but had no way to remove one, so deleting a file meant dropping to the underlying Directory and losing the overlay. Add withoutFile and withoutDirectory, which record the removal in the overlay like any other edit. Signed-off-by: Alex Suraci <[email protected]>
Git worktree and submodule checkouts don't have a .git *directory* at the tree root: they have a .git pointer file (a "gitfile") whose gitdir target lives outside the workspace boundary. Workspace.git previously bailed out on such a checkout with "git worktrees are not supported by Workspace.git yet: .git is a file", so head/uncommitted queries failed outright from a linked worktree or submodule. Port the gitfile resolution already used for contextual module git args (see ModuleSource.resolveGitPointer) to workspaces: extract the flatten logic into a reusable core.FlattenGitPointer, which resolves the pointer against the host, loads the real git directory (plus the shared common directory for worktrees), and flattens everything into a standalone .git directory in the snapshot. Workspace.git now follows the pointer through its owning client session, so a worktree/submodule checkout behaves like a plain clone -- reporting the per-worktree HEAD and detecting uncommitted changes. ensureWorkspaceGitDirectory no longer rejects a regular .git file, since the pointer is followed and flattened when the repository is resolved. Replace TestWorkspaceGitWorktreeUnsupported with TestWorkspaceGitWorktree, which diverges the linked worktree's HEAD from the main checkout to prove the per-worktree state is honored and asserts uncommitted changes are detected. Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
golangci-lint's nolintlint flags the dupl suppressions on withPatchFile and withChanges as unused: dupl no longer considers the two functions duplicates, so the directives suppress nothing. Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
vito
force-pushed
the
llm-workspace-workspace-apis
branch
from
July 31, 2026 18:35
afbeb29 to
9aa1aa4
Compare
kpenfound
approved these changes
Aug 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Additive
WorkspaceandDirectoryAPI surface, independent of the LLM work above it.Directory.withPatch(onConflict:)— a new conflict mode that degrades drifted hunks into labeled conflict markers instead of failing the patch. This is what makes a recorded session survive a checkout that moved underneath it.Workspace.search/glob— both read through the overlay, so a file an agent just wrote is findable without exporting it first.Workspace.withoutFile/withoutDirectory— the overlay could add and modify paths but had no way to remove one, so deleting a file meant dropping to the underlyingDirectoryand losing the overlay. Removals are now recorded in the overlay like any other edit.Workspace.gitfollows.gitpointers, so a worktree or submodule checkout resolves to its real repository.