Merge pull request #40 from continuedev/onboarding-flows
onboarding flow
This commit is contained in:
commit
a293e3e67a
12 changed files with 384 additions and 39 deletions
2
.github/workflows/review.yaml
vendored
2
.github/workflows/review.yaml
vendored
|
|
@ -25,6 +25,6 @@ jobs:
|
|||
npm run build
|
||||
|
||||
- name: Run Continue CLI
|
||||
run: npm run start -- --config $GITHUB_WORKSPACE/.continue/assistants/main.yaml --headless "Please review the last changes to this codebase and provide some feedback. Then, if the changes had problems that indicate they should not be merged into production, then please call the 'exit' tool to fail the GitHub Action."
|
||||
run: npm run start -- --config nate/default-assistant --headless "Please review the last changes to this codebase and provide some feedback. Then, if the changes had problems that indicate they should not be merged into production, then please call the 'exit' tool to fail the GitHub Action."
|
||||
env:
|
||||
CONTINUE_API_KEY: ${{ secrets.CONTINUE_API_KEY }}
|
||||
|
|
|
|||
11
AGENTS.md
11
AGENTS.md
|
|
@ -1,6 +1,6 @@
|
|||
# CLAUDE.md
|
||||
# AGENTS.md
|
||||
|
||||
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||||
This file provides guidance to AI coding agents when working with code in this repository.
|
||||
|
||||
## Development Commands
|
||||
|
||||
|
|
@ -17,25 +17,30 @@ This is a CLI tool for Continue Dev that provides an interactive AI-assisted dev
|
|||
### Core Components
|
||||
|
||||
1. **Entry Point** (`src/index.ts`): Main CLI logic with two modes:
|
||||
|
||||
- **Headless mode**: Non-interactive mode for automation/CI
|
||||
- **TUI mode**: Terminal User Interface using Ink/React
|
||||
- **Standard mode**: Traditional readline-based chat interface
|
||||
|
||||
2. **Authentication** (`src/auth/`): WorkOS-based authentication system
|
||||
|
||||
- `ensureAuth.ts`: Handles authentication flow
|
||||
- `workos.ts`: WorkOS configuration and token management
|
||||
|
||||
3. **Continue SDK Integration** (`src/continueSDK.ts`): Initializes the Continue SDK client with:
|
||||
|
||||
- API key authentication
|
||||
- Assistant configuration (slug-based)
|
||||
- Organization support
|
||||
|
||||
4. **Terminal UI** (`src/ui/`): React/Ink-based TUI components
|
||||
|
||||
- `TUIChat.tsx`: Main chat interface component
|
||||
- `UserInput.tsx`: Input handling with multi-line support
|
||||
- `TextBuffer.ts`: Text display utilities
|
||||
|
||||
5. **Tools System** (`src/tools/`): Built-in development tools including:
|
||||
|
||||
- File operations (read, write, list)
|
||||
- Code search functionality
|
||||
- Terminal command execution
|
||||
|
|
@ -64,4 +69,4 @@ This is a CLI tool for Continue Dev that provides an interactive AI-assisted dev
|
|||
- ESNext target with NodeNext module resolution
|
||||
- Outputs to `dist/` directory
|
||||
- Source maps and inline sources enabled
|
||||
- JSX support for React components
|
||||
- JSX support for React components
|
||||
|
|
|
|||
4
package-lock.json
generated
4
package-lock.json
generated
|
|
@ -32,7 +32,8 @@
|
|||
"readline-sync": "^1.4.10",
|
||||
"turndown": "^7.2.0",
|
||||
"typescript": "^5.8.3",
|
||||
"uuid": "^9.0.1"
|
||||
"uuid": "^9.0.1",
|
||||
"yaml": "^2.8.0"
|
||||
},
|
||||
"bin": {
|
||||
"cn": "dist/index.js"
|
||||
|
|
@ -15759,6 +15760,7 @@
|
|||
"version": "2.8.0",
|
||||
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.0.tgz",
|
||||
"integrity": "sha512-4lLa/EcQCB0cJkyts+FpIRx5G/llPxfP6VQU5KByHEhLxY3IJCH0f0Hy1MHI8sClTvsIb8qwRJ6R/ZdlDJ/leQ==",
|
||||
"license": "ISC",
|
||||
"bin": {
|
||||
"yaml": "bin.mjs"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
"url": "https://github.com/continuedev/cli.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/continuedev/continuedev/issues"
|
||||
"url": "https://github.com/continuedev/continue/issues"
|
||||
},
|
||||
"homepage": "https://continue.dev",
|
||||
"dependencies": {
|
||||
|
|
@ -54,7 +54,8 @@
|
|||
"readline-sync": "^1.4.10",
|
||||
"turndown": "^7.2.0",
|
||||
"typescript": "^5.8.3",
|
||||
"uuid": "^9.0.1"
|
||||
"uuid": "^9.0.1",
|
||||
"yaml": "^2.8.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@semantic-release/changelog": "^6.0.3",
|
||||
|
|
|
|||
33
spec/onboarding.md
Normal file
33
spec/onboarding.md
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
# Onboarding
|
||||
|
||||
When a user first runs `cn` in interactive mode, they will be taken through "onboarding". After they have completed onboarding once, they will follow a normal config loading flow.
|
||||
|
||||
## Onboarding flow
|
||||
|
||||
1. If the --config flag is provided, load this config
|
||||
2. If the user has a ~/.continue/config.yaml with an acceptable model, load this config automatically
|
||||
3. Otherwise, we will present the user with two options:
|
||||
|
||||
- Log in with Continue: log them in, which will automatically create their assistant and then we can load the first assistant from the first org
|
||||
- Enter your Anthropic API key: let them enter the key, and then either create a ~/.continue/config.yaml with the following contents OR update the existing config.yaml to add the model
|
||||
|
||||
```yaml
|
||||
name: Local Config
|
||||
version: 1.0.0
|
||||
schema: v1
|
||||
|
||||
models:
|
||||
- uses: anthropic/claude-4-sonnet
|
||||
with:
|
||||
ANTHROPIC_API_KEY: <THEIR_ANTHROPIC_API_KEY>
|
||||
```
|
||||
|
||||
When something in the onboarding flow is done automatically, we should tell the user what happened.
|
||||
|
||||
## Normal flow
|
||||
|
||||
1. If the --config flag is provided, load this config
|
||||
2. If the user is logged in, look for the first assistant in the selected org
|
||||
3. If there are no assistants in that org, then look for a local ~/.continue/config.yaml
|
||||
4. If there is no config.yaml, look for an ANTHROPIC_API_KEY in the environment and manually construct the config object to include just the claude-4-sonnet model with that API key
|
||||
5. If none of the above, then bring the user to step 3 of the onboarding flow
|
||||
|
|
@ -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<string>
|
||||
): Promise<AuthConfig> {
|
||||
// If CONTINUE_API_KEY environment variable exists, use that instead
|
||||
if (process.env.CONTINUE_API_KEY) {
|
||||
|
|
@ -269,13 +270,15 @@ export async function login(
|
|||
|
||||
// Get auth URL using the direct implementation
|
||||
const authUrl = getAuthUrlForTokenPage(useOnboarding);
|
||||
console.info(chalk.green(`Opening browser to sign in at: ${authUrl}`));
|
||||
console.info(chalk.gray(`Opening browser to sign in at: ${authUrl}`));
|
||||
await open(authUrl);
|
||||
|
||||
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..."));
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
import chalk from "chalk";
|
||||
import { ChatCompletionMessageParam } from "openai/resources.mjs";
|
||||
import * as readlineSync from "readline-sync";
|
||||
import { ensureAuthenticated } from "../auth/ensureAuth.js";
|
||||
import { ensureOrganization, loadAuthConfig } from "../auth/workos.js";
|
||||
import { initialize } from "../config.js";
|
||||
import { introMessage } from "../intro.js";
|
||||
import { configureLogger } from "../logger.js";
|
||||
import { initializeWithOnboarding } from "../onboarding.js";
|
||||
import { loadSession, saveSession } from "../session.js";
|
||||
import { streamChatResponse } from "../streamChatResponse.js";
|
||||
import { constructSystemMessage } from "../systemMessage.js";
|
||||
|
|
@ -18,28 +17,26 @@ export interface ChatOptions {
|
|||
}
|
||||
|
||||
async function initializeChat(options: ChatOptions) {
|
||||
const isAuthenticated = await ensureAuthenticated(true);
|
||||
|
||||
if (!isAuthenticated) {
|
||||
console.error(chalk.red("Authentication failed. Exiting..."));
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const authConfig = loadAuthConfig();
|
||||
|
||||
// Ensure organization is selected
|
||||
const authConfigWithOrg = await ensureOrganization(
|
||||
authConfig,
|
||||
options.headless ?? false
|
||||
);
|
||||
// Use onboarding flow for initialization
|
||||
const result = await initializeWithOnboarding(authConfig, options.config);
|
||||
|
||||
// Initialize ContinueSDK and MCPService once
|
||||
const { config, llmApi, model, mcpService } = await initialize(
|
||||
authConfigWithOrg,
|
||||
options.config
|
||||
);
|
||||
// Ensure organization is selected if authenticated
|
||||
let finalAuthConfig = authConfig;
|
||||
if (result.config && authConfig) {
|
||||
finalAuthConfig = await ensureOrganization(
|
||||
authConfig,
|
||||
options.headless ?? false
|
||||
);
|
||||
}
|
||||
|
||||
return { config, llmApi, model, mcpService };
|
||||
return {
|
||||
config: result.config,
|
||||
llmApi: result.llmApi,
|
||||
model: result.model,
|
||||
mcpService: result.mcpService,
|
||||
};
|
||||
}
|
||||
|
||||
export async function chat(prompt?: string, options: ChatOptions = {}) {
|
||||
|
|
|
|||
250
src/onboarding.ts
Normal file
250
src/onboarding.ts
Normal file
|
|
@ -0,0 +1,250 @@
|
|||
import { AssistantUnrolled } from "@continuedev/config-yaml";
|
||||
import { BaseLlmApi } from "@continuedev/openai-adapters";
|
||||
import chalk from "chalk";
|
||||
import * as fs from "fs";
|
||||
import * as os from "os";
|
||||
import * as path from "path";
|
||||
import * as readlineSync from "readline-sync";
|
||||
import { AuthConfig, isAuthenticated, login } from "./auth/workos.js";
|
||||
import { initialize } from "./config.js";
|
||||
import { MCPService } from "./mcp.js";
|
||||
|
||||
const CONFIG_PATH = path.join(os.homedir(), ".continue", "config.yaml");
|
||||
|
||||
export interface OnboardingResult {
|
||||
config: AssistantUnrolled;
|
||||
llmApi: BaseLlmApi;
|
||||
model: string;
|
||||
mcpService: MCPService;
|
||||
wasOnboarded: boolean;
|
||||
}
|
||||
|
||||
export async function checkHasAcceptableModel(
|
||||
configPath: string
|
||||
): Promise<boolean> {
|
||||
try {
|
||||
if (!fs.existsSync(configPath)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const content = fs.readFileSync(configPath, "utf8");
|
||||
return content.includes("claude");
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
import * as YAML from "yaml";
|
||||
|
||||
export async function createOrUpdateConfig(apiKey: string): Promise<void> {
|
||||
const configDir = path.dirname(CONFIG_PATH);
|
||||
|
||||
if (!fs.existsSync(configDir)) {
|
||||
fs.mkdirSync(configDir, { recursive: true });
|
||||
}
|
||||
|
||||
const newModel = {
|
||||
uses: "anthropic/claude-4-sonnet",
|
||||
with: {
|
||||
ANTHROPIC_API_KEY: apiKey,
|
||||
},
|
||||
};
|
||||
|
||||
if (fs.existsSync(CONFIG_PATH)) {
|
||||
const existingContent = fs.readFileSync(CONFIG_PATH, "utf8");
|
||||
let config;
|
||||
|
||||
try {
|
||||
config = YAML.parse(existingContent);
|
||||
|
||||
// Make sure models array exists
|
||||
if (!config.models) {
|
||||
config.models = [];
|
||||
}
|
||||
|
||||
// Check if model already exists
|
||||
const existingModelIndex = config.models.findIndex(
|
||||
(model: any) => model.uses === "anthropic/claude-4-sonnet"
|
||||
);
|
||||
|
||||
if (existingModelIndex >= 0) {
|
||||
// Update existing model
|
||||
config.models[existingModelIndex].with.ANTHROPIC_API_KEY = apiKey;
|
||||
} else {
|
||||
// Add new model
|
||||
config.models.push(newModel);
|
||||
}
|
||||
} catch (error) {
|
||||
// If parsing fails, create a new config
|
||||
config = {
|
||||
name: "Local Config",
|
||||
version: "1.0.0",
|
||||
schema: "v1",
|
||||
models: [newModel],
|
||||
};
|
||||
}
|
||||
|
||||
// Write back to file
|
||||
fs.writeFileSync(CONFIG_PATH, YAML.stringify(config));
|
||||
} else {
|
||||
// Create new config file
|
||||
const config = {
|
||||
name: "Local Config",
|
||||
version: "1.0.0",
|
||||
schema: "v1",
|
||||
models: [newModel],
|
||||
};
|
||||
|
||||
fs.writeFileSync(CONFIG_PATH, YAML.stringify(config));
|
||||
}
|
||||
}
|
||||
|
||||
export async function runOnboardingFlow(
|
||||
configPath: string | undefined,
|
||||
authConfig: AuthConfig
|
||||
): Promise<OnboardingResult> {
|
||||
console.log(chalk.cyan("\n🚀 Welcome to Continue CLI!"));
|
||||
|
||||
// Step 1: Check if --config flag is provided
|
||||
if (configPath) {
|
||||
const result = await initialize(authConfig, configPath);
|
||||
return { ...result, wasOnboarded: false };
|
||||
}
|
||||
|
||||
// Step 2: Check if user has ~/.continue/config.yaml with acceptable model
|
||||
if (await checkHasAcceptableModel(CONFIG_PATH)) {
|
||||
console.log(chalk.blue(`✓ Using existing ${CONFIG_PATH}`));
|
||||
const result = await initialize(authConfig, CONFIG_PATH);
|
||||
return { ...result, wasOnboarded: true };
|
||||
}
|
||||
|
||||
// Step 3: Present user with two options
|
||||
console.log(chalk.yellow("Choose how you'd like to set up your agent:"));
|
||||
console.log(chalk.white("1. Log in with Continue"));
|
||||
console.log(chalk.white("2. Enter your Anthropic API key"));
|
||||
|
||||
const choice = readlineSync.question(
|
||||
chalk.green("\nSelect option (1 or 2): ")
|
||||
);
|
||||
|
||||
if (choice === "1") {
|
||||
console.log(chalk.cyan("\n🔐 Logging in with Continue..."));
|
||||
try {
|
||||
const newAuthConfig = await login();
|
||||
|
||||
const result = await initialize(newAuthConfig, undefined);
|
||||
return { ...result, wasOnboarded: true };
|
||||
} catch (error) {
|
||||
console.error(
|
||||
chalk.red("❌ Login failed. Please try again or use option 2.")
|
||||
);
|
||||
throw error;
|
||||
}
|
||||
} else if (choice === "2") {
|
||||
console.log(chalk.cyan("\n🔑 Setting up with Anthropic API key..."));
|
||||
const apiKey = readlineSync.question(
|
||||
chalk.green("Enter your Anthropic API key: "),
|
||||
{
|
||||
hideEchoBack: true,
|
||||
}
|
||||
);
|
||||
|
||||
if (!apiKey || !apiKey.startsWith("sk-ant-")) {
|
||||
throw new Error(
|
||||
"Invalid Anthropic API key. Please make sure it starts with 'sk-ant-'"
|
||||
);
|
||||
}
|
||||
|
||||
await createOrUpdateConfig(apiKey);
|
||||
console.log(
|
||||
chalk.green(`✓ Config file updated successfully at ${CONFIG_PATH}`)
|
||||
);
|
||||
|
||||
const result = await initialize(authConfig, CONFIG_PATH);
|
||||
return { ...result, wasOnboarded: true };
|
||||
} else {
|
||||
throw new Error("Invalid choice. Please select 1 or 2.");
|
||||
}
|
||||
}
|
||||
|
||||
export async function runNormalFlow(
|
||||
configPath: string | undefined,
|
||||
authConfig: AuthConfig
|
||||
): Promise<OnboardingResult> {
|
||||
// Step 1: Check if --config flag is provided
|
||||
if (configPath) {
|
||||
console.log(chalk.blue(`✓ Loading config from: ${configPath}`));
|
||||
const result = await initialize(authConfig, configPath);
|
||||
return { ...result, wasOnboarded: false };
|
||||
}
|
||||
|
||||
// Step 2: If user is logged in, look for first assistant in selected org
|
||||
if (isAuthenticated()) {
|
||||
try {
|
||||
const result = await initialize(authConfig, undefined);
|
||||
return { ...result, wasOnboarded: true };
|
||||
} catch (error) {
|
||||
console.log(chalk.yellow("⚠ No assistants found in your organization"));
|
||||
}
|
||||
}
|
||||
|
||||
// Step 3: Look for local ~/.continue/config.yaml
|
||||
if (fs.existsSync(CONFIG_PATH)) {
|
||||
try {
|
||||
console.log(chalk.blue(`✓ Loading config from ${CONFIG_PATH}`));
|
||||
const result = await initialize(authConfig, CONFIG_PATH);
|
||||
return { ...result, wasOnboarded: true };
|
||||
} catch (error) {
|
||||
console.log(chalk.yellow("⚠ Invalid config file found"));
|
||||
}
|
||||
}
|
||||
|
||||
// Step 4: Look for ANTHROPIC_API_KEY in environment
|
||||
if (process.env.ANTHROPIC_API_KEY) {
|
||||
console.log(chalk.blue("✓ Using ANTHROPIC_API_KEY from environment"));
|
||||
await createOrUpdateConfig(process.env.ANTHROPIC_API_KEY);
|
||||
console.log(chalk.gray(` Config saved to: ${CONFIG_PATH}`));
|
||||
const result = await initialize(authConfig, CONFIG_PATH);
|
||||
return { ...result, wasOnboarded: true };
|
||||
}
|
||||
|
||||
// Step 5: Fall back to onboarding flow
|
||||
return runOnboardingFlow(configPath, authConfig);
|
||||
}
|
||||
|
||||
export async function isFirstTime(): Promise<boolean> {
|
||||
return !fs.existsSync(
|
||||
path.join(os.homedir(), ".continue", ".onboarding_complete")
|
||||
);
|
||||
}
|
||||
|
||||
export async function markOnboardingComplete(): Promise<void> {
|
||||
const flagPath = path.join(os.homedir(), ".continue", ".onboarding_complete");
|
||||
const flagDir = path.dirname(flagPath);
|
||||
|
||||
if (!fs.existsSync(flagDir)) {
|
||||
fs.mkdirSync(flagDir, { recursive: true });
|
||||
}
|
||||
|
||||
fs.writeFileSync(flagPath, new Date().toISOString());
|
||||
}
|
||||
|
||||
export async function initializeWithOnboarding(
|
||||
authConfig: AuthConfig,
|
||||
configPath: string | undefined
|
||||
): Promise<OnboardingResult> {
|
||||
const firstTime = await isFirstTime();
|
||||
|
||||
let result: OnboardingResult;
|
||||
|
||||
if (firstTime) {
|
||||
result = await runOnboardingFlow(configPath, authConfig);
|
||||
if (result.wasOnboarded) {
|
||||
await markOnboardingComplete();
|
||||
}
|
||||
} else {
|
||||
result = await runNormalFlow(configPath, authConfig);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
@ -10,7 +10,8 @@ import {
|
|||
|
||||
export async function handleSlashCommands(
|
||||
input: string,
|
||||
assistant: AssistantConfig
|
||||
assistant: AssistantConfig,
|
||||
onLoginPrompt?: (promptText: string) => Promise<string>
|
||||
): Promise<{
|
||||
output?: string;
|
||||
exit?: boolean;
|
||||
|
|
@ -39,7 +40,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(
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ interface TUIChatProps {
|
|||
resume?: boolean;
|
||||
}
|
||||
|
||||
|
||||
const TUIChat: React.FC<TUIChatProps> = ({
|
||||
config: initialAssistant,
|
||||
model: initialModel,
|
||||
|
|
@ -36,6 +35,29 @@ const TUIChat: React.FC<TUIChatProps> = ({
|
|||
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<string> => {
|
||||
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<TUIChatProps> = ({
|
|||
initialPrompt,
|
||||
resume,
|
||||
onShowOrgSelector: () => showOrganizationSelector(),
|
||||
onLoginPrompt: handleLoginPrompt,
|
||||
});
|
||||
|
||||
const { renderMessage } = useMessageRenderer();
|
||||
|
|
@ -75,7 +98,6 @@ const TUIChat: React.FC<TUIChatProps> = ({
|
|||
onChatReset: resetChatHistory,
|
||||
});
|
||||
|
||||
|
||||
return (
|
||||
<Box flexDirection="column" height="100%">
|
||||
{/* Chat history - takes up all available space above input */}
|
||||
|
|
@ -93,6 +115,31 @@ const TUIChat: React.FC<TUIChatProps> = ({
|
|||
</Box>
|
||||
)}
|
||||
|
||||
{/* Login prompt - shows above input when active */}
|
||||
{loginPrompt && (
|
||||
<Box
|
||||
paddingX={1}
|
||||
borderStyle="round"
|
||||
borderColor="yellow"
|
||||
flexDirection="column"
|
||||
gap={1}
|
||||
>
|
||||
<Text color="yellow" bold>
|
||||
Login Required
|
||||
</Text>
|
||||
<Text>{loginPrompt.text}</Text>
|
||||
<UserInput
|
||||
onSubmit={handleLoginTokenSubmit}
|
||||
isWaitingForResponse={false}
|
||||
inputMode={true}
|
||||
assistant={assistant}
|
||||
disabled={false}
|
||||
placeholder="Enter your token..."
|
||||
hideNormalUI={true}
|
||||
/>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{/* Organization selector - shows above input when active */}
|
||||
{showOrgSelector && (
|
||||
<OrganizationSelector
|
||||
|
|
@ -109,7 +156,7 @@ const TUIChat: React.FC<TUIChatProps> = ({
|
|||
onInterrupt={handleInterrupt}
|
||||
assistant={assistant}
|
||||
onFileAttached={handleFileAttached}
|
||||
disabled={showOrgSelector}
|
||||
disabled={showOrgSelector || !!loginPrompt}
|
||||
/>
|
||||
<Box marginRight={2} justifyContent="flex-end">
|
||||
<Text color="gray">● Continue CLI</Text>
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ interface UserInputProps {
|
|||
assistant: AssistantConfig;
|
||||
onFileAttached?: (filePath: string, content: string) => void;
|
||||
disabled?: boolean;
|
||||
placeholder?: string;
|
||||
hideNormalUI?: boolean;
|
||||
}
|
||||
|
||||
const UserInput: React.FC<UserInputProps> = ({
|
||||
|
|
@ -25,6 +27,8 @@ const UserInput: React.FC<UserInputProps> = ({
|
|||
assistant,
|
||||
onFileAttached,
|
||||
disabled = false,
|
||||
placeholder,
|
||||
hideNormalUI = false,
|
||||
}) => {
|
||||
const [textBuffer] = useState(() => new TextBuffer());
|
||||
const [inputHistory] = useState(() => new InputHistory());
|
||||
|
|
@ -379,7 +383,7 @@ const UserInput: React.FC<UserInputProps> = ({
|
|||
});
|
||||
|
||||
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 (
|
||||
<>
|
||||
|
|
@ -467,7 +471,7 @@ const UserInput: React.FC<UserInputProps> = ({
|
|||
</Box>
|
||||
|
||||
{/* Slash command UI */}
|
||||
{showSlashCommands && inputMode && (
|
||||
{showSlashCommands && inputMode && !hideNormalUI && (
|
||||
<SlashCommandUI
|
||||
assistant={assistant}
|
||||
filter={slashCommandFilter}
|
||||
|
|
@ -477,7 +481,7 @@ const UserInput: React.FC<UserInputProps> = ({
|
|||
)}
|
||||
|
||||
{/* File search UI */}
|
||||
{showFileSearch && inputMode && (
|
||||
{showFileSearch && inputMode && !hideNormalUI && (
|
||||
<FileSearchUI
|
||||
filter={fileSearchFilter}
|
||||
selectedIndex={selectedFileIndex}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ interface UseChatProps {
|
|||
initialPrompt?: string;
|
||||
resume?: boolean;
|
||||
onShowOrgSelector: () => void;
|
||||
onLoginPrompt?: (promptText: string) => Promise<string>;
|
||||
}
|
||||
|
||||
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();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue