Resolve thread storage locations without listing - #2100
Conversation
|
🚨 SLOP COP 🚨 · I am reviewing this pull request now. I will check security, code quality, performance, architecture, and the user workflow. |
There was a problem hiding this comment.
🚨 SLOP COP 🚨 · review
Plain-English summary: This change gives the app a direct way to find a thread storage folder. It avoids a slow full scan.
I found two important issues and one documentation issue.
-
P2 — The Docs plugin still scans the complete storage tree.
plugins/docs/server.ts:1048still usesstorageFiles({ limit: "1" })to find the storage root.The daemon scans all files before it applies the limit. Docs repeats this work for each open and save operation.
Replace the paired thread and file-list calls with
storageLocation(). Use itshostIdandstorageRootPathfields. -
P2 — Reconnect recovery omits the new location query.
system-cache-effects.ts:170refreshes other thread storage queries after a reconnect. It does not refresh storage locations.An active query can fail during a disconnect. It can then remain unavailable after the connection returns.
Add
allThreadStorageLocationsQueryKeyPrefix()to that set. Add a reconnect regression test. -
P3 — The exact SDK method map omits the new method.
apps/server/src/services/skills/builtin-skills/bb-plugin-authoring/SKILL.md:585omitsstorageLocationfrom thethreadsmethod list.Add it between
storageFilesandstoragePaths.
The security review found no issue. The route keeps the existing thread, environment, host-session, and path-validation boundaries.
The direct performance path works well. It replaces three requests and a waterfall with one request and no host listing command.
The browser test created a real thread. Five location requests returned HTTP 200 in 1.020 to 2.209 milliseconds.
The clean test database had no storage-file link. Therefore, the browser test did not exercise the final external-file menu.
Focused tests passed: app 27, server 78, SDK 96, and server contract 58. Four affected package type checks also passed.
GitHub reports all required checks as successful. I posted an ordinary review comment and did not approve or request changes.
a989136 to
045d9e1
Compare
|
Addressed all three SlopCop gaps in |
What was wrong
PR #2005 made live thread-storage files resolve through
useThreadStoragePaths({ limit: 1 })even though the caller needs only the authoritative storage root and host. The server therefore senthost.list_paths, whose daemon handler recursively walks the complete storage tree before applying the response limit. Merely opening a file context menu or accepting an external-open request could perform large filesystem work and add remote-host latency. This is the root cause identified in the post-merge review; #2086 lazy-loads the storage browser but does not change this lookup.The first version of this PR added a direct location route, but review found three incomplete consumers: the Docs file opener still recovered the same metadata through
threads.get()plusstorageFiles({ limit: "1" }), reconnect catch-up omitted the new location query-key prefix, and the builtin plugin-authoring skill's exact SDK method map omittedstorageLocation.What changed
GET /api/v1/threads/:id/thread-storage/locationandsdk.threads.storageLocation(). The server reuses its existing authoritativerequireThreadStorageTargetresult and returns{ hostId, storageRootPath }without issuing a host filesystem RPC.rootPathconfinement, and local-versus-remote host context without listing storage.storageLocationto the builtin bb-plugin-authoring skill's exactthreadsSDK method map.HOST_DAEMON_PROTOCOL_VERSIONis unchanged.This is the smallest complete fix because the server already knows the host and derives the root from the active host session; exposing and consistently consuming that existing result deletes the broad listing dependency instead of optimizing or special-casing the recursive listing API.
How you verified
expected 404 to be 200. Afterward, the focused server route passed without reporting any host RPC response, proving the route does not enumerate the filesystem.bb.sdk.threads.get is not stubbed; afterward, the focused Docs server file passed 32/32 while asserting the returned remote host and confined root on read, preview, and CAS write.undefinedinstead of recovering toloaded; afterward, the focused cache-effect and cache-owner tests passed 11/11.origin/mainate171ceba4:pnpm exec turbo run build typecheck --filter=@bb/app --filter=@bb/server --filter=bb-plugin-simple-notespassed 10/10 tasks. A final post-commit Turbo typecheck also passed.pnpm exec turbo run lint --filter=@bb/apppassed with 0 errors and 155 existing warnings outside the changed lines.git diff --checkpassed.Fixes: N/A — no matching issue; post-merge follow-up to #2005.