add a editable refresh to resource - #326
Open
SharonStrats wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
🔵 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
checkAndRefreshEditabletoResourceLogic. - 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.refreshbefore reading the cached editability, so an already-editable resource returnsfalsewhenever the fetcher does not exposerefresheven though no refresh is needed. Check the current editability first and requirerefreshonly 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 returnSPARQL,N3PATCH, orDAVfor an editable document, so this method can still resolve to a string after a successful refresh despite its declaredPromise<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)returnsvoidand reports completion through the callback. Awaiting it here therefore resolves immediately, so the followingeditable()call can inspect the old anonymous response before the refresh finishes and incorrectly returnfalse. 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.refreshAPI is callback-based and returnsvoid, so this Promise-returning stub does not model the production contract and lets the prematureawaitin 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
force-pushed
the
add-edittable-refresh
branch
from
September 12, 2026 11:45
3d58c7f to
3c06085
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a check for edittable that will refresh the resource in case of a previous anonymous fetch.