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.

feat(tabs): show the project's location in a tooltip on hover

review93a17553d2f0
diff --git a/src/renderer/components/TabBar.test.tsx b/src/renderer/components/TabBar.test.tsx
index 944f26d95..ac00c7c01 100644
--- a/src/renderer/components/TabBar.test.tsx
+++ b/src/renderer/components/TabBar.test.tsx
@@ -422,3 +422,114 @@ describe('TabBar Share with team', () => {
expect(onShareWithTeam).not.toHaveBeenCalled()
})
})
+
+describe('TabBar location tooltip', () => {
+ let root: Root
+ let host: HTMLElement
+
+ const tooltip = (): HTMLElement | null => document.querySelector<HTMLElement>('.tooltip')
+ const tab = (name: string): HTMLElement =>
+ Array.from(host.querySelectorAll<HTMLElement>('.tab')).find(
+ (t) => t.querySelector('.tab__name')?.textContent === name
+ )!
+
+ // React synthesises onMouseEnter/onMouseLeave from the delegated mouseover/mouseout events.
+ const hover = (el: HTMLElement): void =>
+ act(() => {
+ el.dispatchEvent(new MouseEvent('mouseover', { bubbles: true }))
+ })
+ const leave = (el: HTMLElement): void =>
+ act(() => {
+ el.dispatchEvent(new MouseEvent('mouseout', { bubbles: true, relatedTarget: document.body }))
+ })
+ const dwell = (ms: number): void =>
+ act(() => {
+ vi.advanceTimersByTime(ms)
+ })
+
+ beforeEach(async () => {
+ const { TabBar, useProjects } = await load()
+ // The tooltip asks which session a tab belongs to; the app always has the local one.
+ const session = await import('../session/session')
+ session.setActiveSession(session.createSession('local', window.nodeTerminal, 'local').id)
+ host = document.createElement('div')
+ document.body.appendChild(host)
+ useProjects.setState({
+ projects: [
+ project({ id: 'p1', name: 'Alpha', cwd: '/repo/alpha' }),
+ project({
+ id: 'p2',
+ name: 'Remote',
+ cwd: undefined,
+ ssh: { server: { user: 'root', host: 'box.example' }, remoteCwd: '/srv/app' }
+ }),
+ project({ id: 'p3', name: 'Scratch', cwd: undefined })
+ ],
+ activeProjectId: 'p1'
+ })
+ root = createRoot(host)
+ await act(async () => {
+ root.render(
+ <TabBar
+ onSwitch={vi.fn()}
+ onReconnect={vi.fn()}
+ onReorder={vi.fn()}
+ onOpenWelcome={vi.fn()}
+ onRename={vi.fn()}
+ onSetFolder={vi.fn()}
+ onCloseProject={vi.fn()}
+ onRemoteAccess={vi.fn()}
+ onSetDefaultAccount={vi.fn()}
+ onSetDefaultPermissionMode={vi.fn()}
+ onOpenProjectSettings={vi.fn()}
+ />
+ )
+ })
+ vi.useFakeTimers()
+ })
+
+ afterEach(() => {
+ vi.useRealTimers()
+ act(() => root.unmount())
+ host.remove()
+ })
+
+ it("shows a local project's folder once the pointer rests on its tab, and not before", () => {
+ hover(tab('Alpha'))
+ dwell(400)
+ expect(tooltip()).toBeNull()
+ dwell(100)
+ expect(tooltip()?.textContent).toBe('/repo/alpha')
+ })
+
+ it('carries no native title, so the OS does not draw a second tooltip over it', () => {
+ expect(tab('Alpha').hasAttribute('title')).toBe(false)
+ })
+
+ it('hides when the pointer leaves, or presses the tab', () => {
+ hover(tab('Alpha'))
+ dwell(500)
+ expect(tooltip()).not.toBeNull()
+ leave(tab('Alpha'))
+ expect(tooltip()).toBeNull()
+
+ hover(tab('Alpha'))
+ dwell(500)
+ act(() => {
+ tab('Alpha').dispatchEvent(new MouseEvent('mousedown', { bubbles: true }))
+ })
+ expect(tooltip()).toBeNull()
+ })
+
+ it('names the host for an SSH project', () => {
+ hover(tab('Remote'))
+ dwell(500)
+ expect(tooltip()?.textContent).toBe('[email protected]:/srv/app')
+ })
+
+ it('shows nothing for a canvas with no folder', () => {
+ hover(tab('Scratch'))
+ dwell(1000)
+ expect(tooltip()).toBeNull()
+ })
+})
diff --git a/src/renderer/components/TabBar.tsx b/src/renderer/components/TabBar.tsx
index e74c1244a..ebdcc422b 100644
--- a/src/renderer/components/TabBar.tsx
+++ b/src/renderer/components/TabBar.tsx
@@ -15,6 +15,8 @@ import { commandTooltip } from '../lib/keybindingOverrides'
import { IconCanvasView, IconKanban, IconMoreVertical, IconPlus, IconUpdate } from './icons'
import { runPendingUpdate, usePendingUpdate } from '../state/pendingUpdate'
import { ProjectGlyph } from './ProjectGlyph'
+import { useTooltip } from './Tooltip'
+import { projectTabTooltip } from '../lib/projectTabTooltip'
import {
ALL_PERMISSION_MODES,
PERMISSION_MODE_LABELS,
@@ -118,6 +120,10 @@ export function TabBar({
null
)
const [editingId, setEditingId] = useState<string | null>(null)
+ // One tooltip for the whole strip: a resting pointer shows the hovered tab's location
+ // (projectTabTooltip). The label is set as the pointer enters a tab, before the dwell runs out.
+ const [tabTipLabel, setTabTipLabel] = useState('')
+ const tabTip = useTooltip(tabTipLabel, { delay: 500 })
const [draft, setDraft] = useState('')
// The stored name the editor opened on. Committing the cut draft of an over-long one
// (issue #940) stores that cut: the user asked to rename and sees what will be stored.
@@ -337,7 +343,18 @@ export function TabBar({
// project's colour.
style={swimlaneHighlight ? { color: p.color } : undefined}
draggable={editingId !== p.id}
+ onMouseEnter={(e) => {
+ // Not over the rename box or this tab's own open menu, where it would cover them.
+ if (editingId === p.id || menuId === p.id) return
+ const label = projectTabTooltip(p, sessionForProject(p.id).source)
+ if (!label) return
+ setTabTipLabel(label)
+ tabTip.triggerProps.onMouseEnter(e)
+ }}
+ onMouseLeave={tabTip.triggerProps.onMouseLeave}
+ onMouseDown={tabTip.triggerProps.onMouseDown}
onDragStart={(e) => {
+ tabTip.triggerProps.onMouseLeave()
e.dataTransfer.effectAllowed = 'move'
setDragId(p.id)
}}
@@ -376,17 +393,6 @@ export function TabBar({
if (action === 'switch') onSwitch(p.id)
else if (action === 'reconnect') onReconnect(p.id)
}}
- title={
- p.unavailable
- ? sessionForProject(p.id).source === 'local'
- ? `${p.cwd ?? 'project'} is unavailable (folder missing or unreachable)`
- : `${p.name} disconnected, click to reconnect`
- : p.ssh
- ? `${p.ssh.server.user}@${p.ssh.server.host}:${p.ssh.remoteCwd}`
- : p.relaySsh
- ? `${p.relaySsh.user}@${p.relaySsh.host}:${p.relaySsh.remoteCwd}`
- : p.cwd || undefined
- }
>
<ProjectGlyph
icon={p.icon}
@@ -501,6 +507,8 @@ export function TabBar({
</div>
</div>
+ {tabTip.bubble}
+
{menuId &&
menuPos &&
menuProject &&
diff --git a/src/renderer/lib/projectTabTooltip.test.ts b/src/renderer/lib/projectTabTooltip.test.ts
new file mode 100644
index 000000000..045d19955
--- /dev/null
+++ b/src/renderer/lib/projectTabTooltip.test.ts
@@ -0,0 +1,32 @@
+import { describe, expect, it } from 'vitest'
+import { projectTabTooltip } from './projectTabTooltip'
+
+describe('projectTabTooltip', () => {
+ it('names a local project by its folder', () => {
+ expect(projectTabTooltip({ name: 'Alpha', cwd: '/repo/alpha' }, 'local')).toBe('/repo/alpha')
+ })
+
+ it('says nothing for a canvas with no folder', () => {
+ expect(projectTabTooltip({ name: 'Scratch' }, 'local')).toBeNull()
+ expect(projectTabTooltip({ name: 'Scratch', cwd: '' }, 'local')).toBeNull()
+ })
+
+ it('names the host of an SSH project, since the path is a folder on that machine', () => {
+ const ssh = { server: { user: 'root', host: 'box.example' }, remoteCwd: '/srv/app' }
+ expect(projectTabTooltip({ name: 'App', ssh }, 'local')).toBe('[email protected]:/srv/app')
+ })
+
+ it('names the host of a relay tab of an SSH project', () => {
+ const relaySsh = { user: 'enes', host: 'niova', remoteCwd: '/root/nodeterm' }
+ expect(projectTabTooltip({ name: 'nt', relaySsh }, 'relay')).toBe('enes@niova:/root/nodeterm')
+ })
+
+ it('says why an unavailable tab cannot open, by where it lives', () => {
+ expect(projectTabTooltip({ name: 'Alpha', cwd: '/gone', unavailable: true }, 'local')).toBe(
+ '/gone is unavailable (folder missing or unreachable)'
+ )
+ expect(projectTabTooltip({ name: 'Team', unavailable: true }, 'relay')).toBe(
+ 'Team disconnected, click to reconnect'
+ )
+ })
+})
diff --git a/src/renderer/lib/projectTabTooltip.ts b/src/renderer/lib/projectTabTooltip.ts
new file mode 100644
index 000000000..a569bd3c1
--- /dev/null
+++ b/src/renderer/lib/projectTabTooltip.ts
@@ -0,0 +1,26 @@
+// What a project tab says when the pointer rests on it: where the project lives.
+//
+// It used to be the tab's native `title`, drawn by the OS on its own delay and in its own style.
+// The tab now shows it in the app's own tooltip bubble (`useTooltip`), and this is the text, kept
+// pure so every branch is testable without mounting the bar.
+
+import type { Project } from '@shared/types'
+import type { SessionSource } from '../session/session'
+
+type TabProject = Pick<Project, 'name' | 'cwd' | 'ssh' | 'relaySsh' | 'unavailable'>
+
+/**
+ * The tab's location tooltip, or null when there is nothing to say (a cwd-less canvas has no
+ * location). An SSH project names its host, because the same path means a different folder there.
+ * An unavailable tab says why it cannot be opened instead, since that is what a click would hit.
+ */
+export function projectTabTooltip(p: TabProject, source: SessionSource): string | null {
+ if (p.unavailable) {
+ return source === 'local'
+ ? `${p.cwd ?? 'project'} is unavailable (folder missing or unreachable)`
+ : `${p.name} disconnected, click to reconnect`
+ }
+ if (p.ssh) return `${p.ssh.server.user}@${p.ssh.server.host}:${p.ssh.remoteCwd}`
+ if (p.relaySsh) return `${p.relaySsh.user}@${p.relaySsh.host}:${p.relaySsh.remoteCwd}`
+ return p.cwd || null
+}