diff --git a/src/auth/workos.ts b/src/auth/workos.ts index 860d96fb0..3548a8023 100644 --- a/src/auth/workos.ts +++ b/src/auth/workos.ts @@ -251,7 +251,8 @@ async function refreshToken( * Authenticates using the Continue web flow */ export async function login( - useOnboarding: boolean = false + useOnboarding: boolean = false, + onPrompt?: (promptText: string) => Promise ): Promise { // If CONTINUE_API_KEY environment variable exists, use that instead if (process.env.CONTINUE_API_KEY) { @@ -275,7 +276,9 @@ export async function login( console.info(chalk.yellow("\nAfter signing in, you'll receive a token.")); // Get token from user - const token = await prompt(chalk.yellow("Paste your sign-in token here: ")); + const token = onPrompt + ? await onPrompt(chalk.yellow("Paste your sign-in token here: ")) + : await prompt(chalk.yellow("Paste your sign-in token here: ")); console.info(chalk.cyan("Verifying token...")); diff --git a/src/onboarding.ts b/src/onboarding.ts index cd4cb55fe..7beec3bd8 100644 --- a/src/onboarding.ts +++ b/src/onboarding.ts @@ -181,7 +181,6 @@ export async function runNormalFlow( // Step 2: If user is logged in, look for first assistant in selected org if (isAuthenticated()) { try { - console.log(chalk.blue("✓ Loading your first assistant from Continue")); const result = await initialize(authConfig, undefined); return { ...result, wasOnboarded: true }; } catch (error) { diff --git a/src/slashCommands.ts b/src/slashCommands.ts index d5ab68f27..cd4332586 100644 --- a/src/slashCommands.ts +++ b/src/slashCommands.ts @@ -10,7 +10,8 @@ import { export async function handleSlashCommands( input: string, - assistant: AssistantConfig + assistant: AssistantConfig, + onLoginPrompt?: (promptText: string) => Promise ): Promise<{ output?: string; exit?: boolean; @@ -37,7 +38,7 @@ export async function handleSlashCommands( case "exit": return { exit: true, output: "Goodbye!" }; case "login": - login() + login(false, onLoginPrompt) .then((config) => { if (config && isAuthenticatedConfig(config)) { console.info( diff --git a/src/ui/TUIChat.tsx b/src/ui/TUIChat.tsx index 2f06613e9..457b24910 100644 --- a/src/ui/TUIChat.tsx +++ b/src/ui/TUIChat.tsx @@ -20,7 +20,6 @@ interface TUIChatProps { resume?: boolean; } - const TUIChat: React.FC = ({ config: initialAssistant, model: initialModel, @@ -36,6 +35,29 @@ const TUIChat: React.FC = ({ const [llmApi, setLlmApi] = useState(initialLlmApi); const [mcpService, setMcpService] = useState(initialMcpService); + // State for login prompt handling + const [loginPrompt, setLoginPrompt] = useState<{ + text: string; + resolve: (value: string) => void; + } | null>(null); + const [loginToken, setLoginToken] = useState(""); + + // Custom login prompt handler for TUI + const handleLoginPrompt = (promptText: string): Promise => { + return new Promise((resolve) => { + setLoginPrompt({ text: promptText, resolve }); + }); + }; + + // Handle login token submission + const handleLoginTokenSubmit = (token: string) => { + if (loginPrompt) { + setLoginToken(""); + loginPrompt.resolve(token); + setLoginPrompt(null); + } + }; + const { messages, setMessages, @@ -52,6 +74,7 @@ const TUIChat: React.FC = ({ initialPrompt, resume, onShowOrgSelector: () => showOrganizationSelector(), + onLoginPrompt: handleLoginPrompt, }); const { renderMessage } = useMessageRenderer(); @@ -75,7 +98,6 @@ const TUIChat: React.FC = ({ onChatReset: resetChatHistory, }); - return ( {/* Chat history - takes up all available space above input */} @@ -93,6 +115,31 @@ const TUIChat: React.FC = ({ )} + {/* Login prompt - shows above input when active */} + {loginPrompt && ( + + + Login Required + + {loginPrompt.text} + + + )} + {/* Organization selector - shows above input when active */} {showOrgSelector && ( = ({ onInterrupt={handleInterrupt} assistant={assistant} onFileAttached={handleFileAttached} - disabled={showOrgSelector} + disabled={showOrgSelector || !!loginPrompt} /> ● Continue CLI diff --git a/src/ui/UserInput.tsx b/src/ui/UserInput.tsx index 0283f2ec2..2cea3a089 100644 --- a/src/ui/UserInput.tsx +++ b/src/ui/UserInput.tsx @@ -15,6 +15,8 @@ interface UserInputProps { assistant: AssistantConfig; onFileAttached?: (filePath: string, content: string) => void; disabled?: boolean; + placeholder?: string; + hideNormalUI?: boolean; } const UserInput: React.FC = ({ @@ -25,6 +27,8 @@ const UserInput: React.FC = ({ assistant, onFileAttached, disabled = false, + placeholder, + hideNormalUI = false, }) => { const [textBuffer] = useState(() => new TextBuffer()); const [inputHistory] = useState(() => new InputHistory()); @@ -378,7 +382,7 @@ const UserInput: React.FC = ({ }); const renderInputText = () => { - const placeholderText = "Ask anything, @ for context, / for slash commands"; + const placeholderText = placeholder || "Ask anything, @ for context, / for slash commands"; if (inputText.length === 0) { return ( <> @@ -466,7 +470,7 @@ const UserInput: React.FC = ({ {/* Slash command UI */} - {showSlashCommands && inputMode && ( + {showSlashCommands && inputMode && !hideNormalUI && ( = ({ )} {/* File search UI */} - {showFileSearch && inputMode && ( + {showFileSearch && inputMode && !hideNormalUI && ( void; + onLoginPrompt?: (promptText: string) => Promise; } export function useChat({ @@ -31,6 +32,7 @@ export function useChat({ initialPrompt, resume, onShowOrgSelector, + onLoginPrompt, }: UseChatProps) { const { exit } = useApp(); @@ -94,7 +96,7 @@ export function useChat({ } // Handle slash commands - const commandResult = await handleSlashCommands(message, assistant); + const commandResult = await handleSlashCommands(message, assistant, onLoginPrompt); if (commandResult) { if (commandResult.exit) { exit();