feat: Add SSH remote execution for multi-host Claude sessions

- Backend: SSH execution via spawn() with -T flag for JSON streaming
- Backend: PATH setup for non-login shells on remote hosts
- Backend: History loading via SSH (tail -n 2000 for large files)
- Frontend: Host selector UI with colored buttons in Sidebar
- Frontend: Auto-select first project when host changes
- Frontend: Pass host parameter to history and session APIs
- Docker: Install openssh-client, mount SSH keys

Enables running Claude sessions on remote hosts via SSH while
viewing them through the web UI.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-15 22:59:34 +01:00
parent 60095d6e25
commit 9eb0ecfb57
6 changed files with 236 additions and 83 deletions

View File

@@ -203,14 +203,15 @@ export function useClaudeSession() {
}
}, []);
const loadHistory = useCallback(async (project) => {
const loadHistory = useCallback(async (project, host = null) => {
try {
const encodedProject = encodeURIComponent(project);
const response = await fetch(`${API_URL}/api/history/${encodedProject}`);
const hostParam = host ? `?host=${host}` : '';
const response = await fetch(`${API_URL}/api/history/${encodedProject}${hostParam}`);
if (response.ok) {
const data = await response.json();
if (data.messages && data.messages.length > 0) {
console.log(`Loaded ${data.messages.length} messages from history`);
console.log(`Loaded ${data.messages.length} messages from history (source: ${data.source || 'local'})`);
setMessages(data.messages);
return data.sessionId;
}
@@ -221,7 +222,7 @@ export function useClaudeSession() {
return null;
}, []);
const startSession = useCallback(async (project = '/projects', resume = true) => {
const startSession = useCallback(async (project = '/projects', resume = true, host = null) => {
if (!wsRef.current || wsRef.current.readyState !== WebSocket.OPEN) {
setError('Not connected');
return;
@@ -229,13 +230,14 @@ export function useClaudeSession() {
// Load history before starting session if resuming
if (resume) {
await loadHistory(project);
await loadHistory(project, host);
}
wsRef.current.send(JSON.stringify({
type: 'start_session',
project,
resume
resume,
host
}));
}, [loadHistory]);