mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-07 16:09:43 +02:00
chore: version packages
Persist the 'I checked it' state of yellow idle tab alerts across reloads and devices. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
+31
-3
@@ -845,6 +845,24 @@ class CodemanApp {
|
||||
this.updateTabAlertFromHooks(sessionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* "I looked at this session": spend its pending IDLE tab alert (the yellow
|
||||
* one), locally AND server-side. The clear used to live only in this tab's
|
||||
* memory, so `seedApprovals()` re-armed it from `GET /api/approvals` on the
|
||||
* next reload (a tab you had already checked went yellow again), and the
|
||||
* user's other devices never heard about it. The server marks the approval
|
||||
* item acknowledged (it stays pending and answerable) and broadcasts
|
||||
* `approval:updated`, which is what clears the alert everywhere else.
|
||||
*
|
||||
* ⚠️ Idle only: action alerts (permission/question) mean an unanswered dialog
|
||||
* is on screen, and looking at one does not answer it.
|
||||
*/
|
||||
markIdleAlertSeen(sessionId) {
|
||||
if (!this.pendingHooks.get(sessionId)?.has('idle_prompt')) return;
|
||||
this.clearPendingHooks(sessionId, 'idle_prompt');
|
||||
this.acknowledgeIdleApprovalOnView?.(sessionId);
|
||||
}
|
||||
|
||||
updateTabAlertFromHooks(sessionId) {
|
||||
const hooks = this.pendingHooks.get(sessionId);
|
||||
if (!hooks || hooks.size === 0) {
|
||||
@@ -5144,7 +5162,15 @@ class CodemanApp {
|
||||
if (this._raiseDetached(sessionId)) return;
|
||||
}
|
||||
const forceReload = options?.forceReload === true;
|
||||
if (this.activeSessionId === sessionId && !forceReload) return;
|
||||
if (this.activeSessionId === sessionId && !forceReload) {
|
||||
// Clicking the tab you are already on is still "I checked it". The alert
|
||||
// can be armed on the ACTIVE tab (a live idle_prompt fires regardless of
|
||||
// which tab is showing, and so does the reload seed), and every other
|
||||
// clear path runs on the switch this early return skips, leaving a
|
||||
// yellow tab that no click could clear.
|
||||
this.markIdleAlertSeen(sessionId);
|
||||
return;
|
||||
}
|
||||
if (this.activeSessionId === sessionId && forceReload) {
|
||||
this.terminalBufferCache?.delete(sessionId);
|
||||
this._xtermSnapshots?.delete(sessionId);
|
||||
@@ -5200,8 +5226,10 @@ class CodemanApp {
|
||||
// switch when that option is on. Transform/opacity/clip-path only, xterm's
|
||||
// FitAddon reads the untransformed layout box, so this cannot reach the PTY.
|
||||
this.playTerminalEntrance?.(sessionId);
|
||||
// Clear idle hooks on view, but keep action hooks until user interacts
|
||||
this.clearPendingHooks(sessionId, 'idle_prompt');
|
||||
// Clear idle hooks on view, but keep action hooks until user interacts.
|
||||
// Also acknowledged server-side, so the yellow does not come back on the
|
||||
// next reload and the user's other devices clear it too.
|
||||
this.markIdleAlertSeen(sessionId);
|
||||
// Instant active-class toggle (no 100ms debounce), then schedule full render for badges/status
|
||||
this._updateActiveTabImmediate(sessionId);
|
||||
// Handheld: the session drawer overlays the terminal, so slide it away now
|
||||
|
||||
@@ -50,6 +50,11 @@ Object.assign(CodemanApp.prototype, {
|
||||
const inboxOn = this.approvalsInboxEnabled();
|
||||
for (const item of (data && data.approvals) || []) {
|
||||
if (inboxOn) this.approvals.set(item.id, item);
|
||||
// ⚠ Skip items a human already looked at (`acknowledgedAt`, set by
|
||||
// markIdleAlertSeen → POST .../viewed). Re-arming those is exactly the
|
||||
// bug this flag exists for: clicking a yellow tab cleared the alert in
|
||||
// this tab's memory only, so the next reload seeded it right back.
|
||||
if (item.acknowledgedAt) continue;
|
||||
// Re-arm the tab alert state machine (idempotent set-add).
|
||||
this.setPendingHook(item.sessionId, approvalKindToHook(item.kind));
|
||||
}
|
||||
@@ -70,7 +75,14 @@ Object.assign(CodemanApp.prototype, {
|
||||
},
|
||||
|
||||
_onApprovalUpdated(item) {
|
||||
if (!item || !item.id || !this.approvals?.has(item.id)) return;
|
||||
if (!item || !item.id) return;
|
||||
// Acknowledged elsewhere (this user opened the session on another device):
|
||||
// spend the tab alert UNCONDITIONALLY, for the same reason
|
||||
// _onApprovalResolved does: with the inbox setting OFF the item was never
|
||||
// stored in `this.approvals`, yet seedApprovals armed its alert, so gating
|
||||
// this on a map hit would strand a yellow tab on every other device.
|
||||
if (item.acknowledgedAt) this.clearPendingHooks(item.sessionId, approvalKindToHook(item.kind));
|
||||
if (!this.approvals?.has(item.id)) return;
|
||||
this.approvals.set(item.id, item);
|
||||
this.renderApprovals();
|
||||
},
|
||||
@@ -89,6 +101,23 @@ Object.assign(CodemanApp.prototype, {
|
||||
|
||||
// ─── Actions ─────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* Tell the server the session's pending IDLE prompt has been looked at, so
|
||||
* the yellow tab alert stays gone: `seedApprovals()` skips acknowledged
|
||||
* items on the next reload, and the resulting `approval:updated` broadcast
|
||||
* clears the alert on the user's other devices. Called by markIdleAlertSeen
|
||||
* (app.js), which owns the local half of the clear.
|
||||
*
|
||||
* Fire-and-forget: the alert is already down locally, `_apiJson` swallows
|
||||
* failures, and the worst case of a lost POST is today's behavior (yellow
|
||||
* returns after a reload). Runs regardless of `approvalsInboxEnabled`,
|
||||
* since the tab alert predates the inbox and is not gated on it.
|
||||
*/
|
||||
acknowledgeIdleApprovalOnView(sessionId) {
|
||||
if (!sessionId) return;
|
||||
this._apiJson(`/api/approvals/session/${encodeURIComponent(sessionId)}/viewed`, { method: 'POST' });
|
||||
},
|
||||
|
||||
async answerApproval(id, action, option) {
|
||||
const body = option !== undefined ? { action, option } : { action };
|
||||
const data = await this._apiJson(`/api/approvals/${encodeURIComponent(id)}/answer`, {
|
||||
|
||||
Reference in New Issue
Block a user