Skip to content

Comments

feat: auto-detect project config on first open#819

Open
Simonstorms wants to merge 2 commits intogeneralaction:mainfrom
Simonstorms:feat/auto-detect-config
Open

feat: auto-detect project config on first open#819
Simonstorms wants to merge 2 commits intogeneralaction:mainfrom
Simonstorms:feat/auto-detect-config

Conversation

@Simonstorms
Copy link

@Simonstorms Simonstorms commented Feb 11, 2026

Motivation

I always had two problems with Emdash: worktrees didn't really work out of the box because the setup
script wasn't configured, and I couldn't find where to edit the config (should have read the docs).
This feature fixes both by auto-detecting your project setup and showing the settings file on project
creation, so new users immediately see where to edit the config.

Summary

  • Auto-detect package manager, install/run scripts, and env files when a project is first opened (no
    .emdash.json yet)
  • Show detected config in a review modal so the user can confirm or edit before saving
  • Extract shared default preserve patterns to src/shared/lifecycle.ts to avoid duplication

Changes

  • New: ProjectDetectionService.ts — detects Node/Python/Ruby/Rust/Go/Java/PHP/Elixir projects,
    scans for env files via git ls-files
  • Modified: fsIpc.ts — returns detected config (without writing) when .emdash.json is missing
  • Modified: ProjectMainView.tsx — auto-opens config editor on first project open
  • Modified: ConfigEditorModal.tsx — adds auto-detect banner, Confirm button, cancel writes
    defaults
  • Modified: lifecycle.ts — shared DEFAULT_PRESERVE_PATTERNS and DEFAULT_EMDASH_CONFIG
  • Modified: WorktreeService.ts — imports shared constants instead of local duplicates

Demo

Screen.Recording.2026-02-11.at.15.34.33.mov

Test plan

  • Open a project that already has .emdash.json — nothing should change
  • Click Cancel on auto-detect modal — defaults written, re-opening shows standard config
  • Delete .emdash.json from a Node/pnpm project, re-open — should detect pnpm install and
    correct env files

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Feb 11, 2026

@Simonstorms is attempting to deploy a commit to the General Action Team on Vercel.

A member of the Team first needs to authorize it.

@greptile-apps
Copy link

greptile-apps bot commented Feb 11, 2026

Greptile Overview

Greptile Summary

This PR adds first-open project config auto-detection when a repo does not yet have an .emdash.json. In the main process, fs:getProjectConfig now returns a synthesized config (scripts + preserve patterns) with an isNew flag rather than writing a default file immediately. The renderer uses that isNew signal to automatically open the config editor and show an “auto-detected” banner with a Confirm action; canceling for a new config writes the standard defaults so subsequent opens don’t re-trigger detection. The shared default preserve patterns and default config object are moved to src/shared/lifecycle.ts and reused by both worktree preservation and the config UI.

Confidence Score: 5/5

  • This PR looks safe to merge with low functional risk.
  • Changes are localized to config detection/UX, reuse existing ignored-file scanning behavior already used for worktree preservation, and maintain backwards compatibility when an existing .emdash.json is present. No definite correctness issues found in the changed code paths.
  • src/main/services/ProjectDetectionService.ts and src/renderer/components/ConfigEditorModal.tsx (behavior on cancel/confirm should match intended UX).

Important Files Changed

Filename Overview
src/main/services/ProjectDetectionService.ts Adds project config auto-detection (scripts + env/preservePatterns) used when .emdash.json is missing; logic aligns with existing ignored-file preservation.
src/main/services/WorktreeService.ts Replaces local default preserve patterns with shared DEFAULT_PRESERVE_PATTERNS; no behavior change beyond constant source.
src/main/services/fsIpc.ts fs:getProjectConfig now returns detected config without writing when .emdash.json is missing and adds isNew flag; otherwise reads existing file.
src/renderer/components/ConfigEditorModal.tsx Adds auto-detect banner/Confirm UX and writes defaults on cancel for new configs; behavior matches PR description though cancel discards detected content.
src/renderer/components/ProjectMainView.tsx On project open, preloads config and auto-opens editor when config is newly detected; ensures state resets on project change/close.
src/renderer/types/electron-api.d.ts Extends getProjectConfig return type with optional isNew flag to support auto-detect flow.
src/shared/lifecycle.ts Introduces shared DEFAULT_PRESERVE_PATTERNS and DEFAULT_EMDASH_CONFIG constants for reuse across main/renderer.

Sequence Diagram

sequenceDiagram
  participant PMV as ProjectMainView
  participant CEM as ConfigEditorModal
  participant API as electronAPI (preload)
  participant IPC as fsIpc (main)
  participant DET as ProjectDetectionService
  participant FS as Filesystem

  PMV->>API: getProjectConfig(projectPath)
  API->>IPC: invoke fs:getProjectConfig

  alt config exists
    IPC->>FS: read .emdash.json
    FS-->>IPC: content
    IPC-->>API: success + content + isNew=false
  else config missing
    IPC->>DET: detectConfig(projectPath)
    DET->>FS: check marker files
    DET->>FS: git ls-files (ignored/untracked)
    DET-->>IPC: detected config
    IPC-->>API: success + detected content + isNew=true
  end

  API-->>PMV: result

  opt auto-detected
    PMV->>PMV: open ConfigEditorModal
    PMV->>CEM: render (isAutoDetected=true)
    CEM->>API: getProjectConfig(projectPath)
    API->>IPC: invoke fs:getProjectConfig
    IPC-->>API: content + isNew
    API-->>CEM: content

    alt user confirms/saves
      CEM->>API: saveProjectConfig(projectPath, content)
      API->>IPC: invoke fs:saveProjectConfig
      IPC->>FS: write .emdash.json
      FS-->>IPC: ok
      IPC-->>API: success
      API-->>CEM: success
    else user cancels (new config)
      CEM->>API: saveProjectConfig(projectPath, DEFAULT_CONFIG)
      API->>IPC: invoke fs:saveProjectConfig
      IPC->>FS: write .emdash.json
      IPC-->>API: success
      API-->>CEM: success (ignored)
    end
  end
Loading

Combine auto-detect config feature with refactored ConfigEditorModal
(Scripts/JSON tabs UI). Keep auto-detect banner, handleCancel defaults
logic, and isAutoDetected prop alongside the new tabbed editor.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

2 participants