Skip to content

feat(android): add contextual SAF document and folder pickers - #3009

Open
marvin1099 wants to merge 8 commits into
Acode-Foundation:mainfrom
marvin1099:feat/android-saf-storage
Open

marvin1099 wants to merge 8 commits into
Acode-Foundation:mainfrom
marvin1099:feat/android-saf-storage

Conversation

@marvin1099

@marvin1099 marvin1099 commented Oct 31, 2026 •

Copy link
Copy Markdown

Summary

Save / Save As
  Create document on device -> ACTION_CREATE_DOCUMENT -> write editor buffer

Open File
  Select document -> ACTION_OPEN_DOCUMENT -> open selected URI

Save File destination / Open Folder
  Choose folder on device -> ACTION_OPEN_DOCUMENT_TREE -> retain folder grant
  • Keep Create document on device in the Save dialog and add it to the save-context File Browser.
  • Expose Choose folder on device only in Save File and Open Folder contexts.
  • Preserve the existing tab URI and persistence state until a Create Document Save As write succeeds; update the filename before re-locking single-document mode.
  • Keep the changes in eight focused commits; no version bumps.

Evidence

  • Before: Save offered only folder selection; the native picker rows were not available in the intended File Browser contexts.
  • After: Real File Browser interaction tests click the picker rows and verify Save File, Open Folder, and Open File availability. Failed saves preserve the existing recovery identity; a real EditorFile test verifies renaming and language switching for a new document.
  • Automated: 96 test files / 873 tests pass; typecheck, Biome, and Rspack pass. F-Droid remains unchanged.

Merge Danger

Door: Two-way; the commits can be reverted independently.

Blast Radius: Medium — Android document save/open and folder-selection flows.

AI was used to make these changes. Feel free to ignore, cherry-pick, or request changes I should make for this PR to be a good fit.

@github-actions github-actions Bot added enhancement New feature or request translations Anything related to Translations Whether a Issue or PR labels Oct 31, 2026
@greptile-apps

greptile-apps Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with a non-blocking issue where newly created documents keep the old tab name.

Findings

  1. P2 Saved tabs keep old names ▶

Summary

Adds contextual Android document and folder pickers.

  • Save and Save As can write editor contents to a new Android document.
  • The File Browser shows Android picker choices only in matching tasks.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Save or Save As] --> B{Choose destination}
  B --> C[Create document on device]
  B --> D[Save File browser]
  D --> C
  D --> E[Choose folder on device]
  C --> F[Write editor contents]
  F --> G{Write succeeds?}
  G -->|No| H[Keep old tab identity]
  G -->|Yes| I[Update URI and permission state]
  I --> J[Filename update is blocked by single mode]
Loading

Reviews (2) · Last reviewed commit: "feat(file-browser): enable device folder..." · Reviewed by Greptile

Comment thread src/lib/saveFile.js Resolved
@marvin1099
marvin1099 force-pushed the feat/android-saf-storage branch 2 times, most recently from 71fb3e4 to 60227cc Compare October 31, 2026 09:29
Comment thread src/lib/saveFile.js Outdated
Comment on lines +242 to +246
file.SAFMode = "single";
file.uri = fileUri;
targetUri = fileUri;
file.persistInSession = createdDocument.persistedUriPermission !== false;
file.filename = filename;

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.

P2 Saved tabs keep old names

When the user creates a document with a different name, saveFile sets SAFMode to "single" before assigning filename. The real EditorFile.filename setter ignores assignments in that mode. The saved tab keeps its old name and does not switch languages if the extension changed.

After the write succeeds, update the name while the setter is unlocked, then set SAFMode to "single". The tests miss this because their file is a plain object.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in the Save-dialog commit: after the document write succeeds, Save As unlocks SAF mode, updates the filename, then restores single-document mode. The regression test uses a real EditorFile starting in single mode, changes the extension, and verifies the filename and language mode update.

@marvin1099
marvin1099 force-pushed the feat/android-saf-storage branch from 60227cc to d6c3746 Compare October 31, 2026 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request translations Anything related to Translations Whether a Issue or PR

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant