Skip to content

Add Agent Instructions toggle - #4542

Draft
shaunandrews wants to merge 6 commits into
agent/improve-settings-usagefrom
agent/add-settings-instructions-toggle
Draft

Add Agent Instructions toggle#4542
shaunandrews wants to merge 6 commits into
agent/improve-settings-usagefrom
agent/add-settings-instructions-toggle

Conversation

@shaunandrews

@shaunandrews shaunandrews commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Related issues

How AI was used in this PR

Codex isolated the Agent Instructions interaction from the broader settings redesign, adapted it to the current edit-session tracking behavior, added focused coverage, and verified the result in the running Agentic UI. The final diff and both color schemes were reviewed interactively.

Proposed Changes

  • Give Agent Instructions an explicit enable/disable switch so people can tell whether global guidance is active without reading an empty field.
  • Keep the editor hidden until instructions are enabled, reducing visual weight in the AI settings tab.
  • Start from a compact three-row editor that can still be resized for longer guidance.
  • Preserve stored instructions when the switch is turned off while preventing them from being injected into new conversations.
  • Restore the preserved instructions when the switch is turned back on.
  • Preserve debounced saves and edit-session analytics when instructions are edited.

Existing installations remain backward compatible: instructions with content default to enabled until the user explicitly changes the switch.

Trunk now chooses the AI provider per conversation, so there is no longer a global provider-disabled state or API-key toggle for this PR to modify. The Anthropic key field remains available independently of the Instructions control.

This PR intentionally keeps the current AI tab and existing settings-card treatment. It is independently useful and is the second layer of the settings-redesign stack.

Screenshots

Light Dark
Instructions toggle in light mode Instructions toggle in dark mode

Testing Instructions

  1. Check out this branch with Improve Settings usage meters #4540 beneath it.
  2. Run npm run cli:build:ui && node apps/cli/dist/cli/main.mjs ui --no-open.
  3. Open Settings → AI.
  4. With no saved instructions, confirm the Instructions switch is off and the editor is hidden.
  5. Turn the switch on and confirm a compact three-row editor appears.
  6. Enter instructions, wait briefly, leave the tab, and return to confirm they persist.
  7. Turn the switch off and confirm the editor disappears and the instructions no longer affect new conversations.
  8. Turn the switch back on and confirm the previously entered instructions return unchanged.
  9. Confirm the Anthropic API-key field remains visible because provider selection now happens per conversation.
  10. Check the controls and editor in both Light and Dark appearance settings.

Verified after merging the refreshed base branch:

  • npx eslint --fix on all modified files
  • npm run typecheck
  • npm test -- apps/ui/src/components/settings-view/studio-code-panel.test.tsx packages/common/ai/tests/global-instructions.test.ts apps/studio/src/modules/user-settings/lib/tests/settings-tracks.test.ts (47 tests)
  • npm run cli:build:ui
  • Browser verification in light and dark themes with no console errors

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

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.

1 participant