Skip to content

Keep tackroom.yaml formatting when a command edits it - #293

Merged
yourconscience merged 1 commit into
mainfrom
config-write-format
Nov 17, 2026
Merged

yourconscience merged 1 commit into
mainfrom
config-write-format

Conversation

@yourconscience

@yourconscience yourconscience commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

What and why

tackroom.yaml is a hand-edited file kept in git. Any command that edited it (skill sources add, mcp add and remove, config set, setup, the web view's edits) re-serialised the whole file, so the diff showed far more than the change:

  1. every blank line disappeared;
  2. a key written with an empty value, such as hooks: [], was deleted together with the comment above it;
  3. agents: [] was added to hook and MCP entries that did not have the key.

Found in the pre-release test of the 3.0 line; 2.8.0 behaves the same.

After this change a command touches only the lines of the entry it adds, changes or removes. One file changes, internal/app/config_document.go:

  • Typed merge. An empty list the file spells out stays as written, and an empty list is not added to an entry that lacks the key. This applies to plain list fields only, where a missing key and [] read back the same; pointer fields (packages, ui) behave as before. A comment on a replaced value is kept.
  • Text pass after re-encoding (keepFileFormat). The old and new text are compared line by line. A changed stretch whose old text decodes to the same YAML data gets its old text back, and a stretch that really changed keeps the blank lines around it. CRLF line endings and a missing final newline follow the original. Every candidate is checked against the decoded data of the re-encoded output, and the function falls back to the re-encoded text when they differ, so formatting can never change the data written.

The web view's raw save is unchanged and stays byte-exact.

Side effect: a fresh tackroom setup now writes the starter tackroom.yaml as it ships, with the detected agents filled in. It keeps hooks: [], its blank lines and the # populated by tackroom setup comment, and no longer adds mcp_servers: [], which the old writer added by accident.

Not covered, and the same as before:

  • A write that goes through the typed config still rewrites values tackroom normalises on read in entries it did not touch, for example a | block scalar becomes |- and a missing enabled is written out. That is a data change in YAML terms, so the text pass keeps it.
  • A changed section written with 4-space indent or flow style is re-indented as a whole.
  • Blank lines in the middle of a changed stretch are not restored.

The 3.0 release note for this comes with the docs PR that collects the notes for the pre-release fixes.

How I checked it

  • go build, go vet, go test ./... pass; lint reports 0 issues. No test was deleted.
  • The same starting file and the same command with a binary from main and one from this branch, in throwaway homes. config print read back by the main binary is identical in every case, and config validate accepts every result:
Command on an awkward file (comments, blank lines, flow style, block scalar, 4-space section) Lines changed, main Lines changed, this branch
config set hooks/lint/enabled false 25 2
config set hooks/notify/enabled false 23 2
mcp add web --command ... 38 23
skill sources add --all --no-sync file://... 35 24
mcp remove docs 23 9
config set hooks/lint/enabled true (no change) 23 0
  • Running each command a second time leaves the file byte-identical.

  • On the file from the test report, skill sources add now changes only the external_skills block, and # Hooks live here (none yet) with hooks: [] stays.

  • CRLF files, a file with no final newline, and a write to tackroom.local.yaml were exercised by the worker's case runner with the same result.

  • Not run: the web view's edit path in a browser (it uses the same code as config set), and mcp import.

  • go test ./... and go vet ./... pass

  • I can explain this change without an AI tool

Summary by Sourcery

Preserve tackroom configuration formatting and comments while limiting command-generated diffs to the data that actually changes.

Bug Fixes:

  • Preserve existing YAML formatting, comments, blank lines, line endings, and final-newline behavior when typed configuration commands modify tackroom files.
  • Prevent typed writes from removing explicitly empty list values or adding empty list keys that were absent from the original configuration.
  • Retain comments associated with replaced YAML values while ensuring formatting preservation cannot alter the resulting configuration data.

Enhancements:

  • Apply formatting preservation consistently to typed configuration operations while leaving raw web-view saves byte-exact.

@sourcery-ai

sourcery-ai Bot commented Nov 17, 2026

Copy link
Copy Markdown

Sorry @yourconscience, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 1 day and 6 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@coderabbitai

coderabbitai Bot commented Nov 17, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ddc7100e-683c-4d52-8db3-f3a2f5f6fc6f
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@sourcery-ai

sourcery-ai Bot commented Nov 17, 2026

Copy link
Copy Markdown

Reviewer's Guide

Implementation

Preserve explicitly written empty plain-list values during typed merges, avoid adding empty-list keys that were absent, and retain comments when replacing values.

  • internal/app/config_document.go L205-237, L275-281, L895-900 (+10 small edits)

Reconcile re-encoded YAML with the original text so unchanged data keeps its formatting and changed stretches retain edge blank lines, while validating that the result preserves the re-encoded data.

  • internal/app/config_document.go L467, L541-666

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@yourconscience
yourconscience merged commit 05ac24d into main Nov 17, 2026
11 checks passed
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.

1 participant