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(ui): open the canvas controls' tooltips to the right
Bas Miliusacff1842f75a
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex db99c6c57..81c29ee66 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -13383,26 +13383,28 @@ export function Canvas() {default modes. */}{glyphLayerActive && <SharedGlyphLayer />}{/* The library's own zoom/fit glyphs are swapped for the shared icon set so this cluster- matches every other floating control; the actions behind them are unchanged. */}+ matches every other floating control; the actions behind them are unchanged. The+ tooltips open to the RIGHT rather than upward like the dock's: this is a vertical+ stack, so an upward bubble covers the button above the one being pointed at. */}<Controls showZoom={false} showFitView={false} showInteractive={false} position="bottom-left">- <Tooltip label="Zoom in" placement="top">+ <Tooltip label="Zoom in" placement="right"><ControlButton aria-label="Zoom in" onClick={() => zoomIn({ duration: ZOOM_STEP_DURATION_MS })}><IconPlus /></ControlButton></Tooltip>- <Tooltip label="Zoom out" placement="top">+ <Tooltip label="Zoom out" placement="right"><ControlButton aria-label="Zoom out" onClick={() => zoomOut({ duration: ZOOM_STEP_DURATION_MS })}><IconMinus /></ControlButton></Tooltip>- <Tooltip label="Fit view" placement="top">+ <Tooltip label="Fit view" placement="right"><ControlButton aria-label="Fit view" onClick={fitAll}><IconFit /></ControlButton></Tooltip><Tooltiplabel={canvasLocked ? 'Unlock view (pan/zoom)' : 'Lock view (pan/zoom); nodes stay movable'}- placement="top"+ placement="right"><ControlButtonclassName={`canvas-lock-btn${canvasLocked ? ' locked' : ''}`}diff --git a/src/renderer/components/Tooltip.test.ts b/src/renderer/components/Tooltip.test.tsnew file mode 100644index 000000000..c24206d04--- /dev/null+++ b/src/renderer/components/Tooltip.test.ts@@ -0,0 +1,43 @@+import { describe, it, expect } from 'vitest'+import { tooltipAnchor, tooltipClass, type TooltipPlacement } from './Tooltip'++/**+ * The anchor and the `.tooltip--*` transform are two halves of one position: the anchor says which+ * point the bubble is pinned to, the CSS says which corner of the bubble lands on it. Change one+ * without the other and the bubble drifts by its own width or height, which renders fine and looks+ * merely misaligned. These pin which edge each placement reads, so that pairing stays deliberate.+ */++const RECT = { top: 100, right: 50, left: 20, width: 30, height: 30 }++describe('tooltipAnchor', () => {+ it('pins a horizontal center above the trigger for top', () => {+ expect(tooltipAnchor(RECT, 'top')).toEqual({ x: 35, y: 94 })+ })++ it('pins a horizontal center below the trigger for bottom', () => {+ expect(tooltipAnchor(RECT, 'bottom')).toEqual({ x: 35, y: 136 })+ })++ it('pins the left edge beside the trigger, vertically centered, for right', () => {+ expect(tooltipAnchor(RECT, 'right')).toEqual({ x: 56, y: 115 })+ })++ it('offsets away from the trigger on the axis it opens along, and only that axis', () => {+ expect(tooltipAnchor(RECT, 'top').x).toBe(tooltipAnchor(RECT, 'bottom').x)+ expect(tooltipAnchor(RECT, 'right').y).toBe(RECT.top + RECT.height / 2)+ })+})++describe('tooltipClass', () => {+ it('leaves bottom on the base rule, since that is what the base rule already does', () => {+ expect(tooltipClass('bottom')).toBe('tooltip')+ })++ it('adds one modifier per other placement', () => {+ const placements: TooltipPlacement[] = ['top', 'right']+ for (const placement of placements) {+ expect(tooltipClass(placement)).toBe(`tooltip tooltip--${placement}`)+ }+ })+})diff --git a/src/renderer/components/Tooltip.tsx b/src/renderer/components/Tooltip.tsxindex 7ad93902a..df8a5c91e 100644--- a/src/renderer/components/Tooltip.tsx+++ b/src/renderer/components/Tooltip.tsx@@ -4,11 +4,51 @@ import { createPortal } from 'react-dom'/** How close the bubble may come to the window edge before it is slid back inward. */const EDGE_MARGIN = 8+/** Gap between the trigger's edge and the bubble, on whichever axis the placement opens along. */+const TOOLTIP_OFFSET = 6++/** Which side of the trigger the bubble opens on. Chrome that hugs the bottom of the window (the+ * dock) must open upward: below it, the bubble lands off-screen. Chrome stacked vertically against+ * the left edge (the canvas controls) opens sideways, where an upward bubble would cover the+ * button above the one being pointed at. */+export type TooltipPlacement = 'top' | 'bottom' | 'right'+interface TooltipOptions {delay?: number- /** Which side of the trigger the bubble opens on. Chrome that hugs the bottom of the window (the- * dock) must open upward: below it, the bubble lands off-screen. */- placement?: 'top' | 'bottom'+ placement?: TooltipPlacement+}++/**+ * The point the bubble is pinned to, in viewport coordinates. It is only half the position: the+ * matching `.tooltip--*` rule supplies the transform that pulls the bubble off that point, so the+ * two must agree. `top`/`bottom` pin a horizontal CENTER and shift the bubble up or down; `right`+ * pins its LEFT edge and centers it vertically instead.+ */+export function tooltipAnchor(+ rect: { top: number; right: number; left: number; width: number; height: number },+ placement: TooltipPlacement+): { x: number; y: number } {+ if (placement === 'right') {+ return { x: rect.right + TOOLTIP_OFFSET, y: rect.top + rect.height / 2 }+ }+ return {+ x: rect.left + rect.width / 2,+ y: placement === 'top' ? rect.top - TOOLTIP_OFFSET : rect.top + rect.height + TOOLTIP_OFFSET+ }+}++/** `bottom` is what the base rule already does, so it takes no modifier. */+export function tooltipClass(placement: TooltipPlacement): string {+ return placement === 'bottom' ? 'tooltip' : `tooltip tooltip--${placement}`+}++/**+ * How much of the bubble sits on either side of `left`, which is what the edge clamp has to know:+ * a centered placement spends half its width each way, `right` spends all of it trailing.+ */+function horizontalExtent(width: number, placement: TooltipPlacement): { leading: number; trailing: number } {+ const leading = placement === 'right' ? 0 : width / 2+ return { leading, trailing: width - leading }}interface TooltipProps extends TooltipOptions {@@ -44,21 +84,20 @@ export function useTooltip(label: string, { delay = 350, placement = 'bottom' }:useLayoutEffect(() => {const el = bubbleRef.currentif (!anchor || !el) return- const half = el.offsetWidth / 2- const min = EDGE_MARGIN + half- const max = window.innerWidth - EDGE_MARGIN - half+ const { leading, trailing } = horizontalExtent(el.offsetWidth, placement)+ const min = EDGE_MARGIN + leading+ const max = window.innerWidth - EDGE_MARGIN - trailingconst next = min > max ? window.innerWidth / 2 : Math.min(Math.max(anchor.x, min), max)if (next !== left) setLeft(next)- }, [anchor, left])+ }, [anchor, left, placement])const show = (e: React.MouseEvent): void => {const el = e.currentTarget as HTMLElementif (timer.current) clearTimeout(timer.current)timer.current = setTimeout(() => {- const r = el.getBoundingClientRect()- const x = r.left + r.width / 2- setLeft(x)- setAnchor({ x, y: placement === 'top' ? r.top - 6 : r.bottom + 6 })+ const next = tooltipAnchor(el.getBoundingClientRect(), placement)+ setLeft(next.x)+ setAnchor(next)}, delay)}@@ -74,7 +113,7 @@ export function useTooltip(label: string, { delay = 350, placement = 'bottom' }:createPortal(<divref={bubbleRef}- className={`tooltip${placement === 'top' ? ' tooltip--top' : ''}`}+ className={tooltipClass(placement)}style={{ left, top: anchor.y }}>{label}diff --git a/src/renderer/styles.css b/src/renderer/styles.cssindex 462cbcd0d..8181eedf4 100644--- a/src/renderer/styles.css+++ b/src/renderer/styles.css@@ -1829,6 +1829,12 @@ body,transform: translate(-50%, -100%);}+/* Opens sideways: the anchor x is the trigger's RIGHT edge and is already the bubble's left edge,+ so the base rule's horizontal pull is dropped and the centering moves to the other axis. */+.tooltip--right {+ transform: translateY(-50%);+}+/* Icon sizing for the boxes that are smaller than the shared 16px glyph. The icon set is one