Fix project isolation: Make loadChatHistory respect active project sessions

- Modified loadChatHistory() to check for active project before fetching all sessions
- When active project exists, use project.sessions instead of fetching from API
- Added detailed console logging to debug session filtering
- This prevents ALL sessions from appearing in every project's sidebar

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
uroma
2026-01-22 14:43:05 +00:00
Unverified
parent b82837aa5f
commit 55aafbae9a
6463 changed files with 1115462 additions and 4486 deletions

View File

@@ -172,13 +172,21 @@
// Check if this is a server-initiated approval or AI-conversational approval
const pendingApproval = window._pendingApprovals && window._pendingApprovals[approvalId];
// Get the session ID
const sessionId = window.attachedSessionId || window.chatSessionId ||
(pendingApproval && pendingApproval.sessionId);
if (pendingApproval) {
// AI-conversational approval - send as chat message
// AI-conversational approval - send as chat message to Claude
// This is the Kimi-style flow: approval responses are sent as chat messages
// Claude will continue execution upon receiving "yes"
console.log('[ApprovalCard] Sending AI-conversational approval as chat message');
let responseMessage;
if (approved) {
if (customCommand) {
responseMessage = `Execute: ${customCommand}`;
responseMessage = customCommand;
} else {
responseMessage = 'yes';
}
@@ -186,24 +194,46 @@
responseMessage = 'no';
}
// Send as chat message
if (typeof sendChatMessage === 'function') {
sendChatMessage(responseMessage, 'webcontainer');
} else if (window.sendMessageToSession) {
window.sendMessageToSession(responseMessage);
// Send directly via WebSocket as a chat command
if (window.ws && window.ws.readyState === WebSocket.OPEN && sessionId) {
window.ws.send(JSON.stringify({
type: 'command',
sessionId: sessionId,
command: responseMessage,
metadata: {
isApprovalResponse: true,
approvalId: approvalId,
originalCommand: pendingApproval.command || null
}
}));
console.log('[ApprovalCard] Sent approval response via WebSocket:', responseMessage);
} else {
console.error('[ApprovalCard] WebSocket not connected for approval response');
if (typeof appendSystemMessage === 'function') {
appendSystemMessage('❌ Failed to send approval: WebSocket not connected');
}
return;
}
// Clean up pending approval
delete window._pendingApprovals[approvalId];
// Show feedback
if (typeof appendSystemMessage === 'function' && approved) {
appendSystemMessage('✅ Approval sent - continuing execution...');
}
} else {
// Server-initiated approval - send via WebSocket
console.log('[ApprovalCard] Sending server-initiated approval via WebSocket');
if (window.ws && window.ws.readyState === WebSocket.OPEN) {
window.ws.send(JSON.stringify({
type: 'approval-response',
id: approvalId,
approved: approved,
customCommand: customCommand,
sessionId: window.attachedSessionId || window.chatSessionId
sessionId: sessionId
}));
} else {
console.error('[ApprovalCard] WebSocket not connected');