From 8b04734538ef696444853f61ccab73d95262a578 Mon Sep 17 00:00:00 2001 From: arkon Date: Wed, 21 Jan 2026 13:38:23 +0100 Subject: [PATCH] feat(ui): persist last used case selection Save selected case to settings when changed, created, or linked. Automatically restore last used case on page load. Co-Authored-By: Claude Opus 4.5 --- src/web/public/app.js | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/src/web/public/app.js b/src/web/public/app.js index c5655b2d..94d026d7 100644 --- a/src/web/public/app.js +++ b/src/web/public/app.js @@ -956,6 +956,7 @@ class ClaudemanApp { if (!select.dataset.listenerAdded) { select.addEventListener('change', () => { this.updateDirDisplayForCase(select.value); + this.saveLastUsedCase(select.value); }); select.dataset.listenerAdded = 'true'; } @@ -977,6 +978,24 @@ class ClaudemanApp { } } + async saveLastUsedCase(caseName) { + try { + // Get current settings + const res = await fetch('/api/settings'); + const settings = res.ok ? await res.json() : {}; + // Update lastUsedCase + settings.lastUsedCase = caseName; + // Save back + await fetch('/api/settings', { + method: 'PUT', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(settings) + }); + } catch (err) { + console.error('Failed to save last used case:', err); + } + } + async quickStart() { // Alias for backward compatibility return this.runClaude(); @@ -1067,13 +1086,16 @@ class ClaudemanApp { if (!createData.success) throw new Error(createData.error); // Apply global Ralph tracker setting - if (ralphEnabled) { - await fetch(`/api/sessions/${createData.session.id}/inner-config`, { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ enabled: true }) - }); - } + // If enabled: enable the tracker + // If disabled: disable auto-enable to prevent pattern-based activation + await fetch(`/api/sessions/${createData.session.id}/inner-config`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ + enabled: ralphEnabled, + disableAutoEnable: !ralphEnabled + }) + }); // Start interactive mode await fetch(`/api/sessions/${createData.session.id}/interactive`, { @@ -2711,6 +2733,8 @@ class ClaudemanApp { this.showToast(`Case "${name}" created`, 'success'); // Reload cases and select the new one await this.loadQuickStartCases(name); + // Save as last used case + await this.saveLastUsedCase(name); } else { this.showToast(data.error || 'Failed to create case', 'error'); } @@ -2752,6 +2776,8 @@ class ClaudemanApp { this.showToast(`Case "${name}" linked to ${path}`, 'success'); // Reload cases and select the new one await this.loadQuickStartCases(name); + // Save as last used case + await this.saveLastUsedCase(name); } else { this.showToast(data.error || 'Failed to link case', 'error'); }