change(settings): debug-options gate is once per session

Passing the gate once (confirmation + any re-auth) now unlocks the DEBUG OPTIONS
dropdown for the rest of the session — subsequent expands skip straight to the
options. The flag lives in the session-lifetime page state, so it resets on app
restart. Collapsing still needs no gate.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-10 18:49:11 -05:00
parent 46fb0029b8
commit a5efbaf83d

View File

@@ -145,8 +145,10 @@ struct SettingsPageState {
bool debug_cats_dirty = false;
bool debug_expanded = false;
// Debug-options gate: a confirmation + warning (and, when a PIN/passphrase is set, re-auth) is
// required before the debug dropdown reveals its options.
// required before the debug dropdown reveals its options — once per session (passing it once
// unlocks the dropdown until the app restarts).
bool debug_gate_open = false;
bool debug_gate_passed = false;
bool debug_gate_verifying = false;
char debug_gate_buf[128] = {0};
std::string debug_gate_err;
@@ -2530,8 +2532,10 @@ void RenderSettingsPage(App* app) {
if (ImGui::Button("##DebugToggle", ImVec2(availWidth, ImGui::GetFrameHeight()))) {
if (s_settingsState.debug_expanded) {
s_settingsState.debug_expanded = false; // collapsing needs no gate
} else if (s_settingsState.debug_gate_passed) {
s_settingsState.debug_expanded = true; // already unlocked this session
} else {
// Expanding is gated: open the confirmation + (if a PIN/passphrase is set) re-auth.
// First expand this session is gated: confirmation + (if secured) re-auth.
s_settingsState.debug_gate_open = true;
s_settingsState.debug_gate_buf[0] = '\0';
s_settingsState.debug_gate_err.clear();
@@ -2704,6 +2708,7 @@ void RenderSettingsPage(App* app) {
if (TactileButton(TR("debug_gate_confirm"), ImVec2(170.0f * gdp, 0)) || submit) {
if (!needAuth) {
st.debug_expanded = true;
st.debug_gate_passed = true;
st.debug_gate_open = false;
} else if (strlen(st.debug_gate_buf) > 0) {
st.debug_gate_verifying = true;
@@ -2712,7 +2717,7 @@ void RenderSettingsPage(App* app) {
app->verifyDebugCredential(secret, [](bool ok) {
auto& s = s_settingsState;
s.debug_gate_verifying = false;
if (ok) { s.debug_expanded = true; s.debug_gate_open = false; }
if (ok) { s.debug_expanded = true; s.debug_gate_passed = true; s.debug_gate_open = false; }
else { s.debug_gate_err = TR("debug_gate_incorrect"); s.debug_gate_err_timer = 4.0f; }
});
if (!secret.empty()) memset(&secret[0], 0, secret.size());