Skip to content

fix: unify diagnostics package export - #1240

Merged
Astro-Han merged 2 commits into
devfrom
codex/i1205-diagnostics-package
Jun 10, 2026
Merged

fix: unify diagnostics package export#1240
Astro-Han merged 2 commits into
devfrom
codex/i1205-diagnostics-package

Conversation

@Astro-Han

@Astro-Han Astro-Han commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Summary

Unifies the user-facing diagnostics path into one support package entry from Help and error reporting, while hiding the old raw session JSON export from the session row menu.

The package now keeps session content, renderer diagnostics, environment context, and both main-process and backend log tails together. If a build has no feedback form URL configured, the same action still prepares the local diagnostics package instead of disappearing.

Why

Issue #1205 asks for one clear support package path without auto-upload, checklist building, or a broad feedback form redesign. The previous UX split troubleshooting across Report a Problem, Export Diagnostics Log, and raw session export, which made it easy to send an incomplete report.

Related Issue

Closes #1205

Human Review Status

Pending

Review Focus

Please check the fallback behavior when PAWWORK_FEEDBACK_FORM_URL is empty, the combined main/backend log tail collection, and the copy that explains what the package may contain before export.

Risk Notes

This touches desktop menu behavior, local diagnostics file generation, and user-facing copy on macOS and Windows. The old standalone diagnostics-log menu item and sidebar raw session JSON entry are no longer user-facing; the IPC helpers remain in place for internal callers and tests.

How To Verify

Desktop focused tests: 95 passed across feedback, problem-report, logging, server, menu, menu-template, and menu-labels tests.
App focused tests: 27 passed across error-report, error-page-source, i18n parity/branding, and session command tests.
Typecheck: bun --cwd packages/app typecheck passed; bun --cwd packages/desktop-electron typecheck passed.
Lint: bun run lint passed.
E2E: bun --cwd packages/app test:e2e:local -- e2e/sidebar/sidebar-session-organization.spec.ts --grep "session row menu does not expose raw export" passed.
Desktop build: bun --cwd packages/desktop-electron build passed.
Desktop smoke: bun --cwd packages/desktop-electron smoke:report returned ready and confirmed the markdown report contains renderer error details, a fenced payload, the main process log tail, and the backend log tail; clipboard summary remained redacted.
Visual check: bun run snap sidebar passed and the generated sidebar grid looked stable with no obvious text overflow or layout breakage.
Fresh-eye review: reviewer found two P2 issues, no-feedback-URL fallback and missing backend log tail; both were fixed and covered by tests/smoke.
Diff hygiene: git diff --check passed.

Screenshots or Recordings

Generated and reviewed docs/design/preview/screenshots/sidebar.png from bun run snap sidebar.

Checklist

How to use this checklist:

  • Tick a box by replacing [ ] with [x]. Do not edit, add, or remove items.
  • The bot-applied label items can only be honestly ticked AFTER the PR is opened and the labeler / priority-triage bots have run — return to the PR description and tick them then.
  • Most items are required. The few that are conditional are explicitly marked (conditional); for those, leave unticked if they truly do not apply and explain why in Risk Notes. All other items must be ticked before requesting human review.
  • Type label — this PR carries exactly one of bug, enhancement, task, documentation. Type labels are author-added; the labeler bot does NOT assign them. Add the label in the GitHub UI, then tick this.
  • Routing labels — this PR carries at least one of app, ui, platform, harness, ci. The labeler bot assigns these on PR open based on changed paths. Confirm the bot's choice (or override if wrong), then tick this.
  • Priority label — this PR carries exactly one of P0, P1, P2, P3. The priority-triage bot suggests one on PR open. Confirm or override, then tick this.
  • Human Review Status above is set to Pending, Approved by @<reviewer>, or Not required: <reason> (default is Pending; "not required" is restricted to bot-authored low-risk PRs).
  • I linked the related issue, or stated in Summary why there is no issue.
  • I described the review focus and any meaningful risks.
  • I replaced the example block in How To Verify with the real verification steps and the key result for each.
  • I did not introduce unrelated refactors, dependencies, generated files, or file changes beyond the stated scope.
  • (conditional) I manually checked visible UI or copy changes when needed, with screenshots or recordings. Leave unticked only if no visible UI or copy changed.
  • (conditional) I considered macOS and Windows impact for platform, packaging, updater, signing, paths, shell, or permissions changes. Leave unticked only if no platform/packaging surface was touched.
  • (conditional) I called out docs, release notes, dependencies, permissions, credentials, deletion behavior, generated content, or local file changes when relevant. Leave unticked only if none of those surfaces was touched.
  • I reviewed the final diff for unrelated changes and suspicious dependency changes.
  • I am targeting dev, and my PR title and commit messages use Conventional Commits in English.

