fix: restore plus mode toggle visibility control

This commit is contained in:
QLHazyCoder
2026-05-18 00:47:10 +08:00
parent 0c034c232d
commit 7564481868
4 changed files with 96 additions and 23 deletions
+1 -16
View File
@@ -294,28 +294,13 @@
label: 'Plus',
rowIds: [
'row-plus-mode',
'row-plus-payment-method',
'row-paypal-account',
'row-gpc-helper-api',
'row-gpc-helper-card-key',
'row-gpc-helper-phone-mode',
'row-gpc-helper-country-code',
'row-gpc-helper-phone',
'row-gpc-helper-otp-channel',
'row-gpc-helper-local-sms-enabled',
'row-gpc-helper-local-sms-url',
'row-gpc-helper-pin',
'row-gopay-country-code',
'row-gopay-phone',
'row-gopay-otp',
'row-gopay-pin',
],
},
'openai-phone': {
id: 'openai-phone',
label: '接码设置',
sectionIds: ['phone-verification-section'],
rowIds: ['row-signup-phone'],
rowIds: [],
},
'openai-oauth': {
id: 'openai-oauth',
+13 -7
View File
@@ -12025,19 +12025,25 @@ function updatePanelModeUI() {
const effectiveSourceId = capabilityState?.effectiveSourceId || sourceId;
renderFlowSelectorOptions(activeFlowId);
renderSourceSelectorOptions(activeFlowId, effectiveSourceId);
const visibleGroupIds = Array.isArray(capabilityState?.visibleGroupIds)
? capabilityState.visibleGroupIds
: [];
if (typeof applyFlowSettingsGroupVisibility === 'function') {
applyFlowSettingsGroupVisibility(visibleGroupIds);
}
const panelMode = capabilityState?.effectivePanelMode || capabilityState?.panelMode || rawPanelMode;
if (selectFlow) {
selectFlow.value = activeFlowId;
}
if (selectPanelMode) {
selectPanelMode.value = effectiveSourceId;
}
const visibleGroupIds = Array.isArray(capabilityState?.visibleGroupIds)
? capabilityState.visibleGroupIds
: [];
if (typeof applyFlowSettingsGroupVisibility === 'function') {
applyFlowSettingsGroupVisibility(visibleGroupIds);
}
if (typeof updatePlusModeUI === 'function') {
updatePlusModeUI();
}
if (typeof updatePhoneVerificationSettingsUI === 'function') {
updatePhoneVerificationSettingsUI();
}
const panelMode = capabilityState?.effectivePanelMode || capabilityState?.panelMode || rawPanelMode;
const useCodex2Api = panelMode === 'codex2api';
const step9Btn = document.querySelector('.step-btn[data-step-key="platform-verify"]');
@@ -25,6 +25,14 @@ test('flow registry exposes openai and kiro with canonical source metadata', ()
flowRegistry.getVisibleGroupIds('kiro', 'kiro-rs'),
['kiro-runtime-status', 'kiro-source-kiro-rs', 'service-email', 'service-proxy']
);
assert.deepEqual(
flowRegistry.getSettingsGroupDefinition('openai-plus')?.rowIds || [],
['row-plus-mode']
);
assert.deepEqual(
flowRegistry.getSettingsGroupDefinition('openai-phone')?.rowIds || [],
[]
);
});
test('settings schema normalizes flat input into canonical flow and service namespaces', () => {
@@ -113,3 +113,77 @@ return {
});
assert.deepEqual(api.calls[1], { type: 'render', stepIds: [88] });
});
test('updatePanelModeUI reapplies dynamic Plus and phone visibility after flow group visibility', () => {
const bundle = [
extractFunction(sidepanelSource, 'updatePanelModeUI'),
].join('\n');
const api = new Function(`
const calls = [];
let latestState = {
activeFlowId: 'openai',
flowId: 'openai',
panelMode: 'cpa',
};
const DEFAULT_ACTIVE_FLOW_ID = 'openai';
const selectFlow = { value: '' };
const selectPanelMode = { value: '' };
function normalizeFlowId(value = '', fallback = DEFAULT_ACTIVE_FLOW_ID) {
return String(value || fallback || DEFAULT_ACTIVE_FLOW_ID).trim().toLowerCase() || DEFAULT_ACTIVE_FLOW_ID;
}
function normalizePanelMode(value = '', fallback = 'cpa') {
return String(value || fallback || 'cpa').trim().toLowerCase() || 'cpa';
}
function getSelectedFlowId() {
return latestState.activeFlowId;
}
function getSelectedSourceId() {
return 'cpa';
}
function renderFlowSelectorOptions(flowId) {
calls.push({ type: 'render-flow', flowId });
}
function renderSourceSelectorOptions(flowId, sourceId) {
calls.push({ type: 'render-source', flowId, sourceId });
}
function applyFlowSettingsGroupVisibility(visibleGroupIds) {
calls.push({ type: 'groups', visibleGroupIds: [...visibleGroupIds] });
}
function updatePlusModeUI() {
calls.push({ type: 'plus' });
}
function updatePhoneVerificationSettingsUI() {
calls.push({ type: 'phone' });
}
function resolveCurrentSidepanelCapabilities() {
return {
visibleGroupIds: ['openai-account', 'openai-plus', 'openai-phone'],
effectivePanelMode: 'cpa',
panelMode: 'cpa',
effectiveSourceId: 'cpa',
};
}
const document = {
querySelector() {
return null;
},
};
${bundle}
return {
calls,
updatePanelModeUI,
selectFlow,
selectPanelMode,
};
`)();
api.updatePanelModeUI();
assert.deepEqual(
api.calls.map((entry) => entry.type),
['render-flow', 'render-source', 'groups', 'plus', 'phone']
);
assert.equal(api.selectFlow.value, 'openai');
assert.equal(api.selectPanelMode.value, 'cpa');
});