Skip to content

Make Iroh transport diagnostics human-readable - #9485

Merged
azooz2003-bit merged 10 commits into
mainfrom
feat-readable-iroh-transport-logs
Aug 4, 2026
Merged

azooz2003-bit merged 10 commits into
mainfrom
feat-readable-iroh-transport-logs

Conversation

@azooz2003-bit

@azooz2003-bit azooz2003-bit commented Aug 3, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Replace compact cmuxdiag rows, camelCase event names, and numeric payload slots with a UTC plain-language timeline.
  • Decode all 55 transport diagnostic event codes into human titles and labeled semantic values.
  • Route Settings Share, cmux iroh-diag, report attachments, Sentry breadcrumbs, and Sentry logs through the same formatter. Stable machine codes remain only in grouping and search metadata.

Testing

  • 51 focused CMUXMobileCore diagnostics and incident-policy tests pass.
  • 7 focused CmuxSentryTelemetry reporter tests pass.
  • The package convention scan no longer reports DiagnosticEventPresentation.
  • Tagged hrlog preflight verified Settings > Networking > Connection Report > Share > Copy and cmux iroh-diag produce the same readable report with raw format tokens absent.
  • Hosted iOS/package run: https://github.com/manaflow-ai/cmux/actions/runs/30862163757

Implementation

DiagnosticEventPresentation is an instantiated, stateless formatter shared by every export owner. This is a principled change because one exhaustive schema now owns user-facing names and payload decoding while stable machine identifiers remain available for telemetry correlation.

Checklist

  • Focused behavior tests updated and run
  • Documentation updated
  • Tagged report and Share entrypoints exercised

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

Replaces compact cmuxdiag v1 rows with a UTC, localized plain‑language timeline for Iroh/transport diagnostics across the app, CLI, socket command, and Sentry. Honors explicit locales for all titles and texts while keeping stable machine codes in tags and grouping.

  • New Features

    • Localized formatter in CMUXMobileCore (format v2) decodes all transport event codes; adds Resources/Localizable.xcstrings and defaultLocalization: "en" with resources processed by the package.
    • DiagnosticLocalization resolves strings for an explicit Locale with a runtime check for compiled catalogs; DiagnosticIncidentTitleFormatter produces localized, pluralized incident titles; TransportIncidentPolicy accepts and honors a Locale.
    • DiagnosticLog.export() and sharing produce a localized timeline with UTC timestamps (or relative time if no wall‑clock anchor) and valid UTF‑8 text.
    • cmux iroh-diag and the iroh_diag socket command print the same readable report; CLI help text is localized via cli.help.irohDiag.
    • Sentry breadcrumbs/logs use readable summaries with structured data; captured events attach the timeline text. Tags keep stable codes like transport.event_code and transport.role_code.
  • Migration

    • DiagnosticReport.compactExport() now returns the same human‑readable report as humanReadableExport() (format v2). Update any parser expecting numeric cmuxdiag v1 rows.
    • CLI and Settings exports now output text timelines; remove downstream decoders for integer rows.
    • Sentry messages are readable summaries; tags keep stable codes (e.g., transport.event_code, transport.role_code). Attachments are the plain‑language timeline.

Written for commit d6ec333. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • New Features
    • Diagnostic exports now provide readable, labeled timelines with timestamps, event descriptions, durations, and decoded values.
    • Reports support English and Japanese localization, clearer transport incident titles, and detailed summaries.
    • Empty reports clearly indicate that no events were recorded.
    • Telemetry attachments and logs now include human-readable diagnostic context.
  • Bug Fixes
    • Timestamps use wall-clock references when available, with relative timing otherwise.
  • Documentation
    • Updated CLI, settings, and diagnostic guidance for the human-readable export format.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026 •

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The PR replaces compact diagnostic exports with localized, human-readable timelines. It adds semantic event decoding, versioned report formatting, localized incident titles, richer Sentry fields, and updated CLI, terminal, iOS, and macOS integrations.

Changes

Diagnostic reporting

Layer / File(s) Summary
Event presentation and localization
Packages/Shared/CMUXMobileCore/Sources/CMUXMobileCore/DiagnosticEventPresentation.swift, Packages/Shared/CMUXMobileCore/Sources/CMUXMobileCore/DiagnosticLocalization.swift, Packages/Shared/CMUXMobileCore/Sources/CMUXMobileCore/Resources/Localizable.xcstrings, Packages/Shared/CMUXMobileCore/Tests/CMUXMobileCoreTests/*
DiagnosticEventPresentation now provides localized titles, summaries, display names, semantic payload fields, formatted values, and unknown-value fallbacks through instance-based Sendable APIs.
Versioned human-readable timeline export
Packages/Shared/CMUXMobileCore/Sources/CMUXMobileCore/DiagnosticReport.swift, Packages/Shared/CMUXMobileCore/Sources/CMUXMobileCore/DiagnosticLog.swift, Packages/Shared/CMUXMobileCore/Sources/CMUXMobileCore/DiagnosticEvent.swift, Packages/Shared/CMUXMobileCore/Tests/CMUXMobileCoreTests/DiagnosticLogTests.swift
DiagnosticReport now emits version 2 localized timelines with metadata, event counts, UTC or relative timestamps, deterministic formatting, and empty-report text. DiagnosticLog uses this output, and compactExport() delegates to it.
Incident titles and Sentry telemetry
Packages/Shared/CMUXMobileCore/Sources/CMUXMobileCore/DiagnosticIncidentTitleFormatter.swift, Packages/Shared/CMUXMobileCore/Sources/CMUXMobileCore/TransportIncidentPolicy.swift, Packages/Shared/CmuxSentryTelemetry/Sources/CmuxSentryReporting/TransportSentryReporter.swift, Packages/Shared/CmuxSentryTelemetry/Tests/CmuxSentryReportingTests/TransportSentryReporterTests.swift, Packages/Shared/CMUXMobileCore/Tests/CMUXMobileCoreTests/TransportIncidentPolicyTests.swift
Incident titles use localized summaries, counts, and durations. Sentry records readable messages, role metadata, and described fields while retaining stable codes for tags and fingerprints.
CLI and application export integration
CLI/cmux.swift, Sources/TerminalController.swift, Packages/iOS/CmuxMobileShellUI/Sources/CmuxMobileShellUI/MobileIrohSettingsModel.swift, Packages/iOS/CmuxMobileShellUI/Tests/CmuxMobileShellUITests/MobileIrohSettingsModelTests.swift, Packages/macOS/CmuxSettingsUI/Sources/CmuxSettingsUI/Models/IrohSettingsModel.swift, Packages/macOS/CmuxSettingsUI/Tests/CmuxSettingsUITests/IrohSettingsModelTests.swift, Resources/Localizable.xcstrings, docs/transport-sentry-diagnostics.md
CLI help, terminal output, application exports, and diagnostics documentation now describe or use localized human-readable timelines.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI_or_Settings
  participant DiagnosticLog
  participant DiagnosticReport
  participant DiagnosticEventPresentation
  CLI_or_Settings->>DiagnosticLog: request diagnostic export
  DiagnosticLog->>DiagnosticReport: serialize snapshot
  DiagnosticReport->>DiagnosticEventPresentation: describe events
  DiagnosticEventPresentation-->>DiagnosticReport: localized titles and labeled values
  DiagnosticReport-->>CLI_or_Settings: human-readable timeline
Loading

Possibly related PRs


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error, 1 warning)

Check name Status Explanation Resolution
Cmux User-Facing Error Privacy ❌ Error The new Settings/CLI report emits “cmux Iroh” and formatter output includes “Iroh” and “Tailscale”, exposing upstream provider names without explicit user configuration. Use generic cmux transport terms in user-facing reports and event titles; keep provider names only in sanitized telemetry or explicit user-configured contexts.
Docstring Coverage ⚠️ Warning Docstring coverage is 28.44% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (23 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Cmux Swift Actor Isolation ✅ Passed Changed formatter and localization types are Sendable value types; report text is nonisolated, UI models remain explicitly @MainActor, and the affected manifests set no MainActor default.
Cmux Swift Blocking Runtime ✅ Passed The production Swift diff adds no semaphores, waits, sleeps, delayed dispatch, polling, main-queue sync, timers, or locks; the existing irohDiag semaphore remains unchanged.
Cmux Browser Automation Off-Main ✅ Passed The full PR diff changes no browser/WebKit/socket automation paths or wait/callback routing; TerminalController changes only iroh_diag report formatting.
Cmux Expensive Synchronous Load ✅ Passed The PR adds no agent-history loader or large-file read. New MainActor callers format bounded in-memory DiagnosticReport values, and CLI work remains off-main.
Cmux Cache Substitution Correctness ✅ Passed The production diff changes diagnostic formatting only; Settings and CLI still obtain reports from controller.irohDiagnosticReport() or DiagnosticLog.snapshot(), with no cached-value substitution.
Cmux No Hacky Sleeps ✅ Passed The full PR diff contains no TypeScript, JavaScript, shell, or non-Swift build/runtime files; all runtime changes are Swift, which this check excludes.
Cmux Algorithmic Complexity ✅ Passed New export work is linear over the bounded diagnostic ring (max 4,096 events); per-event fields are fixed at five slots, locale scans cover only package locales, and existing sorting is unchanged.
Cmux Swift Concurrency ✅ Passed The PR adds a nonisolated async report formatter and awaits it in existing async paths; it adds no Dispatch queues, Combine, completion handlers, or fire-and-forget Tasks.
Cmux Swift @Concurrent ✅ Passed The only new CPU-heavy nonisolated async formatter, DiagnosticReport.humanReadableText, has @concurrent; UI callers await it, while log exports use an explicit Store actor hop.
Cmux Swift Package Boundaries ✅ Passed New formatter, report, and localization logic is in CMUXMobileCore; Sentry and Settings callers are package targets, while app-root changes only update CLI help and delegate iroh_diag export.
Cmux Swiftpm Lockfiles ✅ Passed The PR only adds localization and resources to CMUXMobileCore/Package.swift; it changes no dependencies, Xcode references, workflows, .gitignore files, or Package.resolved lockfiles.
Cmux Swift Logging ✅ Passed The PR adds no print, debugPrint, dump, NSLog, or file/stdout logging. Its changed Sentry logs use fixed diagnostic codes and sanitized fields; CLI report output is allowed user-facing output.
Cmux Full Internationalization ✅ Passed All 201 CMUXMobileCore localization keys have translated en/ja catalog units, and cli.help.irohDiag has translated entries for all 20 root-catalog locales; production text uses localized APIs.
Cmux Swiftui State Layout ✅ Passed The PR diff adds no SwiftUI views, state wrappers, GeometryReader, lazy rows, or render-time writes; UI model changes only format reports in async reload paths.
Cmux Architecture Rethink ✅ Passed The diff adds no timing, blocking, observer, or UI-owner machinery; CLI, Settings, log, and Sentry paths delegate to the shared DiagnosticReport formatter.
Cmux Swift Auxiliary Window Close Shortcuts ✅ Passed PASS: The PR changes diagnostic localization and export code only. It adds no NSWindow, NSPanel, WindowController, WindowGroup, identifier, or Cmd+W ownership code; the auxiliary-window check is no...
Cmux Source Artifacts ✅ Passed All 24 changed paths are source, tests, docs, config, or localization catalogs; the PR adds no artifact-like directories, generated logs, screenshots, recordings, caches, or build output.
Cmux No Test Or Debug Seam In Production Source ✅ Passed The complete feature diff adds no test-build guards or test/debug seam members; new formatter and report APIs have production callers in Sentry, CLI, Settings, and incident paths.
Cmux No Ambient Global State ✅ Passed Production Swift adds no top-level API functions, mutable globals, or new singletons; diagnostic behavior uses constructable instance types, with only static constants/private helpers.
Title check ✅ Passed The title clearly and concisely describes the main change: making Iroh transport diagnostics human-readable.
Description check ✅ Passed The description explains the changes, rationale, testing, implementation, and documentation updates, but omits the template's demo video and review-trigger sections.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat-readable-iroh-transport-logs

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 6

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/transport-sentry-diagnostics.md`:
- Around line 13-15: Update the stable-code location statement in the transport
diagnostics documentation to include breadcrumb event_code and structured-log
transport.event_code and transport.role_code, while retaining the existing
Sentry tags and fingerprints references. Ensure it no longer claims stable case
names appear only in tags and fingerprints.
- Around line 58-65: Update the timestamp description in the transport
diagnostics documentation to state that humanReadableExport() uses UTC
timestamps when a wall date is available and +<seconds> relative
timestamps as the fallback when it is absent.

In
`@Packages/Shared/CMUXMobileCore/Sources/CMUXMobileCore/DiagnosticReport.swift`:
- Around line 192-219: Update the diagnostic report generation around the report
header, empty-state branch, timeline timestamps, and DiagnosticEventPresentation
calls to use localized resources for every user-facing string, including
headings, labels, “No events recorded.”, and the elapsed-seconds suffix. Add
matching entries for all supported locales and preserve the existing report
structure and formatting behavior.
- Around line 207-220: Update humanReadableExport() to reserve capacity for the
output and replace the per-event String(format:) and Locale allocations in the
timeline loop with a bounded integer-based elapsed-time formatter. Preserve the
existing wall-clock timestamp formatting and relative-time output, while
appending each event through the reserved buffer.

In
`@Packages/Shared/CMUXMobileCore/Sources/CMUXMobileCore/TransportIncidentPolicy.swift`:
- Around line 263-269: Update TransportIncidentPolicy.swift at lines 263-269 and
326-328 to use one localized incident-title formatter instead of direct English
string construction. Define ICU .one and .other templates for failure counts and
durations, ensuring singular wording for a count of one, and route the
occurrence suffix through the same formatter at lines 326-328.

In
`@Packages/Shared/CMUXMobileCore/Tests/CMUXMobileCoreTests/DiagnosticEventPresentationTests.swift`:
- Around line 44-48: Add assertions in describesRetryDelayAndCloseAttribution to
cover duration values representing exactly one second and a whole number of
seconds greater than one, verifying the singular “second” and plural “seconds”
outputs respectively. Keep the existing fractional-duration assertion unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: c5f8b990-ab5f-41c4-904a-06a5d2767a4e

📥 Commits

Reviewing files that changed from the base of the PR and between 4adc8e5 and 4f51e64.

📒 Files selected for processing (18)
  • CLI/cmux.swift
  • Packages/Shared/CMUXMobileCore/Sources/CMUXMobileCore/DiagnosticEvent.swift
  • Packages/Shared/CMUXMobileCore/Sources/CMUXMobileCore/DiagnosticEventPresentation.swift
  • Packages/Shared/CMUXMobileCore/Sources/CMUXMobileCore/DiagnosticLog.swift
  • Packages/Shared/CMUXMobileCore/Sources/CMUXMobileCore/DiagnosticReport.swift
  • Packages/Shared/CMUXMobileCore/Sources/CMUXMobileCore/InputResponderIdentity.swift
  • Packages/Shared/CMUXMobileCore/Sources/CMUXMobileCore/TransportIncidentPolicy.swift
  • Packages/Shared/CMUXMobileCore/Tests/CMUXMobileCoreTests/DiagnosticEventPresentationTests.swift
  • Packages/Shared/CMUXMobileCore/Tests/CMUXMobileCoreTests/DiagnosticLogTests.swift
  • Packages/Shared/CMUXMobileCore/Tests/CMUXMobileCoreTests/TransportIncidentPolicyTests.swift
  • Packages/Shared/CmuxSentryTelemetry/Sources/CmuxSentryReporting/TransportSentryReporter.swift
  • Packages/Shared/CmuxSentryTelemetry/Tests/CmuxSentryReportingTests/TransportSentryReporterTests.swift
  • Packages/iOS/CmuxMobileShellUI/Sources/CmuxMobileShellUI/MobileIrohSettingsModel.swift
  • Packages/iOS/CmuxMobileShellUI/Tests/CmuxMobileShellUITests/MobileIrohSettingsModelTests.swift
  • Packages/macOS/CmuxSettingsUI/Sources/CmuxSettingsUI/Models/IrohSettingsModel.swift
  • Packages/macOS/CmuxSettingsUI/Tests/CmuxSettingsUITests/IrohSettingsModelTests.swift
  • Sources/TerminalController.swift
  • docs/transport-sentry-diagnostics.md

Comment thread docs/transport-sentry-diagnostics.md Outdated
Comment thread docs/transport-sentry-diagnostics.md Outdated
Comment thread Packages/Shared/CMUXMobileCore/Sources/CMUXMobileCore/DiagnosticReport.swift Outdated
@cursor

cursor Bot commented Aug 4, 2026

Copy link
Copy Markdown

Bugbot is paused — on-demand spend limit reached

Bugbot uses usage-based billing for this team and has hit its on-demand spend limit.

A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue.

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
Packages/Shared/CMUXMobileCore/Tests/CMUXMobileCoreTests/TransportIncidentPolicyTests.swift (1)

32-35: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Pin the locale for English title assertions.

TransportIncidentPolicy() captures Locale.current. These English assertions will fail when the test host uses a non-English locale.

Pass a fixed English locale to each policy used for title assertions. Alternatively, assert locale-independent presentation data.

- var policy = TransportIncidentPolicy()
+ var policy = TransportIncidentPolicy(locale: Locale(identifier: "en"))

Also applies to: 51-56, 153-158, 172-191

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@Packages/Shared/CMUXMobileCore/Tests/CMUXMobileCoreTests/TransportIncidentPolicyTests.swift`
around lines 32 - 35, Update each TransportIncidentPolicy instance used by the
title assertions, including the cases around the referenced assertion ranges, to
receive a fixed English locale instead of implicitly capturing Locale.current.
Keep the existing English title expectations unchanged and apply the same locale
pinning consistently across all affected tests.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@Packages/Shared/CMUXMobileCore/Sources/CMUXMobileCore/DiagnosticIncidentTitleFormatter.swift`:
- Around line 37-73: Update failureCount, secondCount, and occurrenceCountText
to select distinct ICU-style localization keys with .one for value == 1 and
.other for all other values, while preserving each existing fallback phrase. Add
matching .one and .other catalog entries for each key in every supported locale.

In `@Resources/Localizable.xcstrings`:
- Around line 36829-36845: Add localizations for cli.help.irohDiag covering
every supported catalog locale beyond en and ja, using accurate translations of
the existing CLI help text; if a translation is unavailable, add the
locale-specific fallback values required by the catalog rather than leaving
locales missing.

---

Outside diff comments:
In
`@Packages/Shared/CMUXMobileCore/Tests/CMUXMobileCoreTests/TransportIncidentPolicyTests.swift`:
- Around line 32-35: Update each TransportIncidentPolicy instance used by the
title assertions, including the cases around the referenced assertion ranges, to
receive a fixed English locale instead of implicitly capturing Locale.current.
Keep the existing English title expectations unchanged and apply the same locale
pinning consistently across all affected tests.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 92280c61-bc73-4a49-8cb6-4051e69562dc

📥 Commits

Reviewing files that changed from the base of the PR and between 4f51e64 and 326f67c.

📒 Files selected for processing (15)
  • CLI/cmux.swift
  • Packages/Shared/CMUXMobileCore/Package.swift
  • Packages/Shared/CMUXMobileCore/Sources/CMUXMobileCore/DiagnosticEventPresentation.swift
  • Packages/Shared/CMUXMobileCore/Sources/CMUXMobileCore/DiagnosticIncidentTitleFormatter.swift
  • Packages/Shared/CMUXMobileCore/Sources/CMUXMobileCore/DiagnosticLocalization.swift
  • Packages/Shared/CMUXMobileCore/Sources/CMUXMobileCore/DiagnosticReport.swift
  • Packages/Shared/CMUXMobileCore/Sources/CMUXMobileCore/Resources/Localizable.xcstrings
  • Packages/Shared/CMUXMobileCore/Sources/CMUXMobileCore/TransportIncidentPolicy.swift
  • Packages/Shared/CMUXMobileCore/Tests/CMUXMobileCoreTests/DiagnosticEventPresentationTests.swift
  • Packages/Shared/CMUXMobileCore/Tests/CMUXMobileCoreTests/DiagnosticLogTests.swift
  • Packages/Shared/CMUXMobileCore/Tests/CMUXMobileCoreTests/TransportIncidentPolicyTests.swift
  • Packages/iOS/CmuxMobileShellUI/Sources/CmuxMobileShellUI/MobileIrohSettingsModel.swift
  • Packages/macOS/CmuxSettingsUI/Sources/CmuxSettingsUI/Models/IrohSettingsModel.swift
  • Resources/Localizable.xcstrings
  • docs/transport-sentry-diagnostics.md

Comment thread Resources/Localizable.xcstrings

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@Packages/Shared/CMUXMobileCore/Sources/CMUXMobileCore/DiagnosticLocalization.swift`:
- Around line 25-38: The bundle(for:) locale lookup must canonicalize the locale
using BCP 47 and try script/region parent locales before falling back to the
bare language. Update bundle(for:) to use Bundle localization preferences or
explicit ordered fallbacks so locales such as zh-Hant-TW select zh-Hant.lproj
before zh.lproj, while preserving the final .module fallback.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 39e2ffa2-0577-4a8d-a8c6-dd28a56d01df

📥 Commits

Reviewing files that changed from the base of the PR and between 326f67c and eb73ae2.

📒 Files selected for processing (1)
  • Packages/Shared/CMUXMobileCore/Sources/CMUXMobileCore/DiagnosticLocalization.swift

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
Packages/Shared/CMUXMobileCore/Tests/CMUXMobileCoreTests/DiagnosticEventPresentationTests.swift (1)

35-84: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Make English localization explicit in both test suites.

Both suites use the default locale while comparing localized output with English literals. Use one explicit Locale(identifier: "en") for every English presentation and export assertion.

  • Packages/Shared/CMUXMobileCore/Tests/CMUXMobileCoreTests/DiagnosticEventPresentationTests.swift#L35-L84: use an English presentation for title, field, and summary assertions.
  • Packages/Shared/CMUXMobileCore/Tests/CMUXMobileCoreTests/DiagnosticEventPresentationTests.swift#L86-L106: use an English presentation for lifecycle and fallback assertions.
  • Packages/Shared/CMUXMobileCore/Tests/CMUXMobileCoreTests/DiagnosticEventPresentationTests.swift#L108-L168: pass the English presentation to every title description.
  • Packages/Shared/CMUXMobileCore/Tests/CMUXMobileCoreTests/DiagnosticEventPresentationTests.swift#L170-L236: use the English presentation for structured payload descriptions.
  • Packages/Shared/CMUXMobileCore/Tests/CMUXMobileCoreTests/DiagnosticLogTests.swift#L52-L94: pass the English locale to export calls and export-equivalence checks.
  • Packages/Shared/CMUXMobileCore/Tests/CMUXMobileCoreTests/DiagnosticLogTests.swift#L197-L216: pass the English locale to the empty-report export.
  • Packages/Shared/CMUXMobileCore/Tests/CMUXMobileCoreTests/DiagnosticLogTests.swift#L218-L231: pass the English locale to relative-time export assertions.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@Packages/Shared/CMUXMobileCore/Tests/CMUXMobileCoreTests/DiagnosticEventPresentationTests.swift`
around lines 35 - 84, Make English localization explicit across all affected
tests by creating or reusing one Locale(identifier: "en") value. In
Packages/Shared/CMUXMobileCore/Tests/CMUXMobileCoreTests/DiagnosticEventPresentationTests.swift
ranges 35-84, 86-106, 108-168, and 170-236, pass the English presentation to
title, field, summary, lifecycle, fallback, and structured-payload assertions.
In
Packages/Shared/CMUXMobileCore/Tests/CMUXMobileCoreTests/DiagnosticLogTests.swift
ranges 52-94, 197-216, and 218-231, pass the same English locale to export,
equivalence, empty-report, and relative-time assertions.
♻️ Duplicate comments (1)
Packages/Shared/CMUXMobileCore/Sources/CMUXMobileCore/DiagnosticLocalization.swift (1)

38-50: ⚠️ Potential issue | 🟠 Major

Match script and region parent locales before falling back.

languageBundle(for:) checks only the raw locale identifier and the bare language code. For zh-Hant-TW, it skips zh-Hant.lproj. If zh.lproj exists, the code selects the wrong script. Otherwise, bundle(for:) can fall back to .module. Build an ordered BCP 47 parent chain before the bare language. Apply the same lookup to hasCompiledLocalization(for:).

This repeats the unresolved previous review finding.

Verification
#!/bin/bash
set -euo pipefail

root="Packages/Shared/CMUXMobileCore/Sources/CMUXMobileCore/Resources"

echo "Available localization bundles:"
fd -a -t d '\.lproj$' "$root" | sort

echo
echo "Current locale lookup:"
sed -n '38,50p' \
  Packages/Shared/CMUXMobileCore/Sources/CMUXMobileCore/DiagnosticLocalization.swift
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@Packages/Shared/CMUXMobileCore/Sources/CMUXMobileCore/DiagnosticLocalization.swift`
around lines 38 - 50, Update languageBundle(for:) and
hasCompiledLocalization(for:) to use the same ordered BCP 47 parent-locale
chain: try the full locale, then progressively remove region while preserving
script (for example, zh-Hant-TW → zh-Hant → zh), before any bare-language
fallback. Reuse a shared helper if appropriate, and ensure lookup never selects
zh before zh-Hant or falls through to Bundle.module when a more specific parent
bundle exists.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@Packages/Shared/CMUXMobileCore/Sources/CMUXMobileCore/DiagnosticLocalization.swift`:
- Around line 13-20: Move hasCompiledLocalization(for:) out of the production
DiagnosticLocalization implementation and into shared test support used by
DiagnosticLogTests and DiagnosticEventPresentationTests. Update those tests to
call the test-support probe, preserving the existing locale-checking behavior
while removing the test-only API from the production target.

---

Outside diff comments:
In
`@Packages/Shared/CMUXMobileCore/Tests/CMUXMobileCoreTests/DiagnosticEventPresentationTests.swift`:
- Around line 35-84: Make English localization explicit across all affected
tests by creating or reusing one Locale(identifier: "en") value. In
Packages/Shared/CMUXMobileCore/Tests/CMUXMobileCoreTests/DiagnosticEventPresentationTests.swift
ranges 35-84, 86-106, 108-168, and 170-236, pass the English presentation to
title, field, summary, lifecycle, fallback, and structured-payload assertions.
In
Packages/Shared/CMUXMobileCore/Tests/CMUXMobileCoreTests/DiagnosticLogTests.swift
ranges 52-94, 197-216, and 218-231, pass the same English locale to export,
equivalence, empty-report, and relative-time assertions.

---

Duplicate comments:
In
`@Packages/Shared/CMUXMobileCore/Sources/CMUXMobileCore/DiagnosticLocalization.swift`:
- Around line 38-50: Update languageBundle(for:) and
hasCompiledLocalization(for:) to use the same ordered BCP 47 parent-locale
chain: try the full locale, then progressively remove region while preserving
script (for example, zh-Hant-TW → zh-Hant → zh), before any bare-language
fallback. Reuse a shared helper if appropriate, and ensure lookup never selects
zh before zh-Hant or falls through to Bundle.module when a more specific parent
bundle exists.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 0cd2a668-301e-454c-a6f4-d3db105d940a

📥 Commits

Reviewing files that changed from the base of the PR and between eb73ae2 and 448c5d4.

📒 Files selected for processing (3)
  • Packages/Shared/CMUXMobileCore/Sources/CMUXMobileCore/DiagnosticLocalization.swift
  • Packages/Shared/CMUXMobileCore/Tests/CMUXMobileCoreTests/DiagnosticEventPresentationTests.swift
  • Packages/Shared/CMUXMobileCore/Tests/CMUXMobileCoreTests/DiagnosticLogTests.swift

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@Packages/Shared/CMUXMobileCore/Tests/CMUXMobileCoreTests/DiagnosticLogTests.swift`:
- Around line 72-73: Replace the lossy String(decoding:as:) conversions in
DiagnosticLogTests.swift at lines 72-73, 207-209, and 236-239 with failable
strict UTF-8 decoding, and require each decode to succeed before performing the
existing assertions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 8ae7db5c-c0d1-464e-b9c7-f126db1c91c1

📥 Commits

Reviewing files that changed from the base of the PR and between 448c5d4 and 8f8de53.

📒 Files selected for processing (6)
  • Packages/Shared/CMUXMobileCore/Sources/CMUXMobileCore/DiagnosticLocalization.swift
  • Packages/Shared/CMUXMobileCore/Tests/CMUXMobileCoreTests/DiagnosticEventPresentationTests.swift
  • Packages/Shared/CMUXMobileCore/Tests/CMUXMobileCoreTests/DiagnosticLogTests.swift
  • Packages/Shared/CMUXMobileCore/Tests/CMUXMobileCoreTests/LocalizationTestSupport.swift
  • Packages/Shared/CMUXMobileCore/Tests/CMUXMobileCoreTests/TransportIncidentPolicyTests.swift
  • Resources/Localizable.xcstrings

Comment thread Packages/Shared/CMUXMobileCore/Tests/CMUXMobileCoreTests/DiagnosticLogTests.swift Outdated
@azooz2003-bit
azooz2003-bit merged commit 72fce2f into main Aug 4, 2026
8 of 11 checks passed
@azooz2003-bit
azooz2003-bit deleted the feat-readable-iroh-transport-logs branch August 4, 2026 06:38
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