Skip to content

Conversation

@PENEKhun
Copy link
Member

@PENEKhun PENEKhun commented Oct 9, 2025

TO-BE video

qwer.mov

changes

•	Refactor: separate components in the playground section
•	Redesign: update the UI to resemble VS Code style

How to test for reviewer

  • run following commands
git clone... # pull this branches
cd itdoc-doc
pnpm run build && pnpm run serve
  • go localhost:3000 with browser

Summary by CodeRabbit

  • New Features

    • Redesigned Playground: file explorer, tabbed Monaco editor, multi-file editing (app, tests, package), Run modal with terminal and JSON output, fullscreen OpenAPI/Swagger preview, install progress overlay with milestones and tips, TopBar controls, and workspace placeholder.
  • Refactor

    • Playground split into modular components with shared constants/types; project setup now supports editable package configuration and per-file editing flow.
  • Style

    • Dark theme, refreshed typography, updated responsive layout and explorer/editor styles.
  • Chores

    • Switched editor integration to Monaco.

@PENEKhun PENEKhun self-assigned this Oct 9, 2025
@coderabbitai
Copy link

coderabbitai bot commented Oct 9, 2025

Walkthrough

Replaces CodeMirror with Monaco in package.json and integrates @monaco-editor/react across the playground. Adds modular playground components: EditorTabs, FileExplorer, InstallOverlay, RunModal, SwaggerPreview, TopBar, WorkspacePlaceholder. Introduces typed playground APIs (types.ts) and canned files/constants (constants.ts). Refactors playground/index.tsx to a multi-file tabbed editor flow, updates createProjectFiles to accept packageJson, and wires new components for run/preview/install flows. Stylesheet reworked to a darker theme with new explorer/tab/modal rules. pages/playground extracts PlaygroundHelpModal.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

Suggested reviewers

  • json-choi
  • wnghdcjfe

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The PR title "docs: apply vs-code-style design to playground docs" is directly aligned with the primary changes in the changeset. The most extensive modifications involve a comprehensive styling overhaul in styles.module.css that introduces dark themes, tree-based explorer UI, Monaco Editor integration (replacing CodeMirror), and a modern component architecture—all characteristic of VS Code's visual design. While the PR also includes new React components and refactoring, these changes are fundamentally in service of implementing the stated VS Code-style design objective. The title is concise, specific, and clearly communicates the main purpose to someone reviewing the pull request history.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch docs/playground-re-design

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.

@coderabbitai coderabbitai bot requested review from json-choi and wnghdcjfe October 9, 2025 05:07
@coderabbitai coderabbitai bot added the Documentation Something isn't working label Oct 9, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

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)
itdoc-doc/src/components/Playground/index.tsx (1)

203-214: Keep the package.json tab aligned with fallback updates

switchItDocDependencyToRegistry rewrites package.json inside the WebContainer, but the React state driving the editor still comes from the initial packageJsonRef. After the fallback runs, the package.json tab keeps showing the stale tarball dependency (and will overwrite the container change as soon as the user edits or re-runs). Please store the package.json contents in component state (e.g., useState + ref for initial mount), update that state when the fallback succeeds, and include it in activeFileValue/handleEditorChange so the editor always mirrors the real file. Returning the updated JSON string from this helper and setPackageJson(...) in the caller is one straightforward way to fix this.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a5f197b and e458b1c.

