Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 1 addition & 42 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ import { getWeeklyStats } from './weekly-stats'
import { discoverTools, runTool } from './tools'
import type { TerminalTab, PaneNode, PaneLeaf } from '../shared/state/terminals'
import { findTabById, getLeaves, mapLeaves } from '../shared/state/terminals'
import { createLocalMergeOps } from './local-merge'
import { resolveCommitSha, listWorktrees, listBranches, continueWorktree, isWorktreeDirty, defaultWorktreeDir, getChangedFiles, getFileDiff, getBranchCommits, getCommitDiff, getCommitMeta, getCommitChangedFiles, getCommitFileDiffSides, getCommitRangeChangedFiles, getCommitRangeFileDiffSides, getMainWorktreeStatus, prepareMainForMerge, mergeWorktreeLocally, getBranchSha, previewMergeConflicts, getBranchDiffStats, listAllFiles, listRecentCommitShas, readWorktreeFile, readWorktreeFileBinary, writeWorktreeFile, getFileDiffSides, getCurrentBranch, renameWorktreeBranch, unsymlinkClaudeSettings, readClaudeAllowEntries, pruneWorktrees, type MergeStrategy } from './worktree'
import { resolveCommitSha, listWorktrees, listBranches, continueWorktree, isWorktreeDirty, defaultWorktreeDir, getChangedFiles, getFileDiff, getBranchCommits, getCommitDiff, getCommitMeta, getCommitChangedFiles, getCommitFileDiffSides, getCommitRangeChangedFiles, getCommitRangeFileDiffSides, getBranchDiffStats, listAllFiles, listRecentCommitShas, readWorktreeFile, readWorktreeFileBinary, writeWorktreeFile, getFileDiffSides, getCurrentBranch, renameWorktreeBranch, unsymlinkClaudeSettings, readClaudeAllowEntries, pruneWorktrees } from './worktree'
import { listOpenPRs, getPRByNumber, testToken, starRepo, unstarRepo, isRepoStarred, mergePR, approvePR, getRepoInfo, type GitHubMergeMethod, type MergePRResult, type PRLookupResult } from './github'
import { AVAILABLE_EDITORS, DEFAULT_EDITOR_ID, openInEditor } from './editor'
import { resolveEditorId } from '../shared/editor-resolve'
Expand Down Expand Up @@ -2878,46 +2877,6 @@ function registerIpcHandlers(): void {
return getWeeklyStats(snap.prs, snap.worktrees)
})

transport.onRequest('worktree:mainStatus', async (_ctx, repoRoot: string) => {
if (!repoRoot) throw new Error('No repo root provided')
return getMainWorktreeStatus(repoRoot)
})

transport.onRequest('worktree:previewMerge', async (_ctx, repoRoot: string, sourceBranch: string, worktreePath?: string) => {
if (!repoRoot) throw new Error('No repo root provided')
let branch = sourceBranch
if (worktreePath) {
const resolved = await getCurrentBranch(worktreePath)
if (resolved) branch = resolved
}
const status = await getMainWorktreeStatus(repoRoot)
return previewMergeConflicts(repoRoot, branch, status.baseBranch)
})

const localMerge = createLocalMergeOps({
dispatch: (event) => store.dispatch(event),
getCurrentBranch,
mergeWorktreeLocally,
prepareMainForMerge,
getBranchSha,
recordLocallyMerged: (branch, sha) => {
if (!config.locallyMerged) config.locallyMerged = {}
config.locallyMerged[branch] = sha
saveConfig(config)
},
refreshAll: () => void prPoller.refreshAll()
})

transport.onRequest('worktree:prepareMain', (_ctx, repoRoot: string) =>
localMerge.prepareMain(repoRoot)
)

transport.onRequest(
'worktree:mergeLocal',
(_ctx, repoRoot: string, sourceBranch: string, strategy: MergeStrategy, worktreePath?: string) =>
localMerge.mergeLocal(repoRoot, sourceBranch, strategy, worktreePath)
)

// Legacy worktree:mergedStatus handler is gone — the computation is now
// inlined in PRPoller.refreshAll, which runs across all roots in one pass
// and dispatches prs/mergedChanged.
Expand Down
97 changes: 0 additions & 97 deletions src/main/local-merge.test.ts

This file was deleted.

88 changes: 0 additions & 88 deletions src/main/local-merge.ts

This file was deleted.

13 changes: 7 additions & 6 deletions src/main/persistence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ export interface Config {
// New worktrees are branched from: 'remote' = fetch origin then branch
// from origin/<default>, 'local' = branch from current HEAD.
worktreeBase?: 'remote' | 'local'
// Default strategy for "Merge locally" action. Auto-updates to whatever
// was last used unless the user pinned one in Settings.
// How the PR panel's merge button merges on GitHub ('fast-forward' maps
// to GitHub's rebase method).
mergeStrategy?: 'squash' | 'merge-commit' | 'fast-forward'
// Density of each sidebar worktree row. 'comfy' (default) stacks the
// detail cluster on a second line; 'compact' folds it onto the right of
Expand Down Expand Up @@ -195,17 +195,18 @@ export interface Config {
// Sidebar project drag order as section scope keys (see
// SettingsState.sidebarProjectOrder). Absent until the user reorders.
sidebarProjectOrder?: string[]
// Branches that have been merged locally via Ness, keyed by branch name.
// Value is the branch-tip SHA at merge time — if the branch later advances
// past this SHA, the flag is considered stale and the branch is no longer
// shown as merged.
// Shell command to run after a worktree is created. Runs via login shell
// with cwd=worktree and env vars HARNESS_WORKTREE_PATH, HARNESS_BRANCH,
// HARNESS_REPO_ROOT. Failures are logged but don't block creation.
worktreeSetupCommand?: string
// Shell command to run before a worktree is removed. Same execution model
// as setup. Failures are logged but don't block removal.
worktreeTeardownCommand?: string
// Branches merged by the since-removed "Merge Locally" action, keyed by
// branch name. Value is the branch-tip SHA at merge time — if the branch
// later advances past this SHA, the flag is considered stale and pruned.
// Nothing adds entries any more; the map is read only so worktrees merged
// that way keep grouping under Merged / Closed until they're removed.
locallyMerged?: Record<string, string>
// When true, pass --name "repo/branch" to Claude so sessions are named by
// their worktree rather than auto-summarized. Also sets the name visible
Expand Down
48 changes: 48 additions & 0 deletions src/main/repo-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,51 @@ describe('migrateRepoConfigFilename', () => {
expect(loadRepoConfig(repo).setupCommand).toBe('current')
})
})

