wip(vscode-ide-companion): OnboardingPage

This commit is contained in:
yiliang114
2025-12-13 15:51:34 +08:00
parent 8b29dd130e
commit 5841370b1a
17 changed files with 603 additions and 114 deletions

View File

@@ -14,6 +14,7 @@ interface UseMessageSubmitProps {
setInputText: (text: string) => void;
inputFieldRef: React.RefObject<HTMLDivElement>;
isStreaming: boolean;
isWaitingForResponse: boolean;
// When true, do NOT auto-attach the active editor file/selection to context
skipAutoActiveContext?: boolean;
@@ -40,6 +41,7 @@ export const useMessageSubmit = ({
setInputText,
inputFieldRef,
isStreaming,
isWaitingForResponse,
skipAutoActiveContext = false,
fileContext,
messageHandling,
@@ -48,7 +50,7 @@ export const useMessageSubmit = ({
(e: React.FormEvent) => {
e.preventDefault();
if (!inputText.trim() || isStreaming) {
if (!inputText.trim() || isStreaming || isWaitingForResponse) {
return;
}
@@ -56,7 +58,10 @@ export const useMessageSubmit = ({
if (inputText.trim() === '/login') {
setInputText('');
if (inputFieldRef.current) {
inputFieldRef.current.textContent = '';
// Use a zero-width space to maintain the height of the contentEditable element
inputFieldRef.current.textContent = '\u200B';
// Set the data-empty attribute to show the placeholder
inputFieldRef.current.setAttribute('data-empty', 'true');
}
vscode.postMessage({
type: 'login',
@@ -142,7 +147,10 @@ export const useMessageSubmit = ({
setInputText('');
if (inputFieldRef.current) {
inputFieldRef.current.textContent = '';
// Use a zero-width space to maintain the height of the contentEditable element
inputFieldRef.current.textContent = '\u200B';
// Set the data-empty attribute to show the placeholder
inputFieldRef.current.setAttribute('data-empty', 'true');
}
fileContext.clearFileReferences();
},
@@ -154,6 +162,7 @@ export const useMessageSubmit = ({
vscode,
fileContext,
skipAutoActiveContext,
isWaitingForResponse,
messageHandling,
],
);

View File

@@ -109,6 +109,8 @@ interface UseWebViewMessagesProps {
setInputText: (text: string) => void;
// Edit mode setter (maps ACP modes to UI modes)
setEditMode?: (mode: ApprovalModeValue) => void;
// Authentication state setter
setIsAuthenticated?: (authenticated: boolean | null) => void;
}
/**
@@ -126,6 +128,7 @@ export const useWebViewMessages = ({
inputFieldRef,
setInputText,
setEditMode,
setIsAuthenticated,
}: UseWebViewMessagesProps) => {
// VS Code API for posting messages back to the extension host
const vscode = useVSCode();
@@ -141,6 +144,7 @@ export const useWebViewMessages = ({
clearToolCalls,
setPlanEntries,
handlePermissionRequest,
setIsAuthenticated,
});
// Track last "Updated Plan" snapshot toolcall to support merge/dedupe
@@ -185,6 +189,7 @@ export const useWebViewMessages = ({
clearToolCalls,
setPlanEntries,
handlePermissionRequest,
setIsAuthenticated,
};
});
@@ -216,6 +221,7 @@ export const useWebViewMessages = ({
}
break;
}
case 'loginSuccess': {
// Clear loading state and show a short assistant notice
handlers.messageHandling.clearWaitingForResponse();
@@ -224,12 +230,16 @@ export const useWebViewMessages = ({
content: 'Successfully logged in. You can continue chatting.',
timestamp: Date.now(),
});
// Set authentication state to true
handlers.setIsAuthenticated?.(true);
break;
}
case 'agentConnected': {
// Agent connected successfully; clear any pending spinner
handlers.messageHandling.clearWaitingForResponse();
// Set authentication state to true
handlers.setIsAuthenticated?.(true);
break;
}
@@ -245,6 +255,8 @@ export const useWebViewMessages = ({
content: `Failed to connect to Qwen agent: ${errorMsg}\nYou can still use the chat UI, but messages won't be sent to AI.`,
timestamp: Date.now(),
});
// Set authentication state to false
handlers.setIsAuthenticated?.(false);
break;
}
@@ -259,6 +271,20 @@ export const useWebViewMessages = ({
content: errorMsg,
timestamp: Date.now(),
});
// Set authentication state to false
handlers.setIsAuthenticated?.(false);
break;
}
case 'authState': {
const state = (
message?.data as { authenticated?: boolean | null } | undefined
)?.authenticated;
if (typeof state === 'boolean') {
handlers.setIsAuthenticated?.(state);
} else {
handlers.setIsAuthenticated?.(null);
}
break;
}
@@ -303,6 +329,7 @@ export const useWebViewMessages = ({
}
}
}
console.log('[useWebViewMessages1111]__________ other message:', msg);
break;
}
@@ -336,7 +363,7 @@ export const useWebViewMessages = ({
const reason = (
(message.data as { reason?: string } | undefined)?.reason || ''
).toLowerCase();
if (reason === 'user_cancelled') {
if (reason === 'user_cancelled' || reason === 'cancelled') {
activeExecToolCallsRef.current.clear();
handlers.messageHandling.clearWaitingForResponse();
break;