cmux/Sources
Ismail Pelaseyed d72b014d6d
feat: add markdown viewer panel with live file watching (#883)
* Add markdown viewer panel with live file watching

Introduce a new PanelType.markdown that renders .md files in a dedicated
panel using MarkdownUI (SwiftUI), with live file watching via DispatchSource
so content auto-updates when the file changes on disk.

- New MarkdownPanel class with file system watcher (write/delete/rename/extend)
- New MarkdownPanelView with custom cmux theme (headings, code blocks, tables,
  blockquotes, inline code, lists, horizontal rules, light/dark mode)
- Full workspace integration: SurfaceKind, creation methods, tab subscription
- Session persistence: snapshot/restore across app restarts
- V2 socket command: markdown.open (validates path, resolves workspace, splits)
- CLI command: cmux markdown open <path> with routing flags and help text
- Agent skill: skills/cmux-markdown/ with SKILL.md, openai.yaml, and references
- Cross-link from skills/cmux/SKILL.md to the new markdown skill
- SPM dependency: gonzalezreal/swift-markdown-ui 2.4.1

* Fix unreachable guard in markdown subcommand dispatch

Use looksLikePath() to distinguish subcommands from path arguments
so the guard can catch unknown subcommands and future subcommands
are parsed correctly.

* Use .isoLatin1 fallback instead of .ascii for encoding recovery

ASCII is a strict subset of UTF-8, so falling back to .ascii after
UTF-8 fails is dead code. Use .isoLatin1 which accepts all 256 byte
values and covers legacy encodings like Windows-1252.

* Mark fileWatchSource as nonisolated(unsafe) for deinit safety

deinit is not guaranteed to run on the main actor, so accessing
@MainActor-isolated storage is a data race under strict concurrency.
DispatchSource.cancel() is thread-safe, so nonisolated(unsafe) is
sufficient with a documented invariant that writes only occur on main.

* Fix file watcher reattach: retry loop with cancellation guard

- Replace one-shot 500ms retry with up to 6 attempts (3s total window)
  so files that reappear after a slow atomic replace are picked up
- Add isClosed flag checked before each retry to prevent restarting
  the watcher after close()/deinit

* Harden path validation in markdown.open command

Reject directories and non-absolute paths before panel creation
to prevent ambiguous behavior and generic downstream failures.

* Always reattach file watcher on delete/rename events

After an atomic save (delete old + create new), the DispatchSource still
points to the old inode. Previously we only reattached when the file was
unreadable, so successful atomic saves left the watcher on a stale inode
and live updates silently stopped. Now we always stop and reattach:
immediately if the new file is readable, via retry loop if not.

* Restore markdown panels even when file is missing at launch

MarkdownPanel already handles unavailable files gracefully (shows
'file unavailable' UI and retries via the reattach loop). Dropping
the panel on restore lost the user's layout for files that may
reappear shortly after (network drives, build artifacts, etc.).

* Harden markdown CLI parsing and startup reconnect behavior

---------

Co-authored-by: Lawrence Chen <54008264+lawrencecchen@users.noreply.github.com>
2026-03-04 17:48:28 -08:00
..
Find Add find-in-page (Cmd+F) for browser panels (#837) (#875) 2026-03-04 16:15:15 -08:00
Panels feat: add markdown viewer panel with live file watching (#883) 2026-03-04 17:48:28 -08:00
Update feat: add Japanese localization with String Catalog (#819) 2026-03-04 14:58:28 -08:00
AppDelegate.swift Add custom file support for notification sounds (#869) 2026-03-04 17:18:07 -08:00
Backport.swift Polish browser suggestions, focus, and tagged reload flow 2026-02-14 21:33:28 -08:00
BrowserWindowPortal.swift Fix double-click titlebar zoom not working on browser panel side 2026-02-24 14:35:10 -08:00
cmuxApp.swift Add custom file support for notification sounds (#869) 2026-03-04 17:18:07 -08:00
ContentView.swift Reduce typing lag by hiding invisible views from accessibility tree (#862) 2026-03-04 15:40:57 -08:00
GhosttyConfig.swift Honor Ghostty background-opacity across all cmux chrome (#667) 2026-03-01 03:48:46 -08:00
GhosttyTerminalView.swift Fix voice dictation text insertion path in GhosttyNSView. (#857) 2026-03-04 17:25:39 -08:00
KeyboardLayout.swift Fix Cmd+plus zoom handling on non-US layouts (#680) 2026-02-28 00:16:03 -08:00
KeyboardShortcutSettings.swift feat: add Japanese localization with String Catalog (#819) 2026-03-04 14:58:28 -08:00
NotificationsPage.swift feat: add Japanese localization with String Catalog (#819) 2026-03-04 14:58:28 -08:00
PortScanner.swift Avoid main-thread hops for explicit socket scope 2026-02-20 23:58:47 -08:00
PostHogAnalytics.swift Add telemetry opt-out setting (#610) 2026-02-26 22:02:29 -08:00
SentryHelper.swift Auto-heal missing CLI listener socket (#679) 2026-02-28 01:19:38 -08:00
SessionPersistence.swift feat: add markdown viewer panel with live file watching (#883) 2026-03-04 17:48:28 -08:00
SidebarSelectionState.swift Implement session persistence pass 1 with multi-window restore 2026-02-22 15:39:59 -08:00
SocketControlSettings.swift feat: add Japanese localization with String Catalog (#819) 2026-03-04 14:58:28 -08:00
TabManager.swift Add find-in-page (Cmd+F) for browser panels (#837) (#875) 2026-03-04 16:15:15 -08:00
TerminalController.swift feat: add markdown viewer panel with live file watching (#883) 2026-03-04 17:48:28 -08:00
TerminalNotificationStore.swift Add custom file support for notification sounds (#869) 2026-03-04 17:18:07 -08:00
TerminalView.swift Add sidebar blur effect with withinWindow blending (#9) 2026-02-04 03:04:45 -08:00
TerminalWindowPortal.swift Fix ghost terminal surface rebind after close (#808) 2026-03-03 15:20:42 -08:00
UITestRecorder.swift Fix frozen terminals after split churn (#12) 2026-02-13 16:45:31 -08:00
WindowAccessor.swift Polish browser suggestions, focus, and tagged reload flow 2026-02-14 21:33:28 -08:00
WindowDecorationsController.swift Refine settings/about titlebar styling and controls alignment 2026-02-14 02:11:35 -08:00
WindowDragHandleView.swift Fix re-entrant exclusive-access crash in drag handle hit test (#771) 2026-03-02 19:20:14 -08:00
WindowToolbarController.swift Coalesce title notification updates to reduce main-thread hangs 2026-02-20 20:14:19 -08:00
Workspace.swift feat: add markdown viewer panel with live file watching (#883) 2026-03-04 17:48:28 -08:00
WorkspaceContentView.swift Honor Ghostty background-opacity across all cmux chrome (#667) 2026-03-01 03:48:46 -08:00