// The Merge Locally panel was removed. Repo config files are usually
// committed, so ones written before then must keep loading, and we never
// rewrite them just because they carry its keys.
describe('repo configs from before Merge Locally was removed', () => {
const OLD = {
version: 1,
setupCommand: 'npm ci',
mergeStrategy: 'merge-commit',
hideMergePanel: true,
hiddenRightPanels: { merge: true, commits: true },
rightPanelOrder: ['merge', 'pr', 'commits'],
someFutureKey: { nested: 1 }
}

it('loads without throwing and keeps the fields still in use', () => {
write(NEW, OLD)
const cfg = loadRepoConfig(repo)
expect(cfg.setupCommand).toBe('npm ci')
expect(cfg.mergeStrategy).toBe('merge-commit')
})

it('loading does not touch the file on disk', () => {
write(LEGACY, OLD)
const before = readFileSync(join(repo, LEGACY), 'utf-8')
loadRepoConfig(repo)
expect(readFileSync(join(repo, LEGACY), 'utf-8')).toBe(before)
expect(existsSync(join(repo, NEW))).toBe(false)
})

it('drops the merge panel keys on the next write', () => {
write(NEW, OLD)
const saved = saveRepoConfig(repo, loadRepoConfig(repo))
expect(saved.hiddenRightPanels).toEqual({ commits: true })
expect(saved.rightPanelOrder).toEqual(['pr', 'commits'])
const onDisk = JSON.parse(readFileSync(join(repo, NEW), 'utf-8'))
expect(onDisk).not.toHaveProperty('hideMergePanel')
expect(onDisk.mergeStrategy).toBe('merge-commit')
})

it('an order of only the removed panel is dropped entirely', () => {
const saved = saveRepoConfig(repo, {
setupCommand: 'x',
rightPanelOrder: ['merge'] as unknown as never
})
expect(saved).not.toHaveProperty('rightPanelOrder')
})
})
15 changes: 11 additions & 4 deletions src/main/repo-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export type { RepoConfig }
// everyone's git status for a change they didn't make.
const cache = new Map<string, RepoConfig>()

const REMOVED_MERGE_PANEL_KEY = 'merge'

/** The config file this repo actually uses: the new name if present or if
* the repo has no config yet, otherwise the legacy one it already has. */
export function repoConfigFilename(repoRoot: string): string {
Expand Down Expand Up @@ -58,11 +60,15 @@ export function saveRepoConfig(repoRoot: string, next: RepoConfig): RepoConfig {
if (setup) cleaned.setupCommand = setup
if (teardown) cleaned.teardownCommand = teardown
if (next.mergeStrategy) cleaned.mergeStrategy = next.mergeStrategy
// Migrate legacy hideMergePanel / hidePrPanel into hiddenRightPanels
// on write. Only the new field is persisted going forward.
// Migrate legacy hidePrPanel into hiddenRightPanels on write. Only the
// new field is persisted going forward.
const hidden: Record<string, boolean | undefined> = { ...(next.hiddenRightPanels || {}) }
if (next.hideMergePanel && hidden.merge === undefined) hidden.merge = true
if (next.hidePrPanel && hidden.pr === undefined) hidden.pr = true
// The Merge Locally panel is gone. Files written before then may still
// carry its `hideMergePanel` / `hiddenRightPanels.merge` / order entry;
// they're ignored on read and dropped here, on the next write the user
// makes anyway — never rewritten on their own.
delete hidden[REMOVED_MERGE_PANEL_KEY]
// Compact: drop `false` entries that match the default visibility
// (i.e. NOT in DEFAULT_HIDDEN_RIGHT_PANELS). For keys that default to
// hidden, `false` is a meaningful opt-in signal — keep it.
Expand All @@ -73,7 +79,8 @@ export function saveRepoConfig(repoRoot: string, next: RepoConfig): RepoConfig {
}
if (Object.keys(hidden).length > 0) cleaned.hiddenRightPanels = hidden
if (Array.isArray(next.rightPanelOrder) && next.rightPanelOrder.length > 0) {
cleaned.rightPanelOrder = [...next.rightPanelOrder]
const order = next.rightPanelOrder.filter((k) => (k as string) !== REMOVED_MERGE_PANEL_KEY)
if (order.length > 0) cleaned.rightPanelOrder = order
}

const hasAny = Object.keys(cleaned).some((k) => k !== 'version')
Expand Down
Loading
Loading