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(kanban): flip the "+ New session" menu up when it would fall off-screen (#100)

eneskircaee0fb5aa79e4
diff --git a/src/renderer/components/kanban/KanbanColumn.tsx b/src/renderer/components/kanban/KanbanColumn.tsx
index 2c76b9dbd..a232531dc 100644
--- a/src/renderer/components/kanban/KanbanColumn.tsx
+++ b/src/renderer/components/kanban/KanbanColumn.tsx
@@ -1,4 +1,4 @@
-import { memo, useCallback, useState } from 'react'
+import { memo, useCallback, useLayoutEffect, useRef, useState } from 'react'
import type { KanbanColumn as KanbanColumnT } from '@shared/types'
import { NODE_COLORS } from '../../state/workspace'
import { SessionCard } from './SessionCard'
@@ -61,9 +61,29 @@ export const KanbanColumn = memo(function KanbanColumn({
const [title, setTitle] = useState(column?.title ?? '')
const [swatchesOpen, setSwatchesOpen] = useState(false)
const [newMenuOpen, setNewMenuOpen] = useState(false)
+ // The "+ New session" menu normally drops DOWN (top:100%); a column near the window's bottom edge
+ // would push it off-screen, so we flip it UP when it doesn't fit below. Measured on open.
+ const [menuUp, setMenuUp] = useState(false)
+ const newMenuRef = useRef<HTMLDivElement>(null)
// Trello-style drop highlight: counted enter/leave (dragleave fires when crossing children).
const [dragOverCount, setDragOverCount] = useState(0)
+ useLayoutEffect(() => {
+ if (!newMenuOpen) {
+ setMenuUp(false)
+ return
+ }
+ const el = newMenuRef.current
+ if (!el) return
+ // Measured while rendered DOWN. If its bottom clears the viewport AND there's more room above
+ // the trigger than below it, flip up. (getBoundingClientRect includes the current position.)
+ const rect = el.getBoundingClientRect()
+ const overflowsBelow = rect.bottom > window.innerHeight - 8
+ const spaceAbove = rect.top // menu top ≈ just under the button
+ const spaceBelow = window.innerHeight - rect.top
+ if (overflowsBelow && spaceAbove > spaceBelow) setMenuUp(true)
+ }, [newMenuOpen])
+
const colId = column?.id ?? null
// Binds this column's id onto the shared card-drop handler; stable while the parent's is.
const dropAtCard = useCallback(
@@ -195,7 +215,7 @@ export const KanbanColumn = memo(function KanbanColumn({
</div>
<div className="kanban-col__footer">
{newMenuOpen && (
- <div className="kanban-col__newmenu">
+ <div ref={newMenuRef} className={menuUp ? 'kanban-col__newmenu kanban-col__newmenu--up' : 'kanban-col__newmenu'}>
{createOptions.map((o) => (
<button
key={o.key}
diff --git a/src/renderer/styles.css b/src/renderer/styles.css
index 8a1db23f1..e06e29446 100644
--- a/src/renderer/styles.css
+++ b/src/renderer/styles.css
@@ -7622,6 +7622,13 @@ body,
display: flex;
flex-direction: column;
}
+/* Flipped up when the column sits near the window's bottom edge (see KanbanColumn's layout effect). */
+.kanban-col__newmenu--up {
+ top: auto;
+ bottom: 100%;
+ margin-top: 0;
+ margin-bottom: 4px;
+}
.kanban-col__newmenu button {
display: flex;
align-items: center;