Skip to content

Conversation

@ammar-agent
Copy link
Collaborator

Summary

Replace the hardcoded exec/plan toggle with a flexible, user-extensible mode system. Modes are defined via markdown files with YAML frontmatter in .mux/modes/ directories.

Key Changes

Types & Schemas

  • Expanded src/common/types/mode.ts with ModeDefinition interface and related schemas
  • Added frontmatter schema for mode files with validation

Backend

  • ModeLoaderService (src/node/services/modeLoaderService.ts): Discovers and loads modes from:
    • Built-in modes (bundled in src/node/builtinModes/)
    • Global modes (~/.mux/modes/)
    • Project modes (.mux/modes/) - highest priority
  • Added modes.list and modes.get IPC endpoints
  • Wired ModeLoaderService into ServiceContainer and ORPC context

Frontend

  • Refactored ModeSelector from ToggleGroup to Radix Select dropdown
  • Added useModes hook for fetching available modes
  • Dropdown shows mode icons and colors from definitions

Built-in Modes

  • exec.md - Full execution mode (default)
  • plan.md - Read-only planning mode with propose_plan

Mode File Format

---
name: custom
label: Custom Mode
description: A custom agent behavior mode
icon: 🔧
color: var(--color-custom)
disabled: false  # set true to hide/replace a built-in mode
toolPolicy:
  - regex: propose_plan
    action: enable
exclusiveTools:
  - ask_user_question
fileRestrictions:
  onlyPlanFile: true
subagentRestrictions:
  allowedTypes: [explore]
---

Mode-specific instructions go here as markdown...

Testing

  • Static checks pass (make static-check)
  • TypeScript compiles successfully
  • Existing mode tests pass

Future Work (not in this PR)

  • Full aiService integration to use mode definitions for tool policies and instructions
  • Mode docs generation from built-in mode files
  • Keyboard shortcut cycling through available modes

Generated with mux • Model: anthropic:claude-opus-4-5 • Thinking: high

Replace the hardcoded exec/plan toggle with a flexible, user-extensible
mode system defined via markdown files with YAML frontmatter.

Key changes:
- Add ModeDefinition types and Zod schemas in src/common/types/mode.ts
- Create ModeLoaderService to discover and load modes from:
  - Built-in modes (bundled in src/node/builtinModes/)
  - Global modes (~/.mux/modes/)
  - Project modes (.mux/modes/) - highest priority
- Add modes.list and modes.get IPC endpoints
- Refactor ModeSelector from ToggleGroup to Select dropdown
- Add useModes hook for frontend mode fetching
- Support 'disabled: true' in mode files to hide/replace built-in modes

Mode file format (example .mux/modes/custom.md):
```yaml
---
name: custom
label: Custom Mode
description: A custom agent behavior mode
icon: 🔧
color: var(--color-custom)
toolPolicy:
  - regex: some_tool
    action: enable
---
Mode-specific instructions go here...
```
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Add null check for api.modes?.list to prevent crashes in Storybook
where the full API context may not be available.
Fix path from __dirname/builtinModes to __dirname/../builtinModes since
modeLoaderService.ts is in src/node/services/ not src/node/.
The mode selector changed from a ToggleGroup to a Select dropdown.
Update the setMode utility to click the combobox trigger and select
the option from the dropdown menu.
- Add docs/modes.mdx with comprehensive modes documentation
- Extend gen_docs.ts to generate built-in modes section from src/node/builtinModes/*.md
- Add modes.mdx to docs navigation
- Fix markdown formatting in plan.md for Prettier compatibility
- Remove emoji from mode selector
- Style trigger to match original toggle group appearance
- Hide chevron, use compact pill style with mode-specific colors
- Simplify dropdown items to plain labels
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