Skip to content

feat(ui): replace :env and :config table with full TOML config view#2886

Merged
tusharmath merged 2 commits intomainfrom
improve-config-format
Apr 8, 2026
Merged

feat(ui): replace :env and :config table with full TOML config view#2886
tusharmath merged 2 commits intomainfrom
improve-config-format

Conversation

@tusharmath
Copy link
Copy Markdown
Collaborator

@tusharmath tusharmath commented Apr 8, 2026

Summary

Replace the fragmented :config key-value table and separate :env command with a single :config command that displays the complete resolved ForgeConfig as syntax-highlighted TOML.

Context

Previously :config showed a manually curated table of a handful of fields (active model, provider, commit/suggest model, reasoning effort), while :env showed a separate table of environment/provider metadata. Neither gave a complete picture of the effective configuration, and keeping two commands in sync added maintenance overhead.

The :env command is removed entirely; its shell aliases (env, e) are redirected to :config so existing muscle-memory keeps working.

Changes

  • :config output redesign: serializes the full ForgeConfig struct to pretty TOML via toml_edit and syntax-highlights it for the terminal. Porcelain mode outputs raw TOML for scripting.
  • Removed :env command: SlashCommand::Env, TopLevelCommand::Env, the on_env handler, and the _forge_action_env shell function are all deleted. Shell plugin routes env/e to _forge_action_config.
  • Auto-adapting syntax theme: adds terminal-colorsaurus to detect the terminal background at runtime and picks base16-ocean.dark for dark terminals or InspiredGitHub for light terminals.
  • Extended syntax set: switches SyntaxHighlighter from syntect's built-in defaults to the two-face extended set, which includes first-class TOML support.
  • Public SyntaxHighlighter: highlight() is now public and the module is re-exported from forge_display, allowing forge_main to call it directly.

Key Implementation Details

on_show_config now reduces to two steps: toml_edit::ser::to_string_pretty(&self.config) followed by SyntaxHighlighter::default().highlight(&toml, "toml"). The theme is resolved once per highlight call via a lightweight terminal-colorsaurus query; on terminals that don't support the query it defaults to the dark theme.

Use Cases

  • Run :config (or :env / :e) to instantly see every effective setting — model, provider, custom agents, tool permissions, reasoning config — in readable, copy-pasteable TOML.
  • Pipe :config --porcelain output into scripts or config management tools.

Testing

# Build and run
cargo build

# Interactive: open forge and run
:config        # should print highlighted TOML
:env           # same output (alias redirect)
:e             # same output (alias redirect)

# Porcelain mode (raw TOML, no colour)
forge config --porcelain

# Unit tests
cargo insta test --accept -p forge_display
cargo insta test --accept -p forge_main

@github-actions github-actions bot added the type: feature Brand new functionality, features, pages, workflows, endpoints, etc. label Apr 8, 2026
@tusharmath tusharmath changed the title feat(ui): display resolved config as highlighted toml feat(ui): replace :env and :config table with full TOML config view Apr 8, 2026
@tusharmath tusharmath force-pushed the improve-config-format branch 2 times, most recently from 459af52 to 9a2343e Compare April 8, 2026 08:06
@tusharmath tusharmath merged commit 233394c into main Apr 8, 2026
17 checks passed
@tusharmath tusharmath deleted the improve-config-format branch April 8, 2026 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: feature Brand new functionality, features, pages, workflows, endpoints, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant