fix(cli): remove dead login requirement and Login Required UI (#12637)
Hub/WorkOS authentication was already stubbed out so the CLI runs fully unauthenticated using local config.yaml / API keys / env vars. This removes the now-dead login code paths that remained: - Delete unused `login`/`logout` command modules (no longer registered in the CLI and not imported anywhere). - Remove the unreachable "Login Required" TUI screen and its token-prompt handlers (handleLoginPrompt / handleLoginTokenSubmit / useLoginHandlers), which were never triggered now that login is impossible. - Drop the dead "login" navigation screen and update NavigationContext tests to use other screens. No auth gating remains on startup, headless, TUI, or standard mode. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
003b8b2c7f
commit
a80b6a4b90
7 changed files with 21 additions and 112 deletions
|
|
@ -1,10 +0,0 @@
|
|||
import chalk from "chalk";
|
||||
|
||||
import { gracefulExit } from "../util/exit.js";
|
||||
|
||||
export async function login() {
|
||||
console.error(
|
||||
chalk.red("Login is not available. Hub authentication has been removed."),
|
||||
);
|
||||
await gracefulExit(1);
|
||||
}
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
export async function logout() {
|
||||
// no-op: Hub authentication has been removed
|
||||
}
|
||||
|
|
@ -31,11 +31,7 @@ import { useNavigation } from "./context/NavigationContext.js";
|
|||
import { useChat } from "./hooks/useChat.js";
|
||||
import { useContextPercentage } from "./hooks/useContextPercentage.js";
|
||||
import { useMessageRenderer } from "./hooks/useMessageRenderer.js";
|
||||
import {
|
||||
useIntroMessage,
|
||||
useLoginHandlers,
|
||||
useSelectors,
|
||||
} from "./hooks/useTUIChatHooks.js";
|
||||
import { useIntroMessage, useSelectors } from "./hooks/useTUIChatHooks.js";
|
||||
|
||||
interface TUIChatProps {
|
||||
// Remote mode props
|
||||
|
|
@ -181,13 +177,6 @@ const TUIChat: React.FC<TUIChatProps> = ({
|
|||
allServicesReady,
|
||||
);
|
||||
|
||||
// Use login handlers
|
||||
const { handleLoginTokenSubmit } = useLoginHandlers(
|
||||
navigateTo,
|
||||
navState,
|
||||
closeCurrentScreen,
|
||||
);
|
||||
|
||||
// State to trigger static content refresh for /clear command
|
||||
const [staticRefreshTrigger, setStaticRefreshTrigger] = useState(0);
|
||||
|
||||
|
|
@ -460,9 +449,7 @@ const TUIChat: React.FC<TUIChatProps> = ({
|
|||
{/* All screen-specific content */}
|
||||
<ScreenContent
|
||||
isScreenActive={isScreenActive}
|
||||
navState={navState}
|
||||
services={services}
|
||||
handleLoginTokenSubmit={handleLoginTokenSubmit}
|
||||
handleConfigSelect={handleConfigSelect}
|
||||
handleModelSelect={handleModelSelect}
|
||||
handleSessionSelect={handleSessionSelect}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import { Box, Text } from "ink";
|
||||
import React from "react";
|
||||
|
||||
import { UpdateServiceState } from "src/services/types.js";
|
||||
|
|
@ -17,16 +16,13 @@ import { MCPSelector } from "../MCPSelector.js";
|
|||
import { ModelSelector } from "../ModelSelector.js";
|
||||
import type { ConfigOption, ModelOption } from "../types/selectorTypes.js";
|
||||
import { UpdateSelector } from "../UpdateSelector.js";
|
||||
import { UserInput } from "../UserInput.js";
|
||||
|
||||
import { ChatScreenContent } from "./ChatScreenContent.js";
|
||||
import { SessionSelectorWithLoading } from "./SessionSelectorWithLoading.js";
|
||||
|
||||
interface ScreenContentProps {
|
||||
isScreenActive: (screen: NavigationScreen) => boolean;
|
||||
navState: any;
|
||||
services: any;
|
||||
handleLoginTokenSubmit: (token: string) => void;
|
||||
handleConfigSelect: (config: ConfigOption) => Promise<void>;
|
||||
handleModelSelect: (model: ModelOption) => Promise<void>;
|
||||
handleSessionSelect: (sessionId: string) => Promise<void>;
|
||||
|
|
@ -68,9 +64,7 @@ function hideScreenContent(state?: UpdateServiceState) {
|
|||
|
||||
export const ScreenContent: React.FC<ScreenContentProps> = ({
|
||||
isScreenActive,
|
||||
navState,
|
||||
services,
|
||||
handleLoginTokenSubmit,
|
||||
handleConfigSelect,
|
||||
handleModelSelect,
|
||||
handleSessionSelect,
|
||||
|
|
@ -100,33 +94,6 @@ export const ScreenContent: React.FC<ScreenContentProps> = ({
|
|||
return null;
|
||||
}
|
||||
|
||||
// Login prompt
|
||||
if (isScreenActive("login") && navState.screenData) {
|
||||
return (
|
||||
<Box
|
||||
paddingX={1}
|
||||
borderStyle="round"
|
||||
borderColor="yellow"
|
||||
flexDirection="column"
|
||||
gap={1}
|
||||
>
|
||||
<Text color="yellow" bold>
|
||||
Login Required
|
||||
</Text>
|
||||
<Text>{navState.screenData.text}</Text>
|
||||
<UserInput
|
||||
onSubmit={handleLoginTokenSubmit}
|
||||
isWaitingForResponse={false}
|
||||
inputMode={true}
|
||||
assistant={services.config?.config || undefined}
|
||||
disabled={false}
|
||||
placeholder="Enter your token..."
|
||||
hideNormalUI={true}
|
||||
/>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
// Config selector
|
||||
if (isScreenActive("config")) {
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ export type NavigationScreen =
|
|||
| "chat" // Normal chat interface
|
||||
| "config" // Config selector
|
||||
| "model" // Model selector
|
||||
| "login" // Login prompt
|
||||
| "mcp" // MCP selector
|
||||
| "session" // Session selector
|
||||
| "diff" // Full-screen diff overlay
|
||||
|
|
@ -25,7 +24,7 @@ export type NavigationScreen =
|
|||
|
||||
interface NavigationState {
|
||||
currentScreen: NavigationScreen;
|
||||
// Screen-specific data (e.g., login prompt details)
|
||||
// Screen-specific data passed to the active screen
|
||||
screenData?: any;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,13 +62,13 @@ describe("NavigationContext", () => {
|
|||
|
||||
it("navigates to a new screen with data", () => {
|
||||
const { result } = renderHook(() => useNavigation(), { wrapper });
|
||||
const testData = { text: "Login required", resolve: vi.fn() };
|
||||
const testData = { text: "Some data", resolve: vi.fn() };
|
||||
|
||||
act(() => {
|
||||
result.current.navigateTo("login", testData);
|
||||
result.current.navigateTo("config", testData);
|
||||
});
|
||||
|
||||
expect(result.current.state.currentScreen).toBe("login");
|
||||
expect(result.current.state.currentScreen).toBe("config");
|
||||
expect(result.current.state.screenData).toEqual(testData);
|
||||
});
|
||||
|
||||
|
|
@ -78,8 +78,6 @@ describe("NavigationContext", () => {
|
|||
"chat",
|
||||
"config",
|
||||
"model",
|
||||
|
||||
"login",
|
||||
"mcp",
|
||||
];
|
||||
|
||||
|
|
@ -97,12 +95,12 @@ describe("NavigationContext", () => {
|
|||
const secondData = { value: 2 };
|
||||
|
||||
act(() => {
|
||||
result.current.navigateTo("login", firstData);
|
||||
result.current.navigateTo("config", firstData);
|
||||
});
|
||||
expect(result.current.state.screenData).toEqual(firstData);
|
||||
|
||||
act(() => {
|
||||
result.current.navigateTo("login", secondData);
|
||||
result.current.navigateTo("config", secondData);
|
||||
});
|
||||
expect(result.current.state.screenData).toEqual(secondData);
|
||||
});
|
||||
|
|
@ -112,7 +110,7 @@ describe("NavigationContext", () => {
|
|||
const testData = { value: "test" };
|
||||
|
||||
act(() => {
|
||||
result.current.navigateTo("login", testData);
|
||||
result.current.navigateTo("model", testData);
|
||||
});
|
||||
expect(result.current.state.screenData).toEqual(testData);
|
||||
|
||||
|
|
@ -143,7 +141,7 @@ describe("NavigationContext", () => {
|
|||
const testData = { text: "Test data" };
|
||||
|
||||
act(() => {
|
||||
result.current.navigateTo("login", testData);
|
||||
result.current.navigateTo("config", testData);
|
||||
});
|
||||
expect(result.current.state.screenData).toEqual(testData);
|
||||
|
||||
|
|
@ -167,10 +165,9 @@ describe("NavigationContext", () => {
|
|||
|
||||
it("closes from any screen back to chat", () => {
|
||||
const { result } = renderHook(() => useNavigation(), { wrapper });
|
||||
const screens: Array<"config" | "model" | "login" | "mcp"> = [
|
||||
const screens: Array<"config" | "model" | "mcp"> = [
|
||||
"config",
|
||||
"model",
|
||||
"login",
|
||||
"mcp",
|
||||
];
|
||||
|
||||
|
|
@ -208,7 +205,7 @@ describe("NavigationContext", () => {
|
|||
expect(result.current.isScreenActive("config")).toBe(false);
|
||||
expect(result.current.isScreenActive("model")).toBe(false);
|
||||
expect(result.current.isScreenActive("mcp")).toBe(false);
|
||||
expect(result.current.isScreenActive("login")).toBe(false);
|
||||
expect(result.current.isScreenActive("session")).toBe(false);
|
||||
});
|
||||
|
||||
it("updates correctly when navigating", () => {
|
||||
|
|
@ -250,13 +247,13 @@ describe("NavigationContext", () => {
|
|||
const { result } = renderHook(() => useNavigation(), { wrapper });
|
||||
|
||||
act(() => {
|
||||
result.current.navigateTo("login", { custom: "data" });
|
||||
result.current.navigateTo("config", { custom: "data" });
|
||||
});
|
||||
|
||||
const stateWithData = result.current.state;
|
||||
|
||||
act(() => {
|
||||
result.current.navigateTo("login", { different: "data" });
|
||||
result.current.navigateTo("config", { different: "data" });
|
||||
});
|
||||
|
||||
expect(result.current.state.currentScreen).toBe(
|
||||
|
|
@ -269,23 +266,23 @@ describe("NavigationContext", () => {
|
|||
});
|
||||
|
||||
describe("Integration Scenarios", () => {
|
||||
it("handles login flow correctly", () => {
|
||||
it("handles a screen flow with screen data correctly", () => {
|
||||
const { result } = renderHook(() => useNavigation(), { wrapper });
|
||||
const mockResolve = vi.fn();
|
||||
|
||||
// Navigate to login with resolve callback
|
||||
// Navigate to a screen with screen data
|
||||
act(() => {
|
||||
result.current.navigateTo("login", {
|
||||
text: "Please log in",
|
||||
result.current.navigateTo("config", {
|
||||
text: "Some data",
|
||||
resolve: mockResolve,
|
||||
});
|
||||
});
|
||||
|
||||
expect(result.current.state.currentScreen).toBe("login");
|
||||
expect(result.current.state.screenData?.text).toBe("Please log in");
|
||||
expect(result.current.state.currentScreen).toBe("config");
|
||||
expect(result.current.state.screenData?.text).toBe("Some data");
|
||||
expect(result.current.state.screenData?.resolve).toBe(mockResolve);
|
||||
|
||||
// Close login screen (simulating successful login)
|
||||
// Close the screen
|
||||
act(() => {
|
||||
result.current.closeCurrentScreen();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { useCallback, useEffect, useState } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
import { getGitBranch, getGitRemoteUrl, isGitRepo } from "../../util/git.js";
|
||||
import type { ConfigOption, ModelOption } from "../types/selectorTypes.js";
|
||||
|
|
@ -120,34 +120,6 @@ export function useIntroMessage(
|
|||
return [showIntroMessage, setShowIntroMessage] as const;
|
||||
}
|
||||
|
||||
// Custom hook for login handling
|
||||
export function useLoginHandlers(
|
||||
navigateTo: any,
|
||||
navState: any,
|
||||
closeCurrentScreen: () => void,
|
||||
) {
|
||||
const handleLoginPrompt = useCallback(
|
||||
(promptText: string): Promise<string> => {
|
||||
return new Promise((resolve) => {
|
||||
navigateTo("login", { text: promptText, resolve });
|
||||
});
|
||||
},
|
||||
[navigateTo],
|
||||
);
|
||||
|
||||
const handleLoginTokenSubmit = useCallback(
|
||||
(token: string) => {
|
||||
if (navState.screenData?.resolve) {
|
||||
navState.screenData.resolve(token);
|
||||
closeCurrentScreen();
|
||||
}
|
||||
},
|
||||
[navState.screenData, closeCurrentScreen],
|
||||
);
|
||||
|
||||
return { handleLoginPrompt, handleLoginTokenSubmit };
|
||||
}
|
||||
|
||||
// Custom hook to combine all selector logic
|
||||
export function useSelectors(
|
||||
configPath: string | undefined,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue