@umsai/ums-code 0.5.0-v1 → 0.6.0-v1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/package.json +4 -4
- package/dist/src/acp-integration/acp.d.ts +6 -0
- package/dist/src/acp-integration/acp.js +7 -0
- package/dist/src/acp-integration/acp.js.map +1 -1
- package/dist/src/acp-integration/acpAgent.js +33 -7
- package/dist/src/acp-integration/acpAgent.js.map +1 -1
- package/dist/src/acp-integration/schema.d.ts +1235 -892
- package/dist/src/acp-integration/schema.js +19 -0
- package/dist/src/acp-integration/schema.js.map +1 -1
- package/dist/src/acp-integration/session/Session.d.ts +0 -5
- package/dist/src/acp-integration/session/Session.js +94 -15
- package/dist/src/acp-integration/session/Session.js.map +1 -1
- package/dist/src/commandMode.d.ts +11 -0
- package/dist/src/commandMode.js +238 -0
- package/dist/src/commandMode.js.map +1 -0
- package/dist/src/config/auth.js +26 -0
- package/dist/src/config/auth.js.map +1 -1
- package/dist/src/config/config.d.ts +8 -0
- package/dist/src/config/config.js +96 -21
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/extensions/update.test.js +9 -0
- package/dist/src/config/extensions/update.test.js.map +1 -1
- package/dist/src/config/settingsSchema.d.ts +41 -2
- package/dist/src/config/settingsSchema.js +36 -2
- package/dist/src/config/settingsSchema.js.map +1 -1
- package/dist/src/core/initializer.js +3 -0
- package/dist/src/core/initializer.js.map +1 -1
- package/dist/src/gemini.js +39 -19
- package/dist/src/gemini.js.map +1 -1
- package/dist/src/gemini.test.js +30 -4
- package/dist/src/gemini.test.js.map +1 -1
- package/dist/src/generated/git-commit.d.ts +3 -3
- package/dist/src/generated/git-commit.js +3 -3
- package/dist/src/i18n/index.d.ts +10 -2
- package/dist/src/i18n/index.js +22 -1
- package/dist/src/i18n/index.js.map +1 -1
- package/dist/src/i18n/languages.d.ts +20 -0
- package/dist/src/i18n/languages.js +36 -0
- package/dist/src/i18n/languages.js.map +1 -0
- package/dist/src/i18n/locales/de.js +1073 -0
- package/dist/src/i18n/locales/en.js +120 -162
- package/dist/src/i18n/locales/ru.js +125 -151
- package/dist/src/i18n/locales/zh.js +51 -164
- package/dist/src/nonInteractive/control/controllers/systemController.d.ts +1 -1
- package/dist/src/nonInteractive/control/controllers/systemController.js +5 -10
- package/dist/src/nonInteractive/control/controllers/systemController.js.map +1 -1
- package/dist/src/nonInteractive/io/BaseJsonOutputAdapter.js +11 -4
- package/dist/src/nonInteractive/io/BaseJsonOutputAdapter.js.map +1 -1
- package/dist/src/nonInteractive/io/BaseJsonOutputAdapter.test.js +40 -0
- package/dist/src/nonInteractive/io/BaseJsonOutputAdapter.test.js.map +1 -1
- package/dist/src/nonInteractive/io/StreamJsonOutputAdapter.test.js +50 -0
- package/dist/src/nonInteractive/io/StreamJsonOutputAdapter.test.js.map +1 -1
- package/dist/src/nonInteractiveCli.js +104 -18
- package/dist/src/nonInteractiveCli.js.map +1 -1
- package/dist/src/nonInteractiveCliCommands.d.ts +48 -9
- package/dist/src/nonInteractiveCliCommands.js +180 -64
- package/dist/src/nonInteractiveCliCommands.js.map +1 -1
- package/dist/src/{ui/hooks/useQuotaAndFallback.test.d.ts → nonInteractiveCliCommands.test.d.ts} +1 -1
- package/dist/src/nonInteractiveCliCommands.test.js +157 -0
- package/dist/src/nonInteractiveCliCommands.test.js.map +1 -0
- package/dist/src/services/BuiltinCommandLoader.js +2 -0
- package/dist/src/services/BuiltinCommandLoader.js.map +1 -1
- package/dist/src/services/McpPromptLoader.js +4 -2
- package/dist/src/services/McpPromptLoader.js.map +1 -1
- package/dist/src/services/McpPromptLoader.test.js +1 -1
- package/dist/src/services/McpPromptLoader.test.js.map +1 -1
- package/dist/src/ui/AppContainer.js +23 -20
- package/dist/src/ui/AppContainer.js.map +1 -1
- package/dist/src/ui/AppContainer.test.js +0 -46
- package/dist/src/ui/AppContainer.test.js.map +1 -1
- package/dist/src/ui/auth/AuthDialog.test.js +4 -4
- package/dist/src/ui/auth/AuthDialog.test.js.map +1 -1
- package/dist/src/ui/auth/useAuth.js +11 -3
- package/dist/src/ui/auth/useAuth.js.map +1 -1
- package/dist/src/ui/commands/approvalModeCommand.js +53 -4
- package/dist/src/ui/commands/approvalModeCommand.js.map +1 -1
- package/dist/src/ui/commands/approvalModeCommand.test.js +72 -10
- package/dist/src/ui/commands/approvalModeCommand.test.js.map +1 -1
- package/dist/src/ui/commands/compressCommand.js +86 -16
- package/dist/src/ui/commands/compressCommand.js.map +1 -1
- package/dist/src/ui/commands/languageCommand.d.ts +6 -1
- package/dist/src/ui/commands/languageCommand.js +162 -216
- package/dist/src/ui/commands/languageCommand.js.map +1 -1
- package/dist/src/ui/commands/languageCommand.test.js +105 -10
- package/dist/src/ui/commands/languageCommand.test.js.map +1 -1
- package/dist/src/ui/commands/restoreCommand.js +1 -1
- package/dist/src/ui/commands/restoreCommand.js.map +1 -1
- package/dist/src/ui/commands/resumeCommand.d.ts +7 -0
- package/dist/src/ui/commands/resumeCommand.js +19 -0
- package/dist/src/ui/commands/resumeCommand.js.map +1 -0
- package/dist/src/ui/{components/ProQuotaDialog.test.d.ts → commands/resumeCommand.test.d.ts} +1 -1
- package/dist/src/ui/commands/resumeCommand.test.js +32 -0
- package/dist/src/ui/commands/resumeCommand.test.js.map +1 -0
- package/dist/src/ui/commands/reviewCommand.js +871 -92
- package/dist/src/ui/commands/reviewCommand.js.map +1 -1
- package/dist/src/ui/commands/reviewCommand.test.js +55 -0
- package/dist/src/ui/commands/reviewCommand.test.js.map +1 -1
- package/dist/src/ui/commands/summaryCommand.js +129 -42
- package/dist/src/ui/commands/summaryCommand.js.map +1 -1
- package/dist/src/ui/commands/types.d.ts +21 -2
- package/dist/src/ui/commands/types.js.map +1 -1
- package/dist/src/ui/components/DialogManager.js +4 -4
- package/dist/src/ui/components/DialogManager.js.map +1 -1
- package/dist/src/ui/components/HistoryItemDisplay.test.js +5 -2
- package/dist/src/ui/components/HistoryItemDisplay.test.js.map +1 -1
- package/dist/src/ui/components/PermissionsModifyTrustDialog.js +1 -1
- package/dist/src/ui/components/PermissionsModifyTrustDialog.js.map +1 -1
- package/dist/src/ui/components/SessionPicker.d.ts +18 -0
- package/dist/src/ui/components/SessionPicker.js +69 -0
- package/dist/src/ui/components/SessionPicker.js.map +1 -0
- package/dist/src/ui/components/SessionSummaryDisplay.js +6 -2
- package/dist/src/ui/components/SessionSummaryDisplay.js.map +1 -1
- package/dist/src/ui/components/{ResumeSessionPicker.d.ts → StandaloneSessionPicker.d.ts} +1 -1
- package/dist/src/ui/components/StandaloneSessionPicker.js +78 -0
- package/dist/src/ui/components/StandaloneSessionPicker.js.map +1 -0
- package/dist/src/ui/components/StandaloneSessionPicker.test.d.ts +6 -0
- package/dist/src/ui/components/StandaloneSessionPicker.test.js +410 -0
- package/dist/src/ui/components/StandaloneSessionPicker.test.js.map +1 -0
- package/dist/src/ui/components/ums/UMSKeyPrompt.js +1 -1
- package/dist/src/ui/components/ums/UMSKeyPrompt.js.map +1 -1
- package/dist/src/ui/contexts/UIActionsContext.d.ts +3 -1
- package/dist/src/ui/contexts/UIActionsContext.js.map +1 -1
- package/dist/src/ui/contexts/UIStateContext.d.ts +2 -8
- package/dist/src/ui/contexts/UIStateContext.js.map +1 -1
- package/dist/src/ui/hooks/slashCommandProcessor.d.ts +1 -0
- package/dist/src/ui/hooks/slashCommandProcessor.js +9 -0
- package/dist/src/ui/hooks/slashCommandProcessor.js.map +1 -1
- package/dist/src/ui/hooks/useGeminiStream.js +46 -11
- package/dist/src/ui/hooks/useGeminiStream.js.map +1 -1
- package/dist/src/ui/hooks/useLoadingIndicator.test.js +11 -6
- package/dist/src/ui/hooks/useLoadingIndicator.test.js.map +1 -1
- package/dist/src/ui/hooks/usePhraseCycler.js +12 -136
- package/dist/src/ui/hooks/usePhraseCycler.js.map +1 -1
- package/dist/src/ui/hooks/useQwenAuth.test.js +1 -1
- package/dist/src/ui/hooks/useQwenAuth.test.js.map +1 -1
- package/dist/src/ui/hooks/useResumeCommand.d.ts +20 -0
- package/dist/src/ui/hooks/useResumeCommand.js +49 -0
- package/dist/src/ui/hooks/useResumeCommand.js.map +1 -0
- package/dist/src/ui/hooks/useResumeCommand.test.d.ts +6 -0
- package/dist/src/ui/hooks/useResumeCommand.test.js +144 -0
- package/dist/src/ui/hooks/useResumeCommand.test.js.map +1 -0
- package/dist/src/ui/hooks/useSessionPicker.d.ts +36 -0
- package/dist/src/ui/hooks/useSessionPicker.js +189 -0
- package/dist/src/ui/hooks/useSessionPicker.js.map +1 -0
- package/dist/src/ui/hooks/useToolScheduler.test.js +1 -1
- package/dist/src/ui/models/availableModels.d.ts +1 -0
- package/dist/src/ui/models/availableModels.js +8 -0
- package/dist/src/ui/models/availableModels.js.map +1 -1
- package/dist/src/ui/utils/resumeHistoryUtils.js +5 -1
- package/dist/src/ui/utils/resumeHistoryUtils.js.map +1 -1
- package/dist/src/ui/utils/resumeHistoryUtils.test.js +5 -0
- package/dist/src/ui/utils/resumeHistoryUtils.test.js.map +1 -1
- package/dist/src/ui/utils/sessionPickerUtils.d.ts +30 -0
- package/dist/src/ui/utils/sessionPickerUtils.js +41 -0
- package/dist/src/ui/utils/sessionPickerUtils.js.map +1 -0
- package/dist/src/ui/utils/sessionPickerUtils.test.d.ts +6 -0
- package/dist/src/ui/utils/sessionPickerUtils.test.js +38 -0
- package/dist/src/ui/utils/sessionPickerUtils.test.js.map +1 -0
- package/dist/src/utils/errors.d.ts +1 -1
- package/dist/src/utils/errors.js +14 -3
- package/dist/src/utils/errors.js.map +1 -1
- package/dist/src/utils/errors.test.js +43 -1
- package/dist/src/utils/errors.test.js.map +1 -1
- package/dist/src/utils/gitUtils.js +22 -5
- package/dist/src/utils/gitUtils.js.map +1 -1
- package/dist/src/utils/gitUtils.test.js +59 -0
- package/dist/src/utils/gitUtils.test.js.map +1 -1
- package/dist/src/utils/nonInteractiveHelpers.d.ts +3 -1
- package/dist/src/utils/nonInteractiveHelpers.js +13 -14
- package/dist/src/utils/nonInteractiveHelpers.js.map +1 -1
- package/dist/src/utils/nonInteractiveHelpers.test.js +35 -20
- package/dist/src/utils/nonInteractiveHelpers.test.js.map +1 -1
- package/dist/src/utils/relaunch.js +2 -2
- package/dist/src/utils/relaunch.js.map +1 -1
- package/dist/src/utils/relaunch.test.js +5 -5
- package/dist/src/utils/relaunch.test.js.map +1 -1
- package/dist/src/utils/systemInfo.js +2 -1
- package/dist/src/utils/systemInfo.js.map +1 -1
- package/dist/src/validateNonInterActiveAuth.js +9 -0
- package/dist/src/validateNonInterActiveAuth.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/dist/src/ui/components/ProQuotaDialog.d.ts +0 -13
- package/dist/src/ui/components/ProQuotaDialog.js +0 -24
- package/dist/src/ui/components/ProQuotaDialog.js.map +0 -1
- package/dist/src/ui/components/ProQuotaDialog.test.js +0 -58
- package/dist/src/ui/components/ProQuotaDialog.test.js.map +0 -1
- package/dist/src/ui/components/ResumeSessionPicker.js +0 -249
- package/dist/src/ui/components/ResumeSessionPicker.js.map +0 -1
- package/dist/src/ui/hooks/useQuotaAndFallback.d.ts +0 -21
- package/dist/src/ui/hooks/useQuotaAndFallback.js +0 -122
- package/dist/src/ui/hooks/useQuotaAndFallback.js.map +0 -1
- package/dist/src/ui/hooks/useQuotaAndFallback.test.js +0 -269
- package/dist/src/ui/hooks/useQuotaAndFallback.test.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umsai/ums-code",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0-v1",
|
|
4
4
|
"description": "UMS Code CLI",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -36,14 +36,14 @@
|
|
|
36
36
|
"dist"
|
|
37
37
|
],
|
|
38
38
|
"config": {
|
|
39
|
-
"sandboxImageUri": "ghcr.io/qwenlm/qwen-code:0.
|
|
39
|
+
"sandboxImageUri": "ghcr.io/qwenlm/qwen-code:0.6.0"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@google/genai": "1.
|
|
42
|
+
"@google/genai": "1.30.0",
|
|
43
43
|
"@iarna/toml": "^2.2.5",
|
|
44
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
44
|
+
"@modelcontextprotocol/sdk": "^1.25.1",
|
|
45
45
|
"@types/update-notifier": "^6.0.8",
|
|
46
|
-
"@umsai/ums-code-core": "0.
|
|
46
|
+
"@umsai/ums-code-core": "0.6.0-v1",
|
|
47
47
|
"ansi-regex": "^6.2.2",
|
|
48
48
|
"command-exists": "^1.2.9",
|
|
49
49
|
"comment-json": "^4.2.5",
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
import type React from 'react';
|
|
7
|
-
interface ProQuotaDialogProps {
|
|
8
|
-
failedModel: string;
|
|
9
|
-
fallbackModel: string;
|
|
10
|
-
onChoice: (choice: 'auth' | 'continue') => void;
|
|
11
|
-
}
|
|
12
|
-
export declare function ProQuotaDialog({ failedModel, fallbackModel, onChoice, }: ProQuotaDialogProps): React.JSX.Element;
|
|
13
|
-
export {};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Box, Text } from 'ink';
|
|
3
|
-
import { RadioButtonSelect } from './shared/RadioButtonSelect.js';
|
|
4
|
-
import { theme } from '../semantic-colors.js';
|
|
5
|
-
import { t } from '../../i18n/index.js';
|
|
6
|
-
export function ProQuotaDialog({ failedModel, fallbackModel, onChoice, }) {
|
|
7
|
-
const items = [
|
|
8
|
-
{
|
|
9
|
-
label: t('Change auth (executes the /auth command)'),
|
|
10
|
-
value: 'auth',
|
|
11
|
-
key: 'auth',
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
label: t('Continue with {{model}}', { model: fallbackModel }),
|
|
15
|
-
value: 'continue',
|
|
16
|
-
key: 'continue',
|
|
17
|
-
},
|
|
18
|
-
];
|
|
19
|
-
const handleSelect = (choice) => {
|
|
20
|
-
onChoice(choice);
|
|
21
|
-
};
|
|
22
|
-
return (_jsxs(Box, { borderStyle: "round", flexDirection: "column", paddingX: 1, children: [_jsx(Text, { bold: true, color: theme.status.warning, children: t('Pro quota limit reached for {{model}}.', { model: failedModel }) }), _jsx(Box, { marginTop: 1, children: _jsx(RadioButtonSelect, { items: items, initialIndex: 1, onSelect: handleSelect }) })] }));
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=ProQuotaDialog.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ProQuotaDialog.js","sourceRoot":"","sources":["../../../../src/ui/components/ProQuotaDialog.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAC;AAQxC,MAAM,UAAU,cAAc,CAAC,EAC7B,WAAW,EACX,aAAa,EACb,QAAQ,GACY;IACpB,MAAM,KAAK,GAAG;QACZ;YACE,KAAK,EAAE,CAAC,CAAC,0CAA0C,CAAC;YACpD,KAAK,EAAE,MAAe;YACtB,GAAG,EAAE,MAAM;SACZ;QACD;YACE,KAAK,EAAE,CAAC,CAAC,yBAAyB,EAAE,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC;YAC7D,KAAK,EAAE,UAAmB;YAC1B,GAAG,EAAE,UAAU;SAChB;KACF,CAAC;IAEF,MAAM,YAAY,GAAG,CAAC,MAA2B,EAAE,EAAE;QACnD,QAAQ,CAAC,MAAM,CAAC,CAAC;IACnB,CAAC,CAAC;IAEF,OAAO,CACL,MAAC,GAAG,IAAC,WAAW,EAAC,OAAO,EAAC,aAAa,EAAC,QAAQ,EAAC,QAAQ,EAAE,CAAC,aACzD,KAAC,IAAI,IAAC,IAAI,QAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,YACnC,CAAC,CAAC,wCAAwC,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,GAC/D,EACP,KAAC,GAAG,IAAC,SAAS,EAAE,CAAC,YACf,KAAC,iBAAiB,IAChB,KAAK,EAAE,KAAK,EACZ,YAAY,EAAE,CAAC,EACf,QAAQ,EAAE,YAAY,GACtB,GACE,IACF,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/**
|
|
3
|
-
* @license
|
|
4
|
-
* Copyright 2025 Google LLC
|
|
5
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
6
|
-
*/
|
|
7
|
-
import { render } from 'ink-testing-library';
|
|
8
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
9
|
-
import { ProQuotaDialog } from './ProQuotaDialog.js';
|
|
10
|
-
import { RadioButtonSelect } from './shared/RadioButtonSelect.js';
|
|
11
|
-
// Mock the child component to make it easier to test the parent
|
|
12
|
-
vi.mock('./shared/RadioButtonSelect.js', () => ({
|
|
13
|
-
RadioButtonSelect: vi.fn(),
|
|
14
|
-
}));
|
|
15
|
-
describe('ProQuotaDialog', () => {
|
|
16
|
-
beforeEach(() => {
|
|
17
|
-
vi.clearAllMocks();
|
|
18
|
-
});
|
|
19
|
-
it('should render with correct title and options', () => {
|
|
20
|
-
const { lastFrame } = render(_jsx(ProQuotaDialog, { failedModel: "gemini-2.5-pro", fallbackModel: "gemini-2.5-flash", onChoice: () => { } }));
|
|
21
|
-
const output = lastFrame();
|
|
22
|
-
expect(output).toContain('Pro quota limit reached for gemini-2.5-pro.');
|
|
23
|
-
// Check that RadioButtonSelect was called with the correct items
|
|
24
|
-
expect(RadioButtonSelect).toHaveBeenCalledWith(expect.objectContaining({
|
|
25
|
-
items: [
|
|
26
|
-
{
|
|
27
|
-
label: 'Change auth (executes the /auth command)',
|
|
28
|
-
value: 'auth',
|
|
29
|
-
key: 'auth',
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
label: `Continue with gemini-2.5-flash`,
|
|
33
|
-
value: 'continue',
|
|
34
|
-
key: 'continue',
|
|
35
|
-
},
|
|
36
|
-
],
|
|
37
|
-
}), undefined);
|
|
38
|
-
});
|
|
39
|
-
it('should call onChoice with "auth" when "Change auth" is selected', () => {
|
|
40
|
-
const mockOnChoice = vi.fn();
|
|
41
|
-
render(_jsx(ProQuotaDialog, { failedModel: "gemini-2.5-pro", fallbackModel: "gemini-2.5-flash", onChoice: mockOnChoice }));
|
|
42
|
-
// Get the onSelect function passed to RadioButtonSelect
|
|
43
|
-
const onSelect = RadioButtonSelect.mock.calls[0][0].onSelect;
|
|
44
|
-
// Simulate the selection
|
|
45
|
-
onSelect('auth');
|
|
46
|
-
expect(mockOnChoice).toHaveBeenCalledWith('auth');
|
|
47
|
-
});
|
|
48
|
-
it('should call onChoice with "continue" when "Continue with flash" is selected', () => {
|
|
49
|
-
const mockOnChoice = vi.fn();
|
|
50
|
-
render(_jsx(ProQuotaDialog, { failedModel: "gemini-2.5-pro", fallbackModel: "gemini-2.5-flash", onChoice: mockOnChoice }));
|
|
51
|
-
// Get the onSelect function passed to RadioButtonSelect
|
|
52
|
-
const onSelect = RadioButtonSelect.mock.calls[0][0].onSelect;
|
|
53
|
-
// Simulate the selection
|
|
54
|
-
onSelect('continue');
|
|
55
|
-
expect(mockOnChoice).toHaveBeenCalledWith('continue');
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
//# sourceMappingURL=ProQuotaDialog.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ProQuotaDialog.test.js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
|
-
* Copyright 2025 UMS Code
|
|
5
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
6
|
-
*/
|
|
7
|
-
import { useState, useEffect, useCallback, useRef } from 'react';
|
|
8
|
-
import { render, Box, Text, useInput, useApp } from 'ink';
|
|
9
|
-
import { SessionService, getGitBranch, } from '@umsai/ums-code-core';
|
|
10
|
-
import { theme } from '../semantic-colors.js';
|
|
11
|
-
import { formatRelativeTime } from '../utils/formatters.js';
|
|
12
|
-
const PAGE_SIZE = 20;
|
|
13
|
-
/**
|
|
14
|
-
* Truncates text to fit within a given width, adding ellipsis if needed.
|
|
15
|
-
*/
|
|
16
|
-
function truncateText(text, maxWidth) {
|
|
17
|
-
if (text.length <= maxWidth)
|
|
18
|
-
return text;
|
|
19
|
-
if (maxWidth <= 3)
|
|
20
|
-
return text.slice(0, maxWidth);
|
|
21
|
-
return text.slice(0, maxWidth - 3) + '...';
|
|
22
|
-
}
|
|
23
|
-
function SessionPicker({ sessionService, currentBranch, onSelect, onCancel, }) {
|
|
24
|
-
const { exit } = useApp();
|
|
25
|
-
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
26
|
-
const [sessionState, setSessionState] = useState({
|
|
27
|
-
sessions: [],
|
|
28
|
-
hasMore: true,
|
|
29
|
-
nextCursor: undefined,
|
|
30
|
-
});
|
|
31
|
-
const isLoadingMoreRef = useRef(false);
|
|
32
|
-
const [filterByBranch, setFilterByBranch] = useState(false);
|
|
33
|
-
const [isExiting, setIsExiting] = useState(false);
|
|
34
|
-
const [terminalSize, setTerminalSize] = useState({
|
|
35
|
-
width: process.stdout.columns || 80,
|
|
36
|
-
height: process.stdout.rows || 24,
|
|
37
|
-
});
|
|
38
|
-
// Update terminal size on resize
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
const handleResize = () => {
|
|
41
|
-
setTerminalSize({
|
|
42
|
-
width: process.stdout.columns || 80,
|
|
43
|
-
height: process.stdout.rows || 24,
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
|
-
process.stdout.on('resize', handleResize);
|
|
47
|
-
return () => {
|
|
48
|
-
process.stdout.off('resize', handleResize);
|
|
49
|
-
};
|
|
50
|
-
}, []);
|
|
51
|
-
// Filter sessions by current branch if filter is enabled
|
|
52
|
-
const filteredSessions = filterByBranch && currentBranch
|
|
53
|
-
? sessionState.sessions.filter((session) => session.gitBranch === currentBranch)
|
|
54
|
-
: sessionState.sessions;
|
|
55
|
-
const hasSentinel = sessionState.hasMore;
|
|
56
|
-
// Reset selection when filter changes
|
|
57
|
-
useEffect(() => {
|
|
58
|
-
setSelectedIndex(0);
|
|
59
|
-
}, [filterByBranch]);
|
|
60
|
-
const loadMoreSessions = useCallback(async () => {
|
|
61
|
-
if (!sessionState.hasMore || isLoadingMoreRef.current)
|
|
62
|
-
return;
|
|
63
|
-
isLoadingMoreRef.current = true;
|
|
64
|
-
try {
|
|
65
|
-
const result = await sessionService.listSessions({
|
|
66
|
-
size: PAGE_SIZE,
|
|
67
|
-
cursor: sessionState.nextCursor,
|
|
68
|
-
});
|
|
69
|
-
setSessionState((prev) => ({
|
|
70
|
-
sessions: [...prev.sessions, ...result.items],
|
|
71
|
-
hasMore: result.hasMore && result.nextCursor !== undefined,
|
|
72
|
-
nextCursor: result.nextCursor,
|
|
73
|
-
}));
|
|
74
|
-
}
|
|
75
|
-
finally {
|
|
76
|
-
isLoadingMoreRef.current = false;
|
|
77
|
-
}
|
|
78
|
-
}, [sessionService, sessionState.hasMore, sessionState.nextCursor]);
|
|
79
|
-
// Calculate visible items
|
|
80
|
-
// Reserved space: header (1), footer (1), separators (2), borders (2)
|
|
81
|
-
const reservedLines = 6;
|
|
82
|
-
// Each item takes 2 lines (prompt + metadata) + 1 line margin between items
|
|
83
|
-
// On average, this is ~3 lines per item, but the last item has no margin
|
|
84
|
-
const itemHeight = 3;
|
|
85
|
-
const maxVisibleItems = Math.max(1, Math.floor((terminalSize.height - reservedLines) / itemHeight));
|
|
86
|
-
// Calculate scroll offset
|
|
87
|
-
const scrollOffset = (() => {
|
|
88
|
-
if (filteredSessions.length <= maxVisibleItems)
|
|
89
|
-
return 0;
|
|
90
|
-
const halfVisible = Math.floor(maxVisibleItems / 2);
|
|
91
|
-
let offset = selectedIndex - halfVisible;
|
|
92
|
-
offset = Math.max(0, offset);
|
|
93
|
-
offset = Math.min(filteredSessions.length - maxVisibleItems, offset);
|
|
94
|
-
return offset;
|
|
95
|
-
})();
|
|
96
|
-
const visibleSessions = filteredSessions.slice(scrollOffset, scrollOffset + maxVisibleItems);
|
|
97
|
-
const showScrollUp = scrollOffset > 0;
|
|
98
|
-
const showScrollDown = scrollOffset + maxVisibleItems < filteredSessions.length;
|
|
99
|
-
// Sentinel (invisible) sits after the last session item; consider it visible
|
|
100
|
-
// once the viewport reaches the final real item.
|
|
101
|
-
const sentinelVisible = hasSentinel && scrollOffset + maxVisibleItems >= filteredSessions.length;
|
|
102
|
-
// Load more when sentinel enters view or when filtered list is empty.
|
|
103
|
-
useEffect(() => {
|
|
104
|
-
if (!sessionState.hasMore || isLoadingMoreRef.current)
|
|
105
|
-
return;
|
|
106
|
-
const shouldLoadMore = filteredSessions.length === 0 ||
|
|
107
|
-
sentinelVisible ||
|
|
108
|
-
isLoadingMoreRef.current;
|
|
109
|
-
if (shouldLoadMore) {
|
|
110
|
-
void loadMoreSessions();
|
|
111
|
-
}
|
|
112
|
-
}, [
|
|
113
|
-
filteredSessions.length,
|
|
114
|
-
loadMoreSessions,
|
|
115
|
-
sessionState.hasMore,
|
|
116
|
-
sentinelVisible,
|
|
117
|
-
]);
|
|
118
|
-
// Handle keyboard input
|
|
119
|
-
useInput((input, key) => {
|
|
120
|
-
// Ignore input if already exiting
|
|
121
|
-
if (isExiting) {
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
// Escape or Ctrl+C to cancel
|
|
125
|
-
if (key.escape || (key.ctrl && input === 'c')) {
|
|
126
|
-
setIsExiting(true);
|
|
127
|
-
onCancel();
|
|
128
|
-
exit();
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
if (key.return) {
|
|
132
|
-
const session = filteredSessions[selectedIndex];
|
|
133
|
-
if (session) {
|
|
134
|
-
setIsExiting(true);
|
|
135
|
-
onSelect(session.sessionId);
|
|
136
|
-
exit();
|
|
137
|
-
}
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
if (key.upArrow || input === 'k') {
|
|
141
|
-
setSelectedIndex((prev) => Math.max(0, prev - 1));
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
if (key.downArrow || input === 'j') {
|
|
145
|
-
if (filteredSessions.length === 0) {
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
setSelectedIndex((prev) => Math.min(filteredSessions.length - 1, prev + 1));
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
if (input === 'b' || input === 'B') {
|
|
152
|
-
if (currentBranch) {
|
|
153
|
-
setFilterByBranch((prev) => !prev);
|
|
154
|
-
}
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
// Filtered sessions may have changed, ensure selectedIndex is valid
|
|
159
|
-
useEffect(() => {
|
|
160
|
-
if (selectedIndex >= filteredSessions.length &&
|
|
161
|
-
filteredSessions.length > 0) {
|
|
162
|
-
setSelectedIndex(filteredSessions.length - 1);
|
|
163
|
-
}
|
|
164
|
-
}, [filteredSessions.length, selectedIndex]);
|
|
165
|
-
// Calculate content width (terminal width minus border padding)
|
|
166
|
-
const contentWidth = terminalSize.width - 4;
|
|
167
|
-
const promptMaxWidth = contentWidth - 4; // Account for "› " prefix
|
|
168
|
-
// Return empty while exiting to prevent visual glitches
|
|
169
|
-
if (isExiting) {
|
|
170
|
-
return _jsx(Box, {});
|
|
171
|
-
}
|
|
172
|
-
return (_jsx(Box, { flexDirection: "column", width: terminalSize.width, height: terminalSize.height - 1, overflow: "hidden", children: _jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: theme.border.default, width: terminalSize.width, height: terminalSize.height - 1, overflow: "hidden", children: [_jsx(Box, { paddingX: 1, children: _jsx(Text, { bold: true, color: theme.text.primary, children: "Resume Session" }) }), _jsx(Box, { children: _jsx(Text, { color: theme.border.default, children: '─'.repeat(terminalSize.width - 2) }) }), _jsx(Box, { flexDirection: "column", flexGrow: 1, paddingX: 1, overflow: "hidden", children: filteredSessions.length === 0 ? (_jsx(Box, { paddingY: 1, justifyContent: "center", children: _jsx(Text, { color: theme.text.secondary, children: filterByBranch
|
|
173
|
-
? `No sessions found for branch "${currentBranch}"`
|
|
174
|
-
: 'No sessions found' }) })) : (visibleSessions.map((session, visibleIndex) => {
|
|
175
|
-
const actualIndex = scrollOffset + visibleIndex;
|
|
176
|
-
const isSelected = actualIndex === selectedIndex;
|
|
177
|
-
const isFirst = visibleIndex === 0;
|
|
178
|
-
const isLast = visibleIndex === visibleSessions.length - 1;
|
|
179
|
-
const timeAgo = formatRelativeTime(session.mtime);
|
|
180
|
-
const messageText = session.messageCount === 1
|
|
181
|
-
? '1 message'
|
|
182
|
-
: `${session.messageCount} messages`;
|
|
183
|
-
// Show scroll indicator on first/last visible items
|
|
184
|
-
const showUpIndicator = isFirst && showScrollUp;
|
|
185
|
-
const showDownIndicator = isLast && showScrollDown;
|
|
186
|
-
// Determine the prefix: selector takes priority over scroll indicator
|
|
187
|
-
const prefix = isSelected
|
|
188
|
-
? '› '
|
|
189
|
-
: showUpIndicator
|
|
190
|
-
? '↑ '
|
|
191
|
-
: showDownIndicator
|
|
192
|
-
? '↓ '
|
|
193
|
-
: ' ';
|
|
194
|
-
return (_jsxs(Box, { flexDirection: "column", marginBottom: isLast ? 0 : 1, children: [_jsxs(Box, { children: [_jsx(Text, { color: isSelected
|
|
195
|
-
? theme.text.accent
|
|
196
|
-
: showUpIndicator || showDownIndicator
|
|
197
|
-
? theme.text.secondary
|
|
198
|
-
: undefined, children: prefix }), _jsx(Text, { bold: isSelected, color: isSelected ? theme.text.accent : theme.text.primary, children: truncateText(session.prompt || '(empty prompt)', promptMaxWidth) })] }), _jsxs(Box, { children: [_jsx(Text, { children: ' ' }), _jsxs(Text, { color: theme.text.secondary, children: [timeAgo, " \u00B7 ", messageText, session.gitBranch && ` · ${session.gitBranch}`] })] })] }, session.sessionId));
|
|
199
|
-
})) }), _jsx(Box, { children: _jsx(Text, { color: theme.border.default, children: '─'.repeat(terminalSize.width - 2) }) }), _jsx(Box, { paddingX: 1, children: _jsxs(Text, { color: theme.text.secondary, children: [currentBranch && (_jsxs(_Fragment, { children: [_jsx(Text, { bold: filterByBranch, color: filterByBranch ? theme.text.accent : undefined, children: "B" }), ' to toggle branch · '] })), '↑↓ to navigate · Esc to cancel'] }) })] }) }));
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Clears the terminal screen.
|
|
203
|
-
*/
|
|
204
|
-
function clearScreen() {
|
|
205
|
-
// Move cursor to home position and clear screen
|
|
206
|
-
process.stdout.write('\x1b[2J\x1b[H');
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Shows an interactive session picker and returns the selected session ID.
|
|
210
|
-
* Returns undefined if the user cancels or no sessions are available.
|
|
211
|
-
*/
|
|
212
|
-
export async function showResumeSessionPicker(cwd = process.cwd()) {
|
|
213
|
-
const sessionService = new SessionService(cwd);
|
|
214
|
-
const hasSession = await sessionService.loadLastSession();
|
|
215
|
-
if (!hasSession) {
|
|
216
|
-
console.log('No sessions found. Start a new session with `qwen`.');
|
|
217
|
-
return undefined;
|
|
218
|
-
}
|
|
219
|
-
const currentBranch = getGitBranch(cwd);
|
|
220
|
-
// Clear the screen before showing the picker for a clean fullscreen experience
|
|
221
|
-
clearScreen();
|
|
222
|
-
// Enable raw mode for keyboard input if not already enabled
|
|
223
|
-
const wasRaw = process.stdin.isRaw;
|
|
224
|
-
if (process.stdin.isTTY && !wasRaw) {
|
|
225
|
-
process.stdin.setRawMode(true);
|
|
226
|
-
}
|
|
227
|
-
return new Promise((resolve) => {
|
|
228
|
-
let selectedId;
|
|
229
|
-
const { unmount, waitUntilExit } = render(_jsx(SessionPicker, { sessionService: sessionService, currentBranch: currentBranch, onSelect: (id) => {
|
|
230
|
-
selectedId = id;
|
|
231
|
-
}, onCancel: () => {
|
|
232
|
-
selectedId = undefined;
|
|
233
|
-
} }), {
|
|
234
|
-
exitOnCtrlC: false,
|
|
235
|
-
});
|
|
236
|
-
waitUntilExit().then(() => {
|
|
237
|
-
unmount();
|
|
238
|
-
// Clear the screen after the picker closes for a clean fullscreen experience
|
|
239
|
-
clearScreen();
|
|
240
|
-
// Restore raw mode state only if we changed it and user cancelled
|
|
241
|
-
// (if user selected a session, main app will handle raw mode)
|
|
242
|
-
if (process.stdin.isTTY && !wasRaw && !selectedId) {
|
|
243
|
-
process.stdin.setRawMode(false);
|
|
244
|
-
}
|
|
245
|
-
resolve(selectedId);
|
|
246
|
-
});
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
//# sourceMappingURL=ResumeSessionPicker.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ResumeSessionPicker.js","sourceRoot":"","sources":["../../../../src/ui/components/ResumeSessionPicker.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAC1D,OAAO,EACL,cAAc,EAGd,YAAY,GACb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,MAAM,SAAS,GAAG,EAAE,CAAC;AASrB;;GAEG;AACH,SAAS,YAAY,CAAC,IAAY,EAAE,QAAgB;IAClD,IAAI,IAAI,CAAC,MAAM,IAAI,QAAQ;QAAE,OAAO,IAAI,CAAC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
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
import { type Config, UserTierId } from '@umsai/ums-code-core';
|
|
7
|
-
import { type UseHistoryManagerReturn } from './useHistoryManager.js';
|
|
8
|
-
import { AuthState } from '../types.js';
|
|
9
|
-
import { type ProQuotaDialogRequest } from '../contexts/UIStateContext.js';
|
|
10
|
-
interface UseQuotaAndFallbackArgs {
|
|
11
|
-
config: Config;
|
|
12
|
-
historyManager: UseHistoryManagerReturn;
|
|
13
|
-
userTier: UserTierId | undefined;
|
|
14
|
-
setAuthState: (state: AuthState) => void;
|
|
15
|
-
setModelSwitchedFromQuotaError: (value: boolean) => void;
|
|
16
|
-
}
|
|
17
|
-
export declare function useQuotaAndFallback({ config, historyManager, userTier, setAuthState, setModelSwitchedFromQuotaError, }: UseQuotaAndFallbackArgs): {
|
|
18
|
-
proQuotaRequest: ProQuotaDialogRequest | null;
|
|
19
|
-
handleProQuotaChoice: (choice: "auth" | "continue") => void;
|
|
20
|
-
};
|
|
21
|
-
export {};
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
import { AuthType, isGenericQuotaExceededError, isProQuotaExceededError, UserTierId, } from '@umsai/ums-code-core';
|
|
7
|
-
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
8
|
-
import {} from './useHistoryManager.js';
|
|
9
|
-
import { AuthState, MessageType } from '../types.js';
|
|
10
|
-
import {} from '../contexts/UIStateContext.js';
|
|
11
|
-
export function useQuotaAndFallback({ config, historyManager, userTier, setAuthState, setModelSwitchedFromQuotaError, }) {
|
|
12
|
-
const [proQuotaRequest, setProQuotaRequest] = useState(null);
|
|
13
|
-
const isDialogPending = useRef(false);
|
|
14
|
-
// Set up Flash fallback handler
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
const fallbackHandler = async (failedModel, fallbackModel, error) => {
|
|
17
|
-
if (config.isInFallbackMode()) {
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
// Fallbacks are currently only handled for OAuth users.
|
|
21
|
-
const contentGeneratorConfig = config.getContentGeneratorConfig();
|
|
22
|
-
if (!contentGeneratorConfig ||
|
|
23
|
-
contentGeneratorConfig.authType !== AuthType.LOGIN_WITH_GOOGLE) {
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
// Use actual user tier if available; otherwise, default to FREE tier behavior (safe default)
|
|
27
|
-
const isPaidTier = userTier === UserTierId.LEGACY || userTier === UserTierId.STANDARD;
|
|
28
|
-
let message;
|
|
29
|
-
if (error && isProQuotaExceededError(error)) {
|
|
30
|
-
// Pro Quota specific messages (Interactive)
|
|
31
|
-
if (isPaidTier) {
|
|
32
|
-
message = `⚡ You have reached your daily ${failedModel} quota limit.
|
|
33
|
-
⚡ You can choose to authenticate with a paid API key or continue with the fallback model.
|
|
34
|
-
⚡ To continue accessing the ${failedModel} model today, consider using /auth to switch to using a paid API key from AI Studio at https://aistudio.google.com/apikey`;
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
message = `⚡ You have reached your daily ${failedModel} quota limit.
|
|
38
|
-
⚡ You can choose to authenticate with a paid API key or continue with the fallback model.
|
|
39
|
-
⚡ To increase your limits, upgrade to a Gemini Code Assist Standard or Enterprise plan with higher limits at https://goo.gle/set-up-gemini-code-assist
|
|
40
|
-
⚡ Or you can utilize a Gemini API Key. See: https://goo.gle/gemini-cli-docs-auth#gemini-api-key
|
|
41
|
-
⚡ You can switch authentication methods by typing /auth`;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
else if (error && isGenericQuotaExceededError(error)) {
|
|
45
|
-
// Generic Quota (Automatic fallback)
|
|
46
|
-
const actionMessage = `⚡ You have reached your daily quota limit.\n⚡ Automatically switching from ${failedModel} to ${fallbackModel} for the remainder of this session.`;
|
|
47
|
-
if (isPaidTier) {
|
|
48
|
-
message = `${actionMessage}
|
|
49
|
-
⚡ To continue accessing the ${failedModel} model today, consider using /auth to switch to using a paid API key from AI Studio at https://aistudio.google.com/apikey`;
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
message = `${actionMessage}
|
|
53
|
-
⚡ To increase your limits, upgrade to a Gemini Code Assist Standard or Enterprise plan with higher limits at https://goo.gle/set-up-gemini-code-assist
|
|
54
|
-
⚡ Or you can utilize a Gemini API Key. See: https://goo.gle/gemini-cli-docs-auth#gemini-api-key
|
|
55
|
-
⚡ You can switch authentication methods by typing /auth`;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
// Consecutive 429s or other errors (Automatic fallback)
|
|
60
|
-
const actionMessage = `⚡ Automatically switching from ${failedModel} to ${fallbackModel} for faster responses for the remainder of this session.`;
|
|
61
|
-
if (isPaidTier) {
|
|
62
|
-
message = `${actionMessage}
|
|
63
|
-
⚡ Possible reasons for this are that you have received multiple consecutive capacity errors or you have reached your daily ${failedModel} quota limit
|
|
64
|
-
⚡ To continue accessing the ${failedModel} model today, consider using /auth to switch to using a paid API key from AI Studio at https://aistudio.google.com/apikey`;
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
message = `${actionMessage}
|
|
68
|
-
⚡ Possible reasons for this are that you have received multiple consecutive capacity errors or you have reached your daily ${failedModel} quota limit
|
|
69
|
-
⚡ To increase your limits, upgrade to a Gemini Code Assist Standard or Enterprise plan with higher limits at https://goo.gle/set-up-gemini-code-assist
|
|
70
|
-
⚡ Or you can utilize a Gemini API Key. See: https://goo.gle/gemini-cli-docs-auth#gemini-api-key
|
|
71
|
-
⚡ You can switch authentication methods by typing /auth`;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
// Add message to UI history
|
|
75
|
-
historyManager.addItem({
|
|
76
|
-
type: MessageType.INFO,
|
|
77
|
-
text: message,
|
|
78
|
-
}, Date.now());
|
|
79
|
-
setModelSwitchedFromQuotaError(true);
|
|
80
|
-
config.setQuotaErrorOccurred(true);
|
|
81
|
-
// Interactive Fallback for Pro quota
|
|
82
|
-
if (error && isProQuotaExceededError(error)) {
|
|
83
|
-
if (isDialogPending.current) {
|
|
84
|
-
return 'stop'; // A dialog is already active, so just stop this request.
|
|
85
|
-
}
|
|
86
|
-
isDialogPending.current = true;
|
|
87
|
-
const intent = await new Promise((resolve) => {
|
|
88
|
-
setProQuotaRequest({
|
|
89
|
-
failedModel,
|
|
90
|
-
fallbackModel,
|
|
91
|
-
resolve,
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
return intent;
|
|
95
|
-
}
|
|
96
|
-
return 'stop';
|
|
97
|
-
};
|
|
98
|
-
config.setFallbackModelHandler(fallbackHandler);
|
|
99
|
-
}, [config, historyManager, userTier, setModelSwitchedFromQuotaError]);
|
|
100
|
-
const handleProQuotaChoice = useCallback((choice) => {
|
|
101
|
-
if (!proQuotaRequest)
|
|
102
|
-
return;
|
|
103
|
-
const intent = choice === 'auth' ? 'auth' : 'retry';
|
|
104
|
-
proQuotaRequest.resolve(intent);
|
|
105
|
-
setProQuotaRequest(null);
|
|
106
|
-
isDialogPending.current = false; // Reset the flag here
|
|
107
|
-
if (choice === 'auth') {
|
|
108
|
-
setAuthState(AuthState.Updating);
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
historyManager.addItem({
|
|
112
|
-
type: MessageType.INFO,
|
|
113
|
-
text: 'Switched to fallback model. Tip: Press Ctrl+P (or Up Arrow) to recall your previous prompt and submit it again if you wish.',
|
|
114
|
-
}, Date.now());
|
|
115
|
-
}
|
|
116
|
-
}, [proQuotaRequest, setAuthState, historyManager]);
|
|
117
|
-
return {
|
|
118
|
-
proQuotaRequest,
|
|
119
|
-
handleProQuotaChoice,
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
//# sourceMappingURL=useQuotaAndFallback.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useQuotaAndFall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