GeezerVison is showing github.com — fix(mothership): stop persisting log resources from get_workflow_logs and self-heal stale log panel entries by waleedlatif1 · Pull Request #4424 · simstudioai/sim
Conversation
waleedlatif1
commented
May 4, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary
- Removed
GetWorkflowLogs from RESOURCE_TOOL_NAMES in extraction.ts — get_workflow_logs is a read-only tool and should never auto-persist log IDs as chat resources. Logs now only enter the resource panel via open_resource, which already validates existence before emitting
- Added self-healing to
EmbeddedLog: when useLogDetail returns a 404, the component fires an onNotFound callback 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 load
- Extended
removeResource in use-chat.ts to persist deletions — symmetric with addResource which already persists additions
Fixes 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_logs auto-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
- Code follows project style guidelines
- Self-reviewed my changes
- Tests added/updated and passing
- No new warnings introduced
- I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
greptile-apps[bot] reacted with thumbs up emoji
… and self-heal stale log panel entries
vercel
Bot
commented
May 4, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
| Project |
Deployment |
Actions |
Updated (UTC) |
| docs |
Skipped |
|
May 4, 2026 7:05am |

|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
cursor
Bot
commented
May 4, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
PR Summary
Medium Risk
Medium risk because it changes how chat resources are persisted/removed (new DELETE side-effect) and adds automatic removal behavior on 404s, which could incorrectly drop resources if errors are misclassified.
Overview
Prevents get_workflow_logs tool results from auto-creating persisted log resources, so logs only appear in the resource panel when explicitly opened.
Adds a self-healing path for the log panel: EmbeddedLog detects a 404 from useLogDetail, triggers an onNotFound callback, and MothershipView removes the stale log resource.
Makes resource removals persistent by extending useChat.removeResource to also DELETE /api/mothership/chat/resources, keeping local UI state and stored chat resources in sync.
Reviewed by Cursor Bugbot for commit 6ce9f59. Configure here.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
greptile-apps
Bot
commented
May 4, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Greptile Summary
This PR fixes a bug where Mothership's resource panel displayed stale "Log not found" entries caused by three cooperating issues: get_workflow_logs auto-persisting every returned log ID, no TTL on persisted resources, and the panel auto-selecting the last resource on load. The fix removes GetWorkflowLogs from the auto-persist list, adds self-healing (EmbeddedLog fires onNotFound on 404 which removes the resource from both local state and the DB), and makes removeResource symmetric with addResource by persisting deletions.
Confidence Score: 5/5
Safe 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
| Filename |
Overview |
| apps/sim/lib/copilot/resources/extraction.ts |
Removes GetWorkflowLogs from RESOURCE_TOOL_NAMES and its extraction case — correct because get_workflow_logs is a read-only tool that should never auto-persist log IDs. |
| apps/sim/hooks/queries/logs.ts |
Adds a retry guard to useLogDetail that skips retries on 404 errors, making self-healing instantaneous for deleted logs. |
| apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-content/resource-content.tsx |
Adds onNotFound prop to EmbeddedLog; uses useRef + useEffect to detect 404 errors and fire the callback exactly once before the component unmounts. |
| apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/mothership-view.tsx |
Wires onNotFound to onRemoveResource('log', resourceId) so a 404 on the active log resource triggers both local-state and DB cleanup. |
| apps/sim/app/workspace/[workspaceId]/home/hooks/use-chat.ts |
Extends removeResource to fire-and-forget DELETE /api/mothership/chat/resources, making it symmetric with addResource's persist-on-add behavior. |
Sequence Diagram
sequenceDiagram
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
Loading
Reviews (3): Last reviewed commit: "fix(mothership): simplify onNotFoundRef ..." | Re-trigger Greptile
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
greptile-apps[bot] reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
cursor[bot] reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
✅ 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.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
greptile-apps[bot] reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
cursor[bot] reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
✅ 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.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This branch was previously deployed
1 inactive
deployment
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|