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(browser): Chrome-like start page for a blank browser node
enesc065e4844877
diff --git a/src/renderer/nodes/BrowserNode.tsx b/src/renderer/nodes/BrowserNode.tsxindex c3dc9e3c3..1bea016e9 100644--- a/src/renderer/nodes/BrowserNode.tsx+++ b/src/renderer/nodes/BrowserNode.tsx@@ -1,7 +1,9 @@import { useEffect, useRef, useState } from 'react'import { Handle, NodeResizer, Position, useReactFlow, type NodeProps } from '@xyflow/react'import type { CanvasNode } from '../state/workspace'-import { normalizeAddress } from './browserUrl'+import { searchOrUrl } from './browserUrl'+import { BrowserStartPage } from './BrowserStartPage'+import { useBrowserHistory } from '../state/browserHistory'// Minimal typing for the Electron <webview> element methods/events we use.type WebviewEl = HTMLElement & {@@ -25,6 +27,7 @@ type WebviewEl = HTMLElement & {export default function BrowserNode({ id, data, selected }: NodeProps<CanvasNode>) {const { deleteElements, updateNodeData } = useReactFlow()const ref = useRef<WebviewEl | null>(null)+ const lastUrlRef = useRef('')// Seed the initial webview src ONCE at mount; navigations persist via updateNodeData but must// not re-push `src` into a webview that already navigated there (would cause a reload loop).const [startUrl] = useState(() => (data.url as string) ?? '')@@ -53,10 +56,15 @@ export default function BrowserNode({ id, data, selected }: NodeProps<CanvasNodesetAddress(u)setFailed('')updateNodeData(id, { url: u }) // persist last top-level URL+ lastUrlRef.current = u+ useBrowserHistory.getState().record(u, u)}const onNavInPage = (e: Event): void => setAddress((e as unknown as { url: string }).url)- const onTitle = (e: Event): void =>- updateNodeData(id, { title: (e as unknown as { title: string }).title })+ const onTitle = (e: Event): void => {+ const title = (e as unknown as { title: string }).title+ updateNodeData(id, { title })+ if (lastUrlRef.current) useBrowserHistory.getState().record(lastUrlRef.current, title)+ }const onFail = (e: Event): void => {const ev = e as unknown as { isMainFrame: boolean; errorCode: number; errorDescription: string }// -3 (ABORTED) fires on user-initiated stop / redirect races — ignore it.@@ -96,9 +104,9 @@ export default function BrowserNode({ id, data, selected }: NodeProps<CanvasNode}, [id])const go = (): void => {- const safe = normalizeAddress(address)+ const safe = searchOrUrl(address)if (!safe) {- setFailed('Enter a valid http(s) URL')+ setFailed('Enter a URL or search term')return}setAddress(safe)@@ -193,6 +201,15 @@ export default function BrowserNode({ id, data, selected }: NodeProps<CanvasNodeallowpopups={true}style={{ width: '100%', height: '100%' }}/>+ {!src && (+ <BrowserStartPage+ onNavigate={(u) => {+ setSrc(u)+ setAddress(u)+ setFailed('')+ }}+ />+ )}{failed && <div className="browser-node__error">{failed}</div>}</div></div>diff --git a/src/renderer/nodes/BrowserStartPage.tsx b/src/renderer/nodes/BrowserStartPage.tsxnew file mode 100644index 000000000..52bad88da--- /dev/null+++ b/src/renderer/nodes/BrowserStartPage.tsx@@ -0,0 +1,72 @@+import { useState } from 'react'+import { searchOrUrl } from './browserUrl'+import { SHORTCUTS, SiteIcon } from './browserIcons'+import { useBrowserHistory } from '../state/browserHistory'++function hostLabel(url: string): string {+ try {+ return new URL(url).hostname.replace(/^www\./, '')+ } catch {+ return url+ }+}++/** The Chrome-like new-tab page shown inside a blank browser node. */+export function BrowserStartPage({ onNavigate }: { onNavigate: (url: string) => void }): JSX.Element {+ const [q, setQ] = useState('')+ const recent = useBrowserHistory((s) => s.recent(8))+ const submit = (): void => {+ const u = searchOrUrl(q)+ if (u) onNavigate(u)+ }+ return (+ <div className="startpage nodrag nowheel">+ <div className="startpage__inner">+ <div className="startpage__searchbar">+ <span className="startpage__search-icon">⌕</span>+ <input+ className="startpage__search"+ spellCheck={false}+ value={q}+ placeholder="Search Google or type a URL"+ onChange={(e) => setQ(e.target.value)}+ onKeyDown={(e) => {+ if (e.key === 'Enter') submit()+ }}+ />+ </div>++ <div className="startpage__grid">+ {SHORTCUTS.map((s) => (+ <button+ key={s.url}+ className="startpage__tile"+ title={s.label}+ onClick={() => onNavigate(s.url)}+ >+ <SiteIcon url={s.url} label={s.label} />+ <span className="startpage__tile-label">{s.label}</span>+ </button>+ ))}+ </div>++ {recent.length > 0 && (+ <div className="startpage__recent">+ <div className="startpage__recent-title">Recent</div>+ {recent.map((e) => (+ <button+ key={`${e.url}-${e.ts}`}+ className="startpage__recent-item"+ onClick={() => onNavigate(e.url)}+ >+ <SiteIcon url={e.url} size={22} />+ <span className="startpage__recent-name">{e.title}</span>+ <span className="startpage__recent-host">{hostLabel(e.url)}</span>+ </button>+ ))}+ </div>+ )}+ </div>+ </div>+ )+}diff --git a/src/renderer/nodes/browserIcons.tsx b/src/renderer/nodes/browserIcons.tsxnew file mode 100644index 000000000..a861507b4--- /dev/null+++ b/src/renderer/nodes/browserIcons.tsx@@ -0,0 +1,79 @@+export interface Shortcut {+ label: string+ url: string+}++export const SHORTCUTS: Shortcut[] = [+ { label: 'Google', url: 'https://www.google.com' },+ { label: 'YouTube', url: 'https://www.youtube.com' },+ { label: 'GitHub', url: 'https://github.com' },+ { label: 'Gmail', url: 'https://mail.google.com' },+ { label: 'X', url: 'https://x.com' },+ { label: 'ChatGPT', url: 'https://chatgpt.com' },+ { label: 'Reddit', url: 'https://www.reddit.com' },+ { label: 'Wikipedia', url: 'https://www.wikipedia.org' }+]++function hostKey(url: string): string {+ try {+ return new URL(url).hostname.replace(/^www\./, '')+ } catch {+ return ''+ }+}++// Self-contained inline brand marks (no external fetch), keyed by hostname. Sites not listed+// here fall back to a colored monogram — trivial to add more marks later.+const ICONS: Record<string, JSX.Element> = {+ 'github.com': (+ <svg viewBox="0 0 16 16" width="58%" height="58%" fill="#fff" aria-hidden="true">+ <path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0016 8c0-4.42-3.58-8-8-8z" />+ </svg>+ ),+ 'youtube.com': (+ <svg viewBox="0 0 24 24" width="72%" height="72%" aria-hidden="true">+ <rect x="1" y="5" width="22" height="14" rx="4" fill="#FF0000" />+ <path d="M10 8.5l6 3.5-6 3.5z" fill="#fff" />+ </svg>+ ),+ 'x.com': (+ <svg viewBox="0 0 24 24" width="52%" height="52%" fill="#fff" aria-hidden="true">+ <path d="M18.9 2h3.3l-7.2 8.3L23.5 22h-6.6l-5.2-6.8L5.7 22H2.4l7.7-8.8L1.5 2h6.8l4.7 6.2L18.9 2zM17.7 20h1.8L7.1 4H5.1L17.7 20z" />+ </svg>+ ),+ 'reddit.com': (+ <svg viewBox="0 0 24 24" width="76%" height="76%" aria-hidden="true">+ <circle cx="12" cy="13" r="9" fill="#FF4500" />+ <circle cx="8.6" cy="13" r="1.4" fill="#fff" />+ <circle cx="15.4" cy="13" r="1.4" fill="#fff" />+ <path d="M8.7 16.2c1.1.9 5.5.9 6.6 0" stroke="#fff" strokeWidth="1.1" fill="none" strokeLinecap="round" />+ </svg>+ )+}++const MONO_COLORS = ['#4285F4', '#EA4335', '#34A853', '#F9AB00', '#a259ff', '#ff6d00', '#00b8d4', '#e91e63']+function monoColor(seed: string): string {+ let h = 0+ for (let i = 0; i < seed.length; i++) h = (h * 31 + seed.charCodeAt(i)) >>> 0+ return MONO_COLORS[h % MONO_COLORS.length]+}++/** A site's brand mark (inline SVG) when known, else a colored monogram tile. */+export function SiteIcon({ url, label, size = 44 }: { url: string; label?: string; size?: number }): JSX.Element {+ const key = hostKey(url)+ const svg = ICONS[key]+ const seed = key || label || '?'+ const letter = (label || key || '?').charAt(0).toUpperCase()+ return (+ <span+ className="site-icon"+ style={{+ width: size,+ height: size,+ background: svg ? 'rgba(255,255,255,0.06)' : monoColor(seed)+ }}+ >+ {svg ?? <span className="site-icon__letter">{letter}</span>}+ </span>+ )+}diff --git a/src/renderer/nodes/browserUrl.test.ts b/src/renderer/nodes/browserUrl.test.tsindex 093b7673c..fc0fecee1 100644--- a/src/renderer/nodes/browserUrl.test.ts+++ b/src/renderer/nodes/browserUrl.test.ts@@ -1,5 +1,5 @@import { describe, it, expect } from 'vitest'-import { normalizeAddress } from './browserUrl'+import { normalizeAddress, searchOrUrl } from './browserUrl'describe('normalizeAddress', () => {it('passes http(s) URLs through (normalized)', () => {@@ -18,3 +18,26 @@ describe('normalizeAddress', () => {expect(normalizeAddress('')).toBeNull()})})++describe('searchOrUrl', () => {+ it('passes http(s) URLs through', () => {+ expect(searchOrUrl('https://x.com')).toBe('https://x.com/')+ expect(searchOrUrl('http://a.dev/p')).toBe('http://a.dev/p')+ })+ it('treats a bare host as https', () => {+ expect(searchOrUrl('github.com/a')).toBe('https://github.com/a')+ expect(searchOrUrl('example.com')).toBe('https://example.com/')+ })+ it('treats localhost / 127.0.0.1 as http (dev servers)', () => {+ expect(searchOrUrl('localhost:3000')).toBe('http://localhost:3000/')+ expect(searchOrUrl('127.0.0.1:8080/x')).toBe('http://127.0.0.1:8080/x')+ })+ it('Google-searches free text and non-http schemes', () => {+ expect(searchOrUrl('how to code')).toBe('https://www.google.com/search?q=how%20to%20code')+ expect(searchOrUrl('weather')).toBe('https://www.google.com/search?q=weather')+ expect(searchOrUrl('file:///etc/passwd')).toBe('https://www.google.com/search?q=file%3A%2F%2F%2Fetc%2Fpasswd')+ })+ it('returns null for empty', () => {+ expect(searchOrUrl(' ')).toBeNull()+ })+})diff --git a/src/renderer/nodes/browserUrl.ts b/src/renderer/nodes/browserUrl.tsindex 5500841df..8319548f9 100644--- a/src/renderer/nodes/browserUrl.ts+++ b/src/renderer/nodes/browserUrl.ts@@ -21,3 +21,40 @@ export function normalizeAddress(input: string): string | null {return null}}++function googleSearch(query: string): string {+ return `https://www.google.com/search?q=${encodeURIComponent(query)}`+}++/**+ * Turn an address-bar / start-page entry into a navigable http(s) URL, or a Google search for+ * free text. Returns null only for empty input. localhost/127.0.0.1 default to http (dev servers);+ * other bare hosts to https. Non-http schemes (file:/javascript:/…) are searched, never navigated.+ */+export function searchOrUrl(input: string): string | null {+ const raw = input.trim()+ if (!raw) return null+ // Explicit scheme. The negative lookahead keeps `host:port` (e.g. `localhost:3000`) out of the+ // scheme branch — a real URI scheme's colon is never immediately followed by a port digit.+ if (/^[a-z][a-z0-9+.-]*:(?!\d)/i.test(raw)) {+ if (/^https?:\/\//i.test(raw)) {+ try {+ return new URL(raw).toString()+ } catch {+ return googleSearch(raw)+ }+ }+ return googleSearch(raw)+ }+ // No scheme: is it a host?+ const isLocal = /^(localhost|127\.0\.0\.1)(:\d+)?(\/|$)/i.test(raw)+ const looksHost = !/\s/.test(raw) && (isLocal || /^[^\s/]+\.[^\s/]+/.test(raw))+ if (looksHost) {+ try {+ return new URL(`${isLocal ? 'http' : 'https'}://${raw}`).toString()+ } catch {+ return googleSearch(raw)+ }+ }+ return googleSearch(raw)+}diff --git a/src/renderer/state/browserHistory.test.ts b/src/renderer/state/browserHistory.test.tsnew file mode 100644index 000000000..80cb4a433--- /dev/null+++ b/src/renderer/state/browserHistory.test.ts@@ -0,0 +1,20 @@+import { describe, it, expect } from 'vitest'+import { addEntry, type HistoryEntry } from './browserHistory'++const e = (url: string, ts: number): HistoryEntry => ({ url, title: url, ts })++describe('addEntry', () => {+ it('prepends the newest entry', () => {+ const out = addEntry([e('a', 1)], e('b', 2), 10)+ expect(out.map((x) => x.url)).toEqual(['b', 'a'])+ })+ it('dedups by url, bumping a revisit to the top', () => {+ const out = addEntry([e('a', 1), e('b', 2)], e('a', 3), 10)+ expect(out.map((x) => x.url)).toEqual(['a', 'b'])+ expect(out[0].ts).toBe(3)+ })+ it('enforces the cap (drops the oldest)', () => {+ const out = addEntry([e('a', 1), e('b', 2)], e('c', 3), 2)+ expect(out.map((x) => x.url)).toEqual(['c', 'a'])+ })+})diff --git a/src/renderer/state/browserHistory.ts b/src/renderer/state/browserHistory.tsnew file mode 100644index 000000000..ece3cb656--- /dev/null+++ b/src/renderer/state/browserHistory.ts@@ -0,0 +1,46 @@+import { create } from 'zustand'++export interface HistoryEntry {+ url: string+ title: string+ ts: number+}++export const HISTORY_CAP = 100+const KEY = 'nodeterm.browserHistory'++/** Prepend `entry`, drop any existing entry with the same url (a revisit bumps to top), cap length. */+export function addEntry(list: HistoryEntry[], entry: HistoryEntry, cap: number): HistoryEntry[] {+ return [entry, ...list.filter((e) => e.url !== entry.url)].slice(0, cap)+}++function load(): HistoryEntry[] {+ try {+ const parsed = JSON.parse(localStorage.getItem(KEY) ?? '[]')+ return Array.isArray(parsed) ? (parsed as HistoryEntry[]) : []+ } catch {+ return []+ }+}++interface HistoryState {+ entries: HistoryEntry[]+ /** Record a visited page. Ignores non-http(s) urls (e.g. about:blank) so the start page isn't logged. */+ record: (url: string, title: string) => void+ recent: (n: number) => HistoryEntry[]+}++export const useBrowserHistory = create<HistoryState>((set, get) => ({+ entries: load(),+ record: (url, title) => {+ if (!/^https?:\/\//i.test(url)) return+ const next = addEntry(get().entries, { url, title: title || url, ts: Date.now() }, HISTORY_CAP)+ set({ entries: next })+ try {+ localStorage.setItem(KEY, JSON.stringify(next))+ } catch {+ /* best-effort */+ }+ },+ recent: (n) => get().entries.slice(0, n)+}))diff --git a/src/renderer/styles.css b/src/renderer/styles.cssindex 4ff905e90..b18aa732c 100644--- a/src/renderer/styles.css+++ b/src/renderer/styles.css@@ -4239,3 +4239,126 @@ body,font-size: 12px;padding: 4px 8px;}++/* ── Browser start page (new-tab) ─────────────────────────────── */+.startpage {+ position: absolute;+ inset: 0;+ overflow: auto;+ background: var(--bg);+ display: flex;+ justify-content: center;+}+.startpage__inner {+ width: 100%;+ max-width: 560px;+ padding: 48px 24px 32px;+ display: flex;+ flex-direction: column;+ align-items: center;+ gap: 28px;+}+.startpage__searchbar {+ width: 100%;+ display: flex;+ align-items: center;+ gap: 8px;+ background: var(--panel);+ border: 1px solid var(--border);+ border-radius: 999px;+ padding: 10px 16px;+}+.startpage__searchbar:focus-within {+ border-color: var(--accent);+}+.startpage__search-icon {+ color: var(--muted);+ font-size: 16px;+}+.startpage__search {+ flex: 1;+ background: transparent;+ border: none;+ outline: none;+ color: var(--text);+ font-size: 14px;+}+.startpage__grid {+ width: 100%;+ display: grid;+ grid-template-columns: repeat(4, 1fr);+ gap: 12px;+}+.startpage__tile {+ display: flex;+ flex-direction: column;+ align-items: center;+ gap: 8px;+ background: transparent;+ border: none;+ cursor: pointer;+ padding: 8px 4px;+ border-radius: 10px;+}+.startpage__tile:hover {+ background: var(--panel-header);+}+.site-icon {+ display: inline-flex;+ align-items: center;+ justify-content: center;+ border-radius: 12px;+ overflow: hidden;+ flex: none;+}+.site-icon__letter {+ color: #fff;+ font-weight: 600;+ font-size: 18px;+}+.startpage__tile-label {+ color: var(--text);+ font-size: 12px;+ max-width: 100%;+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+}+.startpage__recent {+ width: 100%;+}+.startpage__recent-title {+ color: var(--muted);+ font-size: 12px;+ text-transform: uppercase;+ letter-spacing: 0.04em;+ margin-bottom: 8px;+}+.startpage__recent-item {+ width: 100%;+ display: flex;+ align-items: center;+ gap: 10px;+ background: transparent;+ border: none;+ cursor: pointer;+ padding: 7px 8px;+ border-radius: 8px;+ text-align: left;+}+.startpage__recent-item:hover {+ background: var(--panel-header);+}+.startpage__recent-name {+ color: var(--text);+ font-size: 13px;+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+ flex: 1;+}+.startpage__recent-host {+ color: var(--muted);+ font-size: 12px;+ flex: none;+}