Summary by CodeRabbit

  • New Features

    • Diagnostics packages can now be generated and saved independently without requiring feedback submission.
  • User-Facing Changes

    • Menu option renamed to "Prepare Diagnostics Package..." (formerly "Report a Problem").
    • Session export option removed from sidebar menu.
    • Updated terminology from "problem report" to "diagnostics package" throughout the interface.
  • Tests

    • Added e2e test to verify sidebar menu behavior.

@Astro-Han Astro-Han added enhancement New feature or request P2 Medium priority app Application behavior and product flows ui Design system and user interface platform Electron shell, OS integration, packaging, updater, signing, paths, and permissions labels Jun 10, 2026
@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@Astro-Han, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 41 minutes and 42 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: cf4f5236-8dba-4bdc-aaba-a6e7ce7480f1

📥 Commits

Reviewing files that changed from the base of the PR and between a15c035 and 8ca5add.

📒 Files selected for processing (7)
  • packages/app/e2e/sidebar/sidebar-session-organization.spec.ts
  • packages/app/src/i18n/zh.ts
  • packages/desktop-electron/src/main/feedback.test.ts
  • packages/desktop-electron/src/main/feedback.ts
  • packages/desktop-electron/src/main/index.ts
  • packages/desktop-electron/src/main/server.test.ts
  • packages/desktop-electron/src/main/server.ts
📝 Walkthrough

Walkthrough

This PR consolidates the fragmented diagnostics and feedback export flows into a single unified "prepare diagnostics package" entry point, updated localization copy throughout the app, added backend log path tracking, and rewired menus to always offer the option regardless of feedback URL availability.

Changes

Diagnostics Package Unification

Layer / File(s) Summary
ReportProblemResult contract and status message handling
packages/app/src/desktop-api-contract.ts, packages/app/src/pages/error-report.ts, packages/app/src/pages/error-report.test.ts
New "package-only" variant in the ReportProblemResult union allows the feedback handler to return a result where the summary is copied and the report is saved locally but the external feedback form is not opened. The error-report page updates errorReportStatusMessage to handle and translate the new status.
Localization copy updates for diagnostics package terminology
packages/app/src/i18n/en.ts, packages/app/src/i18n/zh.ts
English and Chinese UI strings are updated across the error-report and session-export flows, replacing "problem report" and "session export" terminology with "diagnostics package," including preparation labels, success/failure messaging, and privacy/confirmation details about package contents.
Session export removal from app UI
packages/app/src/pages/layout/pawwork-session-commands.ts, packages/app/src/pages/layout/pawwork-session-commands.test.ts
exportSessionAvailable is hardcoded to false to hide raw JSON session export from the sidebar. Comments note that raw export is intentionally hidden and troubleshooting is consolidated through the diagnostics package path.
Feedback handler package-only result path
packages/desktop-electron/src/main/feedback.ts, packages/desktop-electron/src/main/feedback.test.ts
Removes the early exit when feedbackUrl is unavailable. The handler now completes the full summary-copy and report-generation flow, and when feedbackUrl is missing, returns "package-only" with the generated report status. Dialog labels updated to reference diagnostics packages.
Combined main and backend log collection
packages/desktop-electron/src/main/logging.ts, packages/desktop-electron/src/main/logging.test.ts
New diagnosticsLogTail() function builds unified diagnostics output combining main-process and backend log tails. Refactored tail() and tailFile() to support reading from specific file paths, enabling reuse for both main and backend logs.
Backend log file path exposure
packages/desktop-electron/src/main/server.ts, packages/desktop-electron/src/main/server.test.ts
Server initialization captures the backend log file path after Log.init, exposes it via backendLogFilePath(), and provides test utilities to override the path.
Main process diagnostics integration
packages/desktop-electron/src/main/index.ts
Wires the new diagnostics logging into the feedback handler: imports diagnosticsLogTail and backendLogFilePath, and configures the handler's logTail callback to return combined diagnostics instead of a single log tail.
Menu system label and template updates
packages/desktop-electron/src/main/menu-labels.ts, packages/desktop-electron/src/main/menu-template.ts, packages/desktop-electron/src/main/menu-labels.test.ts, packages/desktop-electron/src/main/menu-template.test.ts, packages/desktop-electron/src/main/menu.test.ts
Menu labels updated to "Prepare Diagnostics Package..." in both English and Chinese. Help submenus are refactored to unconditionally include reportProblem (removing the feedbackEnabled guard) and remove exportDiagnosticsLog. Menu tests updated to verify the new structure.
Smoke test and E2E test coverage
packages/desktop-electron/scripts/report-problem-smoke.mjs, packages/app/e2e/sidebar/sidebar-session-organization.spec.ts
Smoke test extended to verify both main and backend log tail markers are present in the generated report. New E2E test verifies sidebar session-row menu items are correct.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • Astro-Han/pawwork#179: Both PRs modify the feedback handler to introduce the "package-only" result path when feedback URL is unavailable.
  • Astro-Han/pawwork#392: Both PRs refactor the createFeedbackHandler/runReportProblem feedback-reporting pipeline.
  • Astro-Han/pawwork#234: This PR disables session JSON export while the retrieved PR added the session export feature, creating a gating relationship.

