feat: Add branch name under worktree in session list (if different than worktree name) (#352)
* feat: show branch info in session sidebar and enrich worktrees * feat: refresh sidebar branch display when switching branches in git menu * fix: ensure branch name displays on mobile by fixing flex alignment * style: make branch name font smaller, especially on mobile
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { opencodeClient } from '@/lib/opencode/client';
|
||||
import { substituteCommandVariables } from '@/lib/openchamberConfig';
|
||||
import type { WorktreeMetadata } from '@/types/worktree';
|
||||
import { deleteRemoteBranch } from '@/lib/gitApi';
|
||||
import { deleteRemoteBranch, getGitStatus } from '@/lib/gitApi';
|
||||
|
||||
export type ProjectRef = { id: string; path: string };
|
||||
|
||||
@@ -143,6 +143,21 @@ export async function listProjectWorktrees(project: ProjectRef): Promise<Worktre
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
|
||||
// Enrich worktrees with branch information from git status
|
||||
await Promise.all(
|
||||
results.map(async (worktree) => {
|
||||
try {
|
||||
const status = await getGitStatus(worktree.path);
|
||||
if (status?.current) {
|
||||
worktree.branch = status.current;
|
||||
}
|
||||
} catch {
|
||||
// ignore - branch will remain empty
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
return results.sort((a, b) => {
|
||||
const aLabel = (a.label || a.branch || a.path).toLowerCase();
|
||||
const bLabel = (b.label || b.branch || b.path).toLowerCase();
|
||||
|
||||
Reference in New Issue
Block a user