Skip to content

fix(sync): stop autosyncing after td comments listings - #219

Merged
marcus merged 1 commit into
marcus:mainfrom
jubishop:worktree-comments-read-only
Oct 17, 2026
Merged

marcus merged 1 commit into
marcus:mainfrom
jubishop:worktree-comments-read-only

Conversation

@jubishop

Copy link
Copy Markdown
Contributor

Summary

td comments <id> only lists an issue's comments, but it runs the post-mutation autosync: a push and pull after the command. The mutating-command list is keyed by command name, and resolveCommandName resolves td comments add to its parent, comments. So when 37c4b25 added comments to make td comments add sync, the listing came along with it.

With sync configured, each listing made an extra pull after its startup sync. When earlier local changes were still unpushed and the server couldn't be reached, a listing also printed Warning: sync: N local change(s) not yet pushed to remote (will retry on next td command). With autosync explicitly turned off and changes pending, it could print the "configured for sync but autosync is off" warning instead.

Changes:

  • The mutating list names comments add instead of comments.
  • The post-run hook counts a command as mutating when either its resolved name or its full path below the root, such as comments add, is listed. Every other command classifies as before.

Startup sync is unchanged, so with on_start enabled (the default) a listing still pulls once before it runs.

Testing

  • make test, go vet ./..., and gofmt pass. golangci-lint v2.13.1 with GOOS=linux and Go 1.27.0, as in CI, reports 0 issues. go test -race -count=1 -run 'Mutat|AutoSync|Autosync' ./cmd/ passes.
  • Tests:
    • TestIsMutatingCommand now expects comments add to be mutating and comments not to be. It fails with main's list.
    • The new TestIsMutatingInvocation resolves real invocations through rootCmd: comments <id> is read-only, while comments add, comment, and board list stay mutating. It fails if either the list change or the full-path check is reverted.
    • The new TestMutationHookSkipsCommentsListing runs runGatedSyncMutationHook for a sync-configured project. The post-mutation sync runs for comments add and not for a listing. If the hook goes back to matching only the resolved name, it catches comments add no longer syncing.
  • Manual, with real binaries:
    • In the e2e harness, with autosync on and on_start off, a listing made one pull on main and none on this branch. comments add pushed and pulled on both.
    • Against my own td-sync server with startup sync on, a listing made two requests with v0.68.0 and one with this branch.

Not in this PR

Other read-only commands still count as mutating:

  • blocked-by and depends-on only read, and both are in the mutating list.
  • td dep <id> with one argument only reads, but it shares dep with the commands that add and remove dependencies.
  • board, ws, epic, and task have read-only subcommands, such as board list, ws show, and epic list, that count as mutating through their parent.

Removing blocked-by and depends-on would be a two-line change. The subcommands could use the full-path lookup by listing only the mutating ones. That list would need updating whenever someone adds a subcommand, and dep <id> depends on its argument count rather than its path, so these seemed better as their own change.

🤖 Generated with Claude Code

`td comments <id>` only reads, but it shared the `comments` entry that makes
`td comments add` sync, so each listing pushed and pulled afterward. The
mutating list now names `comments add`, and the post-run hook also matches a
command's full path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@marcus
marcus merged commit 938261d into marcus:main Oct 17, 2026
3 checks passed
@jubishop
jubishop deleted the worktree-comments-read-only branch October 17, 2026 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants