mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-22 16:25: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,209 +1,177 @@
|
||||
import { c as _c } from "react/compiler-runtime";
|
||||
import React, { useMemo, useState } from 'react';
|
||||
import type { CommandResultDisplay, LocalJSXCommandContext } from '../../commands.js';
|
||||
import { type OptionWithDescription, Select } from '../../components/CustomSelect/select.js';
|
||||
import { Dialog } from '../../components/design-system/Dialog.js';
|
||||
import { getFeatureValue_CACHED_MAY_BE_STALE } from '../../services/analytics/growthbook.js';
|
||||
import { logEvent } from '../../services/analytics/index.js';
|
||||
import { useClaudeAiLimits } from '../../services/claudeAiLimitsHook.js';
|
||||
import type { ToolUseContext } from '../../Tool.js';
|
||||
import type { LocalJSXCommandOnDone } from '../../types/command.js';
|
||||
import { getOauthAccountInfo, getRateLimitTier, getSubscriptionType } from '../../utils/auth.js';
|
||||
import { hasClaudeAiBillingAccess } from '../../utils/billing.js';
|
||||
import { call as extraUsageCall } from '../extra-usage/extra-usage.js';
|
||||
import { extraUsage } from '../extra-usage/index.js';
|
||||
import upgrade from '../upgrade/index.js';
|
||||
import { call as upgradeCall } from '../upgrade/upgrade.js';
|
||||
type RateLimitOptionsMenuOptionType = 'upgrade' | 'extra-usage' | 'cancel';
|
||||
import React, { useMemo, useState } from 'react'
|
||||
import type {
|
||||
CommandResultDisplay,
|
||||
LocalJSXCommandContext,
|
||||
} from '../../commands.js'
|
||||
import {
|
||||
type OptionWithDescription,
|
||||
Select,
|
||||
} from '../../components/CustomSelect/select.js'
|
||||
import { Dialog } from '../../components/design-system/Dialog.js'
|
||||
import { getFeatureValue_CACHED_MAY_BE_STALE } from '../../services/analytics/growthbook.js'
|
||||
import { logEvent } from '../../services/analytics/index.js'
|
||||
import { useClaudeAiLimits } from '../../services/claudeAiLimitsHook.js'
|
||||
import type { ToolUseContext } from '../../Tool.js'
|
||||
import type { LocalJSXCommandOnDone } from '../../types/command.js'
|
||||
import {
|
||||
getOauthAccountInfo,
|
||||
getRateLimitTier,
|
||||
getSubscriptionType,
|
||||
} from '../../utils/auth.js'
|
||||
import { hasClaudeAiBillingAccess } from '../../utils/billing.js'
|
||||
import { call as extraUsageCall } from '../extra-usage/extra-usage.js'
|
||||
import { extraUsage } from '../extra-usage/index.js'
|
||||
import upgrade from '../upgrade/index.js'
|
||||
import { call as upgradeCall } from '../upgrade/upgrade.js'
|
||||
|
||||
type RateLimitOptionsMenuOptionType = 'upgrade' | 'extra-usage' | 'cancel'
|
||||
|
||||
type RateLimitOptionsMenuProps = {
|
||||
onDone: (result?: string, options?: {
|
||||
display?: CommandResultDisplay | undefined;
|
||||
} | undefined) => void;
|
||||
context: ToolUseContext & LocalJSXCommandContext;
|
||||
};
|
||||
function RateLimitOptionsMenu(t0) {
|
||||
const $ = _c(25);
|
||||
const {
|
||||
onDone,
|
||||
context
|
||||
} = t0;
|
||||
const [subCommandJSX, setSubCommandJSX] = useState(null);
|
||||
const claudeAiLimits = useClaudeAiLimits();
|
||||
let t1;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t1 = getSubscriptionType();
|
||||
$[0] = t1;
|
||||
} else {
|
||||
t1 = $[0];
|
||||
}
|
||||
const subscriptionType = t1;
|
||||
let t2;
|
||||
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t2 = getRateLimitTier();
|
||||
$[1] = t2;
|
||||
} else {
|
||||
t2 = $[1];
|
||||
}
|
||||
const rateLimitTier = t2;
|
||||
const hasExtraUsageEnabled = getOauthAccountInfo()?.hasExtraUsageEnabled === true;
|
||||
const isMax = subscriptionType === "max";
|
||||
const isMax20x = isMax && rateLimitTier === "default_claude_max_20x";
|
||||
const isTeamOrEnterprise = subscriptionType === "team" || subscriptionType === "enterprise";
|
||||
const buyFirst = getFeatureValue_CACHED_MAY_BE_STALE("tengu_jade_anvil_4", false);
|
||||
let t3;
|
||||
bb0: {
|
||||
let actionOptions;
|
||||
if ($[2] !== claudeAiLimits.overageDisabledReason || $[3] !== claudeAiLimits.overageStatus) {
|
||||
actionOptions = [];
|
||||
if (extraUsage.isEnabled()) {
|
||||
const hasBillingAccess = hasClaudeAiBillingAccess();
|
||||
const needsToRequestFromAdmin = isTeamOrEnterprise && !hasBillingAccess;
|
||||
const isOrgSpendCapDepleted = claudeAiLimits.overageDisabledReason === "out_of_credits" || claudeAiLimits.overageDisabledReason === "org_level_disabled_until" || claudeAiLimits.overageDisabledReason === "org_service_zero_credit_limit";
|
||||
if (needsToRequestFromAdmin && isOrgSpendCapDepleted) {} else {
|
||||
const isOverageState = claudeAiLimits.overageStatus === "rejected" || claudeAiLimits.overageStatus === "allowed_warning";
|
||||
let label;
|
||||
if (needsToRequestFromAdmin) {
|
||||
label = isOverageState ? "Request more" : "Request extra usage";
|
||||
} else {
|
||||
label = hasExtraUsageEnabled ? "Add funds to continue with extra usage" : "Switch to extra usage";
|
||||
}
|
||||
let t4;
|
||||
if ($[5] !== label) {
|
||||
t4 = {
|
||||
label,
|
||||
value: "extra-usage"
|
||||
};
|
||||
$[5] = label;
|
||||
$[6] = t4;
|
||||
} else {
|
||||
t4 = $[6];
|
||||
}
|
||||
actionOptions.push(t4);
|
||||
onDone: (
|
||||
result?: string,
|
||||
options?:
|
||||
| {
|
||||
display?: CommandResultDisplay | undefined
|
||||
}
|
||||
}
|
||||
if (!isMax20x && !isTeamOrEnterprise && upgrade.isEnabled()) {
|
||||
let t4;
|
||||
if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t4 = {
|
||||
label: "Upgrade your plan",
|
||||
value: "upgrade"
|
||||
};
|
||||
$[7] = t4;
|
||||
| undefined,
|
||||
) => void
|
||||
context: ToolUseContext & LocalJSXCommandContext
|
||||
}
|
||||
|
||||
function RateLimitOptionsMenu({
|
||||
onDone,
|
||||
context,
|
||||
}: RateLimitOptionsMenuProps): React.ReactNode {
|
||||
const [subCommandJSX, setSubCommandJSX] = useState<React.ReactNode>(null)
|
||||
const claudeAiLimits = useClaudeAiLimits()
|
||||
const subscriptionType = getSubscriptionType()
|
||||
const rateLimitTier = getRateLimitTier()
|
||||
const hasExtraUsageEnabled =
|
||||
getOauthAccountInfo()?.hasExtraUsageEnabled === true
|
||||
const isMax = subscriptionType === 'max'
|
||||
const isMax20x = isMax && rateLimitTier === 'default_claude_max_20x'
|
||||
const isTeamOrEnterprise =
|
||||
subscriptionType === 'team' || subscriptionType === 'enterprise'
|
||||
const buyFirst = getFeatureValue_CACHED_MAY_BE_STALE(
|
||||
'tengu_jade_anvil_4',
|
||||
false,
|
||||
)
|
||||
|
||||
const options = useMemo<
|
||||
OptionWithDescription<RateLimitOptionsMenuOptionType>[]
|
||||
>(() => {
|
||||
const actionOptions: OptionWithDescription<RateLimitOptionsMenuOptionType>[] =
|
||||
[]
|
||||
|
||||
if (extraUsage.isEnabled()) {
|
||||
const hasBillingAccess = hasClaudeAiBillingAccess()
|
||||
const needsToRequestFromAdmin = isTeamOrEnterprise && !hasBillingAccess
|
||||
// Org spend cap depleted - non-admins can't request more since there's nothing to allocate
|
||||
// - out_of_credits: wallet empty
|
||||
// - org_level_disabled_until: org spend cap hit for the month
|
||||
// - org_service_zero_credit_limit: org service has zero credit limit
|
||||
const isOrgSpendCapDepleted =
|
||||
claudeAiLimits.overageDisabledReason === 'out_of_credits' ||
|
||||
claudeAiLimits.overageDisabledReason === 'org_level_disabled_until' ||
|
||||
claudeAiLimits.overageDisabledReason === 'org_service_zero_credit_limit'
|
||||
|
||||
// Hide for non-admin Team/Enterprise users when org spend cap is depleted
|
||||
if (needsToRequestFromAdmin && isOrgSpendCapDepleted) {
|
||||
// Don't show extra-usage option
|
||||
} else {
|
||||
const isOverageState =
|
||||
claudeAiLimits.overageStatus === 'rejected' ||
|
||||
claudeAiLimits.overageStatus === 'allowed_warning'
|
||||
|
||||
let label: string
|
||||
if (needsToRequestFromAdmin) {
|
||||
label = isOverageState ? 'Request more' : 'Request extra usage'
|
||||
} else {
|
||||
t4 = $[7];
|
||||
label = hasExtraUsageEnabled
|
||||
? 'Add funds to continue with extra usage'
|
||||
: 'Switch to extra usage'
|
||||
}
|
||||
actionOptions.push(t4);
|
||||
|
||||
actionOptions.push({
|
||||
label,
|
||||
value: 'extra-usage',
|
||||
})
|
||||
}
|
||||
$[2] = claudeAiLimits.overageDisabledReason;
|
||||
$[3] = claudeAiLimits.overageStatus;
|
||||
$[4] = actionOptions;
|
||||
} else {
|
||||
actionOptions = $[4];
|
||||
}
|
||||
let t4;
|
||||
if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t4 = {
|
||||
label: "Stop and wait for limit to reset",
|
||||
value: "cancel"
|
||||
};
|
||||
$[8] = t4;
|
||||
} else {
|
||||
t4 = $[8];
|
||||
|
||||
if (!isMax20x && !isTeamOrEnterprise && upgrade.isEnabled()) {
|
||||
actionOptions.push({
|
||||
label: 'Upgrade your plan',
|
||||
value: 'upgrade',
|
||||
})
|
||||
}
|
||||
const cancelOption = t4;
|
||||
|
||||
const cancelOption: OptionWithDescription<RateLimitOptionsMenuOptionType> =
|
||||
{
|
||||
label: 'Stop and wait for limit to reset',
|
||||
value: 'cancel',
|
||||
}
|
||||
|
||||
if (buyFirst) {
|
||||
let t5;
|
||||
if ($[9] !== actionOptions) {
|
||||
t5 = [...actionOptions, cancelOption];
|
||||
$[9] = actionOptions;
|
||||
$[10] = t5;
|
||||
} else {
|
||||
t5 = $[10];
|
||||
}
|
||||
t3 = t5;
|
||||
break bb0;
|
||||
return [...actionOptions, cancelOption]
|
||||
}
|
||||
let t5;
|
||||
if ($[11] !== actionOptions) {
|
||||
t5 = [cancelOption, ...actionOptions];
|
||||
$[11] = actionOptions;
|
||||
$[12] = t5;
|
||||
} else {
|
||||
t5 = $[12];
|
||||
}
|
||||
t3 = t5;
|
||||
return [cancelOption, ...actionOptions]
|
||||
}, [
|
||||
buyFirst,
|
||||
isMax20x,
|
||||
isTeamOrEnterprise,
|
||||
hasExtraUsageEnabled,
|
||||
claudeAiLimits.overageStatus,
|
||||
claudeAiLimits.overageDisabledReason,
|
||||
])
|
||||
|
||||
function handleCancel(): void {
|
||||
logEvent('tengu_rate_limit_options_menu_cancel', {})
|
||||
onDone(undefined, { display: 'skip' })
|
||||
}
|
||||
const options = t3;
|
||||
let t4;
|
||||
if ($[13] !== onDone) {
|
||||
t4 = function handleCancel() {
|
||||
logEvent("tengu_rate_limit_options_menu_cancel", {});
|
||||
onDone(undefined, {
|
||||
display: "skip"
|
||||
});
|
||||
};
|
||||
$[13] = onDone;
|
||||
$[14] = t4;
|
||||
} else {
|
||||
t4 = $[14];
|
||||
}
|
||||
const handleCancel = t4;
|
||||
let t5;
|
||||
if ($[15] !== context || $[16] !== handleCancel || $[17] !== onDone) {
|
||||
t5 = function handleSelect(value) {
|
||||
if (value === "upgrade") {
|
||||
logEvent("tengu_rate_limit_options_menu_select_upgrade", {});
|
||||
upgradeCall(onDone, context).then(jsx => {
|
||||
if (jsx) {
|
||||
setSubCommandJSX(jsx);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (value === "extra-usage") {
|
||||
logEvent("tengu_rate_limit_options_menu_select_extra_usage", {});
|
||||
extraUsageCall(onDone, context).then(jsx_0 => {
|
||||
if (jsx_0) {
|
||||
setSubCommandJSX(jsx_0);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (value === "cancel") {
|
||||
handleCancel();
|
||||
}
|
||||
|
||||
function handleSelect(value: RateLimitOptionsMenuOptionType): void {
|
||||
if (value === 'upgrade') {
|
||||
logEvent('tengu_rate_limit_options_menu_select_upgrade', {})
|
||||
void upgradeCall(onDone, context).then(jsx => {
|
||||
if (jsx) {
|
||||
setSubCommandJSX(jsx)
|
||||
}
|
||||
}
|
||||
};
|
||||
$[15] = context;
|
||||
$[16] = handleCancel;
|
||||
$[17] = onDone;
|
||||
$[18] = t5;
|
||||
} else {
|
||||
t5 = $[18];
|
||||
})
|
||||
} else if (value === 'extra-usage') {
|
||||
logEvent('tengu_rate_limit_options_menu_select_extra_usage', {})
|
||||
void extraUsageCall(onDone, context).then(jsx => {
|
||||
if (jsx) {
|
||||
setSubCommandJSX(jsx)
|
||||
}
|
||||
})
|
||||
} else if (value === 'cancel') {
|
||||
handleCancel()
|
||||
}
|
||||
}
|
||||
const handleSelect = t5;
|
||||
|
||||
if (subCommandJSX) {
|
||||
return subCommandJSX;
|
||||
return subCommandJSX
|
||||
}
|
||||
let t6;
|
||||
if ($[19] !== handleSelect || $[20] !== options) {
|
||||
t6 = <Select options={options} onChange={handleSelect} visibleOptionCount={options.length} />;
|
||||
$[19] = handleSelect;
|
||||
$[20] = options;
|
||||
$[21] = t6;
|
||||
} else {
|
||||
t6 = $[21];
|
||||
}
|
||||
let t7;
|
||||
if ($[22] !== handleCancel || $[23] !== t6) {
|
||||
t7 = <Dialog title="What do you want to do?" onCancel={handleCancel} color="suggestion">{t6}</Dialog>;
|
||||
$[22] = handleCancel;
|
||||
$[23] = t6;
|
||||
$[24] = t7;
|
||||
} else {
|
||||
t7 = $[24];
|
||||
}
|
||||
return t7;
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
title="What do you want to do?"
|
||||
onCancel={handleCancel}
|
||||
color="suggestion"
|
||||
>
|
||||
<Select<RateLimitOptionsMenuOptionType>
|
||||
options={options}
|
||||
onChange={handleSelect}
|
||||
visibleOptionCount={options.length}
|
||||
/>
|
||||
</Dialog>
|
||||
)
|
||||
}
|
||||
export async function call(onDone: LocalJSXCommandOnDone, context: ToolUseContext & LocalJSXCommandContext): Promise<React.ReactNode> {
|
||||
return <RateLimitOptionsMenu onDone={onDone} context={context} />;
|
||||
|
||||
export async function call(
|
||||
onDone: LocalJSXCommandOnDone,
|
||||
context: ToolUseContext & LocalJSXCommandContext,
|
||||
): Promise<React.ReactNode> {
|
||||
return <RateLimitOptionsMenu onDone={onDone} context={context} />
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user