From 93670c15d9b6542b24078c9cef7b09e09fc8cb47 Mon Sep 17 00:00:00 2001
From: Matthias Nott <mnott@mnsoft.org>
Date: Sat, 07 Mar 2026 13:49:16 +0100
Subject: [PATCH] feat: project picker in session drawer
---
contexts/ChatContext.tsx | 22 ++++++++++++++++++----
1 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/contexts/ChatContext.tsx b/contexts/ChatContext.tsx
index 54a548c..408e878 100644
--- a/contexts/ChatContext.tsx
+++ b/contexts/ChatContext.tsx
@@ -6,7 +6,7 @@
useRef,
useState,
} from "react";
-import { Message, WsIncoming, WsSession } from "../types";
+import { Message, WsIncoming, WsSession, PaiProject } from "../types";
import { useConnection } from "./ConnectionContext";
import { playAudio, encodeAudioToBase64, saveBase64Audio, canAutoplay } from "../services/audio";
import { requestNotificationPermissions, notifyIncomingMessage } from "../services/notifications";
@@ -128,7 +128,9 @@
switchSession: (sessionId: string) => void;
renameSession: (sessionId: string, name: string) => void;
removeSession: (sessionId: string) => void;
- createSession: () => void;
+ createSession: (opts?: { project?: string; path?: string }) => void;
+ fetchProjects: () => void;
+ projects: PaiProject[];
unreadCounts: Record<string, number>;
latestScreenshot: string | null;
requestScreenshot: () => void;
@@ -151,6 +153,8 @@
const [unreadCounts, setUnreadCounts] = useState<Record<string, number>>({});
// Typing indicator from server
const [isTyping, setIsTyping] = useState(false);
+ // PAI projects list
+ const [projects, setProjects] = useState<PaiProject[]>([]);
const {
status,
@@ -386,6 +390,10 @@
// Connection status update — ignore for now
break;
}
+ case "projects": {
+ setProjects(data.projects ?? []);
+ break;
+ }
case "error": {
const msg: Message = {
id: generateId(),
@@ -534,8 +542,12 @@
[sendCommand]
);
- const createSession = useCallback(() => {
- sendCommand("create");
+ const createSession = useCallback((opts?: { project?: string; path?: string }) => {
+ sendCommand("create", opts ?? {});
+ }, [sendCommand]);
+
+ const fetchProjects = useCallback(() => {
+ sendCommand("projects");
}, [sendCommand]);
// --- Screenshot / navigation ---
@@ -567,6 +579,8 @@
renameSession,
removeSession,
createSession,
+ fetchProjects,
+ projects,
unreadCounts,
latestScreenshot,
requestScreenshot,
--
Gitblit v1.3.1