Skip to content

feat(logExplorer): add configurable flatten depth setting - #2297

Merged
jsers merged 1 commit into
mainfrom
feat/log-flatten-depth-setting
Sep 9, 2026
Merged

feat(logExplorer): add configurable flatten depth setting#2297
jsers merged 1 commit into
mainfrom
feat/log-flatten-depth-setting

Conversation

@jsers

@jsers jsers commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Add a "flatten depth" option to LogsViewer for clickHouse/doris ExplorerNG. flattenDepth=0 skips parsing/flattening (raw strings); N>=1 expands nested JSON up to N levels. Refactor flatten() to take explicit maxDepth with depth threaded via recursion, and merge defaultOptions when reading localstorage so existing users get the new default.

Add a "flatten depth" option to LogsViewer for clickHouse/doris
ExplorerNG. flattenDepth=0 skips parsing/flattening (raw strings);
N>=1 expands nested JSON up to N levels. Refactor flatten() to take
explicit maxDepth with depth threaded via recursion, and merge
defaultOptions when reading localstorage so existing users get the
new default.
@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

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.

@jsers
jsers marked this pull request as ready for review September 9, 2026 03:47
Copilot AI lite review requested due to automatic review settings September 9, 2026 03:47
@jsers
jsers merged commit ab6c917 into main Sep 9, 2026
1 check passed

Copilot AI 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.

🟡 Changes recommended

LocalStorage parsing and flattenDepth handling need defensive validation/clamping to avoid corrupted values producing unexpected options merges or excessively deep recursion.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds a configurable “flatten depth” option for ExplorerNG log viewing so users can control how aggressively nested JSON fields are expanded (including an option to skip parsing/flattening entirely), while keeping existing localStorage-stored options compatible via default-merging.

Changes:

  • Introduces flattenDepth (default 1) and a new settings modal entry in LogsViewer (“Flatten depth”) with i18n strings.
  • Refactors flatten() to accept an explicit maxDepth threaded through recursion, and adds unit tests for depth behavior.
  • Threads flattenDepth through clickHouse/doris ExplorerNG Query flows (including view restore via hidden form field) and merges new defaults when reading localStorage.
File summaries
File Description
src/plugins/doris/ExplorerNG/utils/optionsLocalstorage.ts Merge stored options with defaults to backfill newly added fields like flattenDepth.
src/plugins/doris/ExplorerNG/Main/SQL/Table.tsx Stops applying flatten() to SQL table rows (passes raw item fields through).
src/plugins/doris/ExplorerNG/Main/Query/index.tsx Applies flattenDepth in doris query results, supports flattenDepth=0 raw mode, and exposes settings toggle.
src/plugins/doris/ExplorerNG/index.tsx Registers hidden query.flattenDepth field so view restore persists it.
src/plugins/clickHouse/ExplorerNG/utils/optionsLocalstorage.ts Same default-merging behavior for clickHouse ExplorerNG options.
src/plugins/clickHouse/ExplorerNG/Main/SQL/Table.tsx Stops applying flatten() to SQL table rows (passes raw item fields through).
src/plugins/clickHouse/ExplorerNG/Main/Query/index.tsx Applies flattenDepth in clickHouse query results, supports flattenDepth=0 raw mode, and exposes settings toggle.
src/plugins/clickHouse/ExplorerNG/index.tsx Registers hidden query.flattenDepth field so view restore persists it.
src/pages/logExplorer/locale/zh_CN.ts Adds zh-CN strings for flatten depth settings UI.
src/pages/logExplorer/locale/en_US.ts Adds en-US strings for flatten depth settings UI.
src/pages/logExplorer/constants.ts Adds DEFAULT_FLATTEN_DEPTH and includes flattenDepth in DEFAULT_OPTIONS.
src/pages/logExplorer/components/LogsViewer/utils/flatten.ts Refactors flatten recursion to honor explicit maxDepth via a threaded depth param.
src/pages/logExplorer/components/LogsViewer/utils/flatten.test.ts Adds test coverage validating maxDepth semantics and sibling expansion.
src/pages/logExplorer/components/LogsViewer/types.ts Extends OptionsType with flattenDepth.
src/pages/logExplorer/components/LogsViewer/index.tsx Adds showFlattenSettings prop plumbing into settings.
src/pages/logExplorer/components/LogsViewer/components/OriginSettings.tsx Adds a modal UI to configure flattenDepth (0–10) and persists via updateOptions.
Review details
  • Files reviewed: 16/16 changed files
  • Comments generated: 4
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +141 to +142
// 优先 form(视图恢复时 form 即时最新),其次 options,最后默认值
const flattenDepth = typeof queryValues?.flattenDepth === 'number' ? queryValues.flattenDepth : options.flattenDepth ?? DEFAULT_FLATTEN_DEPTH;
if (optionsLocalStorage) {
try {
return JSON.parse(optionsLocalStorage);
return { ...defaultOptions, ...JSON.parse(optionsLocalStorage) };
Comment on lines +138 to +139
// 优先 form(视图恢复时 form 即时最新),其次 options,最后默认值
const flattenDepth = typeof queryValues?.flattenDepth === 'number' ? queryValues.flattenDepth : options.flattenDepth ?? DEFAULT_FLATTEN_DEPTH;
if (optionsLocalStorage) {
try {
return JSON.parse(optionsLocalStorage);
return { ...defaultOptions, ...JSON.parse(optionsLocalStorage) };
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.

2 participants