Skip to content

fix(tools): a new tool can take a slot another tool holds - #94

Closed
tmuka wants to merge 2 commits into
siganberg:mainfrom
tmuka:fix/tool-add-occupied-slot
Closed

tmuka wants to merge 2 commits into
siganberg:mainfrom
tmuka:fix/tool-add-occupied-slot

Conversation

@tmuka

@tmuka tmuka commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Problem

In the Tool Library, adding a new tool and picking a slot that another tool already holds fails. The slot menu offers it ("Already assigned to: #x - name"), but the server's create refuses it: "Failed to add tool: Tool number N already exists".

The error dialog also opens behind the Add Tool form: the form's overlay is z-index: 99999 and Dialog defaults to 9999. So pressing Add Tool looks like it does nothing, and you can press it again and again.

Editing a tool already handles this, because Edit swaps the two tools' slots. Add never tried, so the workaround was to save first and then pick the slot.

Fix (client only, ToolsTab.vue)

  • Add Tool takes the slot. The tool holding it is unassigned first (the same PUT the edit swap uses), then the new tool is created in the slot. If the create fails, or the server doesn't answer, the other tool gets its slot back and the list is reloaded. A new tool has no old slot to swap, so the other tool is left without one, and the menu says so for these slots: "(Takes it from: #x - name)".
  • The Save Error dialog opens above the tool form (:z-index="100000"). It's the only dialog that can open while the form is up.

Empty slots and the Probe slot already worked on create and are unchanged.

Alternative

A server-side version, with AddAsync unassigning the current holder in the same save, would be atomic and send one library broadcast. But it changes the "already exists" contract for every API caller (plugins, import), so I kept this to the client. Happy to switch if you prefer that.

Testing

  • vite build passes.
  • Checked against ToolService on main:
    • The update path has no magazine or probe rules, so unassigning and restoring the holder always passes.
    • After the unassign, the create can only fail on the magazine check or a bad request, and the restore then succeeds.

Generated by Claude Code AI.

https://claude.ai/code/session_01Hf6iZV4QfttXF3t1Lk5qyD

Tony Muka and others added 2 commits October 27, 2026 08:31
Add Tool offered slots already in use ("Already assigned to: ...") but
the server refuses a create into one ("Tool number N already exists").
The error dialog also opened behind the tool form, so Add looked like it
did nothing.

- A new tool now takes the slot: the tool holding it is unassigned
  first, and gets it back if the add fails. The menu says "Takes it
  from: ..." for these slots.
- The save error dialog opens above the tool form.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hf6iZV4QfttXF3t1Lk5qyD
…erver

The rollback only ran when the server answered with an error. A failed
request (server restarting) skipped it, leaving the other tool without
its slot. Now it's restored either way, the list is reloaded, and the
message says if the restore failed.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hf6iZV4QfttXF3t1Lk5qyD
siganberg added a commit that referenced this pull request Oct 28, 2026
Add Tool offered slots another tool held, but the server refused the
create ("Tool number N already exists") and the error opened behind
the tool form. POST /api/tools?takeSlot=true now unassigns the holder in
the same save; without the flag the old contract stands for plugins and
import. The error dialog opens above the form. Reported in PR #94.

Co-Authored-By: Tony Muka <338934+tmuka@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KxSt6fzfYPhsnYpfoTniWK
@siganberg siganberg closed this Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants