From 7564481868c6247358a2472ca436d89d1db4c415 Mon Sep 17 00:00:00 2001 From: QLHazyCoder <2825305047@qq.com> Date: Mon, 18 May 2026 00:47:10 +0800 Subject: [PATCH] fix: restore plus mode toggle visibility control --- shared/flow-registry.js | 17 +---- sidepanel/sidepanel.js | 20 ++++-- tests/flow-registry-settings-schema.test.js | 8 +++ tests/sidepanel-flow-source-registry.test.js | 74 ++++++++++++++++++++ 4 files changed, 96 insertions(+), 23 deletions(-) diff --git a/shared/flow-registry.js b/shared/flow-registry.js index 8f5bb9b..f6875ed 100644 --- a/shared/flow-registry.js +++ b/shared/flow-registry.js @@ -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', diff --git a/sidepanel/sidepanel.js b/sidepanel/sidepanel.js index 58f83db..8dc586e 100644 --- a/sidepanel/sidepanel.js +++ b/sidepanel/sidepanel.js @@ -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"]'); diff --git a/tests/flow-registry-settings-schema.test.js b/tests/flow-registry-settings-schema.test.js index 20db86b..dade205 100644 --- a/tests/flow-registry-settings-schema.test.js +++ b/tests/flow-registry-settings-schema.test.js @@ -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', () => { diff --git a/tests/sidepanel-flow-source-registry.test.js b/tests/sidepanel-flow-source-registry.test.js index 6a538bc..404207e 100644 --- a/tests/sidepanel-flow-source-registry.test.js +++ b/tests/sidepanel-flow-source-registry.test.js @@ -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'); +});