Repository navigation
feat(trellis): history settings and Run maintenance in Settings → Trellis - #21
Conversation
Shows and edits Trellis's history settings (snapshot timer, turn and timer snapshot retention, trash and incoming expiry) through two new RPCs, trellis.getHistorySettings and trellis.updateHistorySettings, backed by GET/PUT /v1/settings/history. Each value commits on blur, Enter or the step buttons and sends only that key; Trellis's refusal shows under the row, and a save that the next thinning acts on says how many snapshots go. Live snapshot counts per kind and the last thinning are shown read only. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…t write - Unchanged-detection compares with the field's pending value, else the value in force, so 30 -> 14 -> 30 before the answer still sends 30. - updateHistorySettings runs serially per environment; each write carries a per-field revision, and only a field's latest write clears its draft or shows its refusal, so a stale failure never undoes a newer edit. - A successful write's returned values show at once (until a newer read), and a failed refresh shows a stale notice beside the cached values. The edit state lives in TrellisSettings.logic.ts with unit tests; the server test also maps all eight keys out in one PUT. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…e number fields mounted while stepping Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0bca20a78b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| runMaintenance: createEnvironmentRpcCommand(connectionAtomRuntime, { | ||
| label: "environment-data:trellis:run-maintenance", | ||
| tag: WS_METHODS.trellisRunMaintenance, | ||
| concurrency: { mode: "serial", key: ({ environmentId }) => environmentId }, |
There was a problem hiding this comment.
Serialize maintenance behind pending history updates
When a user edits a retention/expiry field and immediately clicks Run now—clicking the button can itself blur and commit the field—the update and maintenance commands use separate schedulers, so these identical environment keys do not serialize with each other. The maintenance request can therefore begin before the PUT completes and apply the previous policy; notably, changing an expiry to 0 and running maintenance could still remove data under the old nonzero expiry. Use a shared scheduler/lane or prevent maintenance until all pending writes settle.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Valid: the history section now chains its saves, and Run now awaits that chain before calling maintenance, so a field committed by the click (blur happens first) is saved before maintenance applies the policy. Fixed in 79e2682.
| label: "environment-data:trellis:history-settings", | ||
| tag: WS_METHODS.trellisGetHistorySettings, | ||
| staleTimeMs: 30_000, | ||
| idleTtlMs: 60_000, | ||
| }), |
There was a problem hiding this comment.
Refresh history data while the section remains mounted
This query has a stale threshold but no refresh interval or manual refresh action, so after the initial read its settings, snapshot counts, and last-thinning value remain unchanged indefinitely unless this client saves a setting or runs maintenance. Scheduled hourly maintenance and changes from another connected client therefore leave the open Settings page displaying stale values; add periodic/focus-triggered refresh behavior similar to the adjacent Trellis details query. Multi-device behavior is explicitly a supported case.
AGENTS.md reference: AGENTS.md:L74-L74
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Valid: the history query now refreshes every minute while shown, like the details query, so hourly maintenance and other clients' changes appear. Fixed in 79e2682.
…ngs refresh every minute Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 79e268211d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| await writes.current.catch(() => undefined); | ||
| const result = await runMaintenance({ environmentId, input: {} }); |
There was a problem hiding this comment.
Abort maintenance when an awaited history save fails
When the blur-triggered save fails—for example, a transient PUT failure followed by a successful POST—runAtomCommand fulfills its promise with a _tag: "Failure", so this catch does not run and maintenance still applies the previous retention or expiry policy. That can permanently remove data the user had just attempted to preserve. Fresh evidence beyond the earlier ordering race is that the follow-up waits for settlement but never inspects the settled command result; track failed writes and skip maintenance until the save succeeds.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Valid: the save chain now resolves to whether every save since the last Run now succeeded (a Failure result counts, not just a rejection), and Run now stops with a toast instead of running maintenance under the previous settings; the chain resets afterwards so a later run proceeds. Fixed in 692431f.
…ted for failed Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 692431ffaa
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const saved = await writes.current; | ||
| writes.current = Promise.resolve(true); |
There was a problem hiding this comment.
Keep tracking writes started while maintenance waits
Fresh evidence beyond the fixed blur-ordering case: while Run now is awaiting an already-pending save, the number fields remain enabled, so another edit can append a newer save to writes.current. This code awaits only the previously captured promise and then overwrites the ref with a resolved promise; because updates and maintenance use separate scheduler lanes, maintenance can race that newer PUT and apply the old policy—for example, expiring data before a newly entered 0 expiry takes effect. Disable edits while waiting, drain the evolving save chain atomically, or serialize both operations on a shared lane.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Valid: while Run now waits for earlier saves and runs maintenance, the number fields are disabled and commits (including reset arrows) are ignored, so no save can start after the awaited chain was captured; the chain is reset only after it settled. Fixed in cd03fb4.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Trellis v1 Stage C, Lane T3 step 3 part 2: history settings in Settings → Trellis.
Change
trellis.getHistorySettings(read scope) wraps TrellisGET /v1/settings/history(Add new poem.md with "Small Arrival" poem pingdotgg/t3code#40) and returns values, defaults, snapshot counts per kind, and the last thinning.trellis.updateHistorySettings(operate scope) wrapsPUT /v1/settings/historywith any subset of the eight keys and returns the values in force andwouldRemove.trellis.runMaintenance(operate scope) wrapsPOST /v1/maintenance.wouldRemovewhen it is above 0.docs/user/trellis.md: one paragraph.Checks
Trellis.test.ts: GET decoding, a PUT with all eight keys (snake_case out, camelCase back), a 400 refusal, the older-Trellis message, and maintenance./trellis/dev-t3(Trellis 0bed1e8):removed 0)./tmp/stagec-history-*.pngand/tmp/stagec-hist/.knip:check,vp check,vpr typecheckandrelease-smokepass.t3tests fail only on the knownCodexInstallationandAcpSessionRuntime.processTreefailures. Package tests fail only on the known desktop libsecret and snapshot file-mode failures (desktop rerun after an Electron install race); client-runtime, relay and mobile pass when run separately.build:desktopfails on the known libsecret helper.🤖 Generated with Claude Code