mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-23 08:45:50 +00:00
更新大量 tsx 原始文件; 已经迁移 login panel; 部分 (#121)
* style(B1-1): 格式化 ink/buddy/cli/context/screens/tasks/services/keybindings/state (43 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 修复了 Box.tsx 和 ScrollBox.tsx 中无效的 global.d.ts import。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style(B1-2): 格式化 commands (79 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style(B1-3): 格式化 components/messages,permissions,mcp,sandbox,shell (104 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style(B1-4): 格式化 components/PromptInput,FeedbackSurvey,tasks,agents,skills,design-system,wizard (73 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style(B1-5): 格式化 components其余 + hooks + tools (232 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style(B1-6): 格式化 main/entrypoints/utils/moreright (21 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docs: 更新 README,新增 Run.ps1/TODO.md,删除 V6.md - README.md: 大幅重写,更详细版本历史和配置示例 - Run.ps1: 新增 Windows 启动脚本 - TODO.md: 新增包完成清单 - V6.md: 删除(架构重构规划已不适用) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: 修复以前的问题 * fix: 修复 login 面板的问题 --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,103 +1,113 @@
|
||||
import { c as _c } from "react/compiler-runtime";
|
||||
import { feature } from 'bun:bundle';
|
||||
import * as React from 'react';
|
||||
import { resetCostState } from '../../bootstrap/state.js';
|
||||
import { clearTrustedDeviceToken, enrollTrustedDevice } from '../../bridge/trustedDevice.js';
|
||||
import type { LocalJSXCommandContext } from '../../commands.js';
|
||||
import { ConfigurableShortcutHint } from '../../components/ConfigurableShortcutHint.js';
|
||||
import { ConsoleOAuthFlow } from '../../components/ConsoleOAuthFlow.js';
|
||||
import { Dialog } from '../../components/design-system/Dialog.js';
|
||||
import { useMainLoopModel } from '../../hooks/useMainLoopModel.js';
|
||||
import { Text } from '../../ink.js';
|
||||
import { refreshGrowthBookAfterAuthChange } from '../../services/analytics/growthbook.js';
|
||||
import { refreshPolicyLimits } from '../../services/policyLimits/index.js';
|
||||
import { refreshRemoteManagedSettings } from '../../services/remoteManagedSettings/index.js';
|
||||
import type { LocalJSXCommandOnDone } from '../../types/command.js';
|
||||
import { stripSignatureBlocks } from '../../utils/messages.js';
|
||||
import { checkAndDisableAutoModeIfNeeded, checkAndDisableBypassPermissionsIfNeeded, resetAutoModeGateCheck, resetBypassPermissionsCheck } from '../../utils/permissions/bypassPermissionsKillswitch.js';
|
||||
import { resetUserCache } from '../../utils/user.js';
|
||||
export async function call(onDone: LocalJSXCommandOnDone, context: LocalJSXCommandContext): Promise<React.ReactNode> {
|
||||
return <Login onDone={async success => {
|
||||
context.onChangeAPIKey();
|
||||
// Signature-bearing blocks (thinking, connector_text) are bound to the API key —
|
||||
// strip them so the new key doesn't reject stale signatures.
|
||||
context.setMessages(stripSignatureBlocks);
|
||||
if (success) {
|
||||
// Post-login refresh logic. Keep in sync with onboarding in src/interactiveHelpers.tsx
|
||||
// Reset cost state when switching accounts
|
||||
resetCostState();
|
||||
// Refresh remotely managed settings after login (non-blocking)
|
||||
void refreshRemoteManagedSettings();
|
||||
// Refresh policy limits after login (non-blocking)
|
||||
void refreshPolicyLimits();
|
||||
// Clear user data cache BEFORE GrowthBook refresh so it picks up fresh credentials
|
||||
resetUserCache();
|
||||
// Refresh GrowthBook after login to get updated feature flags (e.g., for claude.ai MCPs)
|
||||
refreshGrowthBookAfterAuthChange();
|
||||
// Clear any stale trusted device token from a previous account before
|
||||
// re-enrolling — prevents sending the old token on bridge calls while
|
||||
// the async enrollTrustedDevice() is in-flight.
|
||||
clearTrustedDeviceToken();
|
||||
// Enroll as a trusted device for Remote Control (10-min fresh-session window)
|
||||
void enrollTrustedDevice();
|
||||
// Reset killswitch gate checks and re-run with new org
|
||||
resetBypassPermissionsCheck();
|
||||
const appState = context.getAppState();
|
||||
void checkAndDisableBypassPermissionsIfNeeded(appState.toolPermissionContext, context.setAppState);
|
||||
if (feature('TRANSCRIPT_CLASSIFIER')) {
|
||||
resetAutoModeGateCheck();
|
||||
void checkAndDisableAutoModeIfNeeded(appState.toolPermissionContext, context.setAppState, appState.fastMode);
|
||||
import { feature } from 'bun:bundle'
|
||||
import * as React from 'react'
|
||||
import { resetCostState } from '../../bootstrap/state.js'
|
||||
import {
|
||||
clearTrustedDeviceToken,
|
||||
enrollTrustedDevice,
|
||||
} from '../../bridge/trustedDevice.js'
|
||||
import type { LocalJSXCommandContext } from '../../commands.js'
|
||||
import { ConfigurableShortcutHint } from '../../components/ConfigurableShortcutHint.js'
|
||||
import { ConsoleOAuthFlow } from '../../components/ConsoleOAuthFlow.js'
|
||||
import { Dialog } from '../../components/design-system/Dialog.js'
|
||||
import { useMainLoopModel } from '../../hooks/useMainLoopModel.js'
|
||||
import { Text } from '../../ink.js'
|
||||
import { refreshGrowthBookAfterAuthChange } from '../../services/analytics/growthbook.js'
|
||||
import { refreshPolicyLimits } from '../../services/policyLimits/index.js'
|
||||
import { refreshRemoteManagedSettings } from '../../services/remoteManagedSettings/index.js'
|
||||
import type { LocalJSXCommandOnDone } from '../../types/command.js'
|
||||
import { stripSignatureBlocks } from '../../utils/messages.js'
|
||||
import {
|
||||
checkAndDisableAutoModeIfNeeded,
|
||||
checkAndDisableBypassPermissionsIfNeeded,
|
||||
resetAutoModeGateCheck,
|
||||
resetBypassPermissionsCheck,
|
||||
} from '../../utils/permissions/bypassPermissionsKillswitch.js'
|
||||
import { resetUserCache } from '../../utils/user.js'
|
||||
|
||||
export async function call(
|
||||
onDone: LocalJSXCommandOnDone,
|
||||
context: LocalJSXCommandContext,
|
||||
): Promise<React.ReactNode> {
|
||||
return (
|
||||
<Login
|
||||
onDone={async success => {
|
||||
context.onChangeAPIKey()
|
||||
// Signature-bearing blocks (thinking, connector_text) are bound to the API key —
|
||||
// strip them so the new key doesn't reject stale signatures.
|
||||
context.setMessages(stripSignatureBlocks)
|
||||
if (success) {
|
||||
// Post-login refresh logic. Keep in sync with onboarding in src/interactiveHelpers.tsx
|
||||
// Reset cost state when switching accounts
|
||||
resetCostState()
|
||||
// Refresh remotely managed settings after login (non-blocking)
|
||||
void refreshRemoteManagedSettings()
|
||||
// Refresh policy limits after login (non-blocking)
|
||||
void refreshPolicyLimits()
|
||||
// Clear user data cache BEFORE GrowthBook refresh so it picks up fresh credentials
|
||||
resetUserCache()
|
||||
// Refresh GrowthBook after login to get updated feature flags (e.g., for claude.ai MCPs)
|
||||
refreshGrowthBookAfterAuthChange()
|
||||
// Clear any stale trusted device token from a previous account before
|
||||
// re-enrolling — prevents sending the old token on bridge calls while
|
||||
// the async enrollTrustedDevice() is in-flight.
|
||||
clearTrustedDeviceToken()
|
||||
// Enroll as a trusted device for Remote Control (10-min fresh-session window)
|
||||
void enrollTrustedDevice()
|
||||
// Reset killswitch gate checks and re-run with new org
|
||||
resetBypassPermissionsCheck()
|
||||
const appState = context.getAppState()
|
||||
void checkAndDisableBypassPermissionsIfNeeded(
|
||||
appState.toolPermissionContext,
|
||||
context.setAppState,
|
||||
)
|
||||
if (feature('TRANSCRIPT_CLASSIFIER')) {
|
||||
resetAutoModeGateCheck()
|
||||
void checkAndDisableAutoModeIfNeeded(
|
||||
appState.toolPermissionContext,
|
||||
context.setAppState,
|
||||
appState.fastMode,
|
||||
)
|
||||
}
|
||||
// Increment authVersion to trigger re-fetching of auth-dependent data in hooks (e.g., MCP servers)
|
||||
context.setAppState(prev => ({
|
||||
...prev,
|
||||
authVersion: prev.authVersion + 1,
|
||||
}))
|
||||
}
|
||||
onDone(success ? 'Login successful' : 'Login interrupted')
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export function Login(props: {
|
||||
onDone: (success: boolean, mainLoopModel: string) => void
|
||||
startingMessage?: string
|
||||
}): React.ReactNode {
|
||||
const mainLoopModel = useMainLoopModel()
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
title="Login"
|
||||
onCancel={() => props.onDone(false, mainLoopModel)}
|
||||
color="permission"
|
||||
inputGuide={exitState =>
|
||||
exitState.pending ? (
|
||||
<Text>Press {exitState.keyName} again to exit</Text>
|
||||
) : (
|
||||
<ConfigurableShortcutHint
|
||||
action="confirm:no"
|
||||
context="Confirmation"
|
||||
fallback="Esc"
|
||||
description="cancel"
|
||||
/>
|
||||
)
|
||||
}
|
||||
// Increment authVersion to trigger re-fetching of auth-dependent data in hooks (e.g., MCP servers)
|
||||
context.setAppState(prev => ({
|
||||
...prev,
|
||||
authVersion: prev.authVersion + 1
|
||||
}));
|
||||
}
|
||||
onDone(success ? 'Login successful' : 'Login interrupted');
|
||||
}} />;
|
||||
}
|
||||
export function Login(props) {
|
||||
const $ = _c(12);
|
||||
const mainLoopModel = useMainLoopModel();
|
||||
let t0;
|
||||
if ($[0] !== mainLoopModel || $[1] !== props) {
|
||||
t0 = () => props.onDone(false, mainLoopModel);
|
||||
$[0] = mainLoopModel;
|
||||
$[1] = props;
|
||||
$[2] = t0;
|
||||
} else {
|
||||
t0 = $[2];
|
||||
}
|
||||
let t1;
|
||||
if ($[3] !== mainLoopModel || $[4] !== props) {
|
||||
t1 = () => props.onDone(true, mainLoopModel);
|
||||
$[3] = mainLoopModel;
|
||||
$[4] = props;
|
||||
$[5] = t1;
|
||||
} else {
|
||||
t1 = $[5];
|
||||
}
|
||||
let t2;
|
||||
if ($[6] !== props.startingMessage || $[7] !== t1) {
|
||||
t2 = <ConsoleOAuthFlow onDone={t1} startingMessage={props.startingMessage} />;
|
||||
$[6] = props.startingMessage;
|
||||
$[7] = t1;
|
||||
$[8] = t2;
|
||||
} else {
|
||||
t2 = $[8];
|
||||
}
|
||||
let t3;
|
||||
if ($[9] !== t0 || $[10] !== t2) {
|
||||
t3 = <Dialog title="Login" onCancel={t0} color="permission" inputGuide={_temp}>{t2}</Dialog>;
|
||||
$[9] = t0;
|
||||
$[10] = t2;
|
||||
$[11] = t3;
|
||||
} else {
|
||||
t3 = $[11];
|
||||
}
|
||||
return t3;
|
||||
}
|
||||
function _temp(exitState) {
|
||||
return exitState.pending ? <Text>Press {exitState.keyName} again to exit</Text> : <ConfigurableShortcutHint action="confirm:no" context="Confirmation" fallback="Esc" description="cancel" />;
|
||||
>
|
||||
<ConsoleOAuthFlow
|
||||
onDone={() => props.onDone(true, mainLoopModel)}
|
||||
startingMessage={props.startingMessage}
|
||||
/>
|
||||
</Dialog>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user