Skip to content

feat: record the result of a background CLI update - #806

Open
zimeg wants to merge 4 commits into
mainfrom
zimeg-feat-auto-update-record
Open

zimeg wants to merge 4 commits into
mainfrom
zimeg-feat-auto-update-record

Conversation

@zimeg

@zimeg zimeg commented Nov 18, 2026

Copy link
Copy Markdown
Member

Changelog

N/A, groundwork for the auto-update experiment.

Summary

This pull request adds a record of the result of a background CLI update, saved in its own file for the next command to report.

  • AutoUpdateResult holds the versions an update went from and to, plus an error when it failed.
  • The record is autoupdate.json in the Slack config directory, so it follows --config-dir. It stays out of config.json because the background process would be a second process writing that file while other commands read it, and config.json writes only lock within one process.
  • Writes go to a temporary file in the same folder that's then renamed into place, so a reader sees either the whole old record or the whole new one.
  • A missing file reads as no record, and clearing removes the file.
  • This comes before upcoming work to update the CLI in the background with the auto-update experiment. Nothing calls these functions yet.

Preview

N/A, nothing changes for developers yet.

Testing

N/A, nothing calls the record yet. The unit tests write and read back a record with and without an error, read a missing record as none, clear a record, and write under a custom --config-dir.

Notes

  • The functions take the ClientFactory and use clients.Fs, like the rest of internal/update. They're unexported since the code that reads and writes the record lives in this package too.

Requirements

🤖 Generated with Claude Code

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
@zimeg zimeg added this to the Next Release milestone Nov 18, 2026
@zimeg zimeg added enhancement M-T: A feature request for new functionality semver:patch Use on pull requests to describe the release version increment labels Nov 18, 2026
@zimeg zimeg self-assigned this Nov 18, 2026
@codecov

codecov Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 72.50000% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.19%. Comparing base (249a48f) to head (04220b3).

Files with missing lines Patch % Lines
internal/update/autoupdate_result.go 72.50% 11 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #806      +/-   ##
==========================================
+ Coverage   80.18%   80.19%   +0.01%     
==========================================
  Files         244      245       +1     
  Lines       18736    18776      +40     
==========================================
+ Hits        15024    15058      +34     
- Misses       3712     3718       +6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zimeg
zimeg marked this pull request as ready for review November 18, 2026 19:59
@zimeg
zimeg requested a review from a team as a code owner November 18, 2026 19:59

@mwbrooks mwbrooks left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Thanks @zimeg! Writing to a temp file and renaming it into place is a nice touch, so a command never reads half a record.

@zimeg
zimeg requested a review from mwbrooks November 18, 2026 20:05

@cchensh cchensh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Non-blocking nits for when this gets wired in:

  1. readAutoUpdateResult returns an error when autoupdate.json doesn't parse. Since the next command reads it on startup, treating a corrupt or old-shape file as "no record" (and maybe clearing it) would keep a bad file from failing an unrelated command. A test for that case would help.
  2. The temp file isn't fsynced before the rename, so after a power loss the record could be empty. Fine for a status file; a Sync() before Close() would cover it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement M-T: A feature request for new functionality semver:patch Use on pull requests to describe the release version increment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants