Skip to content

feat(bot): INITIAL_SETTINGS_PRESET env var to seed default settings#175

Open
tobyrosen wants to merge 2 commits into
grinev:mainfrom
tobyrosen:feat/hide-run-footer
Open

feat(bot): INITIAL_SETTINGS_PRESET env var to seed default settings#175
tobyrosen wants to merge 2 commits into
grinev:mainfrom
tobyrosen:feat/hide-run-footer

Conversation

@tobyrosen

@tobyrosen tobyrosen commented Jul 2, 2026

Copy link
Copy Markdown

Description of changes

I run a few instances of this bot from .env configs, and I kept tripping over the run footer on fresh installs. The /settings menu from 0.22.0 (#171) handles it nicely at runtime, but there's no way to preset the default, so every new instance starts with the footer on until someone opens /settings and toggles it. When you deploy several bots from config, that's a manual step per bot per reinstall.

Following the review suggestion, this now adds an INITIAL_SETTINGS_PRESET env var instead of the original footer-only flag. It takes a JSON object and seeds the initial value for any /settings option (ttsMode, compactOutputMode, showThinkingContent, sendDiffFileAttachments, responseStreamingMode, showAssistantRunFooter). A persisted /settings choice still takes precedence: preset values fill in only where the user hasn't picked anything, so the runtime toggles keep working exactly as they do now.

Parsing is defensive: invalid JSON, unknown keys, or wrong value types log a warning and are ignored, so a bad preset never crashes the bot. With the variable unset, nothing changes and existing users see no difference.

The variable is documented in the README and .env.example, with tests for the parsing and the seeding behavior.

Closes issue (optional)

No open issue for this; #134 covered a different footer request and is already closed.

How it was tested

npm run lint, npm run build, and npm test all pass, including the new tests: preset applied on a fresh install, persisted settings.json values never overwritten, invalid JSON / unknown keys / wrong value types ignored with a warning. It's pure config parsing, nothing OS-sensitive.

Checklist

  • PR title follows Conventional Commits: <type>(<scope>)?: <description>
  • This PR contains one logically complete change
  • Branch is rebased on the latest main
  • I ran npm run lint, npm run build, and npm test
  • If this PR is OS-sensitive, behavior/limitations for Linux/macOS/Windows are described

The assistant run footer (agent, provider/model, elapsed time) can be toggled at runtime from /settings, but there is no way to preset its default for headless or declarative (.env-based) deployments.

Add a HIDE_RUN_FOOTER boolean env var, read via the existing getOptionalBooleanEnvVar helper, that seeds the default for the showAssistantRunFooter setting. It defaults to false (footer shown), so behavior is unchanged unless the variable is set. The runtime /settings toggle still takes precedence and is persisted in settings.json.

Document the variable in README and .env.example, and add config and settings-store tests.
@grinev

grinev commented Jul 2, 2026

Copy link
Copy Markdown
Owner

@tobyrosen thanks for PR. I don't understand the problem, you can hide message footer with /settings command for each install. When I added /settings command, I also wanted to clear .env from some values. If you add something like this, you need to add default values for all runtime settings for consistency. But I'm not sure it's nessesary feature. When you install OpenCode for example you can't set default values for everything in settings

@tobyrosen

Copy link
Copy Markdown
Author

@grinev Fair point on the consistency. I wasn't looking to set defaults for everything in settings, just clear the one churn we actually hit.

The issue: I run several bot instances off .env configs (one per session), and reinstalls happen. /settings works, but toggling it per-bot per-reinstall is a manual step we trip over every time. The env var just lets the default ship preset so fresh installs start clean.

Two potential options, your call:

  • Keep this PR scoped to just HIDE_RUN_FOOTER (it's the common noise pain): small, low-friction to review, and "env defaults for all runtime settings" can be a separate follow-up if you want the consistency.
  • Or I extend this PR to seed env defaults for all runtime settings in one pass: more work and a bigger review surface, but consistent in one go.

Happy to go either way. I should be able to push more today. Thanks!

@grinev

grinev commented Jul 2, 2026

Copy link
Copy Markdown
Owner

@tobyrosen I think this feature can exist in that way:
Add optional env var
INITIAL_SETTINGS_PRESET="
}
"ttsMode": "all",
"compactOutputMode": true,
"showThinkingContent": true,
"sendDiffFileAttachments": false,
"responseStreamingMode": "edit",
"showAssistantRunFooter": false
}
"
If you want you can implement it

Replace HIDE_RUN_FOOTER with a single INITIAL_SETTINGS_PRESET env var
that accepts a JSON object and seeds any runtime /settings value on first
run. Only keys absent from settings.json are affected; settings the user
has already changed via /settings are left untouched.

Supported keys: ttsMode, compactOutputMode, showThinkingContent,
showAssistantRunFooter, responseStreamingMode, sendDiffFileAttachments.

Invalid JSON falls back to built-in defaults without crashing. Unknown
keys and type mismatches are logged as warnings and skipped.

Co-Authored-By: Toby Rosen <46664805+tobyrosen@users.noreply.github.com>
@tobyrosen tobyrosen changed the title feat(bot): add HIDE_RUN_FOOTER env var to preset the run footer default feat(bot): INITIAL_SETTINGS_PRESET env var to seed default settings Jul 3, 2026
@tobyrosen

Copy link
Copy Markdown
Author

@grinev thanks for the design suggestion. I've reworked the PR to implement INITIAL_SETTINGS_PRESET. The var accepts a JSON object and seeds any /settings value at startup; keys already present in settings.json are never touched, so existing users see no change. Invalid JSON, unknown keys, and type mismatches all log a warning and fall back gracefully; no crash.

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