From 6d4e47774b90679027e566a0ea74938e912801b8 Mon Sep 17 00:00:00 2001 From: Codex Date: Wed, 4 Mar 2026 21:10:48 -0500 Subject: [PATCH 1/2] feat: per-agent identity and session filter via VITE env vars --- src/hooks/useGateway.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/hooks/useGateway.ts b/src/hooks/useGateway.ts index 19f7dfe..05b54db 100644 --- a/src/hooks/useGateway.ts +++ b/src/hooks/useGateway.ts @@ -14,7 +14,7 @@ export function useGateway() { const [status, setStatus] = useState('disconnected'); const [messages, setMessages] = useState([]); const [sessions, setSessions] = useState([]); - const [activeSession, setActiveSession] = useState('agent:main:main'); + const [activeSession, setActiveSession] = useState(import.meta.env.VITE_AGENT_SESSION || 'agent:main:main'); const [isGenerating, setIsGenerating] = useState(false); const [isLoadingHistory, setIsLoadingHistory] = useState(false); const [authenticated, setAuthenticated] = useState(null); // null = checking @@ -89,7 +89,7 @@ export function useGateway() { const loadAgentIdentity = useCallback(async () => { try { - const res = await clientRef.current?.send('agent.identity.get', {}); + const res = await clientRef.current?.send('agent.identity.get', { sessionKey: activeSessionRef.current }); if (res) { setAgentIdentity({ name: res.name as string | undefined, @@ -108,15 +108,19 @@ export function useGateway() { const res = await clientRef.current?.send('sessions.list', {}); const sessionList = res?.sessions as Array> | undefined; if (sessionList) { + const agentPrefix = import.meta.env.VITE_AGENT_PREFIX; + const filteredSessionList = agentPrefix + ? sessionList.filter((s) => ((s.key || s.sessionKey) as string).startsWith(agentPrefix)) + : sessionList; const deleted = getDeletedSessions(); // Reconcile: remove blacklisted keys for sessions that no longer exist on the gateway // (they were successfully deleted, so no need to keep hiding them) - const activeKeys = new Set(sessionList.map((s) => (s.key || s.sessionKey) as string)); + const activeKeys = new Set(filteredSessionList.map((s) => (s.key || s.sessionKey) as string)); const reconciled = new Set([...deleted].filter((k) => activeKeys.has(k))); if (reconciled.size !== deleted.size) { localStorage.setItem('pinchchat-deleted-sessions', JSON.stringify([...reconciled])); } - setSessions(sessionList.filter((s) => !deleted.has((s.key || s.sessionKey) as string)).map((s) => ({ + setSessions(filteredSessionList.filter((s) => !deleted.has((s.key || s.sessionKey) as string)).map((s) => ({ key: (s.key || s.sessionKey) as string, label: (s.label || s.key || s.sessionKey) as string, messageCount: s.messageCount as number | undefined, From 397a0e9137e7015b61977b15bafe0cbc9a2a57a2 Mon Sep 17 00:00:00 2001 From: kerbeus-a Date: Wed, 4 Mar 2026 22:05:03 -0500 Subject: [PATCH 2/2] docs: add VITE_AGENT_SESSION and VITE_AGENT_PREFIX to .env.example --- .env.example | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.env.example b/.env.example index 90d0dfd..e5631fb 100644 --- a/.env.example +++ b/.env.example @@ -8,3 +8,14 @@ VITE_LOCALE=en # Optional: client ID sent in the WebSocket connect frame (default: webchat) # Set to "openclaw-control-ui" to use OpenClaw's dangerouslyDisableDeviceAuth bypass VITE_CLIENT_ID=webchat + +# Optional: default session key to open on connect (default: agent:main:main) +# Set this when deploying for a specific OpenClaw agent other than main. +# Example: VITE_AGENT_SESSION=agent:artem:main +VITE_AGENT_SESSION= + +# Optional: filter the session list to only show sessions matching this prefix. +# Useful when multiple agents share a single gateway and you want each +# PinchChat instance to show only its own sessions. +# Example: VITE_AGENT_PREFIX=agent:artem: +VITE_AGENT_PREFIX=