Skip to content

feat(model): report storage engine in tracking metadata#285

Merged
AnnatarHe merged 1 commit into
mainfrom
claude/quirky-bohr-b0cue8
Jun 12, 2026
Merged

feat(model): report storage engine in tracking metadata#285
AnnatarHe merged 1 commit into
mainfrom
claude/quirky-bohr-b0cue8

Conversation

@AnnatarHe

Copy link
Copy Markdown
Contributor

Why

Follow-up to #284: the server (shelltime/server#451) now records which local storage engine buffered each synced command, so web/iOS can display it and suggest switching to bolt.

What

  • CommandStore gains Engine() string (StorageEngineFile / StorageEngineBolt), implemented by both stores
  • TrackingMetaData gains cliEngine (omitempty), populated in BuildTrackingData from the store the payload was actually read from

Setting it at payload-assembly time means all three send paths report the truth without further changes:

  • daemon bolt path (daemon/handlers.track.go)
  • CLI txt-file fallback (commands/track.go)
  • legacy CLI→daemon socket sync (meta travels inside PostTrackArgs; sendTrackArgsToServer doesn't touch it)

A config that says bolt while the daemon is down still correctly reports file, because the engine comes from the store, not the config.

Verification

  • go vet ./... clean; go test ./model/ ./commands/ ./daemon/ pass
  • New assertions: BuildTrackingData meta reports bolt for the bolt store and file for the file store; the daemon flush test now decodes the HTTP body and asserts meta.cliEngine == "bolt" and source == 1
  • TestGitInfoTestSuite fails in this sandbox environment, same as on main (documented in feat: bbolt-backed command store (daemon-owned, feature-gated) #284)

Companion PRs: shelltime/server#451, shelltime/web, shelltime/ios.

https://claude.ai/code/session_015ZzRC212TzpPdHwwcxKohA


Generated by Claude Code

Follow-up to #284: the server now wants to know which local storage
engine buffered each synced command. Add Engine() to the CommandStore
interface (file/bolt) and attach it as cliEngine to TrackingMetaData in
BuildTrackingData, so every send path — daemon bolt handler, CLI file
fallback, and the legacy CLI->daemon socket sync — reports the engine
that actually held the data.

https://claude.ai/code/session_015ZzRC212TzpPdHwwcxKohA
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
unittests 42.01% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
model/api.go 100.00% <ø> (ø)
model/store.go 68.00% <ø> (ø)
model/store_bolt.go 67.14% <100.00%> (+0.23%) ⬆️
model/store_file.go 47.82% <100.00%> (+0.57%) ⬆️
model/tracking_build.go 75.00% <100.00%> (+0.39%) ⬆️

... and 1 file with indirect coverage changes

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

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces tracking of the CLI storage engine (either File or Bolt) used to buffer commands by adding an Engine() method to the CommandStore interface and including this metadata in the payload sent to the server. The review feedback suggests two improvements to the test suite: avoiding platform-dependent environment variables by passing t.TempDir() directly to InitFolder, and explicitly asserting that JSON decoding succeeds in the test HTTP server rather than ignoring the error.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +39 to +40
t.Setenv("HOME", t.TempDir())
InitFolder("") // reset globals to the default .shelltime under the temp HOME

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.

medium

Hardcoding the 'HOME' environment variable is platform-dependent and violates the general rule of avoiding environment variables like '$HOME' for path resolution. It will fail on Windows where 'os.UserHomeDir()' looks up 'USERPROFILE'. Since 'InitFolder' accepts a custom path, pass 't.TempDir()' directly to it to ensure platform independence.

Suggested change
t.Setenv("HOME", t.TempDir())
InitFolder("") // reset globals to the default .shelltime under the temp HOME
InitFolder(t.TempDir())
References
  1. For platform-independent paths, use filepath.Join to combine segments and os.UserHomeDir() to get the home directory, rather than hardcoding path separators or environment variables like $HOME.

func (s *TrackHandlerTestSuite) TestTrackPostFlushSyncsAndPrunes() {
var sentPayload model.PostTrackArgs
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_ = json.NewDecoder(r.Body).Decode(&sentPayload)

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.

medium

Ignoring the error from 'json.NewDecoder().Decode()' can lead to silent test failures or confusing assertion errors if the request body is malformed or empty. It is better to explicitly assert that decoding succeeded.

Suggested change
_ = json.NewDecoder(r.Body).Decode(&sentPayload)
err := json.NewDecoder(r.Body).Decode(&sentPayload)
assert.NoError(s.T(), err)

@AnnatarHe AnnatarHe merged commit e5b8200 into main Jun 12, 2026
6 checks passed
@AnnatarHe AnnatarHe deleted the claude/quirky-bohr-b0cue8 branch June 12, 2026 16:21
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