Repository navigation
feat(mobile): preview build files, lockfiles and text data formats - #830
Merged
Merged
Conversation
The phone's allow-list was a suffix table plus a fixed MIME map, so anything that identifies itself by name was refused before the transfer: `Makefile`, `Dockerfile`, `.gitignore`, `Cargo.lock`, `go.mod`. Text data formats the reader can render itself (`csv`, `tsv`, `yaml`, `xml`, `jsonl`) were handed to another app instead, and a batch of code formats the desktop overlay already reads (`.proto`, `.diff`, `.patch`, `.ndjson`, `.graphql`, `.edn`, `.elm`, `.xhtml`, `.mm`, `.f`) had no route at all. - `mobile/src/remote/fileTypes.ts`: match suffix-less files on the whole base name (plus `Dockerfile.dev` / `Makefile.am` / `.env.local` style prefixes), resolve only the path's last segment, add `.proto` / `.ipynb` (rich JSON) / `.diff` / `.patch` / `.ndjson` / `.graphql` / `.edn` / `.elm` / `.xhtml` / `.mm` / `.f` / `.mk` / `.cmake` / `.lock` / `.plist` / `.xcconfig` / `.csproj` / `.sln` / `.hcl` / `.tfvars` / `.mts` / `.cts`, and move the text data formats onto the in-app text route (keeping MIME + `textFallback` so the menu can still push them to an installed editor). - `desktop/src-tauri/src/remote_host/files.rs`: the host carries the same names (`CODE_TEXT_NAMES` + prefixes) so it serves exactly what the phone will preview, resolves `.ipynb` as JSON, and adds the same suffixes to the text list. A name may arrive as a full path, so it is matched on its last segment with both platform separators. - `mobile/src/components/codeHighlight.ts`: grammars by name (`Makefile`, `Gemfile`, `.gitignore`, `.bashrc`) and for the new suffixes, and monospace now follows the file name alone (`codeStyleForFile`) — `.txt` / `.log` and the licence files stay prose, so a code or data file Prism ships no grammar for (`Cargo.lock`, `.csv`) still lines up. - `desktop/src/features/filepreview/previewKind.ts`: the overlay's own list gains the same names and an `LANGUAGE_BY_NAME` table, so opening a `Makefile` on the desktop is highlighted too.
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.
Why
The phone decides what it can show from a suffix table plus a fixed MIME map (
mobile/src/remote/fileTypes.ts), and the desktop host refuses anything it cannot name (remote_host/files.rs). Two consequences:Makefile,Dockerfile,.gitignore,Cargo.lock,go.mod,.env.local. A suffix table can never see them.csv,tsv,yaml,xml,jsonl), and a batch of code formats the desktop overlay already reads had no route at all (proto,diff,patch,ndjson,graphql,edn,elm,xhtml,mm,f).What changed
1. Suffix-less files match on the base name (
MOBILE_FILE_NAMESon the phone,CODE_TEXT_NAMESon the host): build entry points (Makefile,Dockerfile,Jenkinsfile,CMakeLists.txt,meson.build,Justfile,Gemfile,Podfile, …), lockfiles and manifests (Cargo.lock,go.mod,go.sum), editor/shell dotfiles (.gitignore,.editorconfig,.npmrc,.bashrc,.envrc, …) and the extension-less licence files (LICENSE,README,CHANGELOG,CODEOWNERS). Names that qualify themselves (Dockerfile.dev,Makefile.am,.env.local) match asprefix/prefix.…. The same rule powers the desktop overlay's own preview list.2. New formats.
.proto,.ipynb(rich JSON reader, since a notebook is one JSON document),.diff,.patch,.ndjson,.graphql,.edn,.elm,.xhtml,.mm,.f,.mk,.cmake,.lock,.plist,.xcconfig,.csproj,.sln,.hcl,.tfvars,.mts,.cts.3. Text data formats are read in-app —
csv/tsv/yaml/yml/xml/jsonlmoved fromexternalto thetextroute, keeping their precise MIME andtextFallbackso the preview menu can still push them to an installed editor..htmlis deliberately unchanged (it still opens in a browser).4. Two smaller fixes while in there.
notes.md/scratch) no longer classifies the file, and a Windows-style name (C:\w\Makefile) resolves identically.codeStyleForFile) instead of "a grammar exists". A code or data file Prism/Bundled-Shiki ships no grammar for (Cargo.lock,.csv,meson.build) used to render in the proportional font, which is exactly what makes tabular data unreadable;.txt/.logand the licence files stay prose.Host-side, this only widens the format gate — file access still goes through
ensure_path_allowed, so FutureOS credential files stay blocked, and a file whose bytes are not UTF-8 text still falls back to the exact-original variant (save / share) instead of erroring.Verification
mobile:npx jest --runInBand— 125 suites, 1997 tests pass;tsc --noEmit;eslinton the changed files.desktop:vitest run— 144 files, 1252 tests pass;eslinton the changed files.desktop/src-tauri:cargo fmt --check,cargo clippy --all-targets -- -D warnings,cargo test --lib remote_host::files(35 tests). The full crate suite passes exceptinstance::tests::excludes_second_owner_and_releases_on_drop, which fails under full-suite parallel load and passes in isolation on this machine (file-lock timing, unrelated to this change).Tests updated/added on each side assert the name+prefix rule, the new suffixes, the
.ipynbsize ceiling, the "only the base name decides" rule, and that every mapped suffix and name has a grammar that really colors its source.Notes for review
.env.local/.npmrcstyle files are now previewable on a paired phone, where they were previously refused outright..envwas already allowed, and a paired phone is a trusted device (it can reach any file through the agent), but this is the one place where the allow-list widening has a security flavour — say the word and I'll drop those two names..pem/.crt/.glsl/.nix/.awk/.sln-style project files of other stacks, template languages (.j2,.erb,.hbs,.ejs,.astro), doc formats (.rst,.adoc,.org) and.mdx. Same mechanism, ~10 lines each, whenever they are wanted.desktop/src/lib/fileType.ts) still has no notion of these names — aMakefileshows the generic text glyph. Cosmetic, left out to keep the diff on the preview path.