Skip to content

Commit 6f7c6ff

Browse files
committed
refactor: move codex reset action to device settings tab
1 parent b4bf006 commit 6f7c6ff

5 files changed

Lines changed: 46 additions & 11 deletions

File tree

tests/unit/config-tabs-ui.test.mjs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ test('config template keeps expected config tabs in top and side navigation', ()
4949
assert.match(html, /class="codex-config-grid"/);
5050
assert.match(html, /onSettingsTabClick\('backup'\)/);
5151
assert.match(html, /onSettingsTabClick\('trash'\)/);
52+
assert.match(html, /onSettingsTabClick\('device'\)/);
5253
assert.match(html, /settingsTab === 'backup'/);
5354
assert.match(html, /settingsTab === 'trash'/);
55+
assert.match(html, /settingsTab === 'device'/);
5456
assert.match(html, /sessionTrashCount/);
5557
assert.match(html, /id="side-tab-market"/);
5658
assert.match(html, /id="tab-market"/);
@@ -107,17 +109,29 @@ test('config template keeps expected config tabs in top and side navigation', ()
107109
assert.doesNotMatch(html, /class="market-ecosystem-grid"/);
108110
assert.match(html, /id="settings-tab-backup"/);
109111
assert.match(html, /id="settings-tab-trash"/);
112+
assert.match(html, /id="settings-tab-device"/);
110113
assert.match(html, /role="tab"/);
111114
assert.match(html, /aria-controls="settings-panel-backup"/);
112115
assert.match(html, /aria-controls="settings-panel-trash"/);
116+
assert.match(html, /aria-controls="settings-panel-device"/);
113117
assert.match(html, /:aria-selected="settingsTab === 'backup'"/);
114118
assert.match(html, /:aria-selected="settingsTab === 'trash'"/);
119+
assert.match(html, /:aria-selected="settingsTab === 'device'"/);
115120
assert.match(html, /id="settings-tab-backup"[\s\S]*:tabindex="settingsTab === 'backup' \? 0 : -1"/);
116121
assert.match(html, /id="settings-tab-trash"[\s\S]*:tabindex="settingsTab === 'trash' \? 0 : -1"/);
122+
assert.match(html, /id="settings-tab-device"[\s\S]*:tabindex="settingsTab === 'device' \? 0 : -1"/);
117123
assert.match(html, /id="settings-panel-backup"/);
118124
assert.match(html, /id="settings-panel-trash"/);
125+
assert.match(html, /id="settings-panel-device"/);
119126
assert.match(html, /<div[\s\S]*v-show="settingsTab === 'backup'"[\s\S]*id="settings-panel-backup"[\s\S]*aria-labelledby="settings-tab-backup">/);
120127
assert.match(html, /<div[\s\S]*v-show="settingsTab === 'trash'"[\s\S]*id="settings-panel-trash"[\s\S]*aria-labelledby="settings-tab-trash">/);
128+
assert.match(html, /<div[\s\S]*v-show="settingsTab === 'device'"[\s\S]*id="settings-panel-device"[\s\S]*aria-labelledby="settings-tab-device">/);
129+
assert.match(html, /id="settings-panel-device"[\s\S]*?<span class="selector-title"><\/span>/);
130+
assert.match(html, /id="settings-panel-device"[\s\S]*?@click="resetConfig"/);
131+
assert.doesNotMatch(
132+
html.match(/id="panel-config-provider"[\s\S]*?<\/template>/)?.[0] || '',
133+
/<span class="selector-title"><\/span>/
134+
);
121135
assert.match(html, /class="settings-tab-actions trash-header-actions"/);
122136
assert.match(html, /<button class="btn-tool btn-tool-compact" @click="loadSessionTrash\(\{ forceRefresh: true \}\)"/);
123137
assert.match(html, /<button class="btn-tool btn-tool-compact" @click="clearSessionTrash"/);
@@ -326,6 +340,7 @@ test('web ui script defines provider mode metadata for codex only', () => {
326340
assert.match(appScript, /sessionTrashHasMoreItems\(\)/);
327341
assert.match(appScript, /sessionTrashHiddenCount\(\)/);
328342
assert.match(appScript, /normalizeSettingsTab\(tab\)/);
343+
assert.match(appScript, /tab === 'trash' \|\| tab === 'device'/);
329344
assert.match(appScript, /switchSettingsTab\(tab,\s*options = \{\}\)/);
330345
assert.match(appScript, /loadSessionTrash\(options = \{\}\)/);
331346
assert.match(appScript, /loadMoreSessionTrashItems\(\)/);

tests/unit/web-ui-source-bundle.test.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ test('bundled web ui html inlines partials without leaking include directives',
2222

2323
assert.match(html, /id="panel-market"/);
2424
assert.match(html, /id="settings-panel-trash"/);
25+
assert.match(html, /id="settings-panel-device"/);
2526
assert.match(html, /class="modal modal-wide skills-modal"/);
2627
assert.match(html, /<script type="module" src="\/web-ui\/app\.js"><\/script>/);
2728
assert.doesNotMatch(html, /<script type="module" src="web-ui\/app\.js"><\/script>/);

web-ui/modules/app.methods.session-trash.mjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,10 @@ export function createSessionTrashMethods(options = {}) {
206206
},
207207

208208
normalizeSettingsTab(tab) {
209-
return tab === 'trash' ? 'trash' : 'backup';
209+
if (tab === 'trash' || tab === 'device') {
210+
return tab;
211+
}
212+
return 'backup';
210213
},
211214

212215
async onSettingsTabClick(tab) {

web-ui/partials/index/panel-config-codex.html

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,6 @@
143143
</button>
144144
</div>
145145

146-
<div class="selector-section">
147-
<div class="selector-header">
148-
<span class="selector-title">配置重置</span>
149-
</div>
150-
<div class="config-template-hint">先备份 config.toml,再写默认配置。</div>
151-
<button class="btn-tool" @click="resetConfig" :disabled="resetConfigLoading || loading || !!initError">
152-
{{ resetConfigLoading ? '重装中...' : '重装配置' }}
153-
</button>
154-
</div>
155-
156146
</template>
157147

158148
<div class="selector-section">

web-ui/partials/index/panel-settings.html

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@
2727
回收站
2828
<span class="settings-tab-badge">{{ sessionTrashCount }}</span>
2929
</button>
30+
<button
31+
id="settings-tab-device"
32+
role="tab"
33+
aria-controls="settings-panel-device"
34+
:aria-selected="settingsTab === 'device'"
35+
:tabindex="settingsTab === 'device' ? 0 : -1"
36+
:class="['config-subtab', { active: settingsTab === 'device' }]"
37+
@click="onSettingsTabClick('device')">
38+
设备
39+
</button>
3040
</div>
3141

3242
<div
@@ -137,4 +147,20 @@
137147
</div>
138148
</div>
139149
</div>
150+
151+
<div
152+
v-show="settingsTab === 'device'"
153+
id="settings-panel-device"
154+
role="tabpanel"
155+
aria-labelledby="settings-tab-device">
156+
<div class="selector-section">
157+
<div class="selector-header">
158+
<span class="selector-title">配置重置</span>
159+
</div>
160+
<div class="config-template-hint">先备份 config.toml,再写默认配置。</div>
161+
<button class="btn-tool" @click="resetConfig" :disabled="resetConfigLoading || loading || !!initError">
162+
{{ resetConfigLoading ? '重装中...' : '重装配置' }}
163+
</button>
164+
</div>
165+
</div>
140166
</div>

0 commit comments

Comments
 (0)