Suggested labels

desktop

🐰 A diagnostics package born from scattered reports, one click now gathers all the clues—logs, sessions, and context bundled together at last, hop-hop-hooray! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: unify diagnostics package export' clearly describes the main change: consolidating multiple diagnostics/export entry points into one unified diagnostics package path.
Description check ✅ Passed The PR description comprehensively covers all required sections: Summary, Why, Related Issue, Human Review Status, Review Focus, Risk Notes, How To Verify, and a complete Checklist with all items properly addressed.
Linked Issues check ✅ Passed All coding objectives from issue #1205 are met: single user-facing export entry [menu-template, feedback], consolidated naming to 'diagnostics package' [i18n, error-report], one-click operation [pawwork-session-commands], and inclusion of session/renderer/logs/environment [logging, server, feedback].
Out of Scope Changes check ✅ Passed All changes remain within scope: they consolidate export entry points, unify naming, hide raw session export from UI, include backend/main logs, and avoid automatic upload, redesigned feedback form, or checklist builders as required by the issue.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/i1205-diagnostics-package

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 and usage tips.

@github-actions github-actions Bot removed the ui Design system and user interface label Jun 10, 2026

@github-actions github-actions 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.

Suggested priority: P2 (includes user-path files (packages/app/src/desktop-api-contract.ts, packages/app/src/i18n/en.ts, packages/app/src/i18n/zh.ts, packages/app/src/pages/error-report.test.ts, packages/app/src/pages/error-report.ts, packages/app/src/pages/layout/pawwork-session-commands.test.ts, packages/app/src/pages/layout/pawwork-session-commands.ts, packages/desktop-electron/src/main/feedback.test.ts, packages/desktop-electron/src/main/feedback.ts, packages/desktop-electron/src/main/index.ts, packages/desktop-electron/src/main/logging.test.ts, packages/desktop-electron/src/main/logging.ts, packages/desktop-electron/src/main/menu-labels.test.ts, packages/desktop-electron/src/main/menu-labels.ts, packages/desktop-electron/src/main/menu-template.test.ts, packages/desktop-electron/src/main/menu-template.ts, packages/desktop-electron/src/main/menu.test.ts, packages/desktop-electron/src/main/server.test.ts, packages/desktop-electron/src/main/server.ts)).

P1/P0 are reserved for maintainer confirmation. Please relabel manually if this is a release blocker, security issue, data-loss risk, or updater/runtime failure.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request replaces the raw session JSON export with a comprehensive "Diagnostics Package" that bundles session content, renderer diagnostics, app logs, local paths, and environment details. It also introduces a "package-only" status for builds without a configured feedback form URL, allowing users to still generate and save local diagnostics packages. The feedback dialog, menu items, and tests have been updated and localized accordingly. Feedback on the changes suggests making the confirmation dialog labels dynamically aware of whether a feedback form is configured to avoid confusing users in the package-only scenario.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread packages/desktop-electron/src/main/feedback.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
packages/desktop-electron/src/main/feedback.test.ts (1)

394-411: 💤 Low value

Test coverage for package-only path looks good.

The test verifies the core package-only behavior: summary copied, markdown saved, folder revealed, but feedback form not opened. The result structure correctly expects status: "package-only" with fullReport.status: "ready".

Minor observation: The edge case where saveReport fails AND feedbackUrl is missing (producing package-only + fullReport.status: "failed") is not explicitly tested, though the ternary logic at lines 271-273 of feedback.ts handles it correctly.

