Repository navigation
Conversation
|
@mmontes11 is attempting to deploy a commit to the IndexLabs Team on Vercel. A member of the Team first needs to authorize it. |
Adds POST /api/tasks/{taskId}/move so a member can hand-reorder one agent's queued tasks one step at a time in claim order (priority DESC, created_at ASC, id ASC). The move runs under the agent's claim lock, reuses the CancelTaskByUser tenancy and privacy gates, and broadcasts the existing task:queued event so clients re-sort live.
Co-authored-by: multica-agent <github@multica.ai>
Adds hover chevron actions to queued rows in the agent activity tab that call the new /api/tasks/{taskId}/move endpoint. Queued rows now sort in claim order (priority DESC, created_at ASC) so the row order matches what the daemon claims next; reorders propagate through the existing task:queued WS event.
Co-authored-by: multica-agent <github@multica.ai>
mmontes11
force-pushed
the
feature-task-reorder
branch
from
November 6, 2026 08:41
75d3697 to
38c2090
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this PR do?
Adds manual reordering of an agent's queued tasks: a member can move one queued task a step up or down in the agent's claim order —
priority DESC, created_at ASC, id ASC, the exact orderClaimAgentTaskuses. The move runs in a transaction under the agent's claim lock (the same row lockClaimTasktakes before selecting work), so a reorder cannot race an in-flight claim, and the tenancy/privacy gates mirrorCancelTaskByUserexactly (workspace-scoped task load, chat-session creator privacy, private-agent visibility). The UI adds hover ↑/↓ buttons to queued rows in the agent Activity tab; queued rows now render in claim order, and reorders propagate to every open client through the existingtask:queuedWS event.Related Issue
None, this is a new feature.
Type of Change
Changes Made
server/pkg/db/queries/agent.sql—MoveQueuedTaskUp/MoveQueuedTaskDown: rank-based swap on the coarse 0–4 priority scale (take the neighbor's level across levels, step one level on a same-level tie, no-op at the queue edge); generated code inserver/pkg/db/generated/agent.sql.goserver/internal/handler/task_lifecycle.go—MoveTaskByUserhandler +MoveTaskResponse({task_id, priority, moved})server/cmd/server/router.go—POST /api/tasks/{taskId}/moveserver/internal/handler/task_move_test.go— 12 handler tests: reorder semantics (up/down, same-level step, clamp at both edges, edge no-ops), 409 non-queued, 404 unknown/foreign-workspace, 400 bad direction, private-agent gate, chat-creator-only gatepackages/core/types/agent.ts,packages/core/types/index.ts,packages/core/api/schemas.ts,packages/core/api/client.ts—MoveTaskResponsetype, zod schema + empty fallback,api.moveQueuedTask(taskId, direction)packages/views/agents/components/tabs/activity-tab.tsx— hover chevron actions on queuedLiveTaskRows, queued rows sorted in claim order, edge-reached toastpackages/views/locales/{en,es,fr,ja,ko,zh-Hans,zh-Hant}/agents.json— 7 new strings per localeHow to Test
make dev(bootstraps env + Postgres + migrations; API on :8080, web on :3000), log in.queuedwhile its runtime is busy or absent.prioritychanged:select id, priority from agent_task_queue where status='queued' order by priority desc, created_at asc.task:queuedevent.POST /api/tasks/{taskId}/move{"direction":"up"}→ 200{task_id, priority, moved}; 409 non-queued, 404 foreign workspace, 403 others' chat tasks / inaccessible private agents.Checklist
CancelTaskByUserfor the id-only tenancy/privacy gates;PrioritizeQueuedChatTaskfor the claim-lock-during-queue-mutation pattern; reorder expressed on the existing 0–4prioritycolumn soClaimAgentTaskneeded no changes)-race;go build/go vetclean; sqlc regeneration idempotent;@multica/core2710 TS tests pass;@multica/webbuild passes)apps/docs/content/docs/developers/conventions.zh.mdxmovedflag and the UI toast make edge no-ops explicit; dispatched/running rows are not reorderable — onlyqueued)AI Disclosure
AI tool used: Multica agent (Beaver)
Prompt / approach:
Scouted per-agent queue reorder as the contribution shape; the agent implemented it against repo conventions (AGENTS.md), reusing
CancelTaskByUser's gates and theClaimTasklock, with equivalence tests written first. Human validated the diff and will open the PR.Screenshots (optional)
Before supporting feature, there was no ⬆️ / ⬇️ in the queued tasks:
With the changes in this branch, new ⬆️ / ⬇️ actions are introduced in the queued task, which are very handy for low-concurrent agents like our Beaver (concurrency=1) 🦫 :
⬇️ move down:

⬆️ move up:

The cancel button ❌ is still available:
This is what we see after ⬆️ moving up the "Write bubble sort in Go" task:
If we click again in ⬆️ move up, a pop-up is displayed informing that we are already at the front of the queue:
The tasks that have been moved are eventually scheduled:
Finally, if we click in ⬇️ move down in the task that is at the end of the queue, a pop-up is also displayed: