Skip to content

Make console exports readable with Markdown#407

Open
zzanzifeng wants to merge 1 commit into
HuolalaTech:mainfrom
zzanzifeng:feat/console-markdown-export
Open

Make console exports readable with Markdown#407
zzanzifeng wants to merge 1 commit into
HuolalaTech:mainfrom
zzanzifeng:feat/console-markdown-export

Conversation

@zzanzifeng

@zzanzifeng zzanzifeng commented Jun 3, 2026

Copy link
Copy Markdown

Summary

  • add a snapshot-only console export menu with JSON and Markdown options
  • format Markdown exports as readable message/argument sections with fenced code blocks
  • preserve JSON export for machine-readable output and warn when logs are preview-only atom values
  • add i18n labels for the new export actions

Validation

  • ./node_modules/.bin/eslint --ext .js,.jsx,.ts,.tsx src/pages/Devtools/ConsolePanel/components/HeaderActions/index.tsx src/pages/Devtools/ConsolePanel/utils/export.ts --quiet
  • node scripts/check-i18n.mjs
  • yarn build:client
  • git diff --check
  • headless Chrome + Vite module test against src/pages/Devtools/ConsolePanel/utils/export.ts verified Markdown structure, pretty JSON blocks, stack text blocks, .md download extension, Markdown MIME, preview warning, and unchanged JSON export
  • local Docker rebuild + Chrome CDP smoke test verified the served SDK bundle accepts consoleExportMode: 'complete', caches complete object/array snapshots, and falls back DOM values to HTMLBodyElement atom previews

Notes

This PR only exports the data already present in the Console panel store at click time. Complete snapshots for common serializable/reference console values require the companion SDK PR to enable consoleExportMode: 'complete' on the debugged app.

The export still cannot reconstruct values that the SDK sent as lazy atom previews or values whose runtime internals are not serializable/enumerable.

Add a snapshot-only Markdown export path so long console objects can be reviewed outside the virtualized console without fetching atom details during export.

Constraint: console atom details are lazy and virtualized in the UI, so export must use the click-time store snapshot only.

Rejected: hydrating atom details during export | it can hang or chase logs while the target keeps printing.

Confidence: high

Scope-risk: narrow

Directive: keep JSON export as the machine-readable format and keep Markdown export snapshot-only.

Tested: targeted eslint; node scripts/check-i18n.mjs; yarn build:client; git diff --check; headless Chrome Vite module test for Markdown format and download metadata

Not-tested: full repo lint, which has pre-existing unrelated lint failures
zzanzifeng added a commit to zzanzifeng/page-spy that referenced this pull request Jun 3, 2026
Add an original-by-default consoleExportMode option so apps can export full console objects as log-time JSON snapshots without changing existing lazy atom behavior.

Constraint: object expansion is lazy across PageSpy platforms, and complete export must not invoke getters or require debugger-side hydration.

Rejected: making complete snapshots the default | it changes payload size and legacy console behavior for existing users.

Confidence: high

Scope-risk: moderate

Directive: keep original mode as the default and preserve getter-safe serialization semantics across browser, MP, React Native, and Harmony paths.

Related: HuolalaTech/page-spy-web#407

Tested: yarn workspace @huolala-tech/page-spy-base build; yarn workspace @huolala-tech/page-spy-browser build; yarn jest packages/page-spy-base/tests/atom.test.ts packages/page-spy-browser/tests/plugins/console.test.ts --runInBand; targeted eslint for modified SDK files; git diff --check

Not-tested: full SDK lint/typecheck because existing unrelated Harmony/path issues are outside this change
zzanzifeng added a commit to zzanzifeng/page-spy that referenced this pull request Jun 3, 2026
Add an original-by-default consoleExportMode option so apps can export common console values as getter-safe log-time snapshots without changing existing lazy atom behavior. Complete mode now falls back to original atom previews when a console argument contains values that cannot be fully snapshotted, such as DOM nodes or opaque host objects.

Constraint: object expansion is lazy across PageSpy platforms, and complete export must not invoke getters or require debugger-side hydration.
Rejected: making complete snapshots the default | it changes payload size and legacy console behavior for existing users.
Rejected: representing unsupported host objects as `{ "__type": "..." }` JSON | it hides the useful original atom preview for DOM and other opaque runtime values.
Confidence: high
Scope-risk: moderate
Directive: keep original mode as the default, use ConsoleExportMode instead of repeated string literals, and preserve getter-safe serialization semantics across browser, MP, React Native, and Harmony paths.
Related: HuolalaTech/page-spy-web#407
Tested: yarn workspace @huolala-tech/page-spy-base build; yarn workspace @huolala-tech/page-spy-browser build; yarn workspace @huolala-tech/page-spy-mp-base build; yarn workspace @huolala-tech/page-spy-react-native build; yarn jest packages/page-spy-base/tests/atom.test.ts packages/page-spy-browser/tests/plugins/console.test.ts --runInBand; targeted eslint for modified SDK files; git diff --check; real headless Chrome check for DOM fallback and array object JSON snapshot
Not-tested: full SDK lint/typecheck because existing unrelated Harmony/path issues are outside this change
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