fix: disable submission for global extensions with 0 workers#911
fix: disable submission for global extensions with 0 workers#911
Conversation
Backend returns 409 when submitting to a non-@internal job with no connected workers. Frontend disables the Run Extension button and shows a "No workers connected" tooltip in the same scenario. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
for more information, see https://pre-commit.ci
📝 WalkthroughWalkthroughThis change implements worker availability validation for task submission. A new Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Frontend as Frontend<br/>(SecondaryPanel)
participant Backend as Backend<br/>(router.py)
participant DB as Database<br/>(WorkerJobLink)
User->>Frontend: Click "Run Extension" button
rect rgba(200, 100, 100, 0.5)
Frontend->>Frontend: Check if job has workers<br/>(noWorkers computed)
alt noWorkers = true
Frontend->>User: Button disabled + tooltip<br/>"No workers connected"
else noWorkers = false
Frontend->>Backend: POST /rooms/{id}/tasks/{job}
Backend->>DB: Query WorkerJobLink count<br/>for job
DB-->>Backend: Count result
alt count == 0 (non-@internal)
Backend->>Backend: Raise NoWorkersAvailable
Backend-->>Frontend: 409 Conflict response
Frontend->>User: Display error
else count > 0
Backend->>DB: Create Task (PENDING)
Backend-->>Frontend: 202 Accepted response
Frontend->>User: Task submitted
end
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
frontend/src/components/SecondaryPanel.tsx (1)
200-233: Consider extracting the IIFE touseMemofor readability.The logic is correct, but the inline IIFE pattern is unusual in React components. Extracting
noWorkersandtooltipTitletouseMemowould improve clarity and align with React conventions.♻️ Optional refactor to useMemo
+ const noWorkers = useMemo(() => { + return ( + selectedJob != null && + !selectedJob.full_name.startsWith("@internal:") && + selectedJob.workers.length === 0 + ); + }, [selectedJob]); + + const submitTooltipTitle = useMemo(() => { + if (roomReadOnly) return "Room is locked"; + if (noWorkers) return "No workers connected"; + return ""; + }, [roomReadOnly, noWorkers]);Then in the JSX:
{panelTitle !== "settings" && ( - (() => { - const noWorkers = ...; - const tooltipTitle = ...; - return ( - <Tooltip title={tooltipTitle}> + <Tooltip title={submitTooltipTitle}> <span> <Button ... disabled={ isSubmitting || isLoadingSchema || roomReadOnly || noWorkers } ... > {isSubmitting ? "Running..." : "Run Extension"} </Button> </span> </Tooltip> - ); - })() )}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@frontend/src/components/SecondaryPanel.tsx` around lines 200 - 233, Extract the inline IIFE logic into useMemo hooks: create a memoized noWorkers using selectedJob and its properties (e.g. selectedJob.full_name, selectedJob.workers.length) and a memoized tooltipTitle that depends on roomReadOnly and noWorkers, then replace the IIFE JSX with a simple conditional render that uses the memoized values; keep the Button props and handlers (handleSubmit, isSubmitting, isLoadingSchema, roomReadOnly) unchanged and ensure the disabled logic still references the memoized noWorkers and tooltipTitle is passed into Tooltip.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@frontend/src/components/SecondaryPanel.tsx`:
- Around line 200-233: Extract the inline IIFE logic into useMemo hooks: create
a memoized noWorkers using selectedJob and its properties (e.g.
selectedJob.full_name, selectedJob.workers.length) and a memoized tooltipTitle
that depends on roomReadOnly and noWorkers, then replace the IIFE JSX with a
simple conditional render that uses the memoized values; keep the Button props
and handlers (handleSubmit, isSubmitting, isLoadingSchema, roomReadOnly)
unchanged and ensure the disabled logic still references the memoized noWorkers
and tooltipTitle is passed into Tooltip.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 67721d4e-d407-43de-8cfa-f065cc8228af
📒 Files selected for processing (4)
frontend/src/components/SecondaryPanel.tsxsrc/zndraw_joblib/exceptions.pysrc/zndraw_joblib/router.pytests/zndraw_joblib/test_router_task_submit.py
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #911 +/- ##
==========================================
- Coverage 91.78% 91.75% -0.03%
==========================================
Files 246 246
Lines 22881 22898 +17
==========================================
+ Hits 21001 21011 +10
- Misses 1880 1887 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
Closes #907
submit_task()now rejects submissions for non-@internaljobs that have 0 connected workers (returns 409 with RFC 9457 problem detail)workerCount === 0for non-internal jobstest_submit_global_task_no_workers_returns_409verifies the backend guardTest plan
🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
New Features
Tests