🤖 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/desktop-electron/src/main/feedback.test.ts` around lines 394 - 411,
Add a test covering the edge case where saveReport fails while feedbackUrl is
empty: use the existing setup helper to create subject with feedbackUrl: "" but
stub or mock saveReport to return a failed report (or throw) so
subject.handler() yields status "package-only" and fullReport.status "failed";
assert copied summary, saved markdown, revealed folder, opened is "", and
result.fullReport.fileName/locationHint reflect failure case (use same
expect.stringContaining checks), referencing setup, subject.handler, and
saveReport in feedback.ts to locate where to inject the failing behavior.
🤖 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/app/e2e/sidebar/sidebar-session-organization.spec.ts`:
- Around line 94-98: Add a positive assertion that the session row menu actually
opened before performing the negative checks: after calling
row.locator('[data-action="session-row-menu"]').click(), assert that a known
visible menu item (e.g., page.getByRole("menuitem", { name: /rename/i }) or
another stable menu option) is present using expect(...).toHaveCount(1) or
toBeVisible(), then proceed with the existing negative assertions for
export/diagnostics; update the block around row.locator(...) and the subsequent
page.getByRole("menuitem", { name: /export session/i }) and
page.getByRole("menuitem", { name: /diagnostics package/i }) checks to ensure
the positive check runs first.

In `@packages/app/src/i18n/zh.ts`:
- Around line 491-509: Update the translation for the key
"error.page.report.confirm.privacy" to remove the ambiguous "默认" so it matches
the English phrasing; replace the current value
"诊断包可能包含会话内容、应用日志、本地路径和环境信息。默认不会自动上传你的原始项目文件。" with a definitive privacy
statement (e.g. "诊断包可能包含会话内容、应用日志、本地路径和环境信息。不会自动上传你的原始项目文件。") to ensure
consistency.

In `@packages/desktop-electron/src/main/server.ts`:
- Around line 69-72: Reset backendLogPath to undefined (or an empty value)
before attempting to call Log.file() so stale path isn't retained when Log.file
is absent; specifically, set backendLogPath = undefined right before the block
that reads (Log as typeof Log & { file?: () => string }).file and then only
assign backendLogPath = logFile() if typeof logFile === "function" inside that
block (symbols: backendLogPath, Log.file).

---

Nitpick comments:
In `@packages/desktop-electron/src/main/feedback.test.ts`:
- Around line 394-411: Add a test covering the edge case where saveReport fails
while feedbackUrl is empty: use the existing setup helper to create subject with
feedbackUrl: "" but stub or mock saveReport to return a failed report (or throw)
so subject.handler() yields status "package-only" and fullReport.status
"failed"; assert copied summary, saved markdown, revealed folder, opened is "",
and result.fullReport.fileName/locationHint reflect failure case (use same
expect.stringContaining checks), referencing setup, subject.handler, and
saveReport in feedback.ts to locate where to inject the failing behavior.
🪄 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: CHILL

Plan: Pro Plus

Run ID: 191567ca-62e7-48c6-a917-2d00adad9034

📥 Commits

Reviewing files that changed from the base of the PR and between c925263 and a15c035.

📒 Files selected for processing (21)
  • packages/app/e2e/sidebar/sidebar-session-organization.spec.ts
  • packages/app/src/desktop-api-contract.ts
  • packages/app/src/i18n/en.ts
  • packages/app/src/i18n/zh.ts
  • packages/app/src/pages/error-report.test.ts
  • packages/app/src/pages/error-report.ts
  • packages/app/src/pages/layout/pawwork-session-commands.test.ts
  • packages/app/src/pages/layout/pawwork-session-commands.ts
  • packages/desktop-electron/scripts/report-problem-smoke.mjs
  • packages/desktop-electron/src/main/feedback.test.ts
  • packages/desktop-electron/src/main/feedback.ts
  • packages/desktop-electron/src/main/index.ts
  • packages/desktop-electron/src/main/logging.test.ts
  • packages/desktop-electron/src/main/logging.ts
  • packages/desktop-electron/src/main/menu-labels.test.ts
  • packages/desktop-electron/src/main/menu-labels.ts
  • packages/desktop-electron/src/main/menu-template.test.ts
  • packages/desktop-electron/src/main/menu-template.ts
  • packages/desktop-electron/src/main/menu.test.ts
  • packages/desktop-electron/src/main/server.test.ts
  • packages/desktop-electron/src/main/server.ts

Comment thread packages/app/e2e/sidebar/sidebar-session-organization.spec.ts
Comment thread packages/app/src/i18n/zh.ts
Comment thread packages/desktop-electron/src/main/server.ts
@Astro-Han
Astro-Han merged commit e167c8e into dev Jun 10, 2026
34 checks passed
@Astro-Han
Astro-Han deleted the codex/i1205-diagnostics-package branch June 10, 2026 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app Application behavior and product flows enhancement New feature or request P2 Medium priority platform Electron shell, OS integration, packaging, updater, signing, paths, and permissions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Unify diagnostics and feedback export into one one-click package

1 participant