aicodeman 1.9.5 → 1.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/transcript-watcher.d.ts +2 -0
- package/dist/transcript-watcher.d.ts.map +1 -1
- package/dist/transcript-watcher.js +30 -16
- package/dist/transcript-watcher.js.map +1 -1
- package/dist/web/public/admin-ui.js.gz +0 -0
- package/dist/web/public/api-client.c9b1cddc.js.gz +0 -0
- package/dist/web/public/app.adc992cd.js.gz +0 -0
- package/dist/web/public/constants.e7175b95.js.gz +0 -0
- package/dist/web/public/cron-ui.js.gz +0 -0
- package/dist/web/public/i18n.4dcf1b87.js.gz +0 -0
- package/dist/web/public/image-input.ee16ad88.js.gz +0 -0
- package/dist/web/public/index.html +3 -3
- package/dist/web/public/index.html.br +0 -0
- package/dist/web/public/index.html.gz +0 -0
- package/dist/web/public/input-cjk.63794d0b.js.gz +0 -0
- package/dist/web/public/keyboard-accessory.9936227d.js.gz +0 -0
- package/dist/web/public/mobile-handlers.bc2b8c1d.js.gz +0 -0
- package/dist/web/public/mobile.40e2d64e.css.gz +0 -0
- package/dist/web/public/{notification-manager.fca811fd.js → notification-manager.5d229063.js} +97 -42
- package/dist/web/public/notification-manager.5d229063.js.br +0 -0
- package/dist/web/public/notification-manager.5d229063.js.gz +0 -0
- package/dist/web/public/orchestrator-panel.js.gz +0 -0
- package/dist/web/public/panels-ui.3910e1e2.js.gz +0 -0
- package/dist/web/public/ralph-panel.6de2d0f8.js.gz +0 -0
- package/dist/web/public/ralph-wizard.13a1831e.js.gz +0 -0
- package/dist/web/public/respawn-ui.2d249da9.js.gz +0 -0
- package/dist/web/public/sanitize-html.bc7078d6.js.gz +0 -0
- package/dist/web/public/session-ui.2d3541c6.js.gz +0 -0
- package/dist/web/public/{settings-ui.e1cac0da.js → settings-ui.08c08e71.js} +2 -2
- package/dist/web/public/settings-ui.08c08e71.js.br +0 -0
- package/dist/web/public/settings-ui.08c08e71.js.gz +0 -0
- package/dist/web/public/styles.30e64547.css.gz +0 -0
- package/dist/web/public/subagent-windows.69b60c35.js.gz +0 -0
- package/dist/web/public/sw.js.gz +0 -0
- package/dist/web/public/terminal-ui.f3a51974.js.gz +0 -0
- package/dist/web/public/ultracode-panel.js.gz +0 -0
- package/dist/web/public/ultracode-windows.js.gz +0 -0
- package/dist/web/public/upload.html.gz +0 -0
- package/dist/web/public/vendor/dompurify.min.js.gz +0 -0
- package/dist/web/public/vendor/marked.min.js.gz +0 -0
- package/dist/web/public/vendor/xterm-addon-fit.min.js.gz +0 -0
- package/dist/web/public/vendor/xterm-addon-serialize.min.js.gz +0 -0
- package/dist/web/public/vendor/xterm-addon-unicode11.min.js.gz +0 -0
- package/dist/web/public/vendor/xterm-addon-webgl.min.js.gz +0 -0
- package/dist/web/public/vendor/xterm-zerolag-input.137ad9f0.js.gz +0 -0
- package/dist/web/public/vendor/xterm.css.gz +0 -0
- package/dist/web/public/vendor/xterm.min.js.gz +0 -0
- package/dist/web/public/voice-input.085e9e73.js.gz +0 -0
- package/dist/web/public/webview-tabs.js.gz +0 -0
- package/package.json +1 -1
- package/dist/web/public/notification-manager.fca811fd.js.br +0 -0
- package/dist/web/public/notification-manager.fca811fd.js.gz +0 -0
- package/dist/web/public/settings-ui.e1cac0da.js.br +0 -0
- package/dist/web/public/settings-ui.e1cac0da.js.gz +0 -0
|
@@ -70,6 +70,8 @@ export declare class TranscriptWatcher extends EventEmitter {
|
|
|
70
70
|
private readNewEntries;
|
|
71
71
|
private processEntry;
|
|
72
72
|
private handleAssistantEntry;
|
|
73
|
+
private handleUserEntry;
|
|
74
|
+
private handleToolResult;
|
|
73
75
|
private handleResultEntry;
|
|
74
76
|
private checkPlanMode;
|
|
75
77
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transcript-watcher.d.ts","sourceRoot":"","sources":["../src/transcript-watcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,YAA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CAAC,YAAY;IAepB,OAAO,CAAC,gBAAgB;YA8BV,iBAAiB;IAgC/B,OAAO,CAAC,cAAc;IA8CtB,OAAO,CAAC,YAAY;IAwBpB,OAAO,CAAC,oBAAoB;IAwB5B,OAAO,CAAC,eAAe;IAgBvB,OAAO,CAAC,gBAAgB;IAcxB,OAAO,CAAC,iBAAiB;IAczB,OAAO,CAAC,aAAa;CAkCtB"}
|
|
@@ -242,10 +242,7 @@ export class TranscriptWatcher extends EventEmitter {
|
|
|
242
242
|
this.handleResultEntry(entry);
|
|
243
243
|
break;
|
|
244
244
|
case 'user':
|
|
245
|
-
|
|
246
|
-
this.state.isComplete = false;
|
|
247
|
-
this.state.hasError = false;
|
|
248
|
-
this.state.errorMessage = null;
|
|
245
|
+
this.handleUserEntry(entry);
|
|
249
246
|
break;
|
|
250
247
|
case 'system':
|
|
251
248
|
// System messages are informational
|
|
@@ -274,22 +271,39 @@ export class TranscriptWatcher extends EventEmitter {
|
|
|
274
271
|
this.emit('transcript:tool_start', block.name);
|
|
275
272
|
}
|
|
276
273
|
else if (block.type === 'tool_result') {
|
|
277
|
-
|
|
278
|
-
const wasError = block.is_error === true;
|
|
279
|
-
const toolName = this.state.currentTool;
|
|
280
|
-
this.state.toolExecuting = false;
|
|
281
|
-
this.state.currentTool = null;
|
|
282
|
-
if (toolName) {
|
|
283
|
-
this.emit('transcript:tool_end', toolName, wasError);
|
|
284
|
-
}
|
|
285
|
-
if (wasError && block.content) {
|
|
286
|
-
this.state.hasError = true;
|
|
287
|
-
this.state.errorMessage = String(block.content).slice(0, 200);
|
|
288
|
-
}
|
|
274
|
+
this.handleToolResult(block);
|
|
289
275
|
}
|
|
290
276
|
}
|
|
291
277
|
}
|
|
292
278
|
}
|
|
279
|
+
handleUserEntry(entry) {
|
|
280
|
+
// A user-authored prompt starts a turn, while Claude tool results also use
|
|
281
|
+
// user entries. Reset turn state first, then close any completed tool.
|
|
282
|
+
this.state.isComplete = false;
|
|
283
|
+
this.state.hasError = false;
|
|
284
|
+
this.state.errorMessage = null;
|
|
285
|
+
const content = entry.message?.content;
|
|
286
|
+
if (!Array.isArray(content))
|
|
287
|
+
return;
|
|
288
|
+
for (const block of content) {
|
|
289
|
+
if (block.type === 'tool_result') {
|
|
290
|
+
this.handleToolResult(block);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
handleToolResult(block) {
|
|
295
|
+
const wasError = block.is_error === true;
|
|
296
|
+
const toolName = this.state.currentTool;
|
|
297
|
+
this.state.toolExecuting = false;
|
|
298
|
+
this.state.currentTool = null;
|
|
299
|
+
if (toolName) {
|
|
300
|
+
this.emit('transcript:tool_end', toolName, wasError);
|
|
301
|
+
}
|
|
302
|
+
if (wasError && block.content) {
|
|
303
|
+
this.state.hasError = true;
|
|
304
|
+
this.state.errorMessage = String(block.content).slice(0, 200);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
293
307
|
handleResultEntry(entry) {
|
|
294
308
|
// Result entry indicates completion
|
|
295
309
|
this.state.isComplete = true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transcript-watcher.js","sourceRoot":"","sources":["../src/transcript-watcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAa,MAAM,SAAS,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"transcript-watcher.js","sourceRoot":"","sources":["../src/transcript-watcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAa,MAAM,SAAS,CAAC;AACjE,OAAO,E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C,OAAO;YACT,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1848,7 +1848,7 @@
|
|
|
1848
1848
|
<input type="checkbox" id="eventIdleAudio">
|
|
1849
1849
|
|
|
1850
1850
|
<div class="event-label">Response complete</div>
|
|
1851
|
-
<input type="checkbox" id="eventStopEnabled"
|
|
1851
|
+
<input type="checkbox" id="eventStopEnabled">
|
|
1852
1852
|
<input type="checkbox" id="eventStopBrowser">
|
|
1853
1853
|
<input type="checkbox" id="eventStopPush">
|
|
1854
1854
|
<input type="checkbox" id="eventStopAudio">
|
|
@@ -2609,7 +2609,7 @@
|
|
|
2609
2609
|
<script defer src="i18n.4dcf1b87.js"></script>
|
|
2610
2610
|
<script defer src="mobile-handlers.bc2b8c1d.js"></script>
|
|
2611
2611
|
<script defer src="voice-input.085e9e73.js"></script>
|
|
2612
|
-
<script defer src="notification-manager.
|
|
2612
|
+
<script defer src="notification-manager.5d229063.js"></script>
|
|
2613
2613
|
<script defer src="keyboard-accessory.9936227d.js"></script>
|
|
2614
2614
|
<script defer src="input-cjk.63794d0b.js"></script>
|
|
2615
2615
|
<!-- Hardened markdown HTML sanitizer (wires DOMPurify). Must precede app.js. -->
|
|
@@ -2620,7 +2620,7 @@
|
|
|
2620
2620
|
<script defer src="ralph-panel.6de2d0f8.js"></script>
|
|
2621
2621
|
<script defer src="orchestrator-panel.js"></script>
|
|
2622
2622
|
<script defer src="cron-ui.js"></script>
|
|
2623
|
-
<script defer src="settings-ui.
|
|
2623
|
+
<script defer src="settings-ui.08c08e71.js"></script>
|
|
2624
2624
|
<script defer src="panels-ui.3910e1e2.js"></script>
|
|
2625
2625
|
<script defer src="ultracode-panel.js"></script>
|
|
2626
2626
|
<script defer src="admin-ui.js"></script>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/web/public/{notification-manager.fca811fd.js → notification-manager.5d229063.js}
RENAMED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* 5. Audio alerts (Web Audio API beep, user-opt-in)
|
|
10
10
|
*
|
|
11
11
|
* Features:
|
|
12
|
-
* - Per-event-type preferences (enabled, browser, audio, push) with v1→
|
|
12
|
+
* - Per-event-type preferences (enabled, browser, audio, push) with v1→v5 migration
|
|
13
13
|
* - Device-specific defaults (notifications disabled on mobile by default)
|
|
14
14
|
* - 5s notification grouping window to batch rapid-fire events
|
|
15
15
|
* - 100-notification cap with oldest eviction
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* @param {CodemanApp} app - Reference to the main app instance
|
|
22
22
|
*
|
|
23
23
|
* @dependency constants.js (STUCK_THRESHOLD_DEFAULT_MS, timing constants)
|
|
24
|
-
* @dependency mobile-handlers.js (MobileDetection
|
|
24
|
+
* @dependency mobile-handlers.js (MobileDetection stable handheld identity/device type)
|
|
25
25
|
* @loadorder 4 of 15 — loaded after voice-input.js, before keyboard-accessory.js
|
|
26
26
|
*/
|
|
27
27
|
|
|
@@ -65,12 +65,19 @@ class NotificationManager {
|
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
_usesMobilePreferences() {
|
|
69
|
+
return (
|
|
70
|
+
MobileDetection.isHandheldDevice?.() ??
|
|
71
|
+
MobileDetection.getDeviceType() === 'mobile'
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
getDefaultPreferences() {
|
|
69
76
|
const defaultEventTypes = {
|
|
70
77
|
permission_prompt: { enabled: true, browser: true, audio: true, push: false },
|
|
71
78
|
elicitation_dialog: { enabled: true, browser: true, audio: true, push: false },
|
|
72
79
|
idle_prompt: { enabled: true, browser: true, audio: false, push: false },
|
|
73
|
-
stop: { enabled:
|
|
80
|
+
stop: { enabled: false, browser: false, audio: false, push: false },
|
|
74
81
|
session_error: { enabled: true, browser: true, audio: false, push: false },
|
|
75
82
|
respawn_cycle: { enabled: true, browser: false, audio: false, push: false },
|
|
76
83
|
token_milestone: { enabled: true, browser: false, audio: false, push: false },
|
|
@@ -80,8 +87,8 @@ class NotificationManager {
|
|
|
80
87
|
};
|
|
81
88
|
|
|
82
89
|
// Device-specific defaults: mobile has notifications disabled by default
|
|
83
|
-
const isMobile =
|
|
84
|
-
|
|
90
|
+
const isMobile = this._usesMobilePreferences();
|
|
91
|
+
return {
|
|
85
92
|
enabled: !isMobile, // Disabled on mobile by default
|
|
86
93
|
browserNotifications: !isMobile,
|
|
87
94
|
audioAlerts: false,
|
|
@@ -92,51 +99,97 @@ class NotificationManager {
|
|
|
92
99
|
muteInfo: false,
|
|
93
100
|
// Per-event-type preferences
|
|
94
101
|
eventTypes: defaultEventTypes,
|
|
95
|
-
_version:
|
|
102
|
+
_version: 5,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Apply the complete v1→v5 migration to either local or server-hydrated
|
|
108
|
+
* preferences. Keeping one normalization path prevents fresh browsers from
|
|
109
|
+
* reviving retired drawer-only hook defaults.
|
|
110
|
+
*/
|
|
111
|
+
normalizePreferences(rawPreferences) {
|
|
112
|
+
const defaults = this.getDefaultPreferences();
|
|
113
|
+
if (
|
|
114
|
+
!rawPreferences ||
|
|
115
|
+
typeof rawPreferences !== 'object' ||
|
|
116
|
+
Array.isArray(rawPreferences)
|
|
117
|
+
) {
|
|
118
|
+
return defaults;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const prefs = {
|
|
122
|
+
...rawPreferences,
|
|
123
|
+
eventTypes:
|
|
124
|
+
rawPreferences.eventTypes &&
|
|
125
|
+
typeof rawPreferences.eventTypes === 'object' &&
|
|
126
|
+
!Array.isArray(rawPreferences.eventTypes)
|
|
127
|
+
? Object.fromEntries(
|
|
128
|
+
Object.entries(rawPreferences.eventTypes).map(([key, value]) => [
|
|
129
|
+
key,
|
|
130
|
+
value && typeof value === 'object' ? { ...value } : value,
|
|
131
|
+
])
|
|
132
|
+
)
|
|
133
|
+
: undefined,
|
|
134
|
+
};
|
|
135
|
+
const version = Number.isInteger(prefs._version) ? prefs._version : 0;
|
|
136
|
+
|
|
137
|
+
// Migrate: v1 had browserNotifications defaulting to false
|
|
138
|
+
if (version < 2) {
|
|
139
|
+
prefs.browserNotifications = true;
|
|
140
|
+
}
|
|
141
|
+
// Migrate: v2 -> v3 adds eventTypes
|
|
142
|
+
if (version < 3) {
|
|
143
|
+
prefs.eventTypes = { ...defaults.eventTypes };
|
|
144
|
+
}
|
|
145
|
+
// Migrate: v3 -> v4 adds push field to all eventTypes
|
|
146
|
+
if (version < 4 && prefs.eventTypes) {
|
|
147
|
+
for (const key of Object.keys(prefs.eventTypes)) {
|
|
148
|
+
if (prefs.eventTypes[key] && prefs.eventTypes[key].push === undefined) {
|
|
149
|
+
prefs.eventTypes[key].push = false;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
// Migrate: v4 -> v5 removes the drawer-only Response Complete default.
|
|
154
|
+
// Preserve users who opted into any external delivery channel.
|
|
155
|
+
if (version < 5) {
|
|
156
|
+
const stopPref = prefs.eventTypes?.stop;
|
|
157
|
+
if (
|
|
158
|
+
stopPref?.enabled === true &&
|
|
159
|
+
!stopPref.browser &&
|
|
160
|
+
!stopPref.audio &&
|
|
161
|
+
!stopPref.push
|
|
162
|
+
) {
|
|
163
|
+
stopPref.enabled = false;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return {
|
|
168
|
+
...defaults,
|
|
169
|
+
...prefs,
|
|
170
|
+
eventTypes: { ...defaults.eventTypes, ...prefs.eventTypes },
|
|
171
|
+
_version: 5,
|
|
96
172
|
};
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
loadPreferences() {
|
|
97
176
|
try {
|
|
98
177
|
const storageKey = this.getStorageKey();
|
|
99
178
|
const saved = localStorage.getItem(storageKey);
|
|
100
179
|
if (saved) {
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
prefs.browserNotifications = true;
|
|
105
|
-
prefs._version = 2;
|
|
106
|
-
}
|
|
107
|
-
// Migrate: v2 -> v3 adds eventTypes
|
|
108
|
-
if (prefs._version < 3) {
|
|
109
|
-
prefs.eventTypes = defaultEventTypes;
|
|
110
|
-
prefs._version = 3;
|
|
111
|
-
localStorage.setItem(storageKey, JSON.stringify(prefs));
|
|
112
|
-
}
|
|
113
|
-
// Migrate: v3 -> v4 adds push field to all eventTypes
|
|
114
|
-
if (prefs._version < 4) {
|
|
115
|
-
if (prefs.eventTypes) {
|
|
116
|
-
for (const key of Object.keys(prefs.eventTypes)) {
|
|
117
|
-
if (prefs.eventTypes[key] && prefs.eventTypes[key].push === undefined) {
|
|
118
|
-
prefs.eventTypes[key].push = false;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
prefs._version = 4;
|
|
123
|
-
localStorage.setItem(storageKey, JSON.stringify(prefs));
|
|
124
|
-
}
|
|
125
|
-
// Merge with defaults to ensure all eventTypes exist
|
|
126
|
-
return {
|
|
127
|
-
...defaults,
|
|
128
|
-
...prefs,
|
|
129
|
-
eventTypes: { ...defaultEventTypes, ...prefs.eventTypes },
|
|
130
|
-
};
|
|
180
|
+
const normalized = this.normalizePreferences(JSON.parse(saved));
|
|
181
|
+
localStorage.setItem(storageKey, JSON.stringify(normalized));
|
|
182
|
+
return normalized;
|
|
131
183
|
}
|
|
132
184
|
} catch (_e) { /* ignore */ }
|
|
133
|
-
return
|
|
185
|
+
return this.getDefaultPreferences();
|
|
134
186
|
}
|
|
135
187
|
|
|
136
188
|
// Get storage key for notification prefs (device-specific)
|
|
137
189
|
getStorageKey() {
|
|
138
|
-
|
|
139
|
-
|
|
190
|
+
return this._usesMobilePreferences()
|
|
191
|
+
? 'codeman-notification-prefs-mobile'
|
|
192
|
+
: 'codeman-notification-prefs';
|
|
140
193
|
}
|
|
141
194
|
|
|
142
195
|
savePreferences() {
|
|
@@ -163,8 +216,10 @@ class NotificationManager {
|
|
|
163
216
|
'exit-gate': 'ralph_complete',
|
|
164
217
|
'subagent-spawn': 'subagent_spawn',
|
|
165
218
|
'subagent-complete': 'subagent_complete',
|
|
166
|
-
|
|
167
|
-
|
|
219
|
+
// Team lifecycle hooks are agent activity, not session-idle/stop alerts.
|
|
220
|
+
// Reuse the existing opt-in agent categories instead of making them noisy.
|
|
221
|
+
'hook-teammate-idle': 'subagent_spawn',
|
|
222
|
+
'hook-task-completed': 'subagent_complete',
|
|
168
223
|
};
|
|
169
224
|
const eventTypeKey = categoryToEventType[category] || category;
|
|
170
225
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.assign(CodemanApp.prototype,{_onHookIdlePrompt(e){e.sessionId&&this.setPendingHook(e.sessionId,"idle_prompt"),this._notifySession(e.sessionId,"warning","hook-idle","Waiting for Input",e.message||"Claude is idle and waiting for a prompt")},_onHookPermissionPrompt(e){e.sessionId&&this.setPendingHook(e.sessionId,"permission_prompt");const t=e.tool?`${e.tool}${e.command?": "+e.command:e.file?": "+e.file:""}`:"";this._notifySession(e.sessionId,"critical","hook-permission","Permission Required",t||"Claude needs tool approval to continue")},_onHookElicitationDialog(e){e.sessionId&&this.setPendingHook(e.sessionId,"elicitation_dialog"),this._notifySession(e.sessionId,"critical","hook-elicitation","Question Asked",e.question||"Claude is asking a question and waiting for your answer")},_onHookStop(e){e.sessionId&&this.clearPendingHooks(e.sessionId),this._notifySession(e.sessionId,"info","hook-stop","Response Complete",e.reason||"Claude has finished responding")},_onHookTeammateIdle(e){const t=this.sessions.get(e.sessionId);this._notifySession(e.sessionId,"warning","hook-teammate-idle","Teammate Idle",`A teammate is idle in ${t?.name||e.sessionId}`)},_onHookTaskCompleted(e){const t=this.sessions.get(e.sessionId);this._notifySession(e.sessionId,"info","hook-task-completed","Task Completed",`A team task completed in ${t?.name||e.sessionId}`)},_onTunnelStarted(e){console.log("[Tunnel] Started:",e.url),this._tunnelUrl=e.url,this._dismissTunnelConnecting(),this._updateTunnelUrlDisplay(e.url),this._updateTunnelIndicator(!0),document.getElementById("welcomeOverlay")?.classList.contains("visible")?(this._updateWelcomeTunnelBtn(!0,e.url,!0),this.showToast("Tunnel active","success")):(this._updateWelcomeTunnelBtn(!0,e.url),this.showToast(`Tunnel active: ${e.url}`,"success"),this.showTunnelQR())},_onTunnelStopped(){console.log("[Tunnel] Stopped"),this._tunnelUrl=null,this._dismissTunnelConnecting(),this._updateTunnelUrlDisplay(null),this._updateWelcomeTunnelBtn(!1),this._updateTunnelIndicator(!1),this.closeTunnelPanel(),this.closeTunnelQR()},_onTunnelProgress(e){console.log("[Tunnel] Progress:",e.message);const t=document.getElementById("tunnelConnectingToast");t&&(t.innerHTML=`<span class="tunnel-spinner"></span> ${e.message}`);const n=document.getElementById("welcomeTunnelBtn");n?.classList.contains("connecting")&&(n.innerHTML=`<span class="tunnel-spinner"></span> ${e.message}`)},_onTunnelError(e){console.warn("[Tunnel] Error:",e.message),this._dismissTunnelConnecting(),this.showToast(`Tunnel error: ${e.message}`,"error");const t=document.getElementById("welcomeTunnelBtn");t&&(t.disabled=!1,t.classList.remove("connecting"))},_onTunnelQrRotated(e){if(e.svg){const t=document.getElementById("tunnelQrContainer");t&&(t.innerHTML=e.svg);const n=document.getElementById("welcomeQrInner");n&&(n.innerHTML=e.svg)}else this._refreshTunnelQrFromApi();this._resetQrCountdown()},_onTunnelQrRegenerated(e){if(e.svg){const t=document.getElementById("tunnelQrContainer");t&&(t.innerHTML=e.svg);const n=document.getElementById("welcomeQrInner");n&&(n.innerHTML=e.svg)}else this._refreshTunnelQrFromApi();this._resetQrCountdown()},_onTunnelQrAuthUsed(e){const n=(e.ua||"Unknown device").match(/Chrome|Firefox|Safari|Edge|Mobile/)?.[0]||"Browser";this.showToast(`Device authenticated via QR (${n}, ${e.ip}). Not you?`,"warning",{duration:1e4,action:{label:"Revoke All",onClick:()=>{fetch("/api/auth/revoke",{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"}).then(()=>this.showToast("All sessions revoked","success")).catch(()=>this.showToast("Failed to revoke sessions","error"))}}})},registerServiceWorker(){"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js").then(e=>{this._swRegistration=e,navigator.serviceWorker.addEventListener("message",t=>{if(t.data?.type==="notification-click"){const{sessionId:n}=t.data;n&&this.sessions.has(n)&&this.selectSession(n),window.focus()}}),e.pushManager.getSubscription().then(t=>{t&&(this._pushSubscription=t,this._updatePushUI(!0))})}).catch(()=>{})},async subscribeToPush(){if(!this._swRegistration){this.showToast("Service worker not available. HTTPS or localhost required.","error");return}try{const e=await this._apiJson("/api/push/vapid-key");if(!e)throw new Error("Failed to get VAPID key");const t=urlBase64ToUint8Array(e.publicKey),n=await this._swRegistration.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:t}),s=n.toJSON(),o=await this._apiJson("/api/push/subscribe",{method:"POST",body:{endpoint:s.endpoint,keys:s.keys,userAgent:navigator.userAgent,pushPreferences:this._buildPushPreferences()}});if(!o)throw new Error("Failed to register subscription");this._pushSubscription=n,this._pushSubscriptionId=o.id,localStorage.setItem("codeman-push-subscription-id",o.id),this._updatePushUI(!0),this.showToast("Push notifications enabled","success")}catch(e){this.showToast("Push subscription failed: "+(e.message||e),"error")}},async unsubscribeFromPush(){try{this._pushSubscription&&await this._pushSubscription.unsubscribe();const e=this._pushSubscriptionId||localStorage.getItem("codeman-push-subscription-id");e&&await fetch(`/api/push/subscribe/${e}`,{method:"DELETE"}).catch(()=>{}),this._pushSubscription=null,this._pushSubscriptionId=null,localStorage.removeItem("codeman-push-subscription-id"),this._updatePushUI(!1),this.showToast("Push notifications disabled","success")}catch(e){this.showToast("Failed to unsubscribe: "+(e.message||e),"error")}},async togglePushSubscription(){this._pushSubscription?await this.unsubscribeFromPush():await this.subscribeToPush()},async _syncPushPreferences(){const e=this._pushSubscriptionId||localStorage.getItem("codeman-push-subscription-id");if(e)try{await fetch(`/api/push/subscribe/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({pushPreferences:this._buildPushPreferences()})})}catch{}},_buildPushPreferences(){const e={},t={"hook:permission_prompt":"eventPermissionPush","hook:elicitation_dialog":"eventQuestionPush","hook:idle_prompt":"eventIdlePush","hook:stop":"eventStopPush","respawn:blocked":"eventRespawnPush","session:ralphCompletionDetected":"eventRalphPush"};for(const[n,s]of Object.entries(t)){const o=document.getElementById(s);e[n]=o?o.checked:!0}return e["session:error"]=!0,e},_updatePushUI(e){const t=document.getElementById("pushSubscribeBtn"),n=document.getElementById("pushSubscriptionStatus");t&&(t.textContent=e?"Unsubscribe":"Subscribe"),n&&(n.textContent=e?"active":"off",n.classList.remove("granted","denied"),e&&n.classList.add("granted"))},openAppSettings(){const e=this.loadAppSettingsFromStorage();document.getElementById("appSettingsDisplayName").value=e.displayName||"Codeman",document.getElementById("appSettingsLanguage").value=e.language==="zh-CN"?"zh-CN":"en",document.getElementById("appSettingsClaudeMdPath").value=e.defaultClaudeMdPath||"",document.getElementById("appSettingsDefaultDir").value=e.defaultWorkingDir||"";const t=this.getDefaultSettings();document.getElementById("appSettingsRalphEnabled").checked=e.ralphTrackerEnabled??t.ralphTrackerEnabled??!1,document.getElementById("appSettingsShowFontControls").checked=e.showFontControls??t.showFontControls??!1,document.getElementById("appSettingsShowSystemStats").checked=e.showSystemStats??t.showSystemStats??!0,document.getElementById("appSettingsShowLifecycleLog").checked=e.showLifecycleLog??t.showLifecycleLog??!1,document.getElementById("appSettingsShowResponseViewer").checked=e.showResponseViewer??t.showResponseViewer??!1,document.getElementById("appSettingsShowFileViewerButton").checked=e.showFileViewerButton??t.showFileViewerButton??!0,document.getElementById("appSettingsShowAttachmentsButton").checked=e.showAttachmentsButton??t.showAttachmentsButton??!1,document.getElementById("appSettingsSkin").value=e.skin??t.skin??"daylight-blue",document.getElementById("appSettingsWebglRenderer").checked=e.webglRendererEnabled??t.webglRendererEnabled??!0;const n=document.getElementById("appSettingsWebglRendererItem");n&&(n.style.display=MobileDetection.getDeviceType()==="desktop"?"":"none"),document.getElementById("appSettingsShowMonitor").checked=e.showMonitor??t.showMonitor??!1,document.getElementById("appSettingsShowProjectInsights").checked=e.showProjectInsights??t.showProjectInsights??!1,document.getElementById("appSettingsShowFileBrowser").checked=e.showFileBrowser??t.showFileBrowser??!1,document.getElementById("appSettingsShowSubagents").checked=e.showSubagents??t.showSubagents??!1,document.getElementById("appSettingsShowUltracodeAgents").checked=e.showUltracodeAgents??t.showUltracodeAgents??!1,document.getElementById("appSettingsUltracodeFloatingWindows").checked=e.ultracodeFloatingWindows??t.ultracodeFloatingWindows??!1,document.getElementById("appSettingsShowMultiMonitorButton").checked=e.showMultiMonitorButton??t.showMultiMonitorButton??!1,document.getElementById("appSettingsShowPlanUsageLimits").checked=this.planUsageChipEnabled(e),document.getElementById("appSettingsShowRedrawButton").checked=e.showRedrawButton??t.showRedrawButton??!1,document.getElementById("appSettingsShowSessionButton").checked=e.showSessionButton??t.showSessionButton??!1,document.getElementById("appSettingsShowAwayDigestButton").checked=e.showAwayDigestButton??t.showAwayDigestButton??!1,document.getElementById("appSettingsShowCronButton").checked=e.showCronButton??t.showCronButton??!1;const s=document.getElementById("appSettingsGestureControlItem");s&&(s.style.display=window.__codemanGestureAvailable?"":"none"),document.getElementById("appSettingsGestureControl").checked=e.gestureControlEnabled??t.gestureControlEnabled??!1,document.getElementById("appSettingsSubagentTracking").checked=e.subagentTrackingEnabled??t.subagentTrackingEnabled??!0,document.getElementById("appSettingsSubagentActiveTabOnly").checked=e.subagentActiveTabOnly??t.subagentActiveTabOnly??!0,document.getElementById("appSettingsImageWatcherEnabled").checked=e.imageWatcherEnabled??t.imageWatcherEnabled??!1,document.getElementById("appSettingsTunnelEnabled").checked=e.tunnelEnabled??!1,this.loadTunnelStatus(),document.getElementById("appSettingsLocalEcho").checked=e.localEchoEnabled??MobileDetection.isTouchDevice(),document.getElementById("appSettingsTerminalWheelLocal").checked=e.terminalWheelLocalScrollback??t.terminalWheelLocalScrollback??!1,document.getElementById("appSettingsCjkInput").checked=e.cjkInputEnabled??t.cjkInputEnabled??!1,document.getElementById("appSettingsExtendedKeyboardBar").checked=e.extendedKeyboardBar??!1,document.getElementById("appSettingsTabTwoRows").checked=e.tabTwoRows??t.tabTwoRows??!1;const o=document.getElementById("appSettingsClaudeMode"),a=document.getElementById("allowedToolsRow");o.value=e.claudeMode||"dangerously-skip-permissions",document.getElementById("appSettingsAllowedTools").value=e.allowedTools||"",a.style.display=o.value==="allowedTools"?"":"none",o.onchange=()=>{a.style.display=o.value==="allowedTools"?"":"none"},document.getElementById("appSettingsCodexDangerouslyBypassApprovals").checked=e.codexDangerouslyBypassApprovals??!1,document.getElementById("appSettingsAgentTeams").checked=e.agentTeamsEnabled??!1,document.getElementById("appSettingsClaudeModel").value=e.claudeModel??"",document.getElementById("appSettingsOpusContext1m").checked=e.opusContext1mEnabled??!1,document.getElementById("appSettingsRemoteAutoReconnect").checked=e.remoteAutoReconnect??!0,document.getElementById("appSettingsThinkingEffort").value=e.thinkingEffort??"";const i=e.nice||{};document.getElementById("appSettingsNiceEnabled").checked=i.enabled??!1,document.getElementById("appSettingsNiceValue").value=i.niceValue??10,this.loadModelConfigForSettings();const l=this.notificationManager?.preferences||{};document.getElementById("appSettingsNotifEnabled").checked=l.enabled??!0,document.getElementById("appSettingsNotifBrowser").checked=l.browserNotifications??!1,document.getElementById("appSettingsNotifAudio").checked=l.audioAlerts??!1,document.getElementById("appSettingsNotifStuckMins").value=Math.round((l.stuckThresholdMs||6e5)/6e4),document.getElementById("appSettingsNotifCritical").checked=!l.muteCritical,document.getElementById("appSettingsNotifWarning").checked=!l.muteWarning,document.getElementById("appSettingsNotifInfo").checked=!l.muteInfo,document.getElementById("appSettingsPushEnabled").checked=!!this._pushSubscription,this._updatePushUI(!!this._pushSubscription);const r=l.eventTypes||{},d=r.permission_prompt||{};document.getElementById("eventPermissionEnabled").checked=d.enabled??!0,document.getElementById("eventPermissionBrowser").checked=d.browser??!0,document.getElementById("eventPermissionPush").checked=d.push??!1,document.getElementById("eventPermissionAudio").checked=d.audio??!0;const c=r.elicitation_dialog||{};document.getElementById("eventQuestionEnabled").checked=c.enabled??!0,document.getElementById("eventQuestionBrowser").checked=c.browser??!0,document.getElementById("eventQuestionPush").checked=c.push??!1,document.getElementById("eventQuestionAudio").checked=c.audio??!0;const u=r.idle_prompt||{};document.getElementById("eventIdleEnabled").checked=u.enabled??!0,document.getElementById("eventIdleBrowser").checked=u.browser??!0,document.getElementById("eventIdlePush").checked=u.push??!1,document.getElementById("eventIdleAudio").checked=u.audio??!1;const h=r.stop||{};document.getElementById("eventStopEnabled").checked=h.enabled??!0,document.getElementById("eventStopBrowser").checked=h.browser??!1,document.getElementById("eventStopPush").checked=h.push??!1,document.getElementById("eventStopAudio").checked=h.audio??!1;const p=r.respawn_cycle||{};document.getElementById("eventRespawnEnabled").checked=p.enabled??!0,document.getElementById("eventRespawnBrowser").checked=p.browser??!1,document.getElementById("eventRespawnPush").checked=p.push??!1,document.getElementById("eventRespawnAudio").checked=p.audio??!1;const f=r.ralph_complete||{};document.getElementById("eventRalphEnabled").checked=f.enabled??!0,document.getElementById("eventRalphBrowser").checked=f.browser??!0,document.getElementById("eventRalphPush").checked=f.push??!1,document.getElementById("eventRalphAudio").checked=f.audio??!0;const b=r.subagent_spawn||{};document.getElementById("eventSubagentEnabled").checked=b.enabled??!1,document.getElementById("eventSubagentBrowser").checked=b.browser??!1,document.getElementById("eventSubagentPush").checked=b.push??!1,document.getElementById("eventSubagentAudio").checked=b.audio??!1;const m=document.getElementById("notifPermissionStatus");if(m&&typeof Notification<"u"){const g=Notification.permission;m.textContent=g==="granted"?"\u2713":g==="denied"?"\u2717":"?",m.classList.remove("granted","denied"),g==="granted"?m.classList.add("granted"):g==="denied"&&m.classList.add("denied")}const S=VoiceInput._getDeepgramConfig();document.getElementById("voiceDeepgramKey").value=S.apiKey||"",document.getElementById("voiceLanguage").value=S.language||"en-US",document.getElementById("voiceKeyterms").value=S.keyterms||"refactor, endpoint, middleware, callback, async, regex, TypeScript, npm, API, deploy, config, linter, env, webhook, schema, CLI, JSON, CSS, DOM, SSE, backend, frontend, localhost, dependencies, repository, merge, rebase, diff, commit, com",document.getElementById("voiceInsertMode").value=S.insertMode||"direct";const E=document.getElementById("voiceDeepgramKey");E.type="password",document.getElementById("voiceKeyToggleBtn").textContent="Show";const v=VoiceInput.getActiveProviderName(),y=document.getElementById("voiceProviderStatus");y.textContent=v,y.className="voice-provider-status"+(v.startsWith("Deepgram")?" active":""),this._initUpdatesSection(),this.switchSettingsTab("settings-display");const w=document.getElementById("appSettingsModal");w.querySelectorAll(".modal-tabs .modal-tab-btn").forEach(g=>{g.onclick=()=>this.switchSettingsTab(g.dataset.tab)}),w.classList.add("active"),this.activeFocusTrap=new FocusTrap(w),this.activeFocusTrap.activate()},switchSettingsTab(e){const t=document.getElementById("appSettingsModal");t.querySelectorAll(".modal-tabs .modal-tab-btn").forEach(n=>{n.classList.toggle("active",n.dataset.tab===e)}),t.querySelectorAll(".modal-tab-content").forEach(n=>{n.classList.toggle("hidden",n.id!==e)}),e==="settings-shortcuts"&&this.renderShortcutSettingsList?.()},closeAppSettings(){document.getElementById("appSettingsModal").classList.remove("active"),this.activeFocusTrap&&(this.activeFocusTrap.deactivate(),this.activeFocusTrap=null)},_updatePhaseText(e){return{queued:"Queued\u2026",preparing:"Preparing\u2026",stashing:"Stashing local changes\u2026",fetching:"Fetching release\u2026",checkout:"Checking out release\u2026",installing:"Installing dependencies\u2026",building:"Building\u2026",restarting:"Restarting Codeman\u2026"}[e]||e},_initUpdatesSection(){const e=this.$("updateCurrentVersion");e&&(e.textContent=(this.$("versionDisplay")?.textContent||"").trim()||"\u2014");for(const t of["updateResult","updateActionRow","updateNotes","updateProgress"]){const n=this.$(t);n&&(n.style.display="none")}this._updateCheck=null},_setUpdateResult(e){const t=this.$("updateResult");t&&(t.style.display="block",t.innerHTML=e)},_setUpdateProgress(e){const t=this.$("updateProgress");t&&(t.style.display="block",t.innerHTML=e)},async checkForUpdate(){const e=this.$("updateCheckBtn");e&&(e.disabled=!0,e.textContent="Checking\u2026");const t=await this._apiJson("/api/system/update/check");e&&(e.disabled=!1,e.textContent="Check now");const n=this.$("updateActionRow"),s=this.$("updateNotes");if(n&&(n.style.display="none"),s&&(s.style.display="none"),!t){this._setUpdateResult("Could not check for updates. Try again later.");return}this._updateCheck=t;const o=this.$("updateCurrentVersion");if(o&&t.currentVersion&&(o.textContent=`v${t.currentVersion}`),t.installKind&&t.installKind!=="git"){this._setUpdateResult(`This install can't update itself (${escapeHtml(t.installKind)}). Update with <code>npm i -g aicodeman@latest</code>.`);return}if(t.selfUpdateEnabled===!1){this._setUpdateResult("In-app updates are disabled on this server (CODEMAN_DISABLE_SELF_UPDATE=1).");return}if(t.error&&!t.updateAvailable){this._setUpdateResult(escapeHtml(t.error));return}if(t.updateAvailable&&t.latestVersion){this._setUpdateResult(`Update available: <strong>v${escapeHtml(t.latestVersion)}</strong> (current v${escapeHtml(t.currentVersion||"")})`);const a=this.$("updateActionLabel");a&&(a.textContent=`Update to v${t.latestVersion}`),n&&(n.style.display="flex");const i=this.$("updateNowBtn");i&&(i.disabled=!1,i.textContent="Update now"),s&&t.notes&&(s.style.display="block",s.textContent=t.notes)}else this._setUpdateResult(`You're up to date (v${escapeHtml(t.currentVersion||"")}).`)},async startSelfUpdate(){const e=this._updateCheck?.latestVersion?`v${this._updateCheck.latestVersion}`:"the latest release";if(!confirm(`Update Codeman to ${e}? The server will restart and this page will reload.`))return;const t=this.$("updateNowBtn");t&&(t.disabled=!0,t.textContent="Starting\u2026");const n=await this._apiPost("/api/system/update",{});if(!n||!n.ok){let a="Failed to start the update.";try{const i=await n.json();typeof i?.error=="string"&&i.error&&(a=i.error)}catch{}this._setUpdateProgress(`<span style="color:var(--danger,#e5534b)">${escapeHtml(a)}</span>`),t&&(t.disabled=!1,t.textContent="Update now");return}const s=this.$("updateActionRow");s&&(s.style.display="none");const o=this.$("updateNotes");o&&(o.style.display="none"),this._setUpdateProgress("Starting update\u2026"),this._pollUpdateStatus()},_stopUpdatePolling(){this._updatePollTimer&&(clearInterval(this._updatePollTimer),this._updatePollTimer=null)},_pollUpdateStatus(){this._stopUpdatePolling();const e=new Set(["completed","completed-needs-manual-restart","failed","idle"]),t=async()=>{let n=null;try{const s=await fetch("/api/system/update/status");if(s.ok){const o=await s.json();n=o&&o.success===!0?o.data:o}}catch{}if(!n){this._setUpdateProgress("\u21BB Restarting Codeman\u2026");return}if(!e.has(n.phase)){const s=n.message&&n.message.trim()?n.message.trim():this._updatePhaseText(n.phase);let o="";n.startedAt&&(o=` <span style="color:var(--text-secondary)">\xB7 ${Math.max(0,Math.round((Date.now()-n.startedAt)/1e3))}s</span>`),this._setUpdateProgress(`<span class="tunnel-spinner"></span> ${escapeHtml(s)}${o}`);return}if(this._stopUpdatePolling(),n.phase==="completed"){let s=`<span style="color:var(--success,#3fb950)">\u2713 Updated to v${escapeHtml(n.toVersion||"")}. Reloading\u2026</span>`;n.stashRef&&(s+=`<br><span style="color:var(--text-secondary)">Local changes stashed as <code>${escapeHtml(n.stashRef)}</code> \u2014 run <code>git stash pop</code> to restore.</span>`),this._setUpdateProgress(s),setTimeout(()=>location.reload(),2500)}else if(n.phase==="completed-needs-manual-restart")this._setUpdateProgress(`Update staged. Restart Codeman to apply:<br><code>${escapeHtml(n.manualRestartCommand||"restart codeman web")}</code>`);else if(n.phase==="failed"){let s=`<span style="color:var(--danger,#e5534b)">\u2717 ${escapeHtml(n.message||"Update failed")}.</span>`;n.error&&(s+=`<br><span style="color:var(--text-secondary)">${escapeHtml(n.error)}</span>`),s+='<br><span style="color:var(--text-secondary)">The previous version is still running.</span>',n.stashRef&&(s+=`<br><span style="color:var(--text-secondary)">Local changes stashed as <code>${escapeHtml(n.stashRef)}</code>.</span>`),this._setUpdateProgress(s);const o=this.$("updateNowBtn"),a=this.$("updateActionRow");o&&(o.disabled=!1,o.textContent="Try again"),a&&(a.style.display="flex")}};t(),this._updatePollTimer=setInterval(t,1500)},async loadTunnelStatus(){try{const t=await(await fetch("/api/tunnel/status")).json(),n=t?.success===!0?t.data:t,s=n.running&&n.url;this._tunnelUrl=s?n.url:null,this._updateTunnelUrlDisplay(this._tunnelUrl),this._updateWelcomeTunnelBtn(!!s,this._tunnelUrl),this._updateTunnelIndicator(!!s)}catch{this._tunnelUrl=null,this._updateTunnelUrlDisplay(null),this._updateWelcomeTunnelBtn(!1),this._updateTunnelIndicator(!1)}},_updateTunnelUrlRow(e,t,n,s=""){const o=document.getElementById(e),a=document.getElementById(t);if(!(!o||!a))if(n){const i=n+s;o.style.display="",a.textContent=i,a.onclick=()=>{navigator.clipboard.writeText(i).then(()=>{this.showToast(`${s?"Upload":"Tunnel"} URL copied`,"success")})}}else o.style.display="none",a.textContent="",a.onclick=null},_updateTunnelUrlDisplay(e){this._updateTunnelUrlRow("tunnelUrlRow","tunnelUrlDisplay",e),this._updateTunnelUrlRow("tunnelUploadUrlRow","tunnelUploadUrlDisplay",e,"/upload.html")},showTunnelQR(){this.closeTunnelQR();const e=document.createElement("div");e.id="tunnelQrOverlay",e.style.cssText="position:fixed;inset:0;background:rgba(0,0,0,0.7);z-index:5000;display:flex;align-items:center;justify-content:center;cursor:pointer",e.onclick=n=>{n.target===e&&this.closeTunnelQR()};const t=document.createElement("div");t.style.cssText="background:var(--bg-card);border:1px solid var(--border);border-radius:12px;padding:24px;text-align:center;max-width:340px;width:90vw;box-shadow:var(--shadow-lg);cursor:default",t.innerHTML=`
|
|
1
|
+
"use strict";Object.assign(CodemanApp.prototype,{_onHookIdlePrompt(e){e.sessionId&&this.setPendingHook(e.sessionId,"idle_prompt"),this._notifySession(e.sessionId,"warning","hook-idle","Waiting for Input",e.message||"Claude is idle and waiting for a prompt")},_onHookPermissionPrompt(e){e.sessionId&&this.setPendingHook(e.sessionId,"permission_prompt");const t=e.tool?`${e.tool}${e.command?": "+e.command:e.file?": "+e.file:""}`:"";this._notifySession(e.sessionId,"critical","hook-permission","Permission Required",t||"Claude needs tool approval to continue")},_onHookElicitationDialog(e){e.sessionId&&this.setPendingHook(e.sessionId,"elicitation_dialog"),this._notifySession(e.sessionId,"critical","hook-elicitation","Question Asked",e.question||"Claude is asking a question and waiting for your answer")},_onHookStop(e){e.sessionId&&this.clearPendingHooks(e.sessionId),this._notifySession(e.sessionId,"info","hook-stop","Response Complete",e.reason||"Claude has finished responding")},_onHookTeammateIdle(e){const t=this.sessions.get(e.sessionId);this._notifySession(e.sessionId,"warning","hook-teammate-idle","Teammate Idle",`A teammate is idle in ${t?.name||e.sessionId}`)},_onHookTaskCompleted(e){const t=this.sessions.get(e.sessionId);this._notifySession(e.sessionId,"info","hook-task-completed","Task Completed",`A team task completed in ${t?.name||e.sessionId}`)},_onTunnelStarted(e){console.log("[Tunnel] Started:",e.url),this._tunnelUrl=e.url,this._dismissTunnelConnecting(),this._updateTunnelUrlDisplay(e.url),this._updateTunnelIndicator(!0),document.getElementById("welcomeOverlay")?.classList.contains("visible")?(this._updateWelcomeTunnelBtn(!0,e.url,!0),this.showToast("Tunnel active","success")):(this._updateWelcomeTunnelBtn(!0,e.url),this.showToast(`Tunnel active: ${e.url}`,"success"),this.showTunnelQR())},_onTunnelStopped(){console.log("[Tunnel] Stopped"),this._tunnelUrl=null,this._dismissTunnelConnecting(),this._updateTunnelUrlDisplay(null),this._updateWelcomeTunnelBtn(!1),this._updateTunnelIndicator(!1),this.closeTunnelPanel(),this.closeTunnelQR()},_onTunnelProgress(e){console.log("[Tunnel] Progress:",e.message);const t=document.getElementById("tunnelConnectingToast");t&&(t.innerHTML=`<span class="tunnel-spinner"></span> ${e.message}`);const n=document.getElementById("welcomeTunnelBtn");n?.classList.contains("connecting")&&(n.innerHTML=`<span class="tunnel-spinner"></span> ${e.message}`)},_onTunnelError(e){console.warn("[Tunnel] Error:",e.message),this._dismissTunnelConnecting(),this.showToast(`Tunnel error: ${e.message}`,"error");const t=document.getElementById("welcomeTunnelBtn");t&&(t.disabled=!1,t.classList.remove("connecting"))},_onTunnelQrRotated(e){if(e.svg){const t=document.getElementById("tunnelQrContainer");t&&(t.innerHTML=e.svg);const n=document.getElementById("welcomeQrInner");n&&(n.innerHTML=e.svg)}else this._refreshTunnelQrFromApi();this._resetQrCountdown()},_onTunnelQrRegenerated(e){if(e.svg){const t=document.getElementById("tunnelQrContainer");t&&(t.innerHTML=e.svg);const n=document.getElementById("welcomeQrInner");n&&(n.innerHTML=e.svg)}else this._refreshTunnelQrFromApi();this._resetQrCountdown()},_onTunnelQrAuthUsed(e){const n=(e.ua||"Unknown device").match(/Chrome|Firefox|Safari|Edge|Mobile/)?.[0]||"Browser";this.showToast(`Device authenticated via QR (${n}, ${e.ip}). Not you?`,"warning",{duration:1e4,action:{label:"Revoke All",onClick:()=>{fetch("/api/auth/revoke",{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"}).then(()=>this.showToast("All sessions revoked","success")).catch(()=>this.showToast("Failed to revoke sessions","error"))}}})},registerServiceWorker(){"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js").then(e=>{this._swRegistration=e,navigator.serviceWorker.addEventListener("message",t=>{if(t.data?.type==="notification-click"){const{sessionId:n}=t.data;n&&this.sessions.has(n)&&this.selectSession(n),window.focus()}}),e.pushManager.getSubscription().then(t=>{t&&(this._pushSubscription=t,this._updatePushUI(!0))})}).catch(()=>{})},async subscribeToPush(){if(!this._swRegistration){this.showToast("Service worker not available. HTTPS or localhost required.","error");return}try{const e=await this._apiJson("/api/push/vapid-key");if(!e)throw new Error("Failed to get VAPID key");const t=urlBase64ToUint8Array(e.publicKey),n=await this._swRegistration.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:t}),s=n.toJSON(),o=await this._apiJson("/api/push/subscribe",{method:"POST",body:{endpoint:s.endpoint,keys:s.keys,userAgent:navigator.userAgent,pushPreferences:this._buildPushPreferences()}});if(!o)throw new Error("Failed to register subscription");this._pushSubscription=n,this._pushSubscriptionId=o.id,localStorage.setItem("codeman-push-subscription-id",o.id),this._updatePushUI(!0),this.showToast("Push notifications enabled","success")}catch(e){this.showToast("Push subscription failed: "+(e.message||e),"error")}},async unsubscribeFromPush(){try{this._pushSubscription&&await this._pushSubscription.unsubscribe();const e=this._pushSubscriptionId||localStorage.getItem("codeman-push-subscription-id");e&&await fetch(`/api/push/subscribe/${e}`,{method:"DELETE"}).catch(()=>{}),this._pushSubscription=null,this._pushSubscriptionId=null,localStorage.removeItem("codeman-push-subscription-id"),this._updatePushUI(!1),this.showToast("Push notifications disabled","success")}catch(e){this.showToast("Failed to unsubscribe: "+(e.message||e),"error")}},async togglePushSubscription(){this._pushSubscription?await this.unsubscribeFromPush():await this.subscribeToPush()},async _syncPushPreferences(){const e=this._pushSubscriptionId||localStorage.getItem("codeman-push-subscription-id");if(e)try{await fetch(`/api/push/subscribe/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({pushPreferences:this._buildPushPreferences()})})}catch{}},_buildPushPreferences(){const e={},t={"hook:permission_prompt":"eventPermissionPush","hook:elicitation_dialog":"eventQuestionPush","hook:idle_prompt":"eventIdlePush","hook:stop":"eventStopPush","respawn:blocked":"eventRespawnPush","session:ralphCompletionDetected":"eventRalphPush"};for(const[n,s]of Object.entries(t)){const o=document.getElementById(s);e[n]=o?o.checked:!0}return e["session:error"]=!0,e},_updatePushUI(e){const t=document.getElementById("pushSubscribeBtn"),n=document.getElementById("pushSubscriptionStatus");t&&(t.textContent=e?"Unsubscribe":"Subscribe"),n&&(n.textContent=e?"active":"off",n.classList.remove("granted","denied"),e&&n.classList.add("granted"))},openAppSettings(){const e=this.loadAppSettingsFromStorage();document.getElementById("appSettingsDisplayName").value=e.displayName||"Codeman",document.getElementById("appSettingsLanguage").value=e.language==="zh-CN"?"zh-CN":"en",document.getElementById("appSettingsClaudeMdPath").value=e.defaultClaudeMdPath||"",document.getElementById("appSettingsDefaultDir").value=e.defaultWorkingDir||"";const t=this.getDefaultSettings();document.getElementById("appSettingsRalphEnabled").checked=e.ralphTrackerEnabled??t.ralphTrackerEnabled??!1,document.getElementById("appSettingsShowFontControls").checked=e.showFontControls??t.showFontControls??!1,document.getElementById("appSettingsShowSystemStats").checked=e.showSystemStats??t.showSystemStats??!0,document.getElementById("appSettingsShowLifecycleLog").checked=e.showLifecycleLog??t.showLifecycleLog??!1,document.getElementById("appSettingsShowResponseViewer").checked=e.showResponseViewer??t.showResponseViewer??!1,document.getElementById("appSettingsShowFileViewerButton").checked=e.showFileViewerButton??t.showFileViewerButton??!0,document.getElementById("appSettingsShowAttachmentsButton").checked=e.showAttachmentsButton??t.showAttachmentsButton??!1,document.getElementById("appSettingsSkin").value=e.skin??t.skin??"daylight-blue",document.getElementById("appSettingsWebglRenderer").checked=e.webglRendererEnabled??t.webglRendererEnabled??!0;const n=document.getElementById("appSettingsWebglRendererItem");n&&(n.style.display=MobileDetection.getDeviceType()==="desktop"?"":"none"),document.getElementById("appSettingsShowMonitor").checked=e.showMonitor??t.showMonitor??!1,document.getElementById("appSettingsShowProjectInsights").checked=e.showProjectInsights??t.showProjectInsights??!1,document.getElementById("appSettingsShowFileBrowser").checked=e.showFileBrowser??t.showFileBrowser??!1,document.getElementById("appSettingsShowSubagents").checked=e.showSubagents??t.showSubagents??!1,document.getElementById("appSettingsShowUltracodeAgents").checked=e.showUltracodeAgents??t.showUltracodeAgents??!1,document.getElementById("appSettingsUltracodeFloatingWindows").checked=e.ultracodeFloatingWindows??t.ultracodeFloatingWindows??!1,document.getElementById("appSettingsShowMultiMonitorButton").checked=e.showMultiMonitorButton??t.showMultiMonitorButton??!1,document.getElementById("appSettingsShowPlanUsageLimits").checked=this.planUsageChipEnabled(e),document.getElementById("appSettingsShowRedrawButton").checked=e.showRedrawButton??t.showRedrawButton??!1,document.getElementById("appSettingsShowSessionButton").checked=e.showSessionButton??t.showSessionButton??!1,document.getElementById("appSettingsShowAwayDigestButton").checked=e.showAwayDigestButton??t.showAwayDigestButton??!1,document.getElementById("appSettingsShowCronButton").checked=e.showCronButton??t.showCronButton??!1;const s=document.getElementById("appSettingsGestureControlItem");s&&(s.style.display=window.__codemanGestureAvailable?"":"none"),document.getElementById("appSettingsGestureControl").checked=e.gestureControlEnabled??t.gestureControlEnabled??!1,document.getElementById("appSettingsSubagentTracking").checked=e.subagentTrackingEnabled??t.subagentTrackingEnabled??!0,document.getElementById("appSettingsSubagentActiveTabOnly").checked=e.subagentActiveTabOnly??t.subagentActiveTabOnly??!0,document.getElementById("appSettingsImageWatcherEnabled").checked=e.imageWatcherEnabled??t.imageWatcherEnabled??!1,document.getElementById("appSettingsTunnelEnabled").checked=e.tunnelEnabled??!1,this.loadTunnelStatus(),document.getElementById("appSettingsLocalEcho").checked=e.localEchoEnabled??MobileDetection.isTouchDevice(),document.getElementById("appSettingsTerminalWheelLocal").checked=e.terminalWheelLocalScrollback??t.terminalWheelLocalScrollback??!1,document.getElementById("appSettingsCjkInput").checked=e.cjkInputEnabled??t.cjkInputEnabled??!1,document.getElementById("appSettingsExtendedKeyboardBar").checked=e.extendedKeyboardBar??!1,document.getElementById("appSettingsTabTwoRows").checked=e.tabTwoRows??t.tabTwoRows??!1;const o=document.getElementById("appSettingsClaudeMode"),a=document.getElementById("allowedToolsRow");o.value=e.claudeMode||"dangerously-skip-permissions",document.getElementById("appSettingsAllowedTools").value=e.allowedTools||"",a.style.display=o.value==="allowedTools"?"":"none",o.onchange=()=>{a.style.display=o.value==="allowedTools"?"":"none"},document.getElementById("appSettingsCodexDangerouslyBypassApprovals").checked=e.codexDangerouslyBypassApprovals??!1,document.getElementById("appSettingsAgentTeams").checked=e.agentTeamsEnabled??!1,document.getElementById("appSettingsClaudeModel").value=e.claudeModel??"",document.getElementById("appSettingsOpusContext1m").checked=e.opusContext1mEnabled??!1,document.getElementById("appSettingsRemoteAutoReconnect").checked=e.remoteAutoReconnect??!0,document.getElementById("appSettingsThinkingEffort").value=e.thinkingEffort??"";const i=e.nice||{};document.getElementById("appSettingsNiceEnabled").checked=i.enabled??!1,document.getElementById("appSettingsNiceValue").value=i.niceValue??10,this.loadModelConfigForSettings();const l=this.notificationManager?.preferences||{};document.getElementById("appSettingsNotifEnabled").checked=l.enabled??!0,document.getElementById("appSettingsNotifBrowser").checked=l.browserNotifications??!1,document.getElementById("appSettingsNotifAudio").checked=l.audioAlerts??!1,document.getElementById("appSettingsNotifStuckMins").value=Math.round((l.stuckThresholdMs||6e5)/6e4),document.getElementById("appSettingsNotifCritical").checked=!l.muteCritical,document.getElementById("appSettingsNotifWarning").checked=!l.muteWarning,document.getElementById("appSettingsNotifInfo").checked=!l.muteInfo,document.getElementById("appSettingsPushEnabled").checked=!!this._pushSubscription,this._updatePushUI(!!this._pushSubscription);const r=l.eventTypes||{},d=r.permission_prompt||{};document.getElementById("eventPermissionEnabled").checked=d.enabled??!0,document.getElementById("eventPermissionBrowser").checked=d.browser??!0,document.getElementById("eventPermissionPush").checked=d.push??!1,document.getElementById("eventPermissionAudio").checked=d.audio??!0;const c=r.elicitation_dialog||{};document.getElementById("eventQuestionEnabled").checked=c.enabled??!0,document.getElementById("eventQuestionBrowser").checked=c.browser??!0,document.getElementById("eventQuestionPush").checked=c.push??!1,document.getElementById("eventQuestionAudio").checked=c.audio??!0;const u=r.idle_prompt||{};document.getElementById("eventIdleEnabled").checked=u.enabled??!0,document.getElementById("eventIdleBrowser").checked=u.browser??!0,document.getElementById("eventIdlePush").checked=u.push??!1,document.getElementById("eventIdleAudio").checked=u.audio??!1;const h=r.stop||{};document.getElementById("eventStopEnabled").checked=h.enabled??!1,document.getElementById("eventStopBrowser").checked=h.browser??!1,document.getElementById("eventStopPush").checked=h.push??!1,document.getElementById("eventStopAudio").checked=h.audio??!1;const p=r.respawn_cycle||{};document.getElementById("eventRespawnEnabled").checked=p.enabled??!0,document.getElementById("eventRespawnBrowser").checked=p.browser??!1,document.getElementById("eventRespawnPush").checked=p.push??!1,document.getElementById("eventRespawnAudio").checked=p.audio??!1;const f=r.ralph_complete||{};document.getElementById("eventRalphEnabled").checked=f.enabled??!0,document.getElementById("eventRalphBrowser").checked=f.browser??!0,document.getElementById("eventRalphPush").checked=f.push??!1,document.getElementById("eventRalphAudio").checked=f.audio??!0;const b=r.subagent_spawn||{};document.getElementById("eventSubagentEnabled").checked=b.enabled??!1,document.getElementById("eventSubagentBrowser").checked=b.browser??!1,document.getElementById("eventSubagentPush").checked=b.push??!1,document.getElementById("eventSubagentAudio").checked=b.audio??!1;const m=document.getElementById("notifPermissionStatus");if(m&&typeof Notification<"u"){const g=Notification.permission;m.textContent=g==="granted"?"\u2713":g==="denied"?"\u2717":"?",m.classList.remove("granted","denied"),g==="granted"?m.classList.add("granted"):g==="denied"&&m.classList.add("denied")}const S=VoiceInput._getDeepgramConfig();document.getElementById("voiceDeepgramKey").value=S.apiKey||"",document.getElementById("voiceLanguage").value=S.language||"en-US",document.getElementById("voiceKeyterms").value=S.keyterms||"refactor, endpoint, middleware, callback, async, regex, TypeScript, npm, API, deploy, config, linter, env, webhook, schema, CLI, JSON, CSS, DOM, SSE, backend, frontend, localhost, dependencies, repository, merge, rebase, diff, commit, com",document.getElementById("voiceInsertMode").value=S.insertMode||"direct";const E=document.getElementById("voiceDeepgramKey");E.type="password",document.getElementById("voiceKeyToggleBtn").textContent="Show";const v=VoiceInput.getActiveProviderName(),y=document.getElementById("voiceProviderStatus");y.textContent=v,y.className="voice-provider-status"+(v.startsWith("Deepgram")?" active":""),this._initUpdatesSection(),this.switchSettingsTab("settings-display");const w=document.getElementById("appSettingsModal");w.querySelectorAll(".modal-tabs .modal-tab-btn").forEach(g=>{g.onclick=()=>this.switchSettingsTab(g.dataset.tab)}),w.classList.add("active"),this.activeFocusTrap=new FocusTrap(w),this.activeFocusTrap.activate()},switchSettingsTab(e){const t=document.getElementById("appSettingsModal");t.querySelectorAll(".modal-tabs .modal-tab-btn").forEach(n=>{n.classList.toggle("active",n.dataset.tab===e)}),t.querySelectorAll(".modal-tab-content").forEach(n=>{n.classList.toggle("hidden",n.id!==e)}),e==="settings-shortcuts"&&this.renderShortcutSettingsList?.()},closeAppSettings(){document.getElementById("appSettingsModal").classList.remove("active"),this.activeFocusTrap&&(this.activeFocusTrap.deactivate(),this.activeFocusTrap=null)},_updatePhaseText(e){return{queued:"Queued\u2026",preparing:"Preparing\u2026",stashing:"Stashing local changes\u2026",fetching:"Fetching release\u2026",checkout:"Checking out release\u2026",installing:"Installing dependencies\u2026",building:"Building\u2026",restarting:"Restarting Codeman\u2026"}[e]||e},_initUpdatesSection(){const e=this.$("updateCurrentVersion");e&&(e.textContent=(this.$("versionDisplay")?.textContent||"").trim()||"\u2014");for(const t of["updateResult","updateActionRow","updateNotes","updateProgress"]){const n=this.$(t);n&&(n.style.display="none")}this._updateCheck=null},_setUpdateResult(e){const t=this.$("updateResult");t&&(t.style.display="block",t.innerHTML=e)},_setUpdateProgress(e){const t=this.$("updateProgress");t&&(t.style.display="block",t.innerHTML=e)},async checkForUpdate(){const e=this.$("updateCheckBtn");e&&(e.disabled=!0,e.textContent="Checking\u2026");const t=await this._apiJson("/api/system/update/check");e&&(e.disabled=!1,e.textContent="Check now");const n=this.$("updateActionRow"),s=this.$("updateNotes");if(n&&(n.style.display="none"),s&&(s.style.display="none"),!t){this._setUpdateResult("Could not check for updates. Try again later.");return}this._updateCheck=t;const o=this.$("updateCurrentVersion");if(o&&t.currentVersion&&(o.textContent=`v${t.currentVersion}`),t.installKind&&t.installKind!=="git"){this._setUpdateResult(`This install can't update itself (${escapeHtml(t.installKind)}). Update with <code>npm i -g aicodeman@latest</code>.`);return}if(t.selfUpdateEnabled===!1){this._setUpdateResult("In-app updates are disabled on this server (CODEMAN_DISABLE_SELF_UPDATE=1).");return}if(t.error&&!t.updateAvailable){this._setUpdateResult(escapeHtml(t.error));return}if(t.updateAvailable&&t.latestVersion){this._setUpdateResult(`Update available: <strong>v${escapeHtml(t.latestVersion)}</strong> (current v${escapeHtml(t.currentVersion||"")})`);const a=this.$("updateActionLabel");a&&(a.textContent=`Update to v${t.latestVersion}`),n&&(n.style.display="flex");const i=this.$("updateNowBtn");i&&(i.disabled=!1,i.textContent="Update now"),s&&t.notes&&(s.style.display="block",s.textContent=t.notes)}else this._setUpdateResult(`You're up to date (v${escapeHtml(t.currentVersion||"")}).`)},async startSelfUpdate(){const e=this._updateCheck?.latestVersion?`v${this._updateCheck.latestVersion}`:"the latest release";if(!confirm(`Update Codeman to ${e}? The server will restart and this page will reload.`))return;const t=this.$("updateNowBtn");t&&(t.disabled=!0,t.textContent="Starting\u2026");const n=await this._apiPost("/api/system/update",{});if(!n||!n.ok){let a="Failed to start the update.";try{const i=await n.json();typeof i?.error=="string"&&i.error&&(a=i.error)}catch{}this._setUpdateProgress(`<span style="color:var(--danger,#e5534b)">${escapeHtml(a)}</span>`),t&&(t.disabled=!1,t.textContent="Update now");return}const s=this.$("updateActionRow");s&&(s.style.display="none");const o=this.$("updateNotes");o&&(o.style.display="none"),this._setUpdateProgress("Starting update\u2026"),this._pollUpdateStatus()},_stopUpdatePolling(){this._updatePollTimer&&(clearInterval(this._updatePollTimer),this._updatePollTimer=null)},_pollUpdateStatus(){this._stopUpdatePolling();const e=new Set(["completed","completed-needs-manual-restart","failed","idle"]),t=async()=>{let n=null;try{const s=await fetch("/api/system/update/status");if(s.ok){const o=await s.json();n=o&&o.success===!0?o.data:o}}catch{}if(!n){this._setUpdateProgress("\u21BB Restarting Codeman\u2026");return}if(!e.has(n.phase)){const s=n.message&&n.message.trim()?n.message.trim():this._updatePhaseText(n.phase);let o="";n.startedAt&&(o=` <span style="color:var(--text-secondary)">\xB7 ${Math.max(0,Math.round((Date.now()-n.startedAt)/1e3))}s</span>`),this._setUpdateProgress(`<span class="tunnel-spinner"></span> ${escapeHtml(s)}${o}`);return}if(this._stopUpdatePolling(),n.phase==="completed"){let s=`<span style="color:var(--success,#3fb950)">\u2713 Updated to v${escapeHtml(n.toVersion||"")}. Reloading\u2026</span>`;n.stashRef&&(s+=`<br><span style="color:var(--text-secondary)">Local changes stashed as <code>${escapeHtml(n.stashRef)}</code> \u2014 run <code>git stash pop</code> to restore.</span>`),this._setUpdateProgress(s),setTimeout(()=>location.reload(),2500)}else if(n.phase==="completed-needs-manual-restart")this._setUpdateProgress(`Update staged. Restart Codeman to apply:<br><code>${escapeHtml(n.manualRestartCommand||"restart codeman web")}</code>`);else if(n.phase==="failed"){let s=`<span style="color:var(--danger,#e5534b)">\u2717 ${escapeHtml(n.message||"Update failed")}.</span>`;n.error&&(s+=`<br><span style="color:var(--text-secondary)">${escapeHtml(n.error)}</span>`),s+='<br><span style="color:var(--text-secondary)">The previous version is still running.</span>',n.stashRef&&(s+=`<br><span style="color:var(--text-secondary)">Local changes stashed as <code>${escapeHtml(n.stashRef)}</code>.</span>`),this._setUpdateProgress(s);const o=this.$("updateNowBtn"),a=this.$("updateActionRow");o&&(o.disabled=!1,o.textContent="Try again"),a&&(a.style.display="flex")}};t(),this._updatePollTimer=setInterval(t,1500)},async loadTunnelStatus(){try{const t=await(await fetch("/api/tunnel/status")).json(),n=t?.success===!0?t.data:t,s=n.running&&n.url;this._tunnelUrl=s?n.url:null,this._updateTunnelUrlDisplay(this._tunnelUrl),this._updateWelcomeTunnelBtn(!!s,this._tunnelUrl),this._updateTunnelIndicator(!!s)}catch{this._tunnelUrl=null,this._updateTunnelUrlDisplay(null),this._updateWelcomeTunnelBtn(!1),this._updateTunnelIndicator(!1)}},_updateTunnelUrlRow(e,t,n,s=""){const o=document.getElementById(e),a=document.getElementById(t);if(!(!o||!a))if(n){const i=n+s;o.style.display="",a.textContent=i,a.onclick=()=>{navigator.clipboard.writeText(i).then(()=>{this.showToast(`${s?"Upload":"Tunnel"} URL copied`,"success")})}}else o.style.display="none",a.textContent="",a.onclick=null},_updateTunnelUrlDisplay(e){this._updateTunnelUrlRow("tunnelUrlRow","tunnelUrlDisplay",e),this._updateTunnelUrlRow("tunnelUploadUrlRow","tunnelUploadUrlDisplay",e,"/upload.html")},showTunnelQR(){this.closeTunnelQR();const e=document.createElement("div");e.id="tunnelQrOverlay",e.style.cssText="position:fixed;inset:0;background:rgba(0,0,0,0.7);z-index:5000;display:flex;align-items:center;justify-content:center;cursor:pointer",e.onclick=n=>{n.target===e&&this.closeTunnelQR()};const t=document.createElement("div");t.style.cssText="background:var(--bg-card);border:1px solid var(--border);border-radius:12px;padding:24px;text-align:center;max-width:340px;width:90vw;box-shadow:var(--shadow-lg);cursor:default",t.innerHTML=`
|
|
2
2
|
<div style="font-size:14px;font-weight:600;color:var(--text-primary);margin-bottom:16px">Scan to connect</div>
|
|
3
3
|
<div id="tunnelQrContainer" style="background:#fff;border-radius:8px;padding:16px;display:inline-block">
|
|
4
4
|
<div style="color:#666;font-size:12px">Loading...</div>
|
|
@@ -58,7 +58,7 @@ Enable the unauthenticated public tunnel anyway?`))return this._dismissTunnelCon
|
|
|
58
58
|
<td style="padding:3px 8px;color:#e0e0e0" title="${d.sessionId}">${h}</td>
|
|
59
59
|
<td style="padding:3px 8px;color:#aaa">${d.reason||""}</td>
|
|
60
60
|
<td style="padding:3px 8px;color:#666">${p.join(", ")}</td>
|
|
61
|
-
</tr>`}).join("")}catch(s){console.error("Failed to load lifecycle log:",s)}},async saveAppSettings(){const e=this.loadAppSettingsFromStorage(),t=(e.gestureControlEnabled??!1)===!0,n=(e.webglRendererEnabled??!0)===!0,s={displayName:window.CodemanI18n?.normalizeDisplayName(document.getElementById("appSettingsDisplayName").value)||"Codeman",language:window.CodemanI18n?.normalizeLanguage(document.getElementById("appSettingsLanguage").value)||"en",defaultClaudeMdPath:document.getElementById("appSettingsClaudeMdPath").value.trim(),defaultWorkingDir:document.getElementById("appSettingsDefaultDir").value.trim(),ralphTrackerEnabled:document.getElementById("appSettingsRalphEnabled").checked,showFontControls:document.getElementById("appSettingsShowFontControls").checked,showSystemStats:document.getElementById("appSettingsShowSystemStats").checked,showLifecycleLog:document.getElementById("appSettingsShowLifecycleLog").checked,showResponseViewer:document.getElementById("appSettingsShowResponseViewer").checked,showFileViewerButton:document.getElementById("appSettingsShowFileViewerButton").checked,showAttachmentsButton:document.getElementById("appSettingsShowAttachmentsButton").checked,showMonitor:document.getElementById("appSettingsShowMonitor").checked,showProjectInsights:document.getElementById("appSettingsShowProjectInsights").checked,showFileBrowser:document.getElementById("appSettingsShowFileBrowser").checked,showSubagents:document.getElementById("appSettingsShowSubagents").checked,showUltracodeAgents:document.getElementById("appSettingsShowUltracodeAgents").checked,ultracodeFloatingWindows:document.getElementById("appSettingsUltracodeFloatingWindows").checked,showMultiMonitorButton:document.getElementById("appSettingsShowMultiMonitorButton").checked,showPlanUsageLimits:document.getElementById("appSettingsShowPlanUsageLimits").checked,showRedrawButton:document.getElementById("appSettingsShowRedrawButton").checked,showSessionButton:document.getElementById("appSettingsShowSessionButton").checked,showAwayDigestButton:document.getElementById("appSettingsShowAwayDigestButton").checked,showCronButton:document.getElementById("appSettingsShowCronButton").checked,gestureControlEnabled:document.getElementById("appSettingsGestureControl").checked,subagentTrackingEnabled:document.getElementById("appSettingsSubagentTracking").checked,subagentActiveTabOnly:document.getElementById("appSettingsSubagentActiveTabOnly").checked,imageWatcherEnabled:document.getElementById("appSettingsImageWatcherEnabled").checked,tunnelEnabled:document.getElementById("appSettingsTunnelEnabled").checked,localEchoEnabled:document.getElementById("appSettingsLocalEcho").checked,terminalWheelLocalScrollback:document.getElementById("appSettingsTerminalWheelLocal").checked,cjkInputEnabled:document.getElementById("appSettingsCjkInput").checked,webglRendererEnabled:document.getElementById("appSettingsWebglRenderer").checked,extendedKeyboardBar:document.getElementById("appSettingsExtendedKeyboardBar").checked,tabTwoRows:document.getElementById("appSettingsTabTwoRows").checked,skin:document.getElementById("appSettingsSkin").value,claudeMode:document.getElementById("appSettingsClaudeMode").value,allowedTools:document.getElementById("appSettingsAllowedTools").value.trim(),codexDangerouslyBypassApprovals:document.getElementById("appSettingsCodexDangerouslyBypassApprovals").checked,agentTeamsEnabled:document.getElementById("appSettingsAgentTeams").checked,claudeModel:document.getElementById("appSettingsClaudeModel").value,opusContext1mEnabled:document.getElementById("appSettingsOpusContext1m").checked,remoteAutoReconnect:document.getElementById("appSettingsRemoteAutoReconnect").checked,thinkingEffort:document.getElementById("appSettingsThinkingEffort").value,nice:{enabled:document.getElementById("appSettingsNiceEnabled").checked,niceValue:parseInt(document.getElementById("appSettingsNiceValue").value)||10}};if(e.showTokenCount!==void 0&&(s.showTokenCount=e.showTokenCount),e.showCost!==void 0&&(s.showCost=e.showCost),e.shortcutOverrides!==void 0&&(s.shortcutOverrides=e.shortcutOverrides),this.saveAppSettingsToStorage(s),this._updateLocalEchoState(),!n&&s.webglRendererEnabled)try{localStorage.removeItem("codeman-webgl-disabled")}catch{}const o={apiKey:document.getElementById("voiceDeepgramKey").value.trim(),language:document.getElementById("voiceLanguage").value,keyterms:document.getElementById("voiceKeyterms").value.trim(),insertMode:document.getElementById("voiceInsertMode").value};VoiceInput._saveDeepgramConfig(o);const a={enabled:document.getElementById("appSettingsNotifEnabled").checked,browserNotifications:document.getElementById("appSettingsNotifBrowser").checked,audioAlerts:document.getElementById("appSettingsNotifAudio").checked,stuckThresholdMs:(parseInt(document.getElementById("appSettingsNotifStuckMins").value)||10)*6e4,muteCritical:!document.getElementById("appSettingsNotifCritical").checked,muteWarning:!document.getElementById("appSettingsNotifWarning").checked,muteInfo:!document.getElementById("appSettingsNotifInfo").checked,eventTypes:{permission_prompt:{enabled:document.getElementById("eventPermissionEnabled").checked,browser:document.getElementById("eventPermissionBrowser").checked,push:document.getElementById("eventPermissionPush").checked,audio:document.getElementById("eventPermissionAudio").checked},elicitation_dialog:{enabled:document.getElementById("eventQuestionEnabled").checked,browser:document.getElementById("eventQuestionBrowser").checked,push:document.getElementById("eventQuestionPush").checked,audio:document.getElementById("eventQuestionAudio").checked},idle_prompt:{enabled:document.getElementById("eventIdleEnabled").checked,browser:document.getElementById("eventIdleBrowser").checked,push:document.getElementById("eventIdlePush").checked,audio:document.getElementById("eventIdleAudio").checked},stop:{enabled:document.getElementById("eventStopEnabled").checked,browser:document.getElementById("eventStopBrowser").checked,push:document.getElementById("eventStopPush").checked,audio:document.getElementById("eventStopAudio").checked},session_error:{enabled:!0,browser:this.notificationManager?.preferences?.eventTypes?.session_error?.browser??!0,push:this.notificationManager?.preferences?.eventTypes?.session_error?.push??!1,audio:!1},respawn_cycle:{enabled:document.getElementById("eventRespawnEnabled").checked,browser:document.getElementById("eventRespawnBrowser").checked,push:document.getElementById("eventRespawnPush").checked,audio:document.getElementById("eventRespawnAudio").checked},token_milestone:{enabled:!0,browser:!1,push:!1,audio:!1},ralph_complete:{enabled:document.getElementById("eventRalphEnabled").checked,browser:document.getElementById("eventRalphBrowser").checked,push:document.getElementById("eventRalphPush").checked,audio:document.getElementById("eventRalphAudio").checked},subagent_spawn:{enabled:document.getElementById("eventSubagentEnabled").checked,browser:document.getElementById("eventSubagentBrowser").checked,push:document.getElementById("eventSubagentPush").checked,audio:document.getElementById("eventSubagentAudio").checked},subagent_complete:{enabled:document.getElementById("eventSubagentEnabled").checked,browser:document.getElementById("eventSubagentBrowser").checked,push:document.getElementById("eventSubagentPush").checked,audio:document.getElementById("eventSubagentAudio").checked}},_version:4};this.notificationManager&&(this.notificationManager.preferences=a,this.notificationManager.savePreferences()),this._syncPushPreferences(),this.applyHeaderVisibilitySettings(),this.applySkin(),this.applyLocalization(),this.applyTabWrapSettings(),this._updateTokensImmediate(),this.applyMonitorVisibility(),this.renderProjectInsightsPanel(),this.updateSubagentWindowVisibility(),this._updateCjkInputState(),KeyboardAccessoryBar.setMode(s.extendedKeyboardBar?"extended":"simple");const{localEchoEnabled:i,cjkInputEnabled:l,extendedKeyboardBar:r,skin:d,language:c,showPlanUsageLimits:u,showAttachmentsButton:h,showFileViewerButton:p,webglRendererEnabled:f,terminalWheelLocalScrollback:b,showSessionButton:m,showAwayDigestButton:S,showCronButton:E,...v}=s;try{const y=await this._apiPut("/api/settings",{...v,...s.showPlanUsageLimits?{statusLineTelemetry:!0}:{},notificationPreferences:a,voiceSettings:o});if(s.tunnelEnabled&&await this._handleTunnelEnableRefusal(y)){s.tunnelEnabled=!1,this.saveAppSettingsToStorage(s);const w=document.getElementById("appSettingsTunnelEnabled");w&&(w.checked=!1),this.closeAppSettings();return}await this.saveModelConfigFromSettings(),this.showToast("Settings saved","success"),s.tunnelEnabled&&this.showToast("Tunnel starting \u2014 QR code will appear when ready...","info")}catch{this.showToast("Settings saved locally","warning")}this.closeAppSettings(),s.gestureControlEnabled!==t&&(this.showToast(s.gestureControlEnabled?"Enabling gesture control \u2014 reloading\u2026":"Disabling gesture control \u2014 reloading\u2026","info"),setTimeout(()=>location.reload(),400))},async loadModelConfigForSettings(){try{const t=await(await fetch("/api/execution/model-config")).json();if(t.success&&t.data){const n=t.data,s=document.getElementById("appSettingsDefaultModel");s&&(s.value=n.defaultModel||"");const o=document.getElementById("appSettingsShowModelRecommendations");o&&(o.checked=n.showRecommendations??!0);const a=n.agentTypeOverrides||{},i=document.getElementById("appSettingsModelExplore"),l=document.getElementById("appSettingsModelImplement"),r=document.getElementById("appSettingsModelTest"),d=document.getElementById("appSettingsModelReview");i&&(i.value=a.explore||""),l&&(l.value=a.implement||""),r&&(r.value=a.test||""),d&&(d.value=a.review||"")}}catch(e){console.warn("Failed to load model config:",e)}},async saveModelConfigFromSettings(){const e=document.getElementById("appSettingsDefaultModel"),t=document.getElementById("appSettingsShowModelRecommendations"),n=document.getElementById("appSettingsModelExplore"),s=document.getElementById("appSettingsModelImplement"),o=document.getElementById("appSettingsModelTest"),a=document.getElementById("appSettingsModelReview"),i={};n?.value&&(i.explore=n.value),s?.value&&(i.implement=s.value),o?.value&&(i.test=o.value),a?.value&&(i.review=a.value);const l={defaultModel:e?.value||"",showRecommendations:t?.checked??!0,agentTypeOverrides:i};try{await fetch("/api/execution/model-config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)})}catch(r){console.warn("Failed to save model config:",r)}},isRalphTrackerEnabledByDefault(){return this.loadAppSettingsFromStorage().ralphTrackerEnabled??!1},getSettingsStorageKey(){return MobileDetection.isHandheldDevice?.()??MobileDetection.getDeviceType()==="mobile"?"codeman-app-settings-mobile":"codeman-app-settings"},getDefaultSettings(){return MobileDetection.isHandheldDevice?.()??MobileDetection.getDeviceType()==="mobile"?{showFontControls:!1,showSystemStats:!1,showTokenCount:!1,showCost:!1,showMonitor:!1,showProjectInsights:!1,showFileBrowser:!1,showSubagents:!1,showUltracodeAgents:!1,ultracodeFloatingWindows:!1,showMultiMonitorButton:!1,showPlanUsageLimits:!1,showAttachmentsButton:!1,showFileViewerButton:!1,showRedrawButton:!1,showSessionButton:!1,showAwayDigestButton:!1,showCronButton:!1,remoteAutoReconnect:!0,gestureControlEnabled:!1,subagentTrackingEnabled:!0,subagentActiveTabOnly:!0,imageWatcherEnabled:!1,ralphTrackerEnabled:!1,tabTwoRows:!1,cjkInputEnabled:!1,terminalWheelLocalScrollback:!1,webglRendererEnabled:!1,skin:"daylight-blue"}:{}},loadAppSettingsFromStorage(){if(this._cachedAppSettings)return this._cachedAppSettings;try{const e=this.getSettingsStorageKey(),t=localStorage.getItem(e);if(t)return this._cachedAppSettings=JSON.parse(t),this._cachedAppSettings}catch(e){console.error("Failed to load app settings:",e)}return this._cachedAppSettings=this.getDefaultSettings(),this._cachedAppSettings},saveAppSettingsToStorage(e){this._cachedAppSettings=e;try{const t=this.getSettingsStorageKey();localStorage.setItem(t,JSON.stringify(e))}catch(t){console.error("Failed to save app settings:",t)}},applySkin(){const e=this.loadAppSettingsFromStorage(),t=this.getDefaultSettings(),n=e.skin??t.skin??"daylight-blue";document.documentElement.setAttribute("data-skin",n),window.__codemanSkin=n;const s=getComputedStyle(document.documentElement).getPropertyValue("--bg-dark").trim();s&&document.querySelector('meta[name="theme-color"]')?.setAttribute("content",s);try{localStorage.setItem("codeman:skin",n)}catch{}typeof this.applyTerminalSkin=="function"&&this.applyTerminalSkin(n)},applyLocalization(){const e=this.loadAppSettingsFromStorage();window.CodemanI18n?.configure({language:e.language,displayName:e.displayName})&&this.notificationManager&&(this.notificationManager.originalTitle=document.title)},planUsageChipEnabled(e=null){return(e??this.loadAppSettingsFromStorage()).showPlanUsageLimits??this.getDefaultSettings().showPlanUsageLimits??!0},applyHeaderVisibilitySettings(){const e=this.loadAppSettingsFromStorage(),t=this.getDefaultSettings(),n=MobileDetection.getDeviceType()!=="desktop",s=n?!1:e.showFontControls??t.showFontControls??!1,o=n?!1:e.showSystemStats??t.showSystemStats??!0,a=n?!1:e.showTokenCount??t.showTokenCount??!1,i=document.querySelector(".header-font-controls"),l=document.getElementById("headerSystemStats"),r=document.getElementById("headerTokens");i&&(i.style.display=s?"":"none"),l&&(l.style.display=o?"":"none"),r&&(r.style.display=a?"":"none");const d=e.showLifecycleLog??t.showLifecycleLog??!1,c=document.querySelector(".btn-lifecycle-log");c&&(c.style.display=d?"":"none");const u=e.showResponseViewer??t.showResponseViewer??!1,h=document.querySelector(".btn-response-viewer-header");h&&h.classList.toggle("btn-response-viewer-header--hidden",!u);const p=e.showAttachmentsButton??t.showAttachmentsButton??!1,f=document.getElementById("attachmentsHistoryBtn");f&&f.classList.toggle("btn-attachments-history--hidden",!p);const b=e.showFileViewerButton??t.showFileViewerButton??!0,m=document.querySelector(".btn-file-viewer");m&&m.classList.toggle("btn-file-viewer--hidden",!b);const S=e.showMultiMonitorButton??t.showMultiMonitorButton??!1,E=document.querySelector(".btn-multimonitor");E&&E.classList.toggle("btn-multimonitor--hidden",!S);const v=e.showUltracodeAgents??t.showUltracodeAgents??!1,y=document.querySelector(".btn-ultracode-agents");y&&y.classList.toggle("btn-ultracode-agents--hidden",!v);const w=this.planUsageChipEnabled(e),g=document.getElementById("planUsageChip");g&&g.classList.toggle("header-plan-usage--hidden",!w);const P=e.showRedrawButton??t.showRedrawButton??!1,B=document.querySelector(".btn-redraw-terminal");B&&B.classList.toggle("btn-redraw-terminal--hidden",!P);const L=e.showSessionButton??t.showSessionButton??!1,I=document.querySelector(".btn-session-manager");I&&I.classList.toggle("btn-session-manager--hidden",!L);const A=e.showAwayDigestButton??t.showAwayDigestButton??!1,T=document.querySelector(".btn-away-digest");T&&T.classList.toggle("btn-away-digest--hidden",!A);const M=e.showCronButton??t.showCronButton??!1,k=document.querySelector(".btn-cron");k&&k.classList.toggle("btn-cron--hidden",!M);const _=document.querySelector(".btn-notifications");if(_&&(_.style.display="none"),!(this.notificationManager?.preferences?.enabled??!0)){const C=document.getElementById("notifDrawer");C&&C.classList.remove("open")}},applyTabWrapSettings(){const e=this.loadAppSettingsFromStorage(),t=this.getDefaultSettings(),s=MobileDetection.getDeviceType()==="desktop"?e.tabTwoRows??t.tabTwoRows??!1:!1,o=this._tallTabsEnabled;this._tallTabsEnabled=s;const a=document.getElementById("sessionTabs");a&&(a.classList.toggle("tabs-two-rows",s),a.classList.toggle("tabs-show-folder",s)),o!==void 0&&o!==s&&this._fullRenderSessionTabs()},applyMonitorVisibility(){const e=this.loadAppSettingsFromStorage(),t=this.getDefaultSettings(),n=e.showMonitor??t.showMonitor??!1,s=e.showSubagents??t.showSubagents??!1,o=e.showFileBrowser??t.showFileBrowser??!1,a=document.getElementById("monitorPanel");a&&(a.style.display=n?"":"none",n?a.classList.add("open"):a.classList.remove("open"));const i=document.getElementById("subagentsPanel");i&&(s?i.classList.remove("hidden"):i.classList.add("hidden"));const l=e.showUltracodeAgents??t.showUltracodeAgents??!1,r=document.getElementById("ultracodeAgentsPanel");r&&(l?r.classList.remove("hidden"):(r.classList.remove("open"),r.classList.add("hidden"))),e.ultracodeFloatingWindows??t.ultracodeFloatingWindows??!1?typeof this.syncAllUltracodeFloatingWindows=="function"&&this.syncAllUltracodeFloatingWindows():typeof this.removeAllUltracodeWindows=="function"&&this.removeAllUltracodeWindows();const c=document.getElementById("fileBrowserPanel");if(c)if(o&&this.activeSessionId){if(c.classList.add("visible"),this.loadFileBrowser(this.activeSessionId),!this.fileBrowserDragListeners){const u=c.querySelector(".file-browser-header");if(u){const h=()=>{if(!c.style.left){const p=c.getBoundingClientRect();c.style.left=`${p.left}px`,c.style.top=`${p.top}px`,c.style.right="auto"}};u.addEventListener("mousedown",h),u.addEventListener("touchstart",h,{passive:!0}),this.fileBrowserDragListeners=this.makeWindowDraggable(c,u),this.fileBrowserDragListeners._onFirstDrag=h}}}else c.classList.remove("visible")},closeMonitor(){const e=document.getElementById("monitorPanel");e&&(e.classList.remove("open"),e.style.display="none");const t=this.loadAppSettingsFromStorage();t.showMonitor=!1,this.saveAppSettingsToStorage(t)},closeSubagentsPanel(){const e=document.getElementById("subagentsPanel");e&&(e.classList.remove("open"),e.classList.add("hidden")),this.subagentPanelVisible=!1;const t=this.loadAppSettingsFromStorage();t.showSubagents=!1,this.saveAppSettingsToStorage(t)},async clearAllSubagents(){const e=this.subagents.size;if(e===0){this.showToast("No subagents to clear","info");return}if(confirm(`Clear all ${e} tracked subagent(s)? This removes them from the UI but does not affect running processes.`))try{const n=await(await fetch("/api/subagents",{method:"DELETE"})).json();n.success?(this.subagents.clear(),this.subagentActivity.clear(),this.subagentToolResults.clear(),this.cleanupAllFloatingWindows(),this.renderSubagentPanel(),this.renderMonitorSubagents(),this.updateSubagentBadge(),this.showToast(`Cleared ${n.data.cleared} subagent(s)`,"success")):this.showToast("Failed to clear subagents: "+n.error,"error")}catch{this.showToast("Failed to clear subagents","error")}},toggleSubagentsPanel(){const e=document.getElementById("subagentsPanel"),t=document.getElementById("subagentsToggleBtn");if(e){if(e.classList.contains("hidden")){e.classList.remove("hidden");const n=this.loadAppSettingsFromStorage();n.showSubagents=!0,this.saveAppSettingsToStorage(n)}e.classList.toggle("open"),this.subagentPanelVisible=e.classList.contains("open"),t&&(t.innerHTML=this.subagentPanelVisible?"▼":"▲"),this.subagentPanelVisible&&this.renderSubagentPanel()}},async loadAppSettingsFromServer(e=null){try{if((MobileDetection.isHandheldDevice?.()??MobileDetection.getDeviceType()==="mobile")&&!localStorage.getItem("codeman:planUsagePerDeviceMigrated")){const t=this.loadAppSettingsFromStorage();t&&t.showPlanUsageLimits&&(t.showPlanUsageLimits=!1,this.saveAppSettingsToStorage(t)),localStorage.setItem("codeman:planUsagePerDeviceMigrated","1")}}catch{}try{const t=e?await e:await fetch("/api/settings").then(n=>n.ok?n.json():null).then(n=>n?.success===!0?n.data:n);if(t){const{notificationPreferences:n,voiceSettings:s,respawnPresets:o,runMode:a,...i}=t,l=new Set(["showFontControls","showSystemStats","showTokenCount","showCost","showLifecycleLog","showResponseViewer","showRedrawButton","showMonitor","showProjectInsights","showFileBrowser","showSubagents","subagentActiveTabOnly","tabTwoRows","localEchoEnabled","cjkInputEnabled","extendedKeyboardBar","skin","showPlanUsageLimits","showAttachmentsButton","showFileViewerButton","webglRendererEnabled","language","terminalWheelLocalScrollback","showSessionButton","showAwayDigestButton","showCronButton"]);delete i.showPlanUsageLimits;const r=this.loadAppSettingsFromStorage(),d={...r};for(const[c,u]of Object.entries(i))l.has(c)&&c in r||(d[c]=u);if(this.saveAppSettingsToStorage(d),n&&this.notificationManager&&(localStorage.getItem(this.notificationManager.getStorageKey())||(this.notificationManager.preferences=n,this.notificationManager.savePreferences())),s){const c=localStorage.getItem("codeman-voice-settings");(!c||!JSON.parse(c).apiKey)&&VoiceInput._saveDeepgramConfig(s)}if(o&&Array.isArray(o))this._serverRespawnPresets=o,localStorage.setItem("codeman-respawn-presets",JSON.stringify(o));else{const c=localStorage.getItem("codeman-respawn-presets");if(c){const u=JSON.parse(c);u.length>0&&(this._serverRespawnPresets=u,this._apiPut("/api/settings",{respawnPresets:u}).catch(()=>{}))}}if(a){this.runMode=a;try{localStorage.setItem("codeman_runMode",a)}catch{}this._applyRunMode()}return d}}catch(t){console.error("Failed to load settings from server:",t)}return this.loadAppSettingsFromStorage()},async loadSubagentWindowStates(){let e=null;try{const t=await fetch("/api/subagent-window-states");if(t.ok){const n=await t.json();e=n?.success===!0?n.data:n,localStorage.setItem("codeman-subagent-window-states",JSON.stringify(e))}}catch(t){console.error("Failed to load subagent window states from server:",t)}if(!e)try{const t=localStorage.getItem("codeman-subagent-window-states");t&&(e=JSON.parse(t))}catch(t){console.error("Failed to load subagent window states from localStorage:",t)}return e||{minimized:{},open:[]}},async saveSubagentParentMap(){const e=Object.fromEntries(this.subagentParentMap);try{localStorage.setItem("codeman-subagent-parents",JSON.stringify(e))}catch(t){console.error("Failed to save subagent parents to localStorage:",t)}try{await fetch("/api/subagent-parents",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}catch(t){console.error("Failed to save subagent parents to server:",t)}},async loadSubagentParentMap(){let e=null;try{const t=await fetch("/api/subagent-parents");if(t.ok){const n=await t.json();e=n?.success===!0?n.data:n,localStorage.setItem("codeman-subagent-parents",JSON.stringify(e))}}catch(t){console.error("Failed to load subagent parents from server:",t)}if(!e)try{const t=localStorage.getItem("codeman-subagent-parents");t&&(e=JSON.parse(t))}catch(t){console.error("Failed to load subagent parents from localStorage:",t)}if(e&&typeof e=="object")for(const[t,n]of Object.entries(e))this.sessions.has(n)&&this.subagents.has(t)&&this.subagentParentMap.set(t,n)},getAgentParentSessionId(e){return this.subagentParentMap.get(e)||null},setAgentParentSessionId(e,t){if(!e||!t||this.subagentParentMap.has(e))return;this.subagentParentMap.set(e,t),this.saveSubagentParentMap();const n=this.subagents.get(e);if(n){n.parentSessionId=t;const s=this.sessions.get(t);s&&(n.parentSessionName=this.getSessionName(s)),this.subagents.set(e,n)}},showHelp(){const e=document.getElementById("helpModal");e.classList.add("active"),this.activeFocusTrap=new FocusTrap(e),this.activeFocusTrap.activate()},closeHelp(){document.getElementById("helpModal").classList.remove("active"),this.activeFocusTrap&&(this.activeFocusTrap.deactivate(),this.activeFocusTrap=null)},renderShortcutSettingsList(){const e=document.getElementById("appSettingsShortcutsList");if(!e)return;const t=this.getShortcutRegistry?this.getShortcutRegistry():typeof DEFAULT_SHORTCUTS<"u"?DEFAULT_SHORTCUTS:[],n=this.readShortcutOverridesFromSettings();e.innerHTML=t.map(s=>{const o=s.displayBindings?s.displayBindings.join(" / "):(s.bindings||[]).map(r=>[...r.modifiers||[],r.key||r.code||""].join("+")).join(" / "),a=!!s.action&&Array.isArray(s.bindings),i=!!n[s.id],l=a?`<button type="button" class="shortcut-capture-btn" data-shortcut-action="capture" title="Capture new binding">Edit</button>
|
|
61
|
+
</tr>`}).join("")}catch(s){console.error("Failed to load lifecycle log:",s)}},async saveAppSettings(){const e=this.loadAppSettingsFromStorage(),t=(e.gestureControlEnabled??!1)===!0,n=(e.webglRendererEnabled??!0)===!0,s={displayName:window.CodemanI18n?.normalizeDisplayName(document.getElementById("appSettingsDisplayName").value)||"Codeman",language:window.CodemanI18n?.normalizeLanguage(document.getElementById("appSettingsLanguage").value)||"en",defaultClaudeMdPath:document.getElementById("appSettingsClaudeMdPath").value.trim(),defaultWorkingDir:document.getElementById("appSettingsDefaultDir").value.trim(),ralphTrackerEnabled:document.getElementById("appSettingsRalphEnabled").checked,showFontControls:document.getElementById("appSettingsShowFontControls").checked,showSystemStats:document.getElementById("appSettingsShowSystemStats").checked,showLifecycleLog:document.getElementById("appSettingsShowLifecycleLog").checked,showResponseViewer:document.getElementById("appSettingsShowResponseViewer").checked,showFileViewerButton:document.getElementById("appSettingsShowFileViewerButton").checked,showAttachmentsButton:document.getElementById("appSettingsShowAttachmentsButton").checked,showMonitor:document.getElementById("appSettingsShowMonitor").checked,showProjectInsights:document.getElementById("appSettingsShowProjectInsights").checked,showFileBrowser:document.getElementById("appSettingsShowFileBrowser").checked,showSubagents:document.getElementById("appSettingsShowSubagents").checked,showUltracodeAgents:document.getElementById("appSettingsShowUltracodeAgents").checked,ultracodeFloatingWindows:document.getElementById("appSettingsUltracodeFloatingWindows").checked,showMultiMonitorButton:document.getElementById("appSettingsShowMultiMonitorButton").checked,showPlanUsageLimits:document.getElementById("appSettingsShowPlanUsageLimits").checked,showRedrawButton:document.getElementById("appSettingsShowRedrawButton").checked,showSessionButton:document.getElementById("appSettingsShowSessionButton").checked,showAwayDigestButton:document.getElementById("appSettingsShowAwayDigestButton").checked,showCronButton:document.getElementById("appSettingsShowCronButton").checked,gestureControlEnabled:document.getElementById("appSettingsGestureControl").checked,subagentTrackingEnabled:document.getElementById("appSettingsSubagentTracking").checked,subagentActiveTabOnly:document.getElementById("appSettingsSubagentActiveTabOnly").checked,imageWatcherEnabled:document.getElementById("appSettingsImageWatcherEnabled").checked,tunnelEnabled:document.getElementById("appSettingsTunnelEnabled").checked,localEchoEnabled:document.getElementById("appSettingsLocalEcho").checked,terminalWheelLocalScrollback:document.getElementById("appSettingsTerminalWheelLocal").checked,cjkInputEnabled:document.getElementById("appSettingsCjkInput").checked,webglRendererEnabled:document.getElementById("appSettingsWebglRenderer").checked,extendedKeyboardBar:document.getElementById("appSettingsExtendedKeyboardBar").checked,tabTwoRows:document.getElementById("appSettingsTabTwoRows").checked,skin:document.getElementById("appSettingsSkin").value,claudeMode:document.getElementById("appSettingsClaudeMode").value,allowedTools:document.getElementById("appSettingsAllowedTools").value.trim(),codexDangerouslyBypassApprovals:document.getElementById("appSettingsCodexDangerouslyBypassApprovals").checked,agentTeamsEnabled:document.getElementById("appSettingsAgentTeams").checked,claudeModel:document.getElementById("appSettingsClaudeModel").value,opusContext1mEnabled:document.getElementById("appSettingsOpusContext1m").checked,remoteAutoReconnect:document.getElementById("appSettingsRemoteAutoReconnect").checked,thinkingEffort:document.getElementById("appSettingsThinkingEffort").value,nice:{enabled:document.getElementById("appSettingsNiceEnabled").checked,niceValue:parseInt(document.getElementById("appSettingsNiceValue").value)||10}};if(e.showTokenCount!==void 0&&(s.showTokenCount=e.showTokenCount),e.showCost!==void 0&&(s.showCost=e.showCost),e.shortcutOverrides!==void 0&&(s.shortcutOverrides=e.shortcutOverrides),this.saveAppSettingsToStorage(s),this._updateLocalEchoState(),!n&&s.webglRendererEnabled)try{localStorage.removeItem("codeman-webgl-disabled")}catch{}const o={apiKey:document.getElementById("voiceDeepgramKey").value.trim(),language:document.getElementById("voiceLanguage").value,keyterms:document.getElementById("voiceKeyterms").value.trim(),insertMode:document.getElementById("voiceInsertMode").value};VoiceInput._saveDeepgramConfig(o);const a={enabled:document.getElementById("appSettingsNotifEnabled").checked,browserNotifications:document.getElementById("appSettingsNotifBrowser").checked,audioAlerts:document.getElementById("appSettingsNotifAudio").checked,stuckThresholdMs:(parseInt(document.getElementById("appSettingsNotifStuckMins").value)||10)*6e4,muteCritical:!document.getElementById("appSettingsNotifCritical").checked,muteWarning:!document.getElementById("appSettingsNotifWarning").checked,muteInfo:!document.getElementById("appSettingsNotifInfo").checked,eventTypes:{permission_prompt:{enabled:document.getElementById("eventPermissionEnabled").checked,browser:document.getElementById("eventPermissionBrowser").checked,push:document.getElementById("eventPermissionPush").checked,audio:document.getElementById("eventPermissionAudio").checked},elicitation_dialog:{enabled:document.getElementById("eventQuestionEnabled").checked,browser:document.getElementById("eventQuestionBrowser").checked,push:document.getElementById("eventQuestionPush").checked,audio:document.getElementById("eventQuestionAudio").checked},idle_prompt:{enabled:document.getElementById("eventIdleEnabled").checked,browser:document.getElementById("eventIdleBrowser").checked,push:document.getElementById("eventIdlePush").checked,audio:document.getElementById("eventIdleAudio").checked},stop:{enabled:document.getElementById("eventStopEnabled").checked,browser:document.getElementById("eventStopBrowser").checked,push:document.getElementById("eventStopPush").checked,audio:document.getElementById("eventStopAudio").checked},session_error:{enabled:!0,browser:this.notificationManager?.preferences?.eventTypes?.session_error?.browser??!0,push:this.notificationManager?.preferences?.eventTypes?.session_error?.push??!1,audio:!1},respawn_cycle:{enabled:document.getElementById("eventRespawnEnabled").checked,browser:document.getElementById("eventRespawnBrowser").checked,push:document.getElementById("eventRespawnPush").checked,audio:document.getElementById("eventRespawnAudio").checked},token_milestone:{enabled:!0,browser:!1,push:!1,audio:!1},ralph_complete:{enabled:document.getElementById("eventRalphEnabled").checked,browser:document.getElementById("eventRalphBrowser").checked,push:document.getElementById("eventRalphPush").checked,audio:document.getElementById("eventRalphAudio").checked},subagent_spawn:{enabled:document.getElementById("eventSubagentEnabled").checked,browser:document.getElementById("eventSubagentBrowser").checked,push:document.getElementById("eventSubagentPush").checked,audio:document.getElementById("eventSubagentAudio").checked},subagent_complete:{enabled:document.getElementById("eventSubagentEnabled").checked,browser:document.getElementById("eventSubagentBrowser").checked,push:document.getElementById("eventSubagentPush").checked,audio:document.getElementById("eventSubagentAudio").checked}},_version:5};this.notificationManager&&(this.notificationManager.preferences=a,this.notificationManager.savePreferences()),this._syncPushPreferences(),this.applyHeaderVisibilitySettings(),this.applySkin(),this.applyLocalization(),this.applyTabWrapSettings(),this._updateTokensImmediate(),this.applyMonitorVisibility(),this.renderProjectInsightsPanel(),this.updateSubagentWindowVisibility(),this._updateCjkInputState(),KeyboardAccessoryBar.setMode(s.extendedKeyboardBar?"extended":"simple");const{localEchoEnabled:i,cjkInputEnabled:l,extendedKeyboardBar:r,skin:d,language:c,showPlanUsageLimits:u,showAttachmentsButton:h,showFileViewerButton:p,webglRendererEnabled:f,terminalWheelLocalScrollback:b,showSessionButton:m,showAwayDigestButton:S,showCronButton:E,...v}=s;try{const y=await this._apiPut("/api/settings",{...v,...s.showPlanUsageLimits?{statusLineTelemetry:!0}:{},notificationPreferences:a,voiceSettings:o});if(s.tunnelEnabled&&await this._handleTunnelEnableRefusal(y)){s.tunnelEnabled=!1,this.saveAppSettingsToStorage(s);const w=document.getElementById("appSettingsTunnelEnabled");w&&(w.checked=!1),this.closeAppSettings();return}await this.saveModelConfigFromSettings(),this.showToast("Settings saved","success"),s.tunnelEnabled&&this.showToast("Tunnel starting \u2014 QR code will appear when ready...","info")}catch{this.showToast("Settings saved locally","warning")}this.closeAppSettings(),s.gestureControlEnabled!==t&&(this.showToast(s.gestureControlEnabled?"Enabling gesture control \u2014 reloading\u2026":"Disabling gesture control \u2014 reloading\u2026","info"),setTimeout(()=>location.reload(),400))},async loadModelConfigForSettings(){try{const t=await(await fetch("/api/execution/model-config")).json();if(t.success&&t.data){const n=t.data,s=document.getElementById("appSettingsDefaultModel");s&&(s.value=n.defaultModel||"");const o=document.getElementById("appSettingsShowModelRecommendations");o&&(o.checked=n.showRecommendations??!0);const a=n.agentTypeOverrides||{},i=document.getElementById("appSettingsModelExplore"),l=document.getElementById("appSettingsModelImplement"),r=document.getElementById("appSettingsModelTest"),d=document.getElementById("appSettingsModelReview");i&&(i.value=a.explore||""),l&&(l.value=a.implement||""),r&&(r.value=a.test||""),d&&(d.value=a.review||"")}}catch(e){console.warn("Failed to load model config:",e)}},async saveModelConfigFromSettings(){const e=document.getElementById("appSettingsDefaultModel"),t=document.getElementById("appSettingsShowModelRecommendations"),n=document.getElementById("appSettingsModelExplore"),s=document.getElementById("appSettingsModelImplement"),o=document.getElementById("appSettingsModelTest"),a=document.getElementById("appSettingsModelReview"),i={};n?.value&&(i.explore=n.value),s?.value&&(i.implement=s.value),o?.value&&(i.test=o.value),a?.value&&(i.review=a.value);const l={defaultModel:e?.value||"",showRecommendations:t?.checked??!0,agentTypeOverrides:i};try{await fetch("/api/execution/model-config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)})}catch(r){console.warn("Failed to save model config:",r)}},isRalphTrackerEnabledByDefault(){return this.loadAppSettingsFromStorage().ralphTrackerEnabled??!1},getSettingsStorageKey(){return MobileDetection.isHandheldDevice?.()??MobileDetection.getDeviceType()==="mobile"?"codeman-app-settings-mobile":"codeman-app-settings"},getDefaultSettings(){return MobileDetection.isHandheldDevice?.()??MobileDetection.getDeviceType()==="mobile"?{showFontControls:!1,showSystemStats:!1,showTokenCount:!1,showCost:!1,showMonitor:!1,showProjectInsights:!1,showFileBrowser:!1,showSubagents:!1,showUltracodeAgents:!1,ultracodeFloatingWindows:!1,showMultiMonitorButton:!1,showPlanUsageLimits:!1,showAttachmentsButton:!1,showFileViewerButton:!1,showRedrawButton:!1,showSessionButton:!1,showAwayDigestButton:!1,showCronButton:!1,remoteAutoReconnect:!0,gestureControlEnabled:!1,subagentTrackingEnabled:!0,subagentActiveTabOnly:!0,imageWatcherEnabled:!1,ralphTrackerEnabled:!1,tabTwoRows:!1,cjkInputEnabled:!1,terminalWheelLocalScrollback:!1,webglRendererEnabled:!1,skin:"daylight-blue"}:{}},loadAppSettingsFromStorage(){if(this._cachedAppSettings)return this._cachedAppSettings;try{const e=this.getSettingsStorageKey(),t=localStorage.getItem(e);if(t)return this._cachedAppSettings=JSON.parse(t),this._cachedAppSettings}catch(e){console.error("Failed to load app settings:",e)}return this._cachedAppSettings=this.getDefaultSettings(),this._cachedAppSettings},saveAppSettingsToStorage(e){this._cachedAppSettings=e;try{const t=this.getSettingsStorageKey();localStorage.setItem(t,JSON.stringify(e))}catch(t){console.error("Failed to save app settings:",t)}},applySkin(){const e=this.loadAppSettingsFromStorage(),t=this.getDefaultSettings(),n=e.skin??t.skin??"daylight-blue";document.documentElement.setAttribute("data-skin",n),window.__codemanSkin=n;const s=getComputedStyle(document.documentElement).getPropertyValue("--bg-dark").trim();s&&document.querySelector('meta[name="theme-color"]')?.setAttribute("content",s);try{localStorage.setItem("codeman:skin",n)}catch{}typeof this.applyTerminalSkin=="function"&&this.applyTerminalSkin(n)},applyLocalization(){const e=this.loadAppSettingsFromStorage();window.CodemanI18n?.configure({language:e.language,displayName:e.displayName})&&this.notificationManager&&(this.notificationManager.originalTitle=document.title)},planUsageChipEnabled(e=null){return(e??this.loadAppSettingsFromStorage()).showPlanUsageLimits??this.getDefaultSettings().showPlanUsageLimits??!0},applyHeaderVisibilitySettings(){const e=this.loadAppSettingsFromStorage(),t=this.getDefaultSettings(),n=MobileDetection.getDeviceType()!=="desktop",s=n?!1:e.showFontControls??t.showFontControls??!1,o=n?!1:e.showSystemStats??t.showSystemStats??!0,a=n?!1:e.showTokenCount??t.showTokenCount??!1,i=document.querySelector(".header-font-controls"),l=document.getElementById("headerSystemStats"),r=document.getElementById("headerTokens");i&&(i.style.display=s?"":"none"),l&&(l.style.display=o?"":"none"),r&&(r.style.display=a?"":"none");const d=e.showLifecycleLog??t.showLifecycleLog??!1,c=document.querySelector(".btn-lifecycle-log");c&&(c.style.display=d?"":"none");const u=e.showResponseViewer??t.showResponseViewer??!1,h=document.querySelector(".btn-response-viewer-header");h&&h.classList.toggle("btn-response-viewer-header--hidden",!u);const p=e.showAttachmentsButton??t.showAttachmentsButton??!1,f=document.getElementById("attachmentsHistoryBtn");f&&f.classList.toggle("btn-attachments-history--hidden",!p);const b=e.showFileViewerButton??t.showFileViewerButton??!0,m=document.querySelector(".btn-file-viewer");m&&m.classList.toggle("btn-file-viewer--hidden",!b);const S=e.showMultiMonitorButton??t.showMultiMonitorButton??!1,E=document.querySelector(".btn-multimonitor");E&&E.classList.toggle("btn-multimonitor--hidden",!S);const v=e.showUltracodeAgents??t.showUltracodeAgents??!1,y=document.querySelector(".btn-ultracode-agents");y&&y.classList.toggle("btn-ultracode-agents--hidden",!v);const w=this.planUsageChipEnabled(e),g=document.getElementById("planUsageChip");g&&g.classList.toggle("header-plan-usage--hidden",!w);const P=e.showRedrawButton??t.showRedrawButton??!1,B=document.querySelector(".btn-redraw-terminal");B&&B.classList.toggle("btn-redraw-terminal--hidden",!P);const L=e.showSessionButton??t.showSessionButton??!1,I=document.querySelector(".btn-session-manager");I&&I.classList.toggle("btn-session-manager--hidden",!L);const A=e.showAwayDigestButton??t.showAwayDigestButton??!1,T=document.querySelector(".btn-away-digest");T&&T.classList.toggle("btn-away-digest--hidden",!A);const M=e.showCronButton??t.showCronButton??!1,k=document.querySelector(".btn-cron");k&&k.classList.toggle("btn-cron--hidden",!M);const _=document.querySelector(".btn-notifications");if(_&&(_.style.display="none"),!(this.notificationManager?.preferences?.enabled??!0)){const C=document.getElementById("notifDrawer");C&&C.classList.remove("open")}},applyTabWrapSettings(){const e=this.loadAppSettingsFromStorage(),t=this.getDefaultSettings(),s=MobileDetection.getDeviceType()==="desktop"?e.tabTwoRows??t.tabTwoRows??!1:!1,o=this._tallTabsEnabled;this._tallTabsEnabled=s;const a=document.getElementById("sessionTabs");a&&(a.classList.toggle("tabs-two-rows",s),a.classList.toggle("tabs-show-folder",s)),o!==void 0&&o!==s&&this._fullRenderSessionTabs()},applyMonitorVisibility(){const e=this.loadAppSettingsFromStorage(),t=this.getDefaultSettings(),n=e.showMonitor??t.showMonitor??!1,s=e.showSubagents??t.showSubagents??!1,o=e.showFileBrowser??t.showFileBrowser??!1,a=document.getElementById("monitorPanel");a&&(a.style.display=n?"":"none",n?a.classList.add("open"):a.classList.remove("open"));const i=document.getElementById("subagentsPanel");i&&(s?i.classList.remove("hidden"):i.classList.add("hidden"));const l=e.showUltracodeAgents??t.showUltracodeAgents??!1,r=document.getElementById("ultracodeAgentsPanel");r&&(l?r.classList.remove("hidden"):(r.classList.remove("open"),r.classList.add("hidden"))),e.ultracodeFloatingWindows??t.ultracodeFloatingWindows??!1?typeof this.syncAllUltracodeFloatingWindows=="function"&&this.syncAllUltracodeFloatingWindows():typeof this.removeAllUltracodeWindows=="function"&&this.removeAllUltracodeWindows();const c=document.getElementById("fileBrowserPanel");if(c)if(o&&this.activeSessionId){if(c.classList.add("visible"),this.loadFileBrowser(this.activeSessionId),!this.fileBrowserDragListeners){const u=c.querySelector(".file-browser-header");if(u){const h=()=>{if(!c.style.left){const p=c.getBoundingClientRect();c.style.left=`${p.left}px`,c.style.top=`${p.top}px`,c.style.right="auto"}};u.addEventListener("mousedown",h),u.addEventListener("touchstart",h,{passive:!0}),this.fileBrowserDragListeners=this.makeWindowDraggable(c,u),this.fileBrowserDragListeners._onFirstDrag=h}}}else c.classList.remove("visible")},closeMonitor(){const e=document.getElementById("monitorPanel");e&&(e.classList.remove("open"),e.style.display="none");const t=this.loadAppSettingsFromStorage();t.showMonitor=!1,this.saveAppSettingsToStorage(t)},closeSubagentsPanel(){const e=document.getElementById("subagentsPanel");e&&(e.classList.remove("open"),e.classList.add("hidden")),this.subagentPanelVisible=!1;const t=this.loadAppSettingsFromStorage();t.showSubagents=!1,this.saveAppSettingsToStorage(t)},async clearAllSubagents(){const e=this.subagents.size;if(e===0){this.showToast("No subagents to clear","info");return}if(confirm(`Clear all ${e} tracked subagent(s)? This removes them from the UI but does not affect running processes.`))try{const n=await(await fetch("/api/subagents",{method:"DELETE"})).json();n.success?(this.subagents.clear(),this.subagentActivity.clear(),this.subagentToolResults.clear(),this.cleanupAllFloatingWindows(),this.renderSubagentPanel(),this.renderMonitorSubagents(),this.updateSubagentBadge(),this.showToast(`Cleared ${n.data.cleared} subagent(s)`,"success")):this.showToast("Failed to clear subagents: "+n.error,"error")}catch{this.showToast("Failed to clear subagents","error")}},toggleSubagentsPanel(){const e=document.getElementById("subagentsPanel"),t=document.getElementById("subagentsToggleBtn");if(e){if(e.classList.contains("hidden")){e.classList.remove("hidden");const n=this.loadAppSettingsFromStorage();n.showSubagents=!0,this.saveAppSettingsToStorage(n)}e.classList.toggle("open"),this.subagentPanelVisible=e.classList.contains("open"),t&&(t.innerHTML=this.subagentPanelVisible?"▼":"▲"),this.subagentPanelVisible&&this.renderSubagentPanel()}},async loadAppSettingsFromServer(e=null){try{if((MobileDetection.isHandheldDevice?.()??MobileDetection.getDeviceType()==="mobile")&&!localStorage.getItem("codeman:planUsagePerDeviceMigrated")){const t=this.loadAppSettingsFromStorage();t&&t.showPlanUsageLimits&&(t.showPlanUsageLimits=!1,this.saveAppSettingsToStorage(t)),localStorage.setItem("codeman:planUsagePerDeviceMigrated","1")}}catch{}try{const t=e?await e:await fetch("/api/settings").then(n=>n.ok?n.json():null).then(n=>n?.success===!0?n.data:n);if(t){const{notificationPreferences:n,voiceSettings:s,respawnPresets:o,runMode:a,...i}=t,l=new Set(["showFontControls","showSystemStats","showTokenCount","showCost","showLifecycleLog","showResponseViewer","showRedrawButton","showMonitor","showProjectInsights","showFileBrowser","showSubagents","subagentActiveTabOnly","tabTwoRows","localEchoEnabled","cjkInputEnabled","extendedKeyboardBar","skin","showPlanUsageLimits","showAttachmentsButton","showFileViewerButton","webglRendererEnabled","language","terminalWheelLocalScrollback","showSessionButton","showAwayDigestButton","showCronButton"]);delete i.showPlanUsageLimits;const r=this.loadAppSettingsFromStorage(),d={...r};for(const[c,u]of Object.entries(i))l.has(c)&&c in r||(d[c]=u);if(this.saveAppSettingsToStorage(d),n&&this.notificationManager&&(localStorage.getItem(this.notificationManager.getStorageKey())||(this.notificationManager.preferences=this.notificationManager.normalizePreferences(n),this.notificationManager.savePreferences())),s){const c=localStorage.getItem("codeman-voice-settings");(!c||!JSON.parse(c).apiKey)&&VoiceInput._saveDeepgramConfig(s)}if(o&&Array.isArray(o))this._serverRespawnPresets=o,localStorage.setItem("codeman-respawn-presets",JSON.stringify(o));else{const c=localStorage.getItem("codeman-respawn-presets");if(c){const u=JSON.parse(c);u.length>0&&(this._serverRespawnPresets=u,this._apiPut("/api/settings",{respawnPresets:u}).catch(()=>{}))}}if(a){this.runMode=a;try{localStorage.setItem("codeman_runMode",a)}catch{}this._applyRunMode()}return d}}catch(t){console.error("Failed to load settings from server:",t)}return this.loadAppSettingsFromStorage()},async loadSubagentWindowStates(){let e=null;try{const t=await fetch("/api/subagent-window-states");if(t.ok){const n=await t.json();e=n?.success===!0?n.data:n,localStorage.setItem("codeman-subagent-window-states",JSON.stringify(e))}}catch(t){console.error("Failed to load subagent window states from server:",t)}if(!e)try{const t=localStorage.getItem("codeman-subagent-window-states");t&&(e=JSON.parse(t))}catch(t){console.error("Failed to load subagent window states from localStorage:",t)}return e||{minimized:{},open:[]}},async saveSubagentParentMap(){const e=Object.fromEntries(this.subagentParentMap);try{localStorage.setItem("codeman-subagent-parents",JSON.stringify(e))}catch(t){console.error("Failed to save subagent parents to localStorage:",t)}try{await fetch("/api/subagent-parents",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}catch(t){console.error("Failed to save subagent parents to server:",t)}},async loadSubagentParentMap(){let e=null;try{const t=await fetch("/api/subagent-parents");if(t.ok){const n=await t.json();e=n?.success===!0?n.data:n,localStorage.setItem("codeman-subagent-parents",JSON.stringify(e))}}catch(t){console.error("Failed to load subagent parents from server:",t)}if(!e)try{const t=localStorage.getItem("codeman-subagent-parents");t&&(e=JSON.parse(t))}catch(t){console.error("Failed to load subagent parents from localStorage:",t)}if(e&&typeof e=="object")for(const[t,n]of Object.entries(e))this.sessions.has(n)&&this.subagents.has(t)&&this.subagentParentMap.set(t,n)},getAgentParentSessionId(e){return this.subagentParentMap.get(e)||null},setAgentParentSessionId(e,t){if(!e||!t||this.subagentParentMap.has(e))return;this.subagentParentMap.set(e,t),this.saveSubagentParentMap();const n=this.subagents.get(e);if(n){n.parentSessionId=t;const s=this.sessions.get(t);s&&(n.parentSessionName=this.getSessionName(s)),this.subagents.set(e,n)}},showHelp(){const e=document.getElementById("helpModal");e.classList.add("active"),this.activeFocusTrap=new FocusTrap(e),this.activeFocusTrap.activate()},closeHelp(){document.getElementById("helpModal").classList.remove("active"),this.activeFocusTrap&&(this.activeFocusTrap.deactivate(),this.activeFocusTrap=null)},renderShortcutSettingsList(){const e=document.getElementById("appSettingsShortcutsList");if(!e)return;const t=this.getShortcutRegistry?this.getShortcutRegistry():typeof DEFAULT_SHORTCUTS<"u"?DEFAULT_SHORTCUTS:[],n=this.readShortcutOverridesFromSettings();e.innerHTML=t.map(s=>{const o=s.displayBindings?s.displayBindings.join(" / "):(s.bindings||[]).map(r=>[...r.modifiers||[],r.key||r.code||""].join("+")).join(" / "),a=!!s.action&&Array.isArray(s.bindings),i=!!n[s.id],l=a?`<button type="button" class="shortcut-capture-btn" data-shortcut-action="capture" title="Capture new binding">Edit</button>
|
|
62
62
|
<button type="button" class="shortcut-reset-btn" data-shortcut-action="reset" title="Reset to default"${i?"":" disabled"}>Reset</button>
|
|
63
63
|
<input class="shortcut-enabled-checkbox" type="checkbox" ${s.disabled?"":"checked"} data-shortcut-action="toggle" title="Enable/disable">`:"";return`<div class="shortcut-setting-row${a?"":" shortcut-setting-row--fixed"}" data-shortcut-id="${escapeHtml(s.id)}">
|
|
64
64
|
<label class="shortcut-setting-label">${escapeHtml(s.label)}</label>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/web/public/sw.js.gz
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|