-
Notifications
You must be signed in to change notification settings - Fork 314
fix(cli): persist CLI-created agent to disk before responding #1014
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1015,6 +1015,20 @@ export function useAppRemoteEventListeners(deps: UseAppRemoteEventListenersDeps) | |||||||||||||||||||||||
| isRemote: false, | ||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| // Persist the new agent to disk synchronously before responding. The | ||||||||||||||||||||||||
| // renderer's debounced persistence path (useDebouncedPersistence) is | ||||||||||||||||||||||||
| // driven by React render cycles and a 2s timer, so a CLI consumer that | ||||||||||||||||||||||||
| // runs `create-agent` and then immediately `list agents` / `send` would | ||||||||||||||||||||||||
| // otherwise hit the disk-backed CLI storage layer before the in-memory | ||||||||||||||||||||||||
| // session has been flushed — surfacing as `AGENT_NOT_FOUND` (issue #1013). | ||||||||||||||||||||||||
| // `setMany` is incremental and idempotent: the debounced flush that | ||||||||||||||||||||||||
| // follows simply rewrites the same row. | ||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||
| await window.maestro.sessions.setMany([newSession], []); | ||||||||||||||||||||||||
| } catch (persistErr) { | ||||||||||||||||||||||||
| logger.error('[Remote] Failed to persist new CLI-created session:', undefined, persistErr); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
Comment on lines
+1026
to
+1030
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The codebase's error-handling guideline (CLAUDE.md §Error Handling & Sentry) says unexpected errors should bubble up rather than be silently logged, so Sentry can capture them. A
Suggested change
Context Used: CLAUDE.md (source) |
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| window.maestro.process.sendRemoteCreateSessionResponse(responseChannel, { | ||||||||||||||||||||||||
| sessionId: newId, | ||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||
|
Comment on lines
+1026
to
1034
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Context Used: CLAUDE.md (source) |
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Persistence failure is treated as success (false-positive create result).
On Line 1026, a failed
setManyis logged but the handler still returns success, so CLI callers can getcreate-agentsuccess even when disk persistence failed. Please fail the response path (and capture to Sentry) when this write fails.Proposed fix
try { await window.maestro.sessions.setMany([newSession], []); } catch (persistErr) { + captureException(persistErr, { + extra: { + event: 'maestro:remoteCreateSession', + sessionId: newId, + toolType, + cwd, + responseChannel, + }, + }); logger.error('[Remote] Failed to persist new CLI-created session:', undefined, persistErr); + window.maestro.process.sendRemoteCreateSessionResponse(responseChannel, null); + return; }As per coding guidelines: "Do not silently swallow errors... For unexpected errors, re-throw them... Use Sentry utilities (
captureException,captureMessage) for explicit error reporting with context."🤖 Prompt for AI Agents