Skip to content

Add a Share button to the file viewer toolbar - #112

Open
vivi7 wants to merge 1 commit into
doctly:mainfrom
vivi7:feat/viewer-share-file
Open

vivi7 wants to merge 1 commit into
doctly:mainfrom
vivi7:feat/viewer-share-file

Conversation

@vivi7

@vivi7 vivi7 commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

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

  • A share icon button in the viewer toolbar, between Save and Open in default app. Its tooltip and aria-label are Share.
  • It appears in every 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.
  • It shares the file as saved on disk, the same as Open in default app; unsaved edits stay in the editor.
  • It is hidden when the viewer has no file open, and a click with no file does nothing. Failures are reported with an alert, as Open in default app does.
  • macOS only: Electron's ShareMenu exists only there, so on Windows and Linux the button is not created.

Implementation notes

  • file-management.js: new shareFile(filePath, { share }), next to manageProjectEntry. 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 to share.
  • main.js: new share-file IPC handler that pops a ShareMenu({ 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: share option, shareBtn in the toolbar API, and a SHARE_ICON in the same stroke style as the other icons.
  • public/viewer-panel.js: turns the button on for darwin, shows/hides it in open(), and shares this.filePath on click.
  • No CSS changes: the button uses the existing fp-toolbar-btn fp-icon-btn classes.

Testing

  • test/file-management.test.js: shareFile shares an existing file outside any project, normalizes .. segments, and rejects relative paths, non-string input, missing files and folders without calling share.
  • 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.
  • New test/viewer-toolbar.test.js: loads the real viewer-toolbar.js in a vm context 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 except fileDiff reads tracked and untracked changes… and projectGitInfo and projectGitDiff…, which fail the same way on current main on my machine (a global color.ui = always git setting) and are unrelated.
  • Manual check on macOS in the running app (electron . with an isolated SWITCHBOARD_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 through share-file and popped the share menu over the window; the IPC returned ok for the real file and an error for a missing file and for a relative path.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant