Repository navigation
Inject FocusLogStore instead of a shared singleton - #5239
Conversation
FocusLogStore self-vended a `static let shared`. AppDelegate now owns the single instance (next to updateLog), the in-AppDelegate diagnostic sites use it directly, and the GhosttyTerminalView/Workspace sites reach it via AppDelegate.shared?.focusLog, matching the UpdateLogStore de-singletoning. No behavior change. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughFocusLogStore is converted from a singleton to an externally-constructible instance; AppDelegate now owns a FocusLogStore instance and all DEBUG focus-log writes (AppDelegate internals, Workspace, GhosttyTerminalView) are redirected to AppDelegate.shared?.focusLog. Clipboard export uses the instance snapshot/logPath. ChangesFocus Logging Injection Refactoring
Sequence DiagramsequenceDiagram
participant AppDelegate
participant FocusLogStore
participant Workspace
participant GhosttyNSView
AppDelegate->>FocusLogStore: init() on app startup
Workspace->>AppDelegate: AppDelegate.shared?.focusLog.append(message)
AppDelegate->>FocusLogStore: append(message)
GhosttyNSView->>AppDelegate: AppDelegate.shared?.focusLog.append(message)
AppDelegate->>FocusLogStore: append(message)
AppDelegate->>FocusLogStore: snapshot() + logPath() for clipboard
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 17 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (17 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@codex review |
|
To use Codex here, create a Codex account and connect to github. |
Greptile SummaryThis PR de-singletones
Confidence Score: 5/5Safe to merge; this is a clean DI refactor with no behavioral change in debug builds and a negligible side effect in release builds. All changed code is mechanical: singleton removed, stored property added to AppDelegate, call sites updated. The only noteworthy difference is that FocusLogStore.init() — and therefore ensureLogFile() — now runs unconditionally in release builds, creating an empty log file that was previously never created. This is cosmetic and has no functional impact on users. Sources/Update/UpdateLogStore.swift — FocusLogStore.init() calls ensureLogFile() unconditionally, creating an empty log file in release builds that did not exist before. Important Files Changed
Sequence DiagramsequenceDiagram
participant AD as AppDelegate
participant FLS as FocusLogStore
participant GTV as GhosttyNSView
participant WS as Workspace
Note over AD: App startup
AD->>FLS: "init() → let focusLog = FocusLogStore()"
Note over GTV: focusDebugEnabled check
GTV->>AD: AppDelegate.shared?.focusLog
AD-->>GTV: FocusLogStore instance
GTV->>FLS: "append(message) [#if DEBUG only]"
Note over WS: Inside #if DEBUG block
WS->>AD: AppDelegate.shared?.focusLog
AD-->>WS: FocusLogStore instance
WS->>FLS: append(message)
Note over AD: copyFocusLogs action
AD->>FLS: snapshot() / logPath()
FLS-->>AD: entries / path
Reviews (2): Last reviewed commit: "Compile-time guard the FOCUSDBG NSLog in..." | Re-trigger Greptile |
CodeRabbit's "Cmux Swift Logging" check flagged the NSLog in GhosttyNSView.focusLog as runtime-gated only. Wrap it in #if DEBUG so it is stripped from release builds, matching the repo debug-log requirement. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Follow-up to the CmuxUpdater extraction (#5132), which de-singletoned
UpdateLogStore.FocusLogStore(the DEBUG-only focus-event diagnostic logger that lives in the same file) still self-vended astatic let shared.This applies the same fix:
AppDelegateowns the singleFocusLogStoreinstance next toupdateLog, so its lifecycle has one composition root. The in-AppDelegatecall sites use the instance directly; theGhosttyTerminalViewandWorkspacesites reach it viaAppDelegate.shared?.focusLog, mirroring the existingAppDelegate.shared?.updateLogprecedent. The type is now a plain injectable class with a documented@unchecked Sendable(its mutable state stays confined to the serial queue, unchanged).The second commit compile-time guards the
FOCUSDBGNSLoginGhosttyNSView.focusLogbehind#if DEBUG(it was runtime-gated only), per the repo debug-log requirement.No production behavior change.
FocusLogStore.appendis already#if DEBUG; this only moves ownership.Testing
./scripts/reload.sh --tag focuslog-dibuilds green.FocusLogStore.sharedsymbol.tests-build-and-lagand the CoreAnimation main-thread startup regression pass on the build.~/Library/Logs/cmux-focus.log, the Copy Focus Logs menu action) works exactly as before, now sourced from the AppDelegate-owned instance.🤖 Generated with Claude Code