Skip to content

fix: preview SAF single-file documents#2159

Merged
bajrangCoder merged 1 commit into
Acode-Foundation:mainfrom
bajrangCoder:fix/saf-single-file-preview
Jun 6, 2026
Merged

fix: preview SAF single-file documents#2159
bajrangCoder merged 1 commit into
Acode-Foundation:mainfrom
bajrangCoder:fix/saf-single-file-preview

Conversation

@bajrangCoder
Copy link
Copy Markdown
Member

No description provided.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Jun 6, 2026

Greptile Summary

This PR fixes two stale property references that prevented SAF (Storage Access Framework) single-file documents from being previewed or blocked from renaming. Both sites were checking file.mode === "single", which is always undefined on EditorFile (the actual property is SAFMode, exposed via a getter backed by a private #SAFMode field).

  • commands.js: The rename guard now correctly checks file.SAFMode === "single", so renaming a SAF single-file document is properly blocked with the expected alert.
  • run.js: The preview request handler now correctly checks activeFile.SAFMode === "single", allowing the document's text to be served inline without trying to resolve a URI.

Confidence Score: 5/5

Safe to merge — both changes are minimal, targeted, and consistent with how the rest of the codebase accesses the SAFMode property.

Both changes replace a property name that would always evaluate to undefined with the correct SAFMode getter defined on EditorFile. The fix is verified against the actual class definition and all other existing call sites in the codebase already use SAFMode. No other instances of the old incorrect pattern remain in the changed files or their direct dependencies.

No files require special attention.

Important Files Changed

Filename Overview
src/lib/commands.js Single-line fix: replaces file.mode === "single" with file.SAFMode === "single" in the rename command guard, matching the actual getter on EditorFile.
src/lib/run.js Single-line fix: replaces activeFile.mode === "single" with activeFile.SAFMode === "single" in the preview request handler, enabling SAF single-file documents to be served correctly.

Sequence Diagram

sequenceDiagram
    participant User
    participant commands.js
    participant run.js
    participant EditorFile

    Note over EditorFile: #SAFMode = "single" | "tree" | null
    Note over EditorFile: get SAFMode() { return this.#SAFMode }

    User->>commands.js: rename(file)
    commands.js->>EditorFile: file.SAFMode (was: file.mode)
    EditorFile-->>commands.js: "single"
    commands.js-->>User: alert("unable to rename") [correctly blocked]

    User->>run.js: preview request for SAF file
    run.js->>EditorFile: activeFile.SAFMode (was: activeFile.mode)
    EditorFile-->>run.js: "single"
    run.js->>run.js: sendText(activeFile.session.doc.toString(), ...)
    run.js-->>User: document content served inline
Loading

Reviews (1): Last reviewed commit: "fix: preview SAF single-file documents" | Re-trigger Greptile

@bajrangCoder bajrangCoder merged commit ab1f747 into Acode-Foundation:main Jun 6, 2026
5 checks passed
@bajrangCoder bajrangCoder deleted the fix/saf-single-file-preview branch June 6, 2026 10:38
@github-project-automation github-project-automation Bot moved this from Backlog to Done in The Code Board - Acode Jun 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant