Skip to content

Add configurable editor command and open-file shortcut#43

Merged
cpojer merged 2 commits into
nkzw-tech:mainfrom
gumadeiras:codex/configurable-editor-command
Jun 3, 2026
Merged

Add configurable editor command and open-file shortcut#43
cpojer merged 2 commits into
nkzw-tech:mainfrom
gumadeiras:codex/configurable-editor-command

Conversation

@gumadeiras
Copy link
Copy Markdown
Contributor

Summary

Adds config support for choosing which editor opens files from Codiff. For example, to open the repo in Sublime Text and edit the currently selected file: "editorCommand": "subl {repo} {file}".

This also adds a default Mod+k shortcut to open the currently selected file in the configured editor. The shortcut uses the existing keymap config, so users can customize it like the other shortcuts.

Config defaults are now centralized in config/defaults.json, a packaged-safe shared source used by Electron and the renderer. This keeps the editor setting, shortcut defaults, schema defaults, package contents, and runtime defaults from drifting.

Changes

  • Add settings.editorCommand to config.
  • Add keymap.openFile with default Mod+k.
  • Use the configured editor command when opening files.
  • Keep CODIFF_EDITOR as the environment override.
  • Pass repository context into editor command expansion so {repo} resolves to the repository root.
  • Skip editor opens for deleted files from the renderer.
  • Move config defaults into packaged-safe config/defaults.json.
  • Include config in package files.
  • Add tests for editor command behavior, config defaults, package-shape loading, package inclusion, and the open-file shortcut.

Validation

  • vp check --fix
  • vp test src/__tests__/config-defaults.test.ts src/__tests__/App-render.test.tsx electron/__tests__/editor.test.ts
  • vp build
  • pnpm pack --pack-destination /tmp/codiff-npm-pack-check
  • Verified the npm package includes config/defaults.json.
  • Packaged an unsigned macOS app with Electron Packager using the production package shape and /src excluded.
  • Verified the packaged app includes config/defaults.json and electron/config.cjs.
  • Verified packaged electron/config.cjs loads and returns the expected defaults.
  • Launched the packaged app with an isolated --user-data-dir; it stayed running until timeout with no stderr.

Adds configurable editor command support and a Mod+k open-file shortcut while keeping CODIFF_EDITOR as the override.

Moves config defaults to a packaged-safe shared JSON source so Electron and the renderer cannot drift or depend on excluded src files at runtime.
Copilot AI review requested due to automatic review settings June 2, 2026 23:17
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR centralizes Codiff’s default configuration into a shared JSON file (used by both Electron and the renderer) and adds support for opening the currently selected file in an external editor via a configurable editor command and a new keybinding.

Changes:

  • Added settings.editorCommand and keymap.openFile to config/types and JSON schema/defaults.
  • Moved default config values to config/defaults.json and introduced createDefaultConfig() in both renderer and Electron.
  • Implemented “Open File in Editor” via Mod+K and enhanced editor launching with {file} / {repo} placeholders, plus new tests.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/types.ts Extends preferences type to include editorCommand.
src/lib/app-constants.ts Removes in-app default preferences now that defaults come from shared config.
src/config/types.ts Adds editorCommand and openFile keymap action types.
src/config/defaults.ts Loads shared JSON defaults and exposes a default-config factory.
src/config/codiff-config.schema.json Documents and provides schema defaults for new settings/keybinding.
src/tests/config-defaults.test.ts Ensures schema/electron/renderer defaults stay in sync and package includes config.
src/tests/App-render.test.tsx Adds coverage for the Mod+K open-file shortcut behavior.
src/App.tsx Wires openFile command + keybinding handler and uses createDefaultConfig().
package.json Packages config/ so defaults ship with the npm package.
electron/main/editor.cjs Adds config-driven editor command parsing + {file}/{repo} placeholders.
electron/main.cjs Passes configured editor command and repo context into editor opener.
electron/config.cjs Switches Electron defaults to the shared config/defaults.json and adds new fields to merge.
electron/tests/editor.test.ts Adds tests for configured editor command precedence and placeholder expansion.
config/defaults.json Introduces shared default settings and keymap (including editorCommand + openFile).
README.md Documents new config fields and keybinding in example config.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread README.md Outdated
Comment thread src/config/codiff-config.schema.json
Comment thread src/config/defaults.ts Outdated
Clarifies editor command examples with quoted placeholders and freezes exported renderer defaults so callers cannot mutate the shared JSON import.
Copy link
Copy Markdown
Member

@cpojer cpojer left a comment

Choose a reason for hiding this comment

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

Love it.

@cpojer cpojer merged commit 19a843c into nkzw-tech:main Jun 3, 2026
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.

3 participants