feat(loadfile): request directory contents via new iframe API#10
Merged
Merged
Conversation
…hengLabResearch#9) ouroboros #106 stopped broadcasting the recursive file tree in send-directory-contents, so the plugin's LoadFile modal has been rendering an empty list. ouroboros #114 (merged) added a request-directory-contents / send-directory-contents-response pair scoped per requesting iframe. Wire it up in App: - On send-directory-contents (root change), dispatch a request-directory-contents with recursive:true and a monotonic requestId (loadfile-N). - Track the active requestId in a ref; drop responses whose id does not match, so late responses from a previous root can't clobber current state. - On send-directory-contents-response, merge data.nodes back into directoryData so LoadFile's existing tree renderer sees the tree again without other changes. - Error handling: denied / not-found / internal → empty tree (matches the existing 'no files' rendering); limit → render the partial nodes the response carried (truncated hint deferred as follow-up). - Guard the merge with a path check so an out-of-order response for a previous root can't overwrite the new root's tree. LoadFile itself unchanged. Verified: tsc -b, npm run build. Manual UI smoke against a running Ouroboros not run here — see PR body.
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.
Closes #9.
Depends on ouroboros #114 (merged) which added the request/response iframe API.
Problem
Since ouroboros #106,
send-directory-contentsarrives withnodes: {}. The plugin's LoadFile modal renders an empty list —Object.values(directoryData.data.nodes).map(...)sees nothing.What changed
Wire up the new API in
src/App/index.tsx:send-directory-contents(root change), dispatch arequest-directory-contentswithrecursive: trueand a monotonicrequestId(`loadfile-N`).requestIdin a ref; drop late responses whose id doesn't match, so a response for a previous root can't clobber the current tree.send-directory-contents-response, mergedata.nodesback intodirectoryDataso LoadFile's existing tree renderer works again without changes.data.path === current directoryPathcheck — belt-and-suspenders against the same out-of-order case.error.code:denied/not-found/internal→ empty tree (matches the existing "no files" rendering).internalalso logs viaconsole.error.limitwithtruncated: true→ render the partial nodes the response carries. The truncation hint UI is deferred as a follow-up so this diff stays surgical.LoadFile itself is unchanged.
Verify
npx tsc -b— clean (typecheck passes).npm run build— clean.npm run lint— pre-existing lint errors in the repo (288, mostly@ts-nocheckandno-explicit-anyin NG viewer code, unrelated to this change). No new errors introduced (identical count on `main` vs. this branch).Manual UI smoke against a running Ouroboros not performed here — no display on the automation host. Reviewer checklist for a live test:
Not changed
Followup
If desired, surface `error.truncated: true` in the LoadFile UI (e.g., "showing partial tree") — separate small PR.