Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: Shell tabs show the folder name on Windows and follow a cd (#4624)
[._.]/ Adam Eivy96b8ed2448b2
diff --git a/client/src/components/shell/ShellSessionTabs.jsx b/client/src/components/shell/ShellSessionTabs.jsxindex f09136cc5c..0dfaa0f533 100644--- a/client/src/components/shell/ShellSessionTabs.jsx+++ b/client/src/components/shell/ShellSessionTabs.jsx@@ -4,6 +4,12 @@ import { clickableProps } from '../../lib/a11yKeyboard.js';const shortId = (id) => id?.slice(0, 6) ?? '';+// Separator-agnostic basename for the tab label. A Windows cwd (`I:\code\example-app`)+// contains no `/`, so a POSIX-only split leaves the whole path in the tab and blows+// out its width. `filter(Boolean)` drops the empty tail a trailing separator leaves,+// and yields undefined for a bare root so the caller falls through to the short id.+const folderName = (cwd) => cwd?.split(/[\\/]/).filter(Boolean).pop();+// Presentational session-tab strip for the Shell page. External TUI runs get a// distinct bot icon + accent tint + pulsing dot so they read as "live run you can// watch and drive"; interactive shells use the terminal icon. All session actions@@ -23,7 +29,7 @@ export default function ShellSessionTabs({ sessions, activeSessionId, onSwitch,<div className="flex items-center gap-1.5 overflow-x-auto scrollbar-hide touch-pan-x">{sessions.map((s) => {const isActive = s.sessionId === activeSessionId;- const label = s.label || s.cwd?.split('/').pop() || shortId(s.sessionId);+ const label = s.label || folderName(s.cwd) || shortId(s.sessionId);const isRun = s.external;const TabIcon = isRun ? Bot : TerminalIcon;const age = formatDurationMs(Date.now() - s.createdAt);diff --git a/client/src/components/shell/ShellSessionTabs.test.jsx b/client/src/components/shell/ShellSessionTabs.test.jsxnew file mode 100644index 0000000000..483bf6eb53--- /dev/null+++ b/client/src/components/shell/ShellSessionTabs.test.jsx@@ -0,0 +1,81 @@+import { describe, it, expect, vi } from 'vitest';+import { render, screen, fireEvent } from '@testing-library/react';+import ShellSessionTabs from './ShellSessionTabs';++const session = (overrides = {}) => ({+ sessionId: 'abcdef123456',+ cwd: '/home/user/example-app',+ createdAt: Date.now(),+ ...overrides,+});++const renderTabs = (sessions, props = {}) =>+ render(+ <ShellSessionTabs+ sessions={sessions}+ activeSessionId={sessions[0]?.sessionId}+ onSwitch={vi.fn()}+ onKill={vi.fn()}+ onNew={vi.fn()}+ {...props}+ />+ );++describe('ShellSessionTabs labels', () => {+ it('shows the folder name for a POSIX cwd', () => {+ renderTabs([session()]);+ expect(screen.getByText('example-app')).toBeTruthy();+ });++ it('shows the folder name for a Windows cwd, not the whole drive path', () => {+ renderTabs([session({ cwd: 'I:\\code\\example-app' })]);+ expect(screen.getByText('example-app')).toBeTruthy();+ expect(screen.queryByText('I:\\code\\example-app')).toBeNull();+ });++ it('ignores a trailing separator on either platform', () => {+ renderTabs([+ session({ sessionId: 'posix1', cwd: '/home/user/example-app/' }),+ session({ sessionId: 'win111', cwd: 'I:\\code\\other-app\\' }),+ ]);+ expect(screen.getByText('example-app')).toBeTruthy();+ expect(screen.getByText('other-app')).toBeTruthy();+ });++ it('falls back to the short session id when the cwd is a bare root', () => {+ renderTabs([session({ sessionId: 'abcdef123456', cwd: '/' })]);+ expect(screen.getByText('abcdef')).toBeTruthy();+ });++ it('prefers an explicit label over the cwd', () => {+ renderTabs([session({ label: 'Claude Code TUI' })]);+ expect(screen.getByText('Claude Code TUI')).toBeTruthy();+ expect(screen.queryByText('example-app')).toBeNull();+ });++ it('relabels when a cd moves the session cwd', () => {+ const { rerender } = renderTabs([session()]);+ expect(screen.getByText('example-app')).toBeTruthy();++ rerender(+ <ShellSessionTabs+ sessions={[session({ cwd: 'I:\\code\\other-app' })]}+ activeSessionId="abcdef123456"+ onSwitch={vi.fn()}+ onKill={vi.fn()}+ onNew={vi.fn()}+ />+ );+ expect(screen.getByText('other-app')).toBeTruthy();+ expect(screen.queryByText('example-app')).toBeNull();+ });++ it('kills a session without switching to it', () => {+ const onKill = vi.fn();+ const onSwitch = vi.fn();+ renderTabs([session()], { onKill, onSwitch });+ fireEvent.click(screen.getByRole('button', { name: /kill session/i }));+ expect(onKill).toHaveBeenCalledWith('abcdef123456');+ expect(onSwitch).not.toHaveBeenCalled();+ });+});diff --git a/server/services/shell.js b/server/services/shell.jsindex af63e0abc3..de22d668df 100644--- a/server/services/shell.js+++ b/server/services/shell.js@@ -586,6 +586,8 @@ export function submitToSession(sessionId, line) {* because only the server knows which shell this PTY is running — and the command* differs per shell. See lib/shellCd.js for why.*+ * Updates `session.cwd` on success — see the body for why that is optimistic.+ ** @param {string} sessionId* @param {string} dirPath* @returns {boolean} false when the session is unknown@@ -593,7 +595,16 @@ export function submitToSession(sessionId, line) {export function changeSessionDirectory(sessionId, dirPath) {const session = shellSessions.get(sessionId);if (!session) return false;- return submitToSession(sessionId, buildCdCommand(dirPath, session.shell));+ if (!submitToSession(sessionId, buildCdCommand(dirPath, session.shell))) return false;+ // Track the cd optimistically so the Shell tab label and the Workspace Contexts+ // widget follow the session instead of staying pinned to its spawn directory.+ // `cwd` is display-only after spawn — nothing functional reads it — and the paths+ // come from the managed-apps list, so they exist. Asking the PTY for its REAL cwd+ // would need a per-platform probe plus a round-trip, which is not worth it for a+ // label; a rejected path just leaves the label wrong until the next cd.+ session.cwd = dirPath;+ broadcastSessionList();+ return true;}/**diff --git a/server/services/shell.test.js b/server/services/shell.test.jsindex 9d2985f0e6..0ce05e7cdc 100644--- a/server/services/shell.test.js+++ b/server/services/shell.test.js@@ -390,6 +390,35 @@ describe('changeSessionDirectory', () => {expect(shell.changeSessionDirectory('missing', '/tmp')).toBe(false);});+ it('moves session.cwd to the new directory so the tab label stops showing the spawn dir', () => {+ const sock = makeSocket('sock-cd');+ const id = shell.createShellSession(sock, { shell: '/bin/zsh', cwd: '/home/user/example' });+ expect(shell.listAllSessions(sock).find(s => s.sessionId === id).cwd).toBe('/home/user/example');++ expect(shell.changeSessionDirectory(id, '/home/user/example-app')).toBe(true);+ expect(shell.listAllSessions(sock).find(s => s.sessionId === id).cwd).toBe('/home/user/example-app');+ });++ it('broadcasts the refreshed session list so open Shell tabs relabel without a reload', () => {+ const observer = makeSocket('obs-cd');+ const id = shell.createShellSession(makeSocket('owner-cd'), { shell: '/bin/zsh', cwd: '/home/user/example' });+ shell.subscribeSessionList(observer);++ shell.changeSessionDirectory(id, '/home/user/example-app');++ const broadcasts = observer.emit.mock.calls.filter(c => c[0] === 'shell:sessions');+ expect(broadcasts).toHaveLength(1);+ expect(broadcasts[0][1].find(s => s.sessionId === id).cwd).toBe('/home/user/example-app');+ shell.unsubscribeSessionList(observer);+ });++ it('leaves cwd untouched when the session is gone', () => {+ const sock = makeSocket('sock-cd-gone');+ const id = shell.createShellSession(sock, { shell: '/bin/zsh', cwd: '/home/user/example' });+ shell.killSession(id);+ expect(shell.changeSessionDirectory(id, '/home/user/example-app')).toBe(false);+ });+it('records the shell it spawned when the caller names none', () => {// The recorded shell is what picks the cd dialect, so a session started from// the default must remember which binary that was rather than leaving