From 599f9119640fa7cfdfeb52d7523b63f1412d8fa3 Mon Sep 17 00:00:00 2001 From: Jared Miller Date: Wed, 28 Jan 2026 14:56:53 -0500 Subject: [PATCH] Handle git WebSocket messages and persist to database --- src/db.ts | 7 ++++++- src/server.ts | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/db.ts b/src/db.ts index 4eb24b2..78ae264 100644 --- a/src/db.ts +++ b/src/db.ts @@ -147,7 +147,8 @@ export function initDb(path = "claude-remote.db"): Database { updateSessionStatsStmt = db.prepare(` UPDATE sessions SET state = ?, prompts = ?, completions = ?, tools = ?, compressions = ?, - thinking_seconds = ?, work_seconds = ?, mode = ?, model = ?, idle_since = ? + thinking_seconds = ?, work_seconds = ?, mode = ?, model = ?, idle_since = ?, + git_branch = ?, git_files_json = ? WHERE id = ? `); @@ -286,6 +287,8 @@ export function updateSessionStats( mode: string; model: string | null; idle_since: number | null; + git_branch: string | null; + git_files_json: string | null; }, ): void { updateSessionStatsStmt.run( @@ -299,6 +302,8 @@ export function updateSessionStats( state.mode, state.model, state.idle_since, + state.git_branch, + state.git_files_json, sessionId, ); } diff --git a/src/server.ts b/src/server.ts index c9fbc9c..28ac548 100644 --- a/src/server.ts +++ b/src/server.ts @@ -509,6 +509,24 @@ const server = Bun.serve({ return; } + // Handle git message + if (msg.type === "git") { + const sessionState = sessionStates.get(ws.data.sessionId); + if (sessionState) { + sessionState.git_branch = msg.branch; + sessionState.git_files_json = JSON.stringify(msg.files); + sessionState.dirty = true; + // Broadcast SSE git event + broadcastSSE({ + type: "git", + session_id: ws.data.sessionId, + branch: msg.branch, + files_json: JSON.stringify(msg.files), + }); + } + return; + } + // Handle resize message if (msg.type === "resize") { // Store resize info if needed (not yet implemented)