Repository navigation
feat: session-scoped off-peak protection (/offpeak session on|off) - #15
Merged
Merged
Conversation
/offpeak session off disables off-peak protection for the current interactive OpenCode session only; /offpeak session on restores it. Default is ON for every session; the explicit override persists in OpenCode plugin storage until changed or the session is deleted (no timer, no expiry, no second store). - src/store.ts: SessionOverridesRepository (opencode-offpeak/session-overrides-v1) - src/engine.ts: setSessionProtection/sessionProtection/forgetSession plus bounded lazy pruning on start, session commands, status and the supported session.deleted event; verified-PEAK requests of an overridden session are allowed immediately, a held request wakes through the existing signal, and the same rule releases deferred/retry/pending-title/pending-compaction recoveries for that session without clobbering other classes or sessions. Queue-owned sessions never inherit the override, UNKNOWN and invalid configuration still fail closed, and committed or refused holds are never recalled or resurrected. - src/server.ts: session-off/session-on RPC actions, status sessionID, session.deleted cleanup, explicit not-found errors for missing sessions. - src/tui.ts: /offpeak session on|off resolved from the supported TUI route (ui.router first, active tab fallback), status shows Session protection and 'Requests: ALLOWED (session override)' while PEAK, resume kind override. - tests: 19 new deterministic cases (134 total) covering the full matrix.
…ile current-state wording - README: install #v0.1.10, validation includes 2.0.30, session on/off section (current session only, default ON, persistent, no timer, UNKNOWN still blocked, queue tasks unaffected, status output, compaction behavior, explicit global precedence) - CHANGELOG 0.1.10, RELEASING current release, docs/configuration and docs/troubleshooting updated; ARCHITECTURE session-protection section; DECISIONS entry for the per-session authorization - HANDOFF lower current-state sections: package/install now v0.1.10, verified CLI includes 2.0.30, implemented-behavior list includes session controls
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the session-scoped on/off control for off-peak protection.
/offpeak session offdisables off-peak protection for the current interactivesession only: verified PEAK-priced requests (primary, compaction, title,
generate) run immediately, and a request already held for off-peak is released
through the existing engine signal — no re-send, no duplicate provider call,
no polling, no timer.
/offpeak session onrestores the default.plugin storage (
opencode-offpeak/session-overrides-v1) and survive TUIrestarts, plugin reloads, and server restarts. The supported
session.deletedevent reaps entries; stale entries are cleaned lazily and only on a confident
not-found signal.
ui.router.current(),then the active tab); no session ID typing. Refuses on the home screen.
block, OFF_PEAK/FLAT/UNTRACKED unchanged, queue tasks never inherit the
override, refused/committed holds are never recalled or resurrected.
plugin is globally OFF, for that one session only;
/offpeak offitselfremains passive.
Session protection: ON|OFFandRequests: ALLOWED (session override)while PEAK with protection off; pricing is never misreported.Real OpenCode 2.0.30 TUI + local fixture validation (zero paid traffic):
hold → session off → immediate release before the boundary with exactly one
provider request; a second session stays held through the same peak window;
session on → next request waits again; the override survives
opencode reloadand a full server restart; compaction runs immediately under the override with
no pending-compaction marker, while compact-first with protection on is
unchanged.