mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-18 22:35:51 +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,284 +1,240 @@
|
||||
import { c as _c } from "react/compiler-runtime";
|
||||
import React, { useState } from 'react';
|
||||
import { type OptionWithDescription, Select } from '../../components/CustomSelect/select.js';
|
||||
import { Dialog } from '../../components/design-system/Dialog.js';
|
||||
import { Box, Text } from '../../ink.js';
|
||||
import { useAppState } from '../../state/AppState.js';
|
||||
import { isClaudeAISubscriber } from '../../utils/auth.js';
|
||||
import { openBrowser } from '../../utils/browser.js';
|
||||
import { CLAUDE_IN_CHROME_MCP_SERVER_NAME, openInChrome } from '../../utils/claudeInChrome/common.js';
|
||||
import { isChromeExtensionInstalled } from '../../utils/claudeInChrome/setup.js';
|
||||
import { getGlobalConfig, saveGlobalConfig } from '../../utils/config.js';
|
||||
import { env } from '../../utils/env.js';
|
||||
import { isRunningOnHomespace } from '../../utils/envUtils.js';
|
||||
const CHROME_EXTENSION_URL = 'https://claude.ai/chrome';
|
||||
const CHROME_PERMISSIONS_URL = 'https://clau.de/chrome/permissions';
|
||||
const CHROME_RECONNECT_URL = 'https://clau.de/chrome/reconnect';
|
||||
type MenuAction = 'install-extension' | 'reconnect' | 'manage-permissions' | 'toggle-default';
|
||||
import React, { useState } from 'react'
|
||||
import {
|
||||
type OptionWithDescription,
|
||||
Select,
|
||||
} from '../../components/CustomSelect/select.js'
|
||||
import { Dialog } from '../../components/design-system/Dialog.js'
|
||||
import { Box, Text } from '../../ink.js'
|
||||
import { useAppState } from '../../state/AppState.js'
|
||||
import { isClaudeAISubscriber } from '../../utils/auth.js'
|
||||
import { openBrowser } from '../../utils/browser.js'
|
||||
import {
|
||||
CLAUDE_IN_CHROME_MCP_SERVER_NAME,
|
||||
openInChrome,
|
||||
} from '../../utils/claudeInChrome/common.js'
|
||||
import { isChromeExtensionInstalled } from '../../utils/claudeInChrome/setup.js'
|
||||
import { getGlobalConfig, saveGlobalConfig } from '../../utils/config.js'
|
||||
import { env } from '../../utils/env.js'
|
||||
import { isRunningOnHomespace } from '../../utils/envUtils.js'
|
||||
|
||||
const CHROME_EXTENSION_URL = 'https://claude.ai/chrome'
|
||||
const CHROME_PERMISSIONS_URL = 'https://clau.de/chrome/permissions'
|
||||
const CHROME_RECONNECT_URL = 'https://clau.de/chrome/reconnect'
|
||||
|
||||
type MenuAction =
|
||||
| 'install-extension'
|
||||
| 'reconnect'
|
||||
| 'manage-permissions'
|
||||
| 'toggle-default'
|
||||
|
||||
type Props = {
|
||||
onDone: (result?: string) => void;
|
||||
isExtensionInstalled: boolean;
|
||||
configEnabled: boolean | undefined;
|
||||
isClaudeAISubscriber: boolean;
|
||||
isWSL: boolean;
|
||||
};
|
||||
function ClaudeInChromeMenu(t0) {
|
||||
const $ = _c(41);
|
||||
const {
|
||||
onDone,
|
||||
isExtensionInstalled: installed,
|
||||
configEnabled,
|
||||
isClaudeAISubscriber,
|
||||
isWSL
|
||||
} = t0;
|
||||
const mcpClients = useAppState(_temp);
|
||||
const [selectKey, setSelectKey] = useState(0);
|
||||
const [enabledByDefault, setEnabledByDefault] = useState(configEnabled ?? false);
|
||||
const [showInstallHint, setShowInstallHint] = useState(false);
|
||||
const [isExtensionInstalled, setIsExtensionInstalled] = useState(installed);
|
||||
let t1;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t1 = false && isRunningOnHomespace();
|
||||
$[0] = t1;
|
||||
} else {
|
||||
t1 = $[0];
|
||||
onDone: (result?: string) => void
|
||||
isExtensionInstalled: boolean
|
||||
configEnabled: boolean | undefined
|
||||
isClaudeAISubscriber: boolean
|
||||
isWSL: boolean
|
||||
}
|
||||
|
||||
function ClaudeInChromeMenu({
|
||||
onDone,
|
||||
isExtensionInstalled: installed,
|
||||
configEnabled,
|
||||
isClaudeAISubscriber,
|
||||
isWSL,
|
||||
}: Props): React.ReactNode {
|
||||
const mcpClients = useAppState(s => s.mcp.clients)
|
||||
const [selectKey, setSelectKey] = useState(0)
|
||||
const [enabledByDefault, setEnabledByDefault] = useState(
|
||||
configEnabled ?? false,
|
||||
)
|
||||
const [showInstallHint, setShowInstallHint] = useState(false)
|
||||
const [isExtensionInstalled, setIsExtensionInstalled] = useState(installed)
|
||||
|
||||
const isHomespace = process.env.USER_TYPE === 'ant' && isRunningOnHomespace()
|
||||
|
||||
const chromeClient = mcpClients.find(
|
||||
c => c.name === CLAUDE_IN_CHROME_MCP_SERVER_NAME,
|
||||
)
|
||||
const isConnected = chromeClient?.type === 'connected'
|
||||
|
||||
function openUrl(url: string): void {
|
||||
if (isHomespace) {
|
||||
void openBrowser(url)
|
||||
} else {
|
||||
void openInChrome(url)
|
||||
}
|
||||
}
|
||||
const isHomespace = t1;
|
||||
let t2;
|
||||
if ($[1] !== mcpClients) {
|
||||
t2 = mcpClients.find(_temp2);
|
||||
$[1] = mcpClients;
|
||||
$[2] = t2;
|
||||
} else {
|
||||
t2 = $[2];
|
||||
}
|
||||
const chromeClient = t2;
|
||||
const isConnected = chromeClient?.type === "connected";
|
||||
let t3;
|
||||
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t3 = function openUrl(url) {
|
||||
if (isHomespace) {
|
||||
openBrowser(url);
|
||||
} else {
|
||||
openInChrome(url);
|
||||
|
||||
function handleAction(action: MenuAction): void {
|
||||
switch (action) {
|
||||
case 'install-extension':
|
||||
setSelectKey(k => k + 1)
|
||||
setShowInstallHint(true)
|
||||
openUrl(CHROME_EXTENSION_URL)
|
||||
break
|
||||
case 'reconnect':
|
||||
setSelectKey(k => k + 1)
|
||||
void isChromeExtensionInstalled().then(installed => {
|
||||
setIsExtensionInstalled(installed)
|
||||
if (installed) {
|
||||
setShowInstallHint(false)
|
||||
}
|
||||
})
|
||||
openUrl(CHROME_RECONNECT_URL)
|
||||
break
|
||||
case 'manage-permissions':
|
||||
setSelectKey(k => k + 1)
|
||||
openUrl(CHROME_PERMISSIONS_URL)
|
||||
break
|
||||
case 'toggle-default': {
|
||||
const newValue = !enabledByDefault
|
||||
saveGlobalConfig(current => ({
|
||||
...current,
|
||||
claudeInChromeDefaultEnabled: newValue,
|
||||
}))
|
||||
setEnabledByDefault(newValue)
|
||||
break
|
||||
}
|
||||
};
|
||||
$[3] = t3;
|
||||
} else {
|
||||
t3 = $[3];
|
||||
}
|
||||
const openUrl = t3;
|
||||
let t4;
|
||||
if ($[4] !== enabledByDefault) {
|
||||
t4 = function handleAction(action) {
|
||||
bb22: switch (action) {
|
||||
case "install-extension":
|
||||
{
|
||||
setSelectKey(_temp3);
|
||||
setShowInstallHint(true);
|
||||
openUrl(CHROME_EXTENSION_URL);
|
||||
break bb22;
|
||||
}
|
||||
case "reconnect":
|
||||
{
|
||||
setSelectKey(_temp4);
|
||||
isChromeExtensionInstalled().then(installed_0 => {
|
||||
setIsExtensionInstalled(installed_0);
|
||||
if (installed_0) {
|
||||
setShowInstallHint(false);
|
||||
}
|
||||
});
|
||||
openUrl(CHROME_RECONNECT_URL);
|
||||
break bb22;
|
||||
}
|
||||
case "manage-permissions":
|
||||
{
|
||||
setSelectKey(_temp5);
|
||||
openUrl(CHROME_PERMISSIONS_URL);
|
||||
break bb22;
|
||||
}
|
||||
case "toggle-default":
|
||||
{
|
||||
const newValue = !enabledByDefault;
|
||||
saveGlobalConfig(current => ({
|
||||
...current,
|
||||
claudeInChromeDefaultEnabled: newValue
|
||||
}));
|
||||
setEnabledByDefault(newValue);
|
||||
}
|
||||
}
|
||||
};
|
||||
$[4] = enabledByDefault;
|
||||
$[5] = t4;
|
||||
} else {
|
||||
t4 = $[5];
|
||||
}
|
||||
const handleAction = t4;
|
||||
let options;
|
||||
if ($[6] !== enabledByDefault || $[7] !== isExtensionInstalled) {
|
||||
options = [];
|
||||
const requiresExtensionSuffix = isExtensionInstalled ? "" : " (requires extension)";
|
||||
if (!isExtensionInstalled && !isHomespace) {
|
||||
let t5;
|
||||
if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t5 = {
|
||||
label: "Install Chrome extension",
|
||||
value: "install-extension"
|
||||
};
|
||||
$[9] = t5;
|
||||
} else {
|
||||
t5 = $[9];
|
||||
}
|
||||
options.push(t5);
|
||||
}
|
||||
let t5;
|
||||
if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t5 = <Text>Manage permissions</Text>;
|
||||
$[10] = t5;
|
||||
} else {
|
||||
t5 = $[10];
|
||||
}
|
||||
let t6;
|
||||
if ($[11] !== requiresExtensionSuffix) {
|
||||
t6 = {
|
||||
label: <>{t5}<Text dimColor={true}>{requiresExtensionSuffix}</Text></>,
|
||||
value: "manage-permissions"
|
||||
};
|
||||
$[11] = requiresExtensionSuffix;
|
||||
$[12] = t6;
|
||||
} else {
|
||||
t6 = $[12];
|
||||
}
|
||||
let t7;
|
||||
if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t7 = <Text>Reconnect extension</Text>;
|
||||
$[13] = t7;
|
||||
} else {
|
||||
t7 = $[13];
|
||||
}
|
||||
let t8;
|
||||
if ($[14] !== requiresExtensionSuffix) {
|
||||
t8 = {
|
||||
label: <>{t7}<Text dimColor={true}>{requiresExtensionSuffix}</Text></>,
|
||||
value: "reconnect"
|
||||
};
|
||||
$[14] = requiresExtensionSuffix;
|
||||
$[15] = t8;
|
||||
} else {
|
||||
t8 = $[15];
|
||||
}
|
||||
const t9 = `Enabled by default: ${enabledByDefault ? "Yes" : "No"}`;
|
||||
let t10;
|
||||
if ($[16] !== t9) {
|
||||
t10 = {
|
||||
label: t9,
|
||||
value: "toggle-default"
|
||||
};
|
||||
$[16] = t9;
|
||||
$[17] = t10;
|
||||
} else {
|
||||
t10 = $[17];
|
||||
}
|
||||
options.push(t6, t8, t10);
|
||||
$[6] = enabledByDefault;
|
||||
$[7] = isExtensionInstalled;
|
||||
$[8] = options;
|
||||
} else {
|
||||
options = $[8];
|
||||
}
|
||||
const isDisabled = isWSL;
|
||||
let t5;
|
||||
if ($[18] !== onDone) {
|
||||
t5 = () => onDone();
|
||||
$[18] = onDone;
|
||||
$[19] = t5;
|
||||
} else {
|
||||
t5 = $[19];
|
||||
|
||||
const options: OptionWithDescription<MenuAction>[] = []
|
||||
const requiresExtensionSuffix = isExtensionInstalled
|
||||
? ''
|
||||
: ' (requires extension)'
|
||||
|
||||
if (!isExtensionInstalled && !isHomespace) {
|
||||
options.push({
|
||||
label: 'Install Chrome extension',
|
||||
value: 'install-extension',
|
||||
})
|
||||
}
|
||||
let t6;
|
||||
if ($[20] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t6 = <Text>Claude in Chrome works with the Chrome extension to let you control your browser directly from Claude Code. Navigate websites, fill forms, capture screenshots, record GIFs, and debug with console logs and network requests.</Text>;
|
||||
$[20] = t6;
|
||||
} else {
|
||||
t6 = $[20];
|
||||
}
|
||||
let t7;
|
||||
if ($[21] !== isWSL) {
|
||||
t7 = isWSL && <Text color="error">Claude in Chrome is not supported in WSL at this time.</Text>;
|
||||
$[21] = isWSL;
|
||||
$[22] = t7;
|
||||
} else {
|
||||
t7 = $[22];
|
||||
}
|
||||
let t8;
|
||||
if ($[23] !== isClaudeAISubscriber) {
|
||||
t8 = false;
|
||||
$[23] = isClaudeAISubscriber;
|
||||
$[24] = t8;
|
||||
} else {
|
||||
t8 = $[24];
|
||||
}
|
||||
let t9;
|
||||
if ($[25] !== handleAction || $[26] !== isConnected || $[27] !== isDisabled || $[28] !== isExtensionInstalled || $[29] !== options || $[30] !== selectKey || $[31] !== showInstallHint) {
|
||||
t9 = !isDisabled && <>{!isHomespace && <Box flexDirection="column"><Text>Status:{" "}{isConnected ? <Text color="success">Enabled</Text> : <Text color="inactive">Disabled</Text>}</Text><Text>Extension:{" "}{isExtensionInstalled ? <Text color="success">Installed</Text> : <Text color="warning">Not detected</Text>}</Text></Box>}<Select key={selectKey} options={options} onChange={handleAction} hideIndexes={true} />{showInstallHint && <Text color="warning">Once installed, select {"\"Reconnect extension\""} to connect.</Text>}<Text><Text dimColor={true}>Usage: </Text><Text>claude --chrome</Text><Text dimColor={true}> or </Text><Text>claude --no-chrome</Text></Text><Text dimColor={true}>Site-level permissions are inherited from the Chrome extension. Manage permissions in the Chrome extension settings to control which sites Claude can browse, click, and type on.</Text></>;
|
||||
$[25] = handleAction;
|
||||
$[26] = isConnected;
|
||||
$[27] = isDisabled;
|
||||
$[28] = isExtensionInstalled;
|
||||
$[29] = options;
|
||||
$[30] = selectKey;
|
||||
$[31] = showInstallHint;
|
||||
$[32] = t9;
|
||||
} else {
|
||||
t9 = $[32];
|
||||
}
|
||||
let t10;
|
||||
if ($[33] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t10 = <Text dimColor={true}>Learn more: https://code.claude.com/docs/en/chrome</Text>;
|
||||
$[33] = t10;
|
||||
} else {
|
||||
t10 = $[33];
|
||||
}
|
||||
let t11;
|
||||
if ($[34] !== t7 || $[35] !== t8 || $[36] !== t9) {
|
||||
t11 = <Box flexDirection="column" gap={1}>{t6}{t7}{t8}{t9}{t10}</Box>;
|
||||
$[34] = t7;
|
||||
$[35] = t8;
|
||||
$[36] = t9;
|
||||
$[37] = t11;
|
||||
} else {
|
||||
t11 = $[37];
|
||||
}
|
||||
let t12;
|
||||
if ($[38] !== t11 || $[39] !== t5) {
|
||||
t12 = <Dialog title="Claude in Chrome (Beta)" onCancel={t5} color="chromeYellow">{t11}</Dialog>;
|
||||
$[38] = t11;
|
||||
$[39] = t5;
|
||||
$[40] = t12;
|
||||
} else {
|
||||
t12 = $[40];
|
||||
}
|
||||
return t12;
|
||||
|
||||
options.push(
|
||||
{
|
||||
label: (
|
||||
<>
|
||||
<Text>Manage permissions</Text>
|
||||
<Text dimColor>{requiresExtensionSuffix}</Text>
|
||||
</>
|
||||
),
|
||||
value: 'manage-permissions',
|
||||
},
|
||||
{
|
||||
label: (
|
||||
<>
|
||||
<Text>Reconnect extension</Text>
|
||||
<Text dimColor>{requiresExtensionSuffix}</Text>
|
||||
</>
|
||||
),
|
||||
value: 'reconnect',
|
||||
},
|
||||
{
|
||||
label: `Enabled by default: ${enabledByDefault ? 'Yes' : 'No'}`,
|
||||
value: 'toggle-default',
|
||||
},
|
||||
)
|
||||
|
||||
const isDisabled =
|
||||
isWSL || ("external" !== 'ant' && !isClaudeAISubscriber)
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
title="Claude in Chrome (Beta)"
|
||||
onCancel={() => onDone()}
|
||||
color="chromeYellow"
|
||||
>
|
||||
<Box flexDirection="column" gap={1}>
|
||||
<Text>
|
||||
Claude in Chrome works with the Chrome extension to let you control
|
||||
your browser directly from Claude Code. Navigate websites, fill forms,
|
||||
capture screenshots, record GIFs, and debug with console logs and
|
||||
network requests.
|
||||
</Text>
|
||||
|
||||
{isWSL && (
|
||||
<Text color="error">
|
||||
Claude in Chrome is not supported in WSL at this time.
|
||||
</Text>
|
||||
)}
|
||||
|
||||
|
||||
{"external" !== 'ant' && !isClaudeAISubscriber && (
|
||||
<Text color="error">
|
||||
Claude in Chrome requires a claude.ai subscription.
|
||||
</Text>
|
||||
)}
|
||||
|
||||
{!isDisabled && (
|
||||
<>
|
||||
{!isHomespace && (
|
||||
<Box flexDirection="column">
|
||||
<Text>
|
||||
Status:{' '}
|
||||
{isConnected ? (
|
||||
<Text color="success">Enabled</Text>
|
||||
) : (
|
||||
<Text color="inactive">Disabled</Text>
|
||||
)}
|
||||
</Text>
|
||||
<Text>
|
||||
Extension:{' '}
|
||||
{isExtensionInstalled ? (
|
||||
<Text color="success">Installed</Text>
|
||||
) : (
|
||||
<Text color="warning">Not detected</Text>
|
||||
)}
|
||||
</Text>
|
||||
</Box>
|
||||
)}
|
||||
<Select
|
||||
key={selectKey}
|
||||
options={options}
|
||||
onChange={handleAction}
|
||||
hideIndexes
|
||||
/>
|
||||
|
||||
{showInstallHint && (
|
||||
<Text color="warning">
|
||||
Once installed, select {'"Reconnect extension"'} to connect.
|
||||
</Text>
|
||||
)}
|
||||
|
||||
<Text>
|
||||
<Text dimColor>Usage: </Text>
|
||||
<Text>claude --chrome</Text>
|
||||
<Text dimColor> or </Text>
|
||||
<Text>claude --no-chrome</Text>
|
||||
</Text>
|
||||
|
||||
<Text dimColor>
|
||||
Site-level permissions are inherited from the Chrome extension.
|
||||
Manage permissions in the Chrome extension settings to control
|
||||
which sites Claude can browse, click, and type on.
|
||||
</Text>
|
||||
</>
|
||||
)}
|
||||
<Text dimColor>Learn more: https://code.claude.com/docs/en/chrome</Text>
|
||||
</Box>
|
||||
</Dialog>
|
||||
)
|
||||
}
|
||||
function _temp5(k) {
|
||||
return k + 1;
|
||||
|
||||
export const call = async function (
|
||||
onDone: (result?: string) => void,
|
||||
): Promise<React.ReactNode> {
|
||||
const isExtensionInstalled = await isChromeExtensionInstalled()
|
||||
const config = getGlobalConfig()
|
||||
const isSubscriber = isClaudeAISubscriber()
|
||||
const isWSL = env.isWslEnvironment()
|
||||
|
||||
return (
|
||||
<ClaudeInChromeMenu
|
||||
onDone={onDone}
|
||||
isExtensionInstalled={isExtensionInstalled}
|
||||
configEnabled={config.claudeInChromeDefaultEnabled}
|
||||
isClaudeAISubscriber={isSubscriber}
|
||||
isWSL={isWSL}
|
||||
/>
|
||||
)
|
||||
}
|
||||
function _temp4(k_0) {
|
||||
return k_0 + 1;
|
||||
}
|
||||
function _temp3(k_1) {
|
||||
return k_1 + 1;
|
||||
}
|
||||
function _temp2(c) {
|
||||
return c.name === CLAUDE_IN_CHROME_MCP_SERVER_NAME;
|
||||
}
|
||||
function _temp(s) {
|
||||
return s.mcp.clients;
|
||||
}
|
||||
export const call = async function (onDone: (result?: string) => void): Promise<React.ReactNode> {
|
||||
const isExtensionInstalled = await isChromeExtensionInstalled();
|
||||
const config = getGlobalConfig();
|
||||
const isSubscriber = isClaudeAISubscriber();
|
||||
const isWSL = env.isWslEnvironment();
|
||||
return <ClaudeInChromeMenu onDone={onDone} isExtensionInstalled={isExtensionInstalled} configEnabled={config.claudeInChromeDefaultEnabled} isClaudeAISubscriber={isSubscriber} isWSL={isWSL} />;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user