Uh oh!
There was an error while loading. Please reload this page.
Add functionality to support 3 dots menu - #320
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a dedicated resource logic module to support resource/container operations needed by the UI (e.g., a “3 dots menu”), including recursive deletion and optional type-index cleanup, and wires it into SolidLogic.
Changes:
- Added
ResourceLogic(newsrc/resource/resourceLogic.ts) to centralize container helpers and recursive deletion (optionally deleting type index registrations). - Enhanced container detection and added a container member-count helper in
containerLogic. - Extended type-index logic with
deleteTypeIndexRegistrationForResourceand exposedresourceonSolidLogic.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/util/utilityLogic.ts | Removes recursiveDelete from utility logic (moved responsibility to resource). |
| src/util/containerLogic.ts | Improves isContainer detection and adds getContainerMemberCount. |
| src/types.ts | Adds ResourceLogic/options and extends TypeIndexLogic/SolidLogic types. |
| src/typeIndex/typeIndexLogic.ts | Adds deletion of type-index registrations that reference a resource. |
| src/resource/resourceLogic.ts | New module implementing resource/container helpers and recursive deletion. |
| src/logic/solidLogic.ts | Wires new resource logic into the main SolidLogic object. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Prompt: add resource service regression tests and harden delete recursion Co-authored-by: GPT-5.4 Mini <gpt-5.4-mini@openai.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.
Suppressed comments (4)
src/resource/resourceLogic.ts:179
_fetchresolves with aResponsefor HTTP failures, so a 403/500 response reaches the cache-removal code and is reported as a successful deletion. Validate the returned response, treating only 404/410 as idempotent success, before removing the resource from the store.
deleted = await store.fetcher._fetch(resourceNode.value, { method: 'DELETE' })
src/resource/resourceLogic.ts:43
- A
HEADresponse can legitimately omitContent-Typewhile still returningWAC-AllowandETag. Because the direct response headers are only read whenContent-Typeis present, those access flags are discarded and the menu can incorrectly report that the user cannot edit or that the resource is not public. Read each response header independently wheneverresponse.headersis available.
if (response.headers && response.headers.get('content-type')) {
contentType = response.headers.get('content-type')?.split(';')[0] ?? undefined
const accessFlags = readWacAccessInfo(response.headers.get('wac-allow'))
src/resource/resourceLogic.ts:165
- Type-index registrations are removed before the resource DELETE is attempted. If that DELETE later fails (for example with 403 or 500), the resource still exists but is no longer discoverable through its type index. Defer this cleanup until the resource DELETE succeeds or is confirmed as 404/410.
This issue also appears on line 179 of the same file.
if (options.deleteTypeIndexes) {
await deleteTypeIndexesForResource(resourceNode, options.user)
}
src/typeIndex/typeIndexLogic.ts:229
loadTypeIndexesForis not a read-only lookup: when links are missing it callsfollowOrCreateLinkWithContentOnCreatefor public and private indexes. Consequently, deleting an unregistered resource can create new type-index documents and profile/preference links. Cleanup should use a read-only scope loader that follows only existing index links.
const scopes = await loadTypeIndexesFor(user)
Create a resource service, the need was identified when moving the header from source pane into solid-panes and realizing the need for shared resource logic.
This consists of moving existing functions from solid-panes and source-pane into the resource service.
Some new functions were also created to accomodate the new functionality of the header for identifying if a user can delete a resource.
Some notes
The WAC specification was followed to identify whether a resource could be deleted by not only looking at the resource to see if it has write access, but as well looks at the containing container to also check if the user has write access to that as well. This is outlined in the specification.
To delete a resource additional functionality was added to give the option of deleting the resource from the type indexes. As well the original function was modified to delete the acl if it exists after the resource has been deleted. (The original was only deleted the acl when a container was deleted).