⛔ Files ignored due to path filters (2)
  • itdoc-doc/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (13)
  • itdoc-doc/package.json (1 hunks)
  • itdoc-doc/src/components/Playground/EditorTabs.tsx (1 hunks)
  • itdoc-doc/src/components/Playground/FileExplorer.tsx (1 hunks)
  • itdoc-doc/src/components/Playground/InstallOverlay.tsx (1 hunks)
  • itdoc-doc/src/components/Playground/RunModal.tsx (1 hunks)
  • itdoc-doc/src/components/Playground/SwaggerPreview.tsx (1 hunks)
  • itdoc-doc/src/components/Playground/TopBar.tsx (1 hunks)
  • itdoc-doc/src/components/Playground/WorkspacePlaceholder.tsx (1 hunks)
  • itdoc-doc/src/components/Playground/constants.ts (1 hunks)
  • itdoc-doc/src/components/Playground/index.tsx (8 hunks)
  • itdoc-doc/src/components/Playground/styles.module.css (11 hunks)
  • itdoc-doc/src/components/Playground/types.ts (1 hunks)
  • itdoc-doc/src/pages/playground.tsx (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (6)
itdoc-doc/src/components/Playground/EditorTabs.tsx (1)
itdoc-doc/src/components/Playground/types.ts (2)
  • PlaygroundFileMap (45-45)
  • PlaygroundFileId (19-19)
itdoc-doc/src/components/Playground/constants.ts (1)
itdoc-doc/src/components/Playground/types.ts (4)
  • PlaygroundFileMap (45-45)
  • ExplorerNode (43-43)
  • PlaygroundFileId (19-19)
  • PlaygroundFileDefinition (21-29)
itdoc-doc/src/components/Playground/TopBar.tsx (1)
itdoc-doc/src/components/Playground/types.ts (2)
  • InstallStatus (17-17)
  • PlaygroundFileDefinition (21-29)
itdoc-doc/src/components/Playground/FileExplorer.tsx (1)
itdoc-doc/src/components/Playground/types.ts (3)
  • ExplorerNode (43-43)
  • PlaygroundFileMap (45-45)
  • PlaygroundFileId (19-19)
itdoc-doc/src/components/Playground/InstallOverlay.tsx (1)
itdoc-doc/src/components/Playground/types.ts (1)
  • InstallStatus (17-17)
itdoc-doc/src/components/Playground/index.tsx (2)
itdoc-doc/src/components/Playground/types.ts (1)
  • PlaygroundFileId (19-19)
itdoc-doc/src/components/Playground/constants.ts (6)
  • initialExpressCode (27-58)
  • initialTestCode (60-115)
  • PLAYGROUND_FILES (184-184)
  • ITDOC_TARBALL_ASSET (24-24)
  • EXPLORER_NODES (186-194)
  • installMilestones (117-137)
🔇 Additional comments (5)
itdoc-doc/package.json (1)

27-34: Monaco dependency alignment confirmed.

Bringing in @monaco-editor/react alongside the matching monaco-editor version keeps the new Playground stack consistent with the Monaco-based components you introduced. Nicely scoped update.

itdoc-doc/src/components/Playground/WorkspacePlaceholder.tsx (1)

17-58: Graceful placeholder UX.

The conditional tip card plus optional “Show another idea” hook gives a polished loading state without overcomplicating the component. Nicely composed.

itdoc-doc/src/components/Playground/SwaggerPreview.tsx (1)

17-65: Accessible modal wiring looks solid.

Good call stopping backdrop propagation and wiring aria-labelledby/aria-modal; the empty-state path also reads cleanly.

itdoc-doc/src/components/Playground/FileExplorer.tsx (1)

30-104: Explorer state handling reads well.

The split between folder and file nodes, plus the aria-current hints, makes the tree both legible and keyboard-friendly. Nicely structured.

itdoc-doc/src/pages/playground.tsx (1)

25-124: Modal overflow cleanup handled.

Capturing the original body overflow before hiding scroll and restoring it on teardown keeps the page state tidy while the help dialog is open. Clean refactor.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
itdoc-doc/src/components/Playground/constants.ts (1)

148-178: Consider adding JSDoc comments for public exports.

The file definitions are correctly structured with appropriate metadata. However, adding JSDoc comments to PLAYGROUND_FILES (and other exported constants) would improve developer experience by providing inline documentation.

Example:

+/**
+ * Map of playground file definitions including metadata for Monaco Editor.
+ * @type {PlaygroundFileMap}
+ */
 export const PLAYGROUND_FILES: PlaygroundFileMap = fileDefinitions
itdoc-doc/src/components/Playground/index.tsx (1)

256-266: Simplify the switch statement structure.

The "package" case falls through to the default case. For clarity, either remove the empty "package" case or add a comment explaining the fall-through intent.

Apply this diff to remove the redundant case:

 const activeFileValue = useMemo(() => {
     switch (activeFileId) {
         case "app":
             return expressCode
         case "test":
             return testCode
-        case "package":
         default:
             return packageJsonRef.current
     }
 }, [activeFileId, expressCode, testCode])
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e458b1c and 7d517f1.

📒 Files selected for processing (2)
  • itdoc-doc/src/components/Playground/constants.ts (1 hunks)
  • itdoc-doc/src/components/Playground/index.tsx (8 hunks)
🔇 Additional comments (16)
itdoc-doc/src/components/Playground/constants.ts (6)

1-16: LGTM!

Standard Apache 2.0 license header is properly formatted.


17-19: LGTM!

Type imports and tarball asset path are correctly defined.


21-52: LGTM!

The Express boilerplate is well-structured with appropriate routes and validation. The hardcoded user ID "user_123" (line 43) is acceptable for example/boilerplate code.


54-109: LGTM!

The itdoc test code correctly tests both Express routes with appropriate request/response validation. The test structure aligns well with the initialExpressCode.


180-188: LGTM!

The explorer structure correctly references the file definitions and maintains a logical hierarchy. The fileId values properly match the keys in PLAYGROUND_FILES.


133-146: Verify emoji shortcode rendering.

Line 140 uses the emoji shortcode :grin: which may not render correctly depending on the UI framework being used. Ensure that the consuming component properly converts emoji shortcodes to actual emoji characters or Unicode.

itdoc-doc/src/components/Playground/index.tsx (10)

25-42: LGTM! Clean modularization.

The refactor extracts components and constants into separate modules, improving maintainability and separation of concerns. The import structure is well-organized.


216-221: LGTM! Proper state structure for multi-file editing.

The new state variables and refs correctly support the multi-file editing feature with appropriate TypeScript types.


230-230: LGTM! More descriptive ref name.

Renaming to didAutofocusEditorRef better conveys that this tracks whether autofocus has occurred.


273-295: LGTM! Robust tab closing logic.

The handleCloseTab implementation correctly handles edge cases:

  • Prevents closing the last remaining tab
  • Manages active file fallback when closing the current tab
  • Safe guards against closing files not in the open list

314-319: LGTM! Proper focus management.

Using a ref to track whether the editor has been focused prevents unwanted refocusing on component remounts.


365-365: LGTM! Centralized constant.

Moving the tarball URL to an imported constant improves maintainability and reduces duplication.


466-470: LGTM! Correct signature update.

The createProjectFiles call correctly passes the new packageJson parameter.


786-864: LGTM! Clean modular component composition.

The refactor successfully decomposes the monolithic UI into focused, reusable components. The prop passing appears comprehensive, with proper state, handlers, and refs wired through.

Since the component definitions aren't provided in this review, ensure that all props match the expected interfaces of the new components (TopBar, FileExplorer, EditorTabs, RunModal, SwaggerPreview, InstallOverlay, WorkspacePlaceholder).


104-109: Verify that all callers have been updated.

The function signature now requires a packageJson parameter. Ensure that all invocations of createProjectFiles throughout the codebase have been updated to match this new signature.


297-312: Verify package.json editability intent.

The handleEditorChange function only updates state for "app" and "test" files, even though it checks if the file is editable. If package.json is intended to be editable in the future, this handler would need to be extended to persist those changes to packageJsonRef.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
itdoc-doc/src/components/Playground/styles.module.css (1)

534-534: Consider reducing z-index values to a reasonable range.

The z-index values are excessively high (9999999999 and 999999999999), which suggests poor z-index management. Standard practice is to define a z-index scale (e.g., 1-100 or 1-1000) to maintain predictable stacking contexts.

Consider defining CSS custom properties for z-index layers:

:root {
  --z-modal: 1000;
  --z-modal-overlay: 1010;
  --z-preview: 1020;
}

.runModalBackdrop {
    z-index: var(--z-modal);
}

.previewModalBackdrop {
    z-index: var(--z-preview);
}

Also applies to: 1134-1134

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7d517f1 and 09ee785.

📒 Files selected for processing (3)
  • itdoc-doc/src/components/Playground/SwaggerPreview.tsx (1 hunks)
  • itdoc-doc/src/components/Playground/index.tsx (9 hunks)
  • itdoc-doc/src/components/Playground/styles.module.css (10 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
itdoc-doc/src/components/Playground/index.tsx (2)
itdoc-doc/src/components/Playground/types.ts (1)
  • PlaygroundFileId (19-19)
itdoc-doc/src/components/Playground/constants.ts (6)
  • initialExpressCode (21-52)
  • initialTestCode (54-109)
  • PLAYGROUND_FILES (178-178)
  • ITDOC_TARBALL_ASSET (19-19)
  • EXPLORER_NODES (180-188)
  • installMilestones (111-131)
🔇 Additional comments (7)
itdoc-doc/src/components/Playground/SwaggerPreview.tsx (1)

62-62: Verify necessity of permissive iframe sandbox attributes.

The sandbox allows both allow-scripts and allow-same-origin, which significantly reduces isolation. While this may be required for Redoc to function, it exposes the iframe to XSS risks if the content is not fully trusted.

Verify whether Redoc requires both attributes or if you can remove allow-same-origin for better security isolation. Check the Redoc documentation for minimum sandbox requirements.

itdoc-doc/src/components/Playground/index.tsx (6)

253-253: Consider future updates to packageJsonRef if package.json becomes editable.

The packageJsonRef is initialized but never updated. If the package.json file becomes editable in future iterations, this could lead to stale data being used during project file creation.

Since the package file is currently not marked as editable in PLAYGROUND_FILES, this is acceptable for now. However, if you plan to allow editing package.json, ensure packageJsonRef.current is updated when changes are made.


344-349: Autofocus flag never resets, preventing refocus on remount.

The didAutofocusEditorRef flag is set to true on first mount but never resets, which means the editor won't autofocus if the component remounts (e.g., after navigation).

If this behavior is intentional to prevent unexpected focus changes, that's fine. Otherwise, consider resetting the flag in a cleanup function or when installStatus changes to "ready" to ensure the editor gains focus when the workspace becomes available.


138-175: Verify that the generated OpenAPI spec is trusted data.

The createRedocPreviewHtml function injects the OpenAPI spec directly into a script tag. While basic escaping is applied (lines 139-141), this could pose an XSS risk if the spec contains malicious content.

Confirm that the OpenAPI spec is always generated by itdoc from trusted sources and cannot be tampered with. If there's any possibility of untrusted data entering the spec, additional sanitization may be required.

Based on learnings, the spec is generated from the itdoc library output, so it should be safe. However, verifying this assumption is recommended for defense-in-depth.


96-127: LGTM! Function signature correctly updated.

The createProjectFiles function now properly accepts the packageJson parameter and uses it when creating the file system tree. This aligns with the modular refactor and the initialization flow.


303-325: LGTM! Tab closing logic handles edge cases well.

The handleCloseTab function correctly prevents closing the last tab and properly updates the active file when closing the currently active tab. The fallback logic ensures a valid tab remains active.


750-827: LGTM! Component composition is well-structured.

The modular component composition with TopBar, FileExplorer, EditorTabs, RunModal, SwaggerPreview, and InstallOverlay is clean and follows React best practices. Props are properly wired to state and handlers.

@PENEKhun PENEKhun marked this pull request as ready for review October 19, 2025 12:32
@PENEKhun PENEKhun changed the title Docs/playground re design docs: apply VS Code-style design to playground docs Oct 19, 2025
@PENEKhun PENEKhun changed the title docs: apply VS Code-style design to playground docs docs: apply vs-code-style design to playground docs Oct 19, 2025
@PENEKhun PENEKhun merged commit 366cdb0 into develop Oct 23, 2025
2 checks passed
@PENEKhun PENEKhun deleted the docs/playground-re-design branch October 23, 2025 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants