Skip to content

[codex] Fix Markdown default app registration#133

Merged
samuelstroschein merged 2 commits into
mainfrom
fix/md-default-handler-canonical-app
Jun 17, 2026
Merged

[codex] Fix Markdown default app registration#133
samuelstroschein merged 2 commits into
mainfrom
fix/md-default-handler-canonical-app

Conversation

@samuelstroschein

@samuelstroschein samuelstroschein commented Jun 17, 2026

Copy link
Copy Markdown
Member

Summary

Fix macOS Markdown default-app registration so Flashtype does not let old DMGs or local release builds compete with the installed app.

  • only the canonical /Applications/Flashtype.app may register Markdown defaults
  • preserve third-party Markdown handlers like VS Code or Obsidian
  • replace missing handlers, Xcode, or Flashtype itself
  • unregister stale noncanonical com.flashtype.app registrations before refreshing the installed app
  • lower the passive document handler rank from Owner to Alternate

Root Cause

LaunchServices stores default document handlers by bundle id, not by app path. Multiple Flashtype bundles used com.flashtype.app and claimed Markdown ownership, so macOS could resolve .md opens to an old mounted DMG or local release build instead of the installed 0.2.x app.

Validation

  • pnpm vitest run electron/markdown-default-handler.test.ts
  • pnpm oxlint --tsconfig ./tsconfig.json --ignore-path .gitignore electron/main.mjs electron/markdown-default-handler.mjs electron/markdown-default-handler.test.ts
  • pnpm typecheck
  • git diff --check

Note

Medium Risk
Startup code mutates system LaunchServices defaults and unregisters bundles; mistakes could affect which app opens Markdown or leave stale registrations, though scope is limited to darwin packaged installs and replaceable handlers.

Overview
Fixes macOS Markdown default-app behavior so multiple com.flashtype.app bundles (DMGs, local builds) no longer steal .md opens from the installed app.

Markdown registration moves from inline logic in electron/main.mjs into electron/markdown-default-handler.mjs. On startup, only /Applications/Flashtype.app may register defaults: it unregisters stale non-canonical Flashtype bundles via lsregister, refreshes the canonical bundle, reads current editor handlers, and calls LSSetDefaultRoleHandlerForContentType only for content types whose current handler is missing, Xcode, TextEdit, or Flashtype—third-party choices (e.g. VS Code, Obsidian) are left alone. Packaged electron-builder.yml changes Markdown document LSHandlerRank from Owner to Alternate. Vitest coverage documents the policy and full workflow.

Reviewed by Cursor Bugbot for commit 7e1255c. Bugbot is set up for automated code reviews on this repo. Configure here.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 17, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
flashtype-website 7e1255c Commit Preview URL

Branch Preview URL
Jun 17 2026, 06:56 PM

@samuelstroschein samuelstroschein marked this pull request as ready for review June 17, 2026 18:45

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 553412f. Configure here.

Comment thread electron/markdown-default-handler.mjs Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 553412f6ed

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +10 to +13
export const REPLACEABLE_MARKDOWN_HANDLER_BUNDLE_IDS = new Set([
APP_BUNDLE_ID,
"com.apple.dt.Xcode",
]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Treat TextEdit fallback as replaceable

When the existing Markdown default is macOS's TextEdit fallback (com.apple.TextEdit), this replacement allowlist treats it like a user-selected third-party Markdown editor, so getMarkdownContentTypesToRegister() returns nothing and the packaged /Applications/Flashtype.app never becomes the default. That regresses the previous first-run registration path for users whose .md files still open in TextEdit, while the preservation logic was meant for explicit third-party handlers such as VS Code or Obsidian.

Useful? React with 👍 / 👎.

@samuelstroschein samuelstroschein merged commit a0e7c09 into main Jun 17, 2026
5 checks passed
@samuelstroschein samuelstroschein deleted the fix/md-default-handler-canonical-app branch June 17, 2026 19:06
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