Skip to content

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.

fix(ui): make the tab drop line visible at both ends of the strip

Bas Miliusfa26fa8b6bce
diff --git a/src/renderer/components/TabBar.test.tsx b/src/renderer/components/TabBar.test.tsx
index 5b20bb99b..b784c7522 100644
--- a/src/renderer/components/TabBar.test.tsx
+++ b/src/renderer/components/TabBar.test.tsx
@@ -116,7 +116,6 @@ describe('TabBar caret menu', () => {
expect(document.querySelector('.tab-menu')).toBeNull()
})
})
-
describe('TabBar New-project pin', () => {
let root: Root
let host: HTMLElement
@@ -177,3 +176,91 @@ describe('TabBar New-project pin', () => {
expect(onOpenWelcome).toHaveBeenCalledTimes(1)
})
})
+
+describe('TabBar drag-reorder', () => {
+ let root: Root
+ let host: HTMLElement
+ let onReorder: ReturnType<typeof vi.fn<(dragged: string, before: string | null) => void>>
+
+ // jsdom has no DragEvent, and React reads `dataTransfer` in onDragStart. One shared stub is
+ // enough: nothing here inspects what was put on it.
+ const drag = async (el: Element, type: string): Promise<void> => {
+ const e = new Event(type, { bubbles: true, cancelable: true })
+ Object.defineProperty(e, 'dataTransfer', { value: { effectAllowed: '', setData: (): void => {} } })
+ await act(async () => {
+ el.dispatchEvent(e)
+ })
+ }
+
+ const tabs = (): Element[] => Array.from(host.querySelectorAll('.tab'))
+
+ beforeEach(async () => {
+ const { TabBar, useProjects } = await load()
+ host = document.createElement('div')
+ document.body.appendChild(host)
+ useProjects.setState({
+ projects: [
+ project(),
+ project({ id: 'p2', name: 'Beta', cwd: '/repo/beta' }),
+ project({ id: 'p3', name: 'Gamma', cwd: '/repo/gamma' })
+ ],
+ activeProjectId: 'p1'
+ })
+ onReorder = vi.fn<(dragged: string, before: string | null) => void>()
+ root = createRoot(host)
+ await act(async () => {
+ root.render(
+ <TabBar
+ onSwitch={vi.fn()}
+ onReconnect={vi.fn()}
+ onReorder={onReorder}
+ onOpenWelcome={vi.fn()}
+ onRename={vi.fn()}
+ onSetFolder={vi.fn()}
+ onCloseProject={vi.fn()}
+ onRemoteAccess={vi.fn()}
+ onSetDefaultAccount={vi.fn()}
+ onSetDefaultPermissionMode={vi.fn()}
+ onOpenProjectSettings={vi.fn()}
+ />
+ )
+ })
+ })
+
+ afterEach(() => {
+ act(() => root.unmount())
+ host.remove()
+ useProjects.setState({ projects: [], activeProjectId: '' })
+ })
+
+ it('drops a tab before the one it was released on', async () => {
+ const [first, , third] = tabs()
+ await drag(third, 'dragstart')
+ await drag(first, 'dragover')
+ await drag(first, 'drop')
+ expect(onReorder).toHaveBeenCalledWith('p3', 'p1')
+ })
+
+ it('marks the hovered tab so the insertion line has something to hang on', async () => {
+ const [first, , third] = tabs()
+ await drag(third, 'dragstart')
+ await drag(first, 'dragover')
+ expect(first.classList.contains('is-drop-before')).toBe(true)
+ })
+
+ it('shows an insertion line for the end zone, which has no tab to hang one off', async () => {
+ const [first] = tabs()
+ await drag(first, 'dragstart')
+ expect(host.querySelector('.tab__dropline')).toBeNull()
+ await drag(host.querySelector('.tabbar__tabs')!, 'dragover')
+ expect(host.querySelector('.tab__dropline')).not.toBeNull()
+ })
+
+ it('drops at the end when released on the strip itself', async () => {
+ const [first] = tabs()
+ await drag(first, 'dragstart')
+ await drag(host.querySelector('.tabbar__tabs')!, 'dragover')
+ await drag(host.querySelector('.tabbar__tabs')!, 'drop')
+ expect(onReorder).toHaveBeenCalledWith('p1', null)
+ })
+})
diff --git a/src/renderer/components/TabBar.tsx b/src/renderer/components/TabBar.tsx
index 3b8b29045..f3538b900 100644
--- a/src/renderer/components/TabBar.tsx
+++ b/src/renderer/components/TabBar.tsx
@@ -416,6 +416,12 @@ export function TabBar({
</div>
)
})}
+ {/* The end-of-strip drop zone (`dropId === ''`) had no marker at all — every other target
+ draws its line as the `::before` of the tab it lands in front of, and "after the last
+ one" has no such tab. It lives INSIDE the scroller so it lands after the last tab
+ rather than at the window edge. Rendered only mid-drag, and its negative margins
+ cancel its own width so appearing costs no layout shift. */}
+ {dragId && dropId === '' && <span className="tab__dropline" aria-hidden />}
</div>
<button
type="button"
diff --git a/src/renderer/styles.css b/src/renderer/styles.css
index 1db7ff007..a4c757dda 100644
--- a/src/renderer/styles.css
+++ b/src/renderer/styles.css
@@ -7807,7 +7807,25 @@ button.group-node__setup:disabled {
.ss-rowdrop.is-drop-before::before { content: ''; position: absolute; top: -1px; left: 6px; right: 6px; height: 2px; border-radius: 1px; background: var(--accent); pointer-events: none; }
/* Project reorder: vertical insertion line before the tab / horizontal line above the
sidebar project header the dragged project will land before */
-.tab.is-drop-before::before { content: ''; position: absolute; left: -3px; top: 8px; bottom: 8px; width: 2px; border-radius: 1px; background: var(--accent); pointer-events: none; }
+/* The insertion line, drawn INSIDE the tab it lands in front of. Two things it must not do:
+ hang outside the tab (at `left: -3px` the first tab's line fell outside `.tabbar__tabs`, which
+ is `overflow-x: auto` and clipped it — so the leftmost drop target showed nothing), and sit
+ under the ACTIVE tab, whose `z-index: 1` swallowed it whenever the target was the tab right
+ after it. Hence `left: 0` and z-index 2. */
+.tab.is-drop-before::before { content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 2px; border-radius: 1px; background: var(--accent); pointer-events: none; z-index: 2; }
+
+/* The same line for "after the last tab", which has no tab to hang off. A real flex item rather
+ than a pseudo-element: the strip scrolls, and an absolutely positioned marker on a scroll
+ container drifts away from the end it is marking. The -1px side margins cancel its 2px width,
+ so the tabs do not shift when it appears. */
+.tab__dropline {
+ flex: 0 0 2px;
+ align-self: stretch;
+ margin: 8px -1px;
+ border-radius: 1px;
+ background: var(--accent);
+ pointer-events: none;
+}
.ss-group { position: relative; }
.ss-group.is-drop-before::before { content: ''; position: absolute; top: -1px; left: 6px; right: 6px; height: 2px; border-radius: 1px; background: var(--accent); pointer-events: none; z-index: 1; }