Repository navigation
Conversation
The viewer panels (the file panel beside a session, plans and memory) get a share button right after Save that opens the macOS share menu for the open file: AirDrop, Mail, Messages and any app with a share extension, such as WhatsApp or Telegram. It shares the file as saved on disk, media previews included. A new share-file IPC takes an absolute path, since these panels open files outside any project, and only shares a file that exists. Electron has a share menu only on macOS, so the button is not shown elsewhere.
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.
Summary
Adds a Share button to the viewer toolbar, right after Save. On macOS it opens the system share menu for the open file: AirDrop, Mail, Messages, Notes and any app with a share extension, such as WhatsApp or Telegram.
Why
A session often points at a file worth sending to someone: a plan, a report it wrote, a screenshot. Today that means opening the file in Finder (or copying its path) and sharing it from there, which is slowest for the files outside the project, such as plans in
~/.claude/plans. The share menu is one click away from the file you are already looking at.What it does
aria-labelareShare.ViewerPanel: the file panel beside a session, and the plan and memory viewers. It works for text, markdown, JSON, HTML and the image/PDF/PowerPoint previews alike.ShareMenuexists only there, so on Windows and Linux the button is not created.Implementation notes
file-management.js: newshareFile(filePath, { share }), next tomanageProjectEntry. It takes an absolute path, because these viewers open files outside any attached project. It rejects non-strings, relative paths, missing files and folders, and hands the resolved path toshare.main.js: newshare-fileIPC handler that pops aShareMenu({ filePaths: [file] })in the sender's window, returning{ ok, filePath }or{ ok: false, error }(also on a platform without the menu).preload.js:window.api.shareFile(filePath).public/viewer-toolbar.js:shareoption,shareBtnin the toolbar API, and aSHARE_ICONin the same stroke style as the other icons.public/viewer-panel.js: turns the button on fordarwin, shows/hides it inopen(), and sharesthis.filePathon click.fp-toolbar-btn fp-icon-btnclasses.Testing
test/file-management.test.js:shareFileshares an existing file outside any project, normalizes..segments, and rejects relative paths, non-string input, missing files and folders without callingshare.test/viewer-panel.test.js: the button shares the open file, including a media preview, does nothing with no file, is hidden with no file, and alerts the error the IPC returns.test/viewer-toolbar.test.js: loads the realviewer-toolbar.jsin avmcontext and checks the button sits right after Save and before Open in default app, its label, and that it is absent unless requested.npm test: all pass exceptfileDiff reads tracked and untracked changes…andprojectGitInfo and projectGitDiff…, which fail the same way on currentmainon my machine (a globalcolor.ui = alwaysgit setting) and are unrelated.electron .with an isolatedSWITCHBOARD_DATA_DIR): opened a markdown file outside any project in the viewer. The toolbar showed Preview, Copy, Wrap, Go to line, Save, Share, Open in default app. Clicking Share went throughshare-fileand popped the share menu over the window; the IPC returnedokfor the real file and an error for a missing file and for a relative path.