Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
feat(worktree): custom branch dropdown, matching the app's own menus
enes16a12a914910
diff --git a/src/renderer/components/BranchSelect.tsx b/src/renderer/components/BranchSelect.tsxnew file mode 100644index 000000000..0abd3f30b--- /dev/null+++ b/src/renderer/components/BranchSelect.tsx@@ -0,0 +1,92 @@+import { useState, type MouseEvent } from 'react'+import { createPortal } from 'react-dom'++interface Props {+ value: string+ onChange: (v: string) => void+ /** Local branch names to pick from. */+ options: string[]+ /** Shown (muted) when `value` is empty. */+ placeholder: string+ /** Base allows any ref, not just a local branch: a free-text field at the foot of the menu lets+ * the user type a tag / SHA / `origin/x`. The "existing branch" field leaves this off. */+ allowCustom?: boolean+ /** Placeholder for the free-text ref field (only shown when `allowCustom`). */+ customPlaceholder?: string+}++/**+ * A dark-theme dropdown that matches the app's own menus (`.tab-menu`) rather than a browser-default+ * `<select>`. It reuses the Source Control branch switcher's approach: a field-styled trigger opens a+ * portaled, anchored list, closed by a full-screen `.tab-backdrop`. Portaling to `document.body`+ * escapes the dialog's overflow/stacking context, and z-index 78/80 clears the dialog overlay (70).+ */+export function BranchSelect({+ value,+ onChange,+ options,+ placeholder,+ allowCustom,+ customPlaceholder+}: Props) {+ const [menu, setMenu] = useState<{ top: number; left: number; width: number } | null>(null)+ const [custom, setCustom] = useState('')++ const open = (e: MouseEvent<HTMLButtonElement>) => {+ const r = e.currentTarget.getBoundingClientRect()+ setMenu({ top: r.bottom + 4, left: r.left, width: r.width })+ setCustom('')+ }+ const pick = (v: string) => {+ onChange(v)+ setMenu(null)+ }++ return (+ <>+ <button type="button" className="bind-select" onClick={open}>+ <span className={value ? 'bind-select__val' : 'bind-select__ph'}>{value || placeholder}</span>+ <span className="bind-select__chev">⌄</span>+ </button>+ {menu &&+ createPortal(+ <>+ {/* Full-screen click-catcher (the app's menu idiom — no document listener). It sits above+ the dialog overlay, so a click near the dialog closes the menu instead of the dialog. */}+ <div className="tab-backdrop" style={{ zIndex: 78 }} onClick={() => setMenu(null)} />+ <div+ className="tab-menu bind-select__menu"+ style={{ top: menu.top, left: menu.left, minWidth: menu.width, zIndex: 80 }}+ >+ {options.map((b) => (+ <button type="button" key={b} onClick={() => pick(b)}>+ <span className="tab-menu__check">{b === value ? '✓' : ''}</span>+ {b}+ </button>+ ))}+ {allowCustom && (+ <>+ <div className="ctx-sep" />+ <input+ className="tab__edit"+ placeholder={customPlaceholder ?? 'type a ref…'}+ value={custom}+ spellCheck={false}+ autoFocus+ onChange={(e) => setCustom(e.target.value)}+ onKeyDown={(e) => {+ if (e.key === 'Enter' && custom.trim()) {+ e.preventDefault()+ pick(custom.trim())+ }+ }}+ />+ </>+ )}+ </div>+ </>,+ document.body+ )}+ </>+ )+}diff --git a/src/renderer/components/WorktreeDialog.tsx b/src/renderer/components/WorktreeDialog.tsxindex cbb282aae..0828a76a6 100644--- a/src/renderer/components/WorktreeDialog.tsx+++ b/src/renderer/components/WorktreeDialog.tsx@@ -1,6 +1,7 @@import { useEffect, useState } from 'react'import { createPortal } from 'react-dom'import { useDialogStack } from './dialog-stack'+import { BranchSelect } from './BranchSelect'import { isValidGitRef, type WorktreeCreateValue, type WorktreeEntry } from '@shared/worktree'interface Props {@@ -14,9 +15,8 @@ interface Props {/** The repo's default branch (the main checkout's), used as the Base default. */defaultBaseRef: string/** The repo's local branch names. Base and the "existing branch" field pick from these with a- * real `<select>` (a `<datalist>` filters its options by the field's current value, so a Base- * defaulting to `main` would hide every branch that isn't a prefix of "main"). Base keeps an- * "Other ref…" escape so it can still be a tag / SHA / `origin/x`. Empty ⇒ plain text inputs. */+ * custom dropdown (`BranchSelect`). Base's dropdown also carries a free-text field so a base can+ * be any ref (a tag / SHA / `origin/x`), not just a local branch. Empty ⇒ plain text inputs. */branches: string[]/** Suggested worktree path. Returns '' when no writable base dir is known — see `pathUnknown`. */defaultPath: (repoPath: string, branch: string) => string@@ -65,10 +65,6 @@ export function WorktreeDialog({if (!baseEdited) setBaseRef(defaultBaseRef)}, [defaultBaseRef, baseEdited])- // Base defaults to picking a branch from the dropdown; "Other ref…" flips it to a free-text field- // so the base can be a tag, a commit, or a remote branch (`origin/x`) that isn't a local branch.- const [baseCustom, setBaseCustom] = useState(false)- const CUSTOM_BASE = ' other' // sentinel option value; a space cannot be in a git branch nameconst hasBranches = branches.length > 0// Only the topmost modal answers a key (./dialog-stack): this dialog and a ConfirmDialog can be@@ -150,26 +146,24 @@ export function WorktreeDialog({</label></div>- <label className="bind-field">- Branch- {/* New branch = a name that must NOT exist yet, so free text. Existing branch = check out- one that DOES exist, so pick it from the list (falls back to text if none were read). */}- {mode === 'existing' && hasBranches ? (- <select+ {/* New branch = a name that must NOT exist yet, so free text. Existing branch = check out+ one that DOES exist, so pick it from the dropdown (falls back to text if none were read). */}+ {mode === 'existing' && hasBranches ? (+ <div className="bind-field">+ Branch+ <BranchSelectvalue={branches.includes(branch) ? branch : ''}- onChange={(e) => {- setBranch(e.target.value)+ options={branches}+ placeholder="Select a branch…"+ onChange={(v) => {+ setBranch(v)setBranchEdited(true)}}- >- <option value="">Select a branch…</option>- {branches.map((b) => (- <option key={b} value={b}>- {b}- </option>- ))}- </select>- ) : (+ />+ </div>+ ) : (+ <label className="bind-field">+ Branch<inputvalue={branch}onChange={(e) => {@@ -177,8 +171,8 @@ export function WorktreeDialog({setBranchEdited(true)}}/>- )}- </label>+ </label>+ )}{branchEdited && branchInvalid && (<div className="bind-error">@@ -188,40 +182,38 @@ export function WorktreeDialog({)}{mode === 'new' && (- <label className="bind-field">- Base- {/* Pick a branch, or "Other ref…" to type a tag / SHA / origin/x. If the branch list- could not be read, degrade to a plain text field. */}- {hasBranches && !baseCustom ? (- <select- value={branches.includes(baseRef) ? baseRef : CUSTOM_BASE}- onChange={(e) => {- if (e.target.value === CUSTOM_BASE) {- setBaseCustom(true)- } else {- setBaseRef(e.target.value)+ <>+ {/* Pick a branch from the dropdown, or type any ref (tag / SHA / origin/x) in its+ free-text field. If the branch list could not be read, degrade to a plain input. */}+ {hasBranches ? (+ <div className="bind-field">+ Base+ <BranchSelect+ value={baseRef}+ options={branches}+ placeholder="Select a base…"+ allowCustom+ customPlaceholder="or a tag, commit, origin/…"+ onChange={(v) => {+ setBaseRef(v)setBaseEdited(true)- }- }}- >- {branches.map((b) => (- <option key={b} value={b}>- {b}- </option>- ))}- <option value={CUSTOM_BASE}>Other ref…</option>- </select>+ }}+ />+ </div>) : (- <input- value={baseRef}- placeholder="e.g. origin/main, a tag, or a commit"- onChange={(e) => {- setBaseRef(e.target.value)- setBaseEdited(true)- }}- />+ <label className="bind-field">+ Base+ <input+ value={baseRef}+ placeholder="e.g. origin/main, a tag, or a commit"+ onChange={(e) => {+ setBaseRef(e.target.value)+ setBaseEdited(true)+ }}+ />+ </label>)}- </label>+ </>)}<label className="bind-field">diff --git a/src/renderer/styles.css b/src/renderer/styles.cssindex 7a3affb99..455a24db7 100644--- a/src/renderer/styles.css+++ b/src/renderer/styles.css@@ -3125,6 +3125,44 @@ body,border-color: var(--accent);}+/* Custom-dropdown trigger (BranchSelect) — matches `.bind-field input` so it reads as the same kind+ * of field, with a chevron and a muted placeholder. The popover reuses the app's `.tab-menu`. */+.bind-select {+ display: flex;+ align-items: center;+ justify-content: space-between;+ gap: 8px;+ width: 100%;+ background: var(--panel-header);+ border: 1px solid var(--border);+ border-radius: 8px;+ color: var(--text);+ font-size: 13px;+ padding: 7px 10px;+ cursor: pointer;+ text-align: left;+}+.bind-select:hover {+ border-color: rgba(255, 255, 255, 0.2);+}+.bind-select__val {+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+}+.bind-select__ph {+ color: var(--muted);+}+.bind-select__chev {+ flex-shrink: 0;+ color: var(--muted);+}+/* A branch list can be long — the app's menus don't cap height, so this instance does. */+.bind-select__menu {+ max-height: 280px;+ overflow-y: auto;+}+/* Repo root, resolved from the project cwd — read-only context, not a field. */.bind-repo {margin: 0 0 12px;