fix(mothership): stop persisting log resources from get_workflow_logs and self-heal stale log panel entries#4424
Conversation
… and self-heal stale log panel entries
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Adds a self-healing path for the log panel: Makes resource removals persistent by extending Reviewed by Cursor Bugbot for commit 6ce9f59. Configure here. |
Greptile SummaryThis PR fixes a bug where Mothership's resource panel displayed stale "Log not found" entries caused by three cooperating issues: Confidence Score: 5/5Safe to merge — all three cooperating causes of the stale-resource bug are addressed correctly with no new defects introduced. No P0 or P1 findings. The self-heal flow is correct: 404 fires exactly once before the component unmounts, local state and DB are both cleaned up symmetrically, and the retry guard prevents unnecessary delay. The extraction.ts removal is clean. All changed paths are narrow and well-contained. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant Panel as ResourcePanel
participant EmbeddedLog
participant RQ as React Query (useLogDetail)
participant API as /api/mothership/chat/resources
participant DB as Database
Panel->>EmbeddedLog: render log (stale logId)
EmbeddedLog->>RQ: useLogDetail(logId)
RQ->>API: GET log detail
API-->>RQ: 404 (log deleted)
Note over RQ: retry: skip on 404
RQ-->>EmbeddedLog: error (404)
EmbeddedLog->>EmbeddedLog: useEffect detects 404
EmbeddedLog->>Panel: onNotFound(resourceId)
Panel->>Panel: removeResource('log', id) / setResources / setActiveResourceId
Panel->>API: DELETE /api/mothership/chat/resources {chatId, resourceType, resourceId}
API->>DB: UPDATE copilotChats remove resource from JSONB array
DB-->>API: updated resources
Note over Panel: EmbeddedLog unmounts, stale entry gone permanently
Reviews (3): Last reviewed commit: "fix(mothership): simplify onNotFoundRef ..." | Re-trigger Greptile |
|
@greptile |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit fd31526. Configure here.
|
@greptile |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 6ce9f59. Configure here.
Summary
GetWorkflowLogsfromRESOURCE_TOOL_NAMESinextraction.ts—get_workflow_logsis a read-only tool and should never auto-persist log IDs as chat resources. Logs now only enter the resource panel viaopen_resource, which already validates existence before emittingEmbeddedLog: whenuseLogDetailreturns a 404, the component fires anonNotFoundcallback that removes the stale resource from both local state and the DB (DELETE/api/mothership/chat/resources) so it doesn't reappear on next chat loadremoveResourceinuse-chat.tsto persist deletions — symmetric withaddResourcewhich already persists additionsFixes the bug where Mothership opens log entries that no longer exist, showing "Log not found - This log may have been deleted or is no longer available."
Root cause: three cooperating issues —
get_workflow_logsauto-persisted every returned log ID on each call, persisted resources had no TTL, and the panel auto-selects the last resource on chat load. Free-tier 30-day log cleanup made stale IDs inevitable.Type of Change
Testing
Tested manually
Checklist