Repository navigation
Zed extension: Export Markdown to PDF via LSP code actions - #1
Merged
lecstor merged 5 commits intoSep 30, 2026
Merged
Conversation
…roject root The language server process runs with the worktree root as its working directory (lsp_store.rs passes the worktree path to LanguageServer::new, which sets current_dir), and Zed resolves only command.command against the extension directory, never arguments. The relative npm entry path therefore resolved inside the user's project for every user; join it with the extension's WASI cwd (env::current_dir), as the official html extension does, and fail clearly when the installed package lacks it. Also from the adversarial pass: - dev override MAKESPDF_ZED_SERVER_JS: the README's 'npm install ./server' at the repo root never reached the extension work dir Zed preopens, so a dev could not run the sidecar before it is published. - fontSize accepts any finite number in 6..24, matching the VS Code plugin and the server schema (a fractional size was silently reset). - api.ts reuses feedback.ts's asErrorCode instead of a duplicate rule. - README documents that local relative images are not embedded in v1; CHANGELOG says every request sends the client header.
…etached commands - apiToken is sent only when serviceUrl is makespdf.com, staging.makespdf.com or a loopback address. Zed deep-merges project settings, so a repo's .zed/settings.json that set only serviceUrl would otherwise receive the user's global token on the next export. A withheld token is reported once. - Validate accessibility is offered only when a token can be sent: /api/v1/md/validate has no anonymous access, so without one it could only fail. - workspace/executeCommand is answered at once and the command runs detached, so a slow render or an open "Report problem" prompt cannot run into Zed's 120 s request timeout. Each command logs "<command> finished", which the integration tests wait on. - Failed validate calls are no longer worded as failed exports. - lib.rs: a failed npm update falls back to the installed sidecar, and the registry is checked once per session instead of on every server start. - Ignore the extension.wasm Zed builds for a dev install.
Official clients send their plain kind (vscode, obsidian, zed, cli, gh-action) rather than a -plugin/-extension suffix, so the header value matches the kind the server records.
Member
Author
|
by @lecstor's coding agent Two commits after an independent review and a manual smoke test in Zed (the PR description predates them):
Smoke test in Zed (dev extension, local sidecar via
Not tested: Report problem submission (it would write a real feedback row), and the npm install path (the package is unpublished; see MAK-138). |
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.
What
The makesPDF extension for Zed: a WASM coordinator (
src/lib.rs) that registers a Markdown language server, plus the@makespdf/zed-language-serversidecar (server/) whose code actions do the work. Zed has no command palette for extensions, so — likestemper-dev/zed-markdown-pdf— the user surface is the code-actions menu (cmd-./ctrl-.).Behaviour
/api/v1/md, writes<same dir>/<name>.pdf(overwriting), and shows the path plus page/render stats. TheX-MakesPDF-Tipupsell is surfaced once per session./api/v1/md/validate, showsNo accessibility issues found.orN errors, M warningsplus the first issues, and logs each issue viawindow/logMessage.window/showMessageRequestoffers it; picking it POSTs the VS Codefeedback.tspayload builder's fingerprints to/api/v1/feedback, including its 401-retry-without-auth rule. The message is built from the failure shape — the server's error text is never forwarded (a 500 body can quote document content).X-MakesPDF-Client: zed-extension/<package version>(recognised by MAK-136'sinferClient→ kindzed);Authorization: Beareronly whenapiTokenis set.lsp.makespdf.settingswith the same names/enums/defaults as the VS Code plugin (serviceUrl,apiToken,pageSize,fontFamily,fontSize,margins), forwarded vialanguage_server_workspace_configurationand merged field-by-field over the defaults.Repo layout
extension.toml/Cargo.toml/src/lib.rs: registersmakespdffor Markdown, installs/updates the npm package withnpm_install_packageand runs it withnode_binary_path.server/: TypeScript,vscode-languageserver, bundled by esbuild todist/server.js..github/workflows/ci.yml:cargo build --target wasm32-wasip2 --release --locked+ server typecheck/unit/integration..github/workflows/release.yml: tag-triggered npm trusted publishing with provenance (first publish is MAK-138, human; nothing was published here).Tests
cd server && npm test:dist/server.js, spawned over stdio):file://.md returns Export/Validate; executing Export writes<name>.pdfwith the mock's bytes and sendsX-MakesPDF-Client: zed-extension/<version>Bearerwith one/api/v1/feedbackwith the fingerprints and none of the document textcargo build --target wasm32-wasip2 --release --lockedsucceeds locally.Adversarial review pass (commit 2644ecc)
lsp_store.rs→LanguageServer::new→current_dir), and Zed resolves onlycommand.commandagainst the extension directory — never arguments — so node could never find the npm package for a real user. The entry is now absolute (env::current_dir()join, the pattern the officialhtmlextension uses), with a clear error when the installed package lacks it, plus aMAKESPDF_ZED_SERVER_JSdev override so a local build can run before the package is published (the README's previousnpm install ./serverput the package where the extension's WASI preopen never looks).fontSizeaccepts any finite number in 6..24 like the VS Code plugin and the server schema (a fractional size was silently reset to the default).api.tsreusesfeedback.ts'sasErrorCodeinstead of keeping a second copy of the code-shaped rule.http(s)/data:URLs) — deferred to MAK-144; CHANGELOG wording fixed.writeFilefailures — the synthesized feedback message is built from the failure shape, and a local disk error has no HTTP status (the report would read "(no response)" for a render that succeeded).CI on 2644ecc: WASM extension ✅, Language server ✅.
Closes MAK-134 (implementation; review follows the task flow).