Skip to content

live_diff: add live_diff.enabled_on_startup config option#2002

Open
sinelaw wants to merge 1 commit into
masterfrom
claude/jolly-archimedes-jjtiZ
Open

live_diff: add live_diff.enabled_on_startup config option#2002
sinelaw wants to merge 1 commit into
masterfrom
claude/jolly-archimedes-jjtiZ

Conversation

@sinelaw
Copy link
Copy Markdown
Owner

@sinelaw sinelaw commented May 16, 2026

Closes #1950.

Summary

Live Diff is opt-in: every session starts with the global toggle off, so users who rely on it have to invoke Live Diff: Toggle (Global) from the command palette before decorations appear. This adds a new live_diff.enabled_on_startup config field (default false, preserving current behavior). When true, the plugin force-enables the global toggle on startup — equivalent to the manual toggle, but automatic.

The user can still toggle Live Diff off mid-session via the command palette; the next startup re-enables it, which matches the requested "always on" semantics.

Implementation

  • New LiveDiffConfig struct in config.rs with a single enabled_on_startup: bool field, alongside the existing terminal, clipboard, etc. sections. Default impl matches the WarningsConfig/TerminalConfig pattern. Schema regenerated via ./scripts/gen_schema.sh.
  • Mirror PartialLiveDiffConfig in partial_config.rs (Merge + From + resolve) so layered config loading handles the new section.
  • live_diff.ts reads config.live_diff.enabled_on_startup via editor.getConfig() and force-enables the global state. The check is gated by a startupConfigApplied boolean and fires lazily on the first buffer event (after_file_open / buffer_activated / plugin init with an active buffer) rather than at plugin load — getConfig() reads from a snapshot that the editor refreshes between ticks, so it can return {} if the plugin runs first.

Test plan

  • New e2e test test_live_diff_enabled_on_startup_config_renders_without_manual_toggle builds a Config with enabled_on_startup = true, opens a modified file, and asserts the + gutter glyph appears with no command-palette invocation. Fails without the change (the existing test had to call enable_live_diff_globally for the same gutter to appear).
  • All 10 live_diff e2e tests pass (cargo test --test e2e_tests -p fresh-editor live_diff).
  • All 326 plugin e2e tests pass (cargo test --test e2e_tests -p fresh-editor plugins::).
  • All 60 config unit tests pass (cargo test -p fresh-editor --lib config::), including the roundtrip-to-partial test.
  • Manual validation in tmux:
    • With live_diff.enabled_on_startup: true, opening a modified file shows the + gutter glyph with no toggling.
    • With live_diff.enabled_on_startup: false (default), the gutter stays empty until the user runs the toggle command.

Generated by Claude Code

Closes #1950.

Live Diff is opt-in: every session starts with the global toggle off
and the user has to invoke "Live Diff: Toggle (Global)" from the
command palette before decorations appear. Users who rely on Live Diff
as part of their normal workflow asked for a way to skip the manual
toggle.

Adds a new top-level `live_diff` config section with a single
`enabled_on_startup` field (default false, preserving current
behavior). When true, the live_diff plugin force-enables the global
toggle the first time it sees a buffer event, regardless of any
persisted state. The user can still toggle off mid-session; the next
startup re-enables it, which is the requested semantics.

The check is deferred via `applyStartupConfigOnce()` rather than run
at plugin load: `editor.getConfig()` reads from a snapshot the editor
refreshes between ticks, and the plugin can execute before that
snapshot is populated.

E2E test creates a `Config` with `enabled_on_startup = true`, opens a
modified file, and waits for the `+` gutter glyph — no command-palette
invocation. The default-off path is exercised by every other
`live_diff` test in the file, all of which call
`enable_live_diff_globally` to flip the toggle.
@sinelaw
Copy link
Copy Markdown
Owner Author

sinelaw commented May 16, 2026

Plugins need their own dedicated config value registration mechanism so that we don't hard code them into rust or touch the config.rs when updating a plugin's config abilities

@sinelaw sinelaw added the question Further information is requested label May 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

question Further information is requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: Config option to enable Live Diff on startup

2 participants