mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-09 16:59:43 +02:00
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 <noreply@anthropic.com>
This commit is contained in:
+33
-7
@@ -956,6 +956,7 @@ class ClaudemanApp {
|
|||||||
if (!select.dataset.listenerAdded) {
|
if (!select.dataset.listenerAdded) {
|
||||||
select.addEventListener('change', () => {
|
select.addEventListener('change', () => {
|
||||||
this.updateDirDisplayForCase(select.value);
|
this.updateDirDisplayForCase(select.value);
|
||||||
|
this.saveLastUsedCase(select.value);
|
||||||
});
|
});
|
||||||
select.dataset.listenerAdded = 'true';
|
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() {
|
async quickStart() {
|
||||||
// Alias for backward compatibility
|
// Alias for backward compatibility
|
||||||
return this.runClaude();
|
return this.runClaude();
|
||||||
@@ -1067,13 +1086,16 @@ class ClaudemanApp {
|
|||||||
if (!createData.success) throw new Error(createData.error);
|
if (!createData.success) throw new Error(createData.error);
|
||||||
|
|
||||||
// Apply global Ralph tracker setting
|
// Apply global Ralph tracker setting
|
||||||
if (ralphEnabled) {
|
// If enabled: enable the tracker
|
||||||
await fetch(`/api/sessions/${createData.session.id}/inner-config`, {
|
// If disabled: disable auto-enable to prevent pattern-based activation
|
||||||
method: 'POST',
|
await fetch(`/api/sessions/${createData.session.id}/inner-config`, {
|
||||||
headers: { 'Content-Type': 'application/json' },
|
method: 'POST',
|
||||||
body: JSON.stringify({ enabled: true })
|
headers: { 'Content-Type': 'application/json' },
|
||||||
});
|
body: JSON.stringify({
|
||||||
}
|
enabled: ralphEnabled,
|
||||||
|
disableAutoEnable: !ralphEnabled
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
// Start interactive mode
|
// Start interactive mode
|
||||||
await fetch(`/api/sessions/${createData.session.id}/interactive`, {
|
await fetch(`/api/sessions/${createData.session.id}/interactive`, {
|
||||||
@@ -2711,6 +2733,8 @@ class ClaudemanApp {
|
|||||||
this.showToast(`Case "${name}" created`, 'success');
|
this.showToast(`Case "${name}" created`, 'success');
|
||||||
// Reload cases and select the new one
|
// Reload cases and select the new one
|
||||||
await this.loadQuickStartCases(name);
|
await this.loadQuickStartCases(name);
|
||||||
|
// Save as last used case
|
||||||
|
await this.saveLastUsedCase(name);
|
||||||
} else {
|
} else {
|
||||||
this.showToast(data.error || 'Failed to create case', 'error');
|
this.showToast(data.error || 'Failed to create case', 'error');
|
||||||
}
|
}
|
||||||
@@ -2752,6 +2776,8 @@ class ClaudemanApp {
|
|||||||
this.showToast(`Case "${name}" linked to ${path}`, 'success');
|
this.showToast(`Case "${name}" linked to ${path}`, 'success');
|
||||||
// Reload cases and select the new one
|
// Reload cases and select the new one
|
||||||
await this.loadQuickStartCases(name);
|
await this.loadQuickStartCases(name);
|
||||||
|
// Save as last used case
|
||||||
|
await this.saveLastUsedCase(name);
|
||||||
} else {
|
} else {
|
||||||
this.showToast(data.error || 'Failed to link case', 'error');
|
this.showToast(data.error || 'Failed to link case', 'error');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user