Skip to content

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

fix: Claude Code button opens web terminal instead of silent headless spawn

Adam Eivy90318ef05c8c
diff --git a/.changelog/v1.26.x.md b/.changelog/v1.26.x.md
index 65f0ed2b12..fd8f6f1107 100644
--- a/.changelog/v1.26.x.md
+++ b/.changelog/v1.26.x.md
@@ -18,3 +18,8 @@ Actionable GSD project management dashboard with phase detail views, action trig
- **Phase file parsing**: Backend was looking for hardcoded `PLAN.md` and `VERIFICATION.md` in phase directories, but actual files use prefixed naming (`01-01-PLAN.md`, `01-VERIFICATION.md`) — phases now correctly scan for `*-PLAN.md`, `*-VERIFICATION.md`, `*-RESEARCH.md`, and `*-SUMMARY.md` files
- **Multi-plan phases**: Phases with multiple sub-plans (e.g., `03-01-PLAN.md`, `03-02-PLAN.md`, `03-03-PLAN.md`) are now properly parsed as arrays instead of returning null
+- **Claude Code button**: "Open Claude Code" on GSD page now opens a web terminal at `/shell` with Claude Code running in the app directory, instead of silently spawning a headless process
+
+## 🔧 Improvements
+
+- **Shell session options**: `shell:start` socket event now accepts optional `cwd` and `initialCommand` parameters, enabling pre-configured terminal sessions via URL params (`/shell?cwd=/path&cmd=claude`)
diff --git a/client/src/components/apps/tabs/GsdTab.jsx b/client/src/components/apps/tabs/GsdTab.jsx
index ebee890fb7..1a6ad6612c 100644
--- a/client/src/components/apps/tabs/GsdTab.jsx
+++ b/client/src/components/apps/tabs/GsdTab.jsx
@@ -1,5 +1,5 @@
import { useState, useEffect } from 'react';
-import { useSearchParams } from 'react-router-dom';
+import { useSearchParams, useNavigate } from 'react-router-dom';
import { RefreshCw, Compass, CheckCircle, ArrowRight, FolderSearch, FileText, Map, Play, Terminal } from 'lucide-react';
import toast from 'react-hot-toast';
import BrailleSpinner from '../../BrailleSpinner';
@@ -16,6 +16,7 @@ const STEP_DESCRIPTIONS = {
};
function GsdSetupGuide({ gsd, appId, repoPath, onRefresh }) {
+ const navigate = useNavigate();
const [runningStep, setRunningStep] = useState(null);
// Determine the current step based on what exists
@@ -60,9 +61,8 @@ function GsdSetupGuide({ gsd, appId, repoPath, onRefresh }) {
setTimeout(() => setRunningStep(null), 2000);
};
- const handleOpenClaude = async () => {
- toast('Opening Claude Code...');
- await api.openAppInClaude(appId).catch(() => null);
+ const handleOpenClaude = () => {
+ navigate(`/shell?cwd=${encodeURIComponent(repoPath)}&cmd=claude`);
};
return (
@@ -286,7 +286,6 @@ export default function GsdTab({ appId, repoPath }) {
{/* Project Header */}
<GsdProjectHeader
project={project}
- pendingActions={pendingActions}
appId={appId}
repoPath={repoPath}
onRefresh={fetchData}
diff --git a/client/src/components/gsd/GsdProjectHeader.jsx b/client/src/components/gsd/GsdProjectHeader.jsx
index 46dc662615..7d8715946f 100644
--- a/client/src/components/gsd/GsdProjectHeader.jsx
+++ b/client/src/components/gsd/GsdProjectHeader.jsx
@@ -1,5 +1,5 @@
+import { useNavigate } from 'react-router-dom';
import { RefreshCw, Terminal, Play, Settings } from 'lucide-react';
-import toast from 'react-hot-toast';
import * as api from '../../services/api';
const STATUS_COLORS = {
@@ -8,7 +8,8 @@ const STATUS_COLORS = {
paused: 'bg-port-warning text-port-warning',
};
-export default function GsdProjectHeader({ project, pendingActions, appId, repoPath, onRefresh }) {
+export default function GsdProjectHeader({ project, appId, repoPath, onRefresh }) {
+ const navigate = useNavigate();
const state = project?.state?.frontmatter || {};
const phases = project?.phases || [];
const completedPhases = phases.filter(p => p.totalTasks > 0 && p.completedTasks === p.totalTasks && p.verification?.status === 'passed').length;
@@ -19,9 +20,8 @@ export default function GsdProjectHeader({ project, pendingActions, appId, repoP
const mode = project?.config?.mode || state.mode;
const depth = project?.config?.depth || state.depth;
- const handleOpenClaude = async () => {
- toast('Opening Claude Code...');
- await api.openAppInClaude(appId).catch(() => null);
+ const handleOpenClaude = () => {
+ navigate(`/shell?cwd=${encodeURIComponent(repoPath)}&cmd=claude`);
};
const handleNewMilestone = async () => {
diff --git a/client/src/pages/Shell.jsx b/client/src/pages/Shell.jsx
index e958e3460f..35a30a5027 100644
--- a/client/src/pages/Shell.jsx
+++ b/client/src/pages/Shell.jsx
@@ -1,4 +1,5 @@
import { useEffect, useRef, useState, useCallback } from 'react';
+import { useSearchParams } from 'react-router-dom';
import { Terminal } from '@xterm/xterm';
import { FitAddon } from '@xterm/addon-fit';
import { WebLinksAddon } from '@xterm/addon-web-links';
@@ -16,13 +17,28 @@ const getThemeHex = (varName) => {
};
export default function Shell() {
+ const [searchParams, setSearchParams] = useSearchParams();
const terminalRef = useRef(null);
const termInstanceRef = useRef(null);
const fitAddonRef = useRef(null);
const sessionIdRef = useRef(null);
+ const initialOptsRef = useRef(null);
const socket = useSocket();
const [connected, setConnected] = useState(false);
+ // Read query params once on mount for initial session options
+ if (!initialOptsRef.current) {
+ const cwd = searchParams.get('cwd');
+ const cmd = searchParams.get('cmd');
+ if (cwd || cmd) {
+ initialOptsRef.current = { cwd, cmd };
+ // Clear query params from URL so restart/refresh starts a plain shell
+ setSearchParams({}, { replace: true });
+ } else {
+ initialOptsRef.current = {};
+ }
+ }
+
// Initialize terminal once
useEffect(() => {
if (!terminalRef.current || termInstanceRef.current) return;
@@ -129,7 +145,13 @@ export default function Shell() {
termInstanceRef.current.clear();
termInstanceRef.current.writeln('\x1b[36mStarting shell session...\x1b[0m');
}
- socket.emit('shell:start');
+ const opts = initialOptsRef.current || {};
+ const startOpts = {};
+ if (opts.cwd) startOpts.cwd = opts.cwd;
+ if (opts.cmd) startOpts.initialCommand = opts.cmd;
+ // Only use initial opts once
+ initialOptsRef.current = {};
+ socket.emit('shell:start', Object.keys(startOpts).length > 0 ? startOpts : undefined);
}, [socket]);
const stopSession = useCallback(() => {
diff --git a/package-lock.json b/package-lock.json
index 7615f0174b..587c6ce3a3 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "portos",
- "version": "1.27.0",
+ "version": "1.27.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "portos",
- "version": "1.27.0",
+ "version": "1.27.1",
"license": "MIT",
"dependencies": {
"express": "^4.21.2",
diff --git a/package.json b/package.json
index 380d7ff527..c615ca134d 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "portos",
- "version": "1.27.0",
+ "version": "1.27.1",
"private": true,
"description": "Local dev machine App OS portal",
"author": "Adam Eivy (@antic|@atomantic)",
diff --git a/server/services/socket.js b/server/services/socket.js
index 69058a2a47..30ee07fb91 100644
--- a/server/services/socket.js
+++ b/server/services/socket.js
@@ -369,10 +369,15 @@ export function initSocket(io) {
});
// Shell session handlers
- socket.on('shell:start', () => {
- const sessionId = shellService.createShellSession(socket);
+ socket.on('shell:start', (options) => {
+ const cwd = options?.cwd || undefined;
+ const initialCommand = options?.initialCommand || undefined;
+ const sessionId = shellService.createShellSession(socket, { cwd });
if (sessionId) {
socket.emit('shell:started', { sessionId });
+ if (initialCommand) {
+ setTimeout(() => shellService.writeToSession(sessionId, initialCommand + '\n'), 200);
+ }
} else {
socket.emit('shell:error', { error: 'Failed to create shell session' });
}