Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile SummaryThis PR fixes a request-validation contention bug where opening a scheduled-task artifact in the mothership viewer triggered a full workspace-schedule list fetch that competed with the chat stream. The fix introduces a dedicated
Confidence Score: 4/5Safe to merge — authorization is correctly enforced on the new GET endpoint and the copilot context resolver validates workspace ownership before returning any data. The new endpoint and hook are both correct and well-scoped. Two minor issues hold the score below the max: the GET handler queries the database twice for the same row (auth partial-select then full-select), and the EmbeddedScheduledTaskProps interface retains a workspaceId field that the component no longer reads, leaving a dead prop still required at every call site. apps/sim/app/api/schedules/[id]/route.ts (double DB query in the GET handler); apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-content/resource-content.tsx (stale workspaceId prop in EmbeddedScheduledTaskProps) Important Files Changed
Sequence Diagram%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant UI as Mothership UI
participant Hook as useScheduleById
participant API as GET /api/schedules/[id]
participant Auth as fetchAndAuthorize
participant DB as Database
UI->>Hook: scheduleId
Hook->>API: "GET /api/schedules/{id}"
API->>Auth: fetchAndAuthorize(scheduleId, userId, 'read')
Auth->>DB: "SELECT partial row WHERE id=? AND archivedAt IS NULL"
DB-->>Auth: partial ScheduleRow
Auth-->>API: "{ schedule, workspaceId }"
API->>DB: "SELECT * WHERE id=? AND archivedAt IS NULL"
DB-->>API: full WorkflowSchedule row
API-->>Hook: "{ schedule: fullRow }"
Hook-->>UI: schedule data
Note over UI,DB: copilot chat path
UI->>API: "POST /api/copilot/chat (kind='scheduledtask')"
API->>DB: resolveScheduledTaskResource(scheduleId, workspaceId)
Note right of DB: filters sourceType='job' and sourceWorkspaceId
DB-->>API: "{ id, jobTitle }"
API-->>UI: "VFS path jobs/{title}/meta.json"
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant UI as Mothership UI
participant Hook as useScheduleById
participant API as GET /api/schedules/[id]
participant Auth as fetchAndAuthorize
participant DB as Database
UI->>Hook: scheduleId
Hook->>API: "GET /api/schedules/{id}"
API->>Auth: fetchAndAuthorize(scheduleId, userId, 'read')
Auth->>DB: "SELECT partial row WHERE id=? AND archivedAt IS NULL"
DB-->>Auth: partial ScheduleRow
Auth-->>API: "{ schedule, workspaceId }"
API->>DB: "SELECT * WHERE id=? AND archivedAt IS NULL"
DB-->>API: full WorkflowSchedule row
API-->>Hook: "{ schedule: fullRow }"
Hook-->>UI: schedule data
Note over UI,DB: copilot chat path
UI->>API: "POST /api/copilot/chat (kind='scheduledtask')"
API->>DB: resolveScheduledTaskResource(scheduleId, workspaceId)
Note right of DB: filters sourceType='job' and sourceWorkspaceId
DB-->>API: "{ id, jobTitle }"
API-->>UI: "VFS path jobs/{title}/meta.json"
|
Summary
Fix request validation bug with scheduled tasks in the mship stream
Type of Change
Testing
Manual
Checklist