Skip to content

Detaching the last workspace skill never removes it from bound projects #1219

Description

@sahrizvi

Problem

Detaching the last skill from a workspace never removes it from bound projects. The stale bundle stays on disk indefinitely.

parsePage in packages/opencode/src/altimate/workspace/skill-sync.ts rejected pages < 1 as a malformed envelope. But the server sends exactly this for an empty workspace:

{"items":[],"total":0,"page":1,"size":50,"pages":0}

So pages: 0 was read as error, the caller kept whatever was on disk, and zero skills became unobservable. The remote.length === 0 → removeManaged branch behind it was therefore unreachable dead code.

Reproduction

Verified live against production during workspace e2e:

  1. Attach a skill to a workspace, sync it into a bound project — bundle lands.
  2. Detach it in the SaaS. GET /skills?datamate_id=… now returns total: 0, pages: 0.
  3. Run the agent again. The bundle is still on disk — confirmed unchanged across three further turns.

Why tests did not catch it

Every fixture standing in for a healthy empty workspace used pages: 1, a shape the server never sends. One test listed 0 among malformed values and asserted it must not purge, locking the behaviour in.

Fix

Accept pages: 0 only when the rest of the envelope agrees it is empty (items: [] and total: 0); pages: 0 alongside rows is still refused as inconsistent. 0 removed from the malformed list, two real cases added. Mutation-tested — reverting the fix fails exactly the new assertion.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions