Skip to content

add a editable refresh to resource - #326

Open
SharonStrats wants to merge 2 commits into
stagingfrom
add-edittable-refresh
Open

add a editable refresh to resource#326
SharonStrats wants to merge 2 commits into
stagingfrom
add-edittable-refresh

Conversation

@SharonStrats

Copy link
Copy Markdown
Contributor

Add a check for edittable that will refresh the resource in case of a previous anonymous fetch.

@SharonStrats
SharonStrats requested review from bourgeoa and a lite review from Copilot September 12, 2026 11:30
@SharonStrats SharonStrats self-assigned this Sep 12, 2026
@SharonStrats SharonStrats added bug Something isn't working enhancement New feature or request labels Sep 12, 2026
@SharonStrats SharonStrats moved this to In review in SolidOS NLNet UI Sep 12, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Refresh callback handling, editability checks, and boolean return behavior need correction before approval.

Pull request overview

Adds a resource editability check that refreshes stale resources after anonymous fetching.

Changes:

  • Adds checkAndRefreshEditable to ResourceLogic.
  • Exposes the helper through the resource logic types.
  • Adds regression coverage for refresh behavior.
File summaries
File Reviewed changes
test/resourceLogic.test.ts Tests stale editability refresh behavior.
src/types.ts Exposes the new resource helper.
src/resource/resourceLogic.ts Implements editability checks and refresh logic.
Review details

Suppressed comments (4)

src/resource/resourceLogic.ts:172

  • This guard checks for fetcher.refresh before reading the cached editability, so an already-editable resource returns false whenever the fetcher does not expose refresh even though no refresh is needed. Check the current editability first and require refresh only when the result is stale.
    if (!resourceNode || !store.updater || !store.fetcher || typeof store.fetcher.refresh !== 'function') return false

src/resource/resourceLogic.ts:188

  • The post-refresh call has the same contract violation: rdflib's editable() may return SPARQL, N3PATCH, or DAV for an editable document, so this method can still resolve to a string after a successful refresh despite its declared Promise<boolean> return type. Convert this result to a boolean before returning it.
    return store.updater.editable(resourceUri, store)

src/resource/resourceLogic.ts:183

  • In rdflib 2.4.0, Fetcher.refresh(term, callback) returns void and reports completion through the callback. Awaiting it here therefore resolves immediately, so the following editable() call can inspect the old anonymous response before the refresh finishes and incorrectly return false. Wrap the callback-based refresh in a promise (and update the test double to invoke that callback) before checking editability again.
      await store.fetcher.refresh(resourceNode)

test/resourceLogic.test.ts:116

  • The pinned rdflib Fetcher.refresh API is callback-based and returns void, so this Promise-returning stub does not model the production contract and lets the premature await in the implementation pass. Make the mock accept the refresh callback and invoke it when the refresh completes; otherwise this test cannot catch the race described by the PR.
    const refresh = vi.fn().mockResolvedValue(undefined)

    store.updater = {
      editable
    } as unknown as LiveStore['updater']
    store.fetcher.refresh = refresh as unknown as Fetcher['refresh']
  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@SharonStrats SharonStrats changed the title add a edittable refresh to resource add a editable refresh to resource Sep 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

2 participants