feat: auto-detect project config on first open#819
feat: auto-detect project config on first open#819Simonstorms wants to merge 2 commits intogeneralaction:mainfrom
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@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 OverviewGreptile SummaryThis PR adds first-open project config auto-detection when a repo does not yet have an Confidence Score: 5/5
|
| 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
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>
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
.emdash.jsonyet)src/shared/lifecycle.tsto avoid duplicationChanges
ProjectDetectionService.ts— detects Node/Python/Ruby/Rust/Go/Java/PHP/Elixir projects,scans for env files via
git ls-filesfsIpc.ts— returns detected config (without writing) when.emdash.jsonis missingProjectMainView.tsx— auto-opens config editor on first project openConfigEditorModal.tsx— adds auto-detect banner, Confirm button, cancel writesdefaults
lifecycle.ts— sharedDEFAULT_PRESERVE_PATTERNSandDEFAULT_EMDASH_CONFIGWorktreeService.ts— imports shared constants instead of local duplicatesDemo
Screen.Recording.2026-02-11.at.15.34.33.mov
Test plan
.emdash.json— nothing should change.emdash.jsonfrom a Node/pnpm project, re-open — should detectpnpm installandcorrect env files