Chat turn diffs: leave out the harness home inside the folder (CLAUDE_CONFIG_DIR)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 19:32:30 +00:00
parent a5c502a0d8
commit 4a40539ece
2 changed files with 64 additions and 0 deletions
+38
View File
@@ -11,6 +11,7 @@ import (
"git.a-wan.net/alan/pipelines/internal/filediff"
"git.a-wan.net/alan/pipelines/internal/protocol"
"git.a-wan.net/alan/pipelines/internal/stage"
)
// Per-turn chat diffs (protocol/chat_turn_diff.go). The hub snapshots the
@@ -193,6 +194,10 @@ func (h *chatHub) finishTurnDiff(sessionID string, capture *chatTurnCapture, end
return
}
changes := filediff.Compare(capture.baseline, after)
// The harness's own home inside the folder (CLAUDE_CONFIG_DIR, e.g. a
// per-project .claude-profile) changes on every turn; it is not the
// operator's work.
changes = withoutHarnessState(changes, capture.dir, stage.HarnessStateDirs(workspaceEnv(ctx, capture.dir)))
summary, ok := chatTurnDiffSummary(capture, ended, changes)
if !ok {
return
@@ -292,3 +297,36 @@ func handleChatTurnDiff(ctx context.Context, request protocol.Message, hub *chat
Changes: &changes,
}})
}
// withoutHarnessState drops the files under any of dirs that lie inside
// workspace; the rest of changes is kept as it was.
func withoutHarnessState(changes *protocol.StageFileChanges, workspace string, dirs []string) *protocol.StageFileChanges {
if changes == nil {
return nil
}
var prefixes []string
for _, dir := range dirs {
if rel, ok := workspaceRelative(workspace, dir); ok && rel != "." {
prefixes = append(prefixes, rel+"/")
}
}
if len(prefixes) == 0 {
return changes
}
kept := changes.Files[:0:0]
for _, file := range changes.Files {
inside := false
for _, prefix := range prefixes {
if strings.HasPrefix(file.Path+"/", prefix) {
inside = true
break
}
}
if !inside {
kept = append(kept, file)
}
}
filtered := *changes
filtered.Files = kept
return &filtered
}