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(workspace): unavailable tabs, external-change reload + conflict bar, migration note

enes30b91b74f4b3
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsx
index 83a88d0b1..4d10a53e4 100644
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@ -67,6 +67,7 @@ import { CloneRepoDialog } from '../components/CloneRepoDialog'
import { ShortcutsPanel } from '../components/ShortcutsPanel'
import { UpdateCard } from '../components/UpdateCard'
import { AnnouncementBanner } from '../components/AnnouncementBanner'
+import { ConflictBar } from '../components/ConflictBar'
import { ConfirmDialog } from '../components/ConfirmDialog'
import { promptDialog } from '../components/promptDialog'
import { UpgradeDialog } from '../components/UpgradeDialog'
@@ -119,7 +120,7 @@ import { requireProOr } from '../state/upgradeGate'
import { useEntitlement } from '../state/entitlement'
import type { SshServer } from '@shared/ssh'
import { sshHostKey } from '@shared/ssh'
-import type { SshProjectStatus, TranscriptHit } from '@shared/types'
+import type { Project, SshProjectStatus, TranscriptHit } from '@shared/types'
import {
applyCanvasMutation,
claudeLaunchCommand,
@@ -269,6 +270,10 @@ export function Canvas() {
const controlEdgesRef = useRef<Edge[]>([])
controlEdgesRef.current = controlEdges
const [dirty, setDirty] = useState(false)
+ // The active project's .nodeterm file changed on disk while we have unsaved local edits
+ // (the user must pick a side). One-shot v2→v3 migration note (dismissible strip).
+ const [conflict, setConflict] = useState<Project | null>(null)
+ const [migrationNote, setMigrationNote] = useState<string | null>(null)
const [zoomPct, setZoomPct] = useState(100)
const [menu, setMenu] = useState<{ x: number; y: number; items: MenuItem[] } | null>(null)
const [remotePicker, setRemotePicker] = useState<{ x: number; y: number } | null>(null)
@@ -823,6 +828,58 @@ export function Canvas() {
await writeDisk()
}, [commitActiveToStore, writeDisk])
+ // Mirror `dirty` into a ref so the external-change listener (mounted once) reads the
+ // live value without re-subscribing on every edit.
+ const dirtyRef = useRef(false)
+ useEffect(() => {
+ dirtyRef.current = dirty
+ }, [dirty])
+
+ /** Re-runs the active-project load effect by nudging its dependency: flip the active id
+ * to '' (the effect early-returns) then back to the same id on a microtask. */
+ const reloadActiveProject = useCallback(() => {
+ const id = useProjects.getState().activeProjectId
+ useProjects.getState().setActive('')
+ queueMicrotask(() => useProjects.getState().setActive(id))
+ }, [])
+
+ // Outside edits to a project's .nodeterm file (git pull / sync / teammate / another machine).
+ useEffect(() => {
+ return window.nodeTerminal.workspace.onExternalChange((project) => {
+ const { activeProjectId: current } = useProjects.getState()
+ if (project.id !== current) {
+ // Background project: adopt silently — it reloads into React Flow on next switch.
+ useProjects.getState().replaceProject(project)
+ return
+ }
+ if (!dirtyRef.current) {
+ // Active but no unsaved local edits: reload in place.
+ useProjects.getState().replaceProject(project)
+ reloadActiveProject()
+ return
+ }
+ // Active with unsaved local edits: let the user pick a side.
+ setConflict(project)
+ })
+ }, [reloadActiveProject])
+
+ // One-shot note after a v2→v3 on-disk migration (dismissible, non-blocking strip).
+ useEffect(() => {
+ return window.nodeTerminal.workspace.onMigrated(() => {
+ setMigrationNote(
+ 'Projects now live in a .nodeterm folder inside each project directory — commit it to share the canvas, or add it to .gitignore.'
+ )
+ })
+ }, [])
+
+ // A pending conflict is scoped to the project that was active when it fired. If the user
+ // switches projects first, drop it: commitActiveToStore already preserved the local edits in
+ // the store, so the next save keeps our version — resolving the stale bar against a different
+ // active project would be wrong.
+ useEffect(() => {
+ setConflict(null)
+ }, [activeProjectId])
+
// Debounced auto-save for canvas edits.
useEffect(() => {
if (!dirty) return
@@ -3693,6 +3750,34 @@ export function Canvas() {
<div className="top-banners">
<AnnouncementBanner />
+ {migrationNote && (
+ <div className="announce-banner announce-banner--info">
+ <span className="announce-banner__dot" />
+ <div className="announce-banner__content">
+ <span className="announce-banner__body">{migrationNote}</span>
+ </div>
+ <button
+ className="announce-banner__close"
+ title="Dismiss"
+ onClick={() => setMigrationNote(null)}
+ >
+ ✕
+ </button>
+ </div>
+ )}
+ {conflict && (
+ <ConflictBar
+ onReload={() => {
+ useProjects.getState().replaceProject(conflict)
+ setConflict(null)
+ reloadActiveProject()
+ }}
+ onKeepMine={() => {
+ setConflict(null)
+ void persist() // our in-memory canvas wins; the save overwrites the disk file
+ }}
+ />
+ )}
{activeSshServer &&
sshStatus[activeProjectId] &&
sshStatus[activeProjectId] !== 'connected' &&
diff --git a/src/renderer/components/ConflictBar.tsx b/src/renderer/components/ConflictBar.tsx
new file mode 100644
index 000000000..c150725da
--- /dev/null
+++ b/src/renderer/components/ConflictBar.tsx
@@ -0,0 +1,18 @@
+/** Non-blocking strip shown when the active project's .nodeterm file changed on disk
+ * while there are unsaved local edits. Reload = take the disk version; Keep mine =
+ * overwrite disk with the in-memory canvas on the next save. */
+export function ConflictBar({
+ onReload,
+ onKeepMine
+}: {
+ onReload(): void
+ onKeepMine(): void
+}): JSX.Element {
+ return (
+ <div className="conflict-bar">
+ <span>Project file changed on disk (git pull or another machine).</span>
+ <button onClick={onReload}>Reload from disk</button>
+ <button onClick={onKeepMine}>Keep my version</button>
+ </div>
+ )
+}
diff --git a/src/renderer/components/TabBar.tsx b/src/renderer/components/TabBar.tsx
index 3107eb01d..47f876a60 100644
--- a/src/renderer/components/TabBar.tsx
+++ b/src/renderer/components/TabBar.tsx
@@ -152,10 +152,14 @@ export function TabBar({
return (
<div
key={p.id}
- className={`tab${active ? ' active' : ''}`}
+ className={`tab${active ? ' active' : ''}${p.unavailable ? ' unavailable' : ''}`}
style={active ? { color: p.color } : undefined}
- onClick={() => !editingId && onSwitch(p.id)}
- title={p.cwd || undefined}
+ onClick={() => !editingId && !p.unavailable && onSwitch(p.id)}
+ title={
+ p.unavailable
+ ? `${p.cwd ?? 'project'} is unavailable (folder missing or unreachable)`
+ : p.cwd || undefined
+ }
>
<span
className="tab__dot"
diff --git a/src/renderer/styles.css b/src/renderer/styles.css
index 8a6e30d0d..34cbe0c7e 100644
--- a/src/renderer/styles.css
+++ b/src/renderer/styles.css
@@ -142,6 +142,15 @@ body,
font-weight: 600;
}
+/* Project whose folder/ref is missing or unreachable — greyed and not switchable. */
+.tab.unavailable {
+ opacity: 0.45;
+ cursor: default;
+}
+.tab.unavailable .tab__name {
+ text-decoration: line-through;
+}
+
.tab__dot {
width: 9px;
height: 9px;
@@ -2236,6 +2245,37 @@ body,
background: rgba(255, 255, 255, 0.08);
}
+/* Active project's .nodeterm file changed on disk while there are unsaved local edits. */
+.conflict-bar {
+ display: flex;
+ align-items: center;
+ gap: 12px;
+ max-width: 560px;
+ padding: 6px 12px;
+ background: rgba(255, 159, 10, 0.15);
+ border: 1px solid rgba(255, 159, 10, 0.4);
+ border-radius: 10px;
+ box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
+ font-size: 12.5px;
+ color: var(--text);
+}
+
+.conflict-bar button {
+ flex: none;
+ padding: 2px 10px;
+ background: transparent;
+ border: 1px solid rgba(255, 159, 10, 0.6);
+ border-radius: 7px;
+ color: var(--text);
+ font-size: 12px;
+ font-weight: 600;
+ cursor: pointer;
+}
+
+.conflict-bar button:hover {
+ background: rgba(255, 159, 10, 0.18);
+}
+
.controls-cluster button {
width: 34px;
height: 34px;