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(sessions): IconSessions/IconPin + SessionRow component + styles

enesffbb43194fc4
diff --git a/src/renderer/components/SessionRow.tsx b/src/renderer/components/SessionRow.tsx
new file mode 100644
index 000000000..742fafaee
--- /dev/null
+++ b/src/renderer/components/SessionRow.tsx
@@ -0,0 +1,98 @@
+import { useState } from 'react'
+import type { SessionRowVM } from '../lib/sessionList'
+import { useContextWindow } from '../state/contextWindow'
+
+export interface SessionRowProps {
+ row: SessionRowVM
+ onClick(): void
+ onClose(): void
+ onRename(title: string): void
+ onContextMenu(e: React.MouseEvent): void
+}
+
+function ctxColor(pct: number): string {
+ if (pct > 85) return '#ff453a'
+ if (pct >= 60) return '#ffd60a'
+ return '#30d158'
+}
+
+function dirName(p?: string): string {
+ if (!p) return ''
+ const parts = p.replace(/\/+$/, '').split('/')
+ return parts[parts.length - 1] || p
+}
+
+export function SessionRow({ row, onClick, onClose, onRename, onContextMenu }: SessionRowProps): JSX.Element {
+ const [editing, setEditing] = useState(false)
+ const [draft, setDraft] = useState(row.title)
+ const usage = useContextWindow((s) => (row.sessionId ? s.bySessionId[row.sessionId] : undefined))
+
+ const commit = (): void => {
+ const t = draft.trim()
+ if (t && t !== row.title) onRename(t)
+ setEditing(false)
+ }
+
+ return (
+ <div className="ss-row" onClick={onClick} onContextMenu={onContextMenu}>
+ <span className={`ss-dot ss-dot--${row.statusKind}`} title={row.stateLabel} />
+ <div className="ss-row__body">
+ <div className="ss-row__titleline">
+ <span className="ss-mark" style={{ background: row.color }} />
+ {editing ? (
+ <input
+ className="ss-title-input"
+ autoFocus
+ value={draft}
+ onClick={(e) => e.stopPropagation()}
+ onChange={(e) => setDraft(e.target.value)}
+ onBlur={commit}
+ onKeyDown={(e) => {
+ if (e.key === 'Enter') commit()
+ if (e.key === 'Escape') setEditing(false)
+ }}
+ />
+ ) : (
+ <span
+ className={`ss-title${row.unread ? ' is-unread' : ''}`}
+ onDoubleClick={(e) => {
+ e.stopPropagation()
+ setDraft(row.title)
+ setEditing(true)
+ }}
+ >
+ {row.title}
+ </span>
+ )}
+ {row.session && <span className="ss-chip">{row.session}</span>}
+ {row.loop && (
+ <span className="ss-loop">
+ {row.loop.kind} · {row.loop.count}
+ </span>
+ )}
+ {row.usesContext && usage && (
+ <span className="ss-ctx" style={{ background: ctxColor(usage.usedPercent) }}>
+ {Math.round(usage.usedPercent)}%
+ </span>
+ )}
+ <button
+ className="ss-row__close"
+ title="Close session"
+ onClick={(e) => {
+ e.stopPropagation()
+ onClose()
+ }}
+ >
+ ×
+ </button>
+ </div>
+ {(row.cwd || row.sshHost) && (
+ <div className="ss-meta">
+ {row.sshHost && <span className="ss-meta__ssh">⇅ {row.sshHost}</span>}
+ {row.cwd && <span className="ss-meta__cwd">{dirName(row.cwd)}</span>}
+ </div>
+ )}
+ </div>
+ </div>
+ )
+}
diff --git a/src/renderer/components/icons.tsx b/src/renderer/components/icons.tsx
index e37969dc5..31db6e008 100644
--- a/src/renderer/components/icons.tsx
+++ b/src/renderer/components/icons.tsx
@@ -159,3 +159,19 @@ export const IconSearch = () => (
<path d="M21 21l-4.35-4.35" />
</svg>
)
+
+export const IconSessions = () => (
+ <svg {...S}>
+ <rect x="3" y="4" width="18" height="5" rx="1.5" />
+ <rect x="3" y="11" width="18" height="5" rx="1.5" />
+ <line x1="6" y1="6.5" x2="6" y2="6.5" />
+ <line x1="6" y1="13.5" x2="6" y2="13.5" />
+ </svg>
+)
+
+export const IconPin = () => (
+ <svg {...S}>
+ <path d="M9 3h6l-1 6 3 3v2H7v-2l3-3-1-6z" />
+ <line x1="12" y1="14" x2="12" y2="21" />
+ </svg>
+)
diff --git a/src/renderer/styles.css b/src/renderer/styles.css
index 40957e1c4..75ec9f311 100644
--- a/src/renderer/styles.css
+++ b/src/renderer/styles.css
@@ -3708,3 +3708,45 @@ body,
.pubdlg__opt:hover .pubdlg__opt-hint {
opacity: 0.85;
}
+
+/* Sessions sidebar — row + status dot */
+@keyframes nt-spin { to { transform: rotate(360deg); } }
+
+.ss-row {
+ display: flex;
+ align-items: flex-start;
+ gap: 7px;
+ padding: 6px 8px;
+ border-radius: 7px;
+ cursor: pointer;
+ border: 1px solid transparent;
+}
+.ss-row:hover { background: var(--panel-header); }
+.ss-row.is-active { background: rgba(255, 255, 255, 0.06); border-color: var(--border); }
+
+.ss-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex: 0 0 auto; }
+.ss-dot--idle { background: rgba(160, 160, 160, 0.4); }
+.ss-dot--done { background: #30d158; }
+.ss-dot--attention { background: #ffd60a; }
+.ss-dot--working {
+ background: transparent;
+ border: 2px solid #ffd60a;
+ border-top-color: transparent;
+ animation: nt-spin 1s steps(12, end) infinite;
+}
+
+.ss-row__body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
+.ss-row__titleline { display: flex; align-items: center; gap: 6px; min-width: 0; }
+.ss-mark { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 auto; }
+.ss-title { font-size: 12.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+.ss-title.is-unread { font-weight: 600; }
+.ss-title-input { font-size: 12.5px; background: var(--panel); color: var(--text); border: 1px solid var(--accent); border-radius: 4px; padding: 1px 4px; }
+.ss-chip { font-size: 10px; color: var(--text); opacity: 0.7; background: var(--panel-header); border-radius: 4px; padding: 0 5px; max-width: 9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 0 0 auto; }
+.ss-loop { font-size: 9.5px; color: #ffd60a; border: 1px solid rgba(255, 214, 10, 0.4); border-radius: 4px; padding: 0 4px; flex: 0 0 auto; }
+.ss-meta { display: flex; align-items: center; gap: 6px; font-size: 10.5px; color: rgba(180, 180, 185, 0.85); min-width: 0; }
+.ss-meta__cwd { font-family: var(--mono, monospace); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+.ss-meta__ssh { display: inline-flex; align-items: center; gap: 3px; flex: 0 0 auto; }
+.ss-ctx { font-size: 9.5px; padding: 0 5px; border-radius: 4px; color: #000; font-weight: 600; flex: 0 0 auto; }
+.ss-row__close { margin-left: auto; opacity: 0; border: none; background: transparent; color: var(--text); cursor: pointer; font-size: 14px; line-height: 1; padding: 0 2px; flex: 0 0 auto; }
+.ss-row:hover .ss-row__close { opacity: 0.6; }
+.ss-row__close:hover { opacity: 1 !important; color: #ff453a; }