Skip to content

Conversation

@k0d13
Copy link
Owner

@k0d13 k0d13 commented Jul 18, 2025

Summary by CodeRabbit

  • New Features

    • Added utility functions for generating URLs to share or edit code in the playground from the Discord bot.
    • Discord bot now dynamically uses the default filename for each runtime when executing code.
  • Improvements

    • Execution result handling across the Discord bot, browser extension, and website was streamlined for clearer output and timeout messaging.
    • The website terminal interface was redesigned for a simpler, more consistent tab experience.
    • Discord bot input fields now allow empty submissions and use single-line input styles.
    • Browser extension UI now conditionally renders execution result tabs only when results are present.
    • Execution dialogs and output displays were refined for improved clarity and user feedback.
  • Bug Fixes

    • Browser extension and Discord bot now consistently determine and use the correct default filename for code execution.
  • Chores

    • Updated several package dependencies to newer versions across multiple apps and packages.
    • Refactored execution result data structures for more accurate success and expiry status handling.

@vercel
Copy link

vercel bot commented Jul 18, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
evaluate ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 18, 2025 0:38am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 18, 2025

Walkthrough

This update refactors execution result handling across the browser extension, Discord bot, and shared shapes package, introducing a new phase-based execution result schema. It also updates dependency versions in several package files, simplifies output and tab rendering logic in UI components, and adds new utility functions for generating code sharing URLs.

Changes

File(s) Change Summary
apps/browser-extension/package.json
apps/discord-bot/package.json
apps/website/package.json
packages/components/package.json
packages/scripts/package.json
package.json
Updated dependency versions for various packages (e.g., @babel/traverse, tsup, next, @next/bundle-analyzer, tailwindcss, @next/env, turbo) with some moving to exact versions. No other config or script changes.
apps/browser-extension/src/background/index.ts Now uses dynamic runtime default filenames for code execution and simplifies PostHog metrics logic, leveraging new getRuntimeDefaultFileName and updated execution result structure.
apps/browser-extension/src/content-script/execution/dialog.tsx Tabs and related UI are now rendered only if there are results, preventing empty tab displays.
apps/browser-extension/src/content-script/execution/result.tsx Refactored output display logic: removes useMemo, simplifies timeout and output handling, updates placeholder text, and adjusts textarea styling based on result success.
apps/discord-bot/src/components/evaluate-modal.ts Changes input fields from multiline to single-line and allows empty submissions by setting minLength to 0.
apps/discord-bot/src/handlers/evaluate.ts Removes compressed URL generation, introduces new code URL utility, simplifies output and embed logic, uses dynamic runtime filenames, and updates imports. Adds a workaround for Discord interaction edits.
apps/discord-bot/src/utilities/make-url.ts New module for generating code playground URLs with compressed state, supporting both runtime-specific and runtime-picking flows.
apps/website/src/components/terminal/index.tsx Completely rewrites the terminal tab UI: now statically defines "Run", "Compile", and "Preview" tabs, simplifies output display, and removes detailed conditional overlays. Old implementation is commented out.
packages/shapes/src/execute.ts Introduces ExecutionPhaseResult type for phase-based execution results, adds derived fields (success, expired, output) to ExecuteResult, and updates schema transformations accordingly.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI_Component
    participant ExecutionEngine
    participant Utility
    participant Playground

    User->>UI_Component: Submit code (with args/input)
    UI_Component->>ExecutionEngine: Execute code (with dynamic filename)
    ExecutionEngine-->>UI_Component: Return ExecuteResult (phase-based)
    UI_Component->>Utility: Generate code share/edit URL
    Utility->>Playground: Construct URL with compressed state
    UI_Component-->>User: Display results (tabs, output, links)
Loading

Possibly related PRs

  • Bump dependencies #88: Updates the version of @babel/traverse in the browser extension package, similar to the version update in this PR.

Poem

A bunny hopped through fields of code,
Tidy tabs and outputs showed,
With URLs now compressed and neat,
Execution flows are quite a treat!
From Discord chats to browser screens,
A phase-based world behind the scenes.
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b0f434d and a1184c1.

📒 Files selected for processing (1)
  • apps/website/src/components/terminal/index.tsx (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/website/src/components/terminal/index.tsx
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@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: 4

🔭 Outside diff range comments (1)
apps/website/src/components/terminal/index.tsx (1)

150-291: Remove commented-out code.

Large blocks of commented code should be removed as version control preserves the history. This improves file readability and maintenance.

🧹 Nitpick comments (3)
packages/scripts/package.json (1)

12-12: Version pinning removes caret – doc comment recommended

Hard-pinning @next/env to 15.3.5 stops silent minor upgrades, which is sensible after the breakage in 15.3.6. Consider leaving a one-liner comment in the README or commit message so the next upgrader knows the rationale.

apps/discord-bot/src/utilities/make-url.ts (1)

1-2: Track the code consolidation task.

The TODO indicates code duplication between browser extension and Discord bot that should be consolidated.

Would you like me to create an issue to track moving these URL utilities to a shared package?

apps/discord-bot/src/handlers/evaluate.ts (1)

48-54: Consider a cleaner approach for handling cross-user edits.

Using Reflect.set to mutate interaction data is a hack that could lead to maintenance issues. Consider handling this logic more explicitly in the control flow.

-  // HACK: If trying to edit an existing evaluation owned by another user, create new instead
-  if (
-    interaction.rawData.message &&
-    interaction.rawData.message.interaction_metadata?.user.id !==
-      interaction.user?.id
-  )
-    Reflect.set(interaction.rawData.data, 'custom_id', 'evaluate,new');
+  const isOtherUserEdit = 
+    interaction.rawData.message &&
+    interaction.rawData.message.interaction_metadata?.user.id !== interaction.user?.id;
+  
+  const treatAsNew = isNew(interaction) || (isEdit(interaction) && isOtherUserEdit);
+  const treatAsEdit = isEdit(interaction) && !isOtherUserEdit;

-  if (isNew(interaction)) await interaction.defer();
-  if (isEdit(interaction)) await interaction.acknowledge();
+  if (treatAsNew) await interaction.defer();
+  if (treatAsEdit) await interaction.acknowledge();
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7ba3932 and b0f434d.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (14)
  • apps/browser-extension/package.json (1 hunks)
  • apps/browser-extension/src/background/index.ts (2 hunks)
  • apps/browser-extension/src/content-script/execution/dialog.tsx (1 hunks)
  • apps/browser-extension/src/content-script/execution/result.tsx (2 hunks)
  • apps/discord-bot/package.json (1 hunks)
  • apps/discord-bot/src/components/evaluate-modal.ts (2 hunks)
  • apps/discord-bot/src/handlers/evaluate.ts (6 hunks)
  • apps/discord-bot/src/utilities/make-url.ts (1 hunks)
  • apps/website/package.json (2 hunks)
  • apps/website/src/components/terminal/index.tsx (2 hunks)
  • package.json (1 hunks)
  • packages/components/package.json (1 hunks)
  • packages/scripts/package.json (1 hunks)
  • packages/shapes/src/execute.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: apteryxxyz
PR: apteryxxyz/Evaluate#95
File: apps/browser-extension/vite-plugins.ts:50-86
Timestamp: 2025-07-16T23:10:36.498Z
Learning: User apteryxxyz prefers if statements without braces when there's a single statement, formatting them as:
if (condition)
  statement;
instead of using curly braces around the statement.
apps/browser-extension/package.json (1)
Learnt from: apteryxxyz
PR: apteryxxyz/Evaluate#95
File: apps/browser-extension/vite-plugins.ts:69-69
Timestamp: 2025-07-16T23:10:33.941Z
Learning: In the Evaluate codebase, apteryxxyz prefers to let errors throw naturally in internal Vite plugins rather than adding explicit error handling, as it's acceptable for development tooling to fail fast and surface errors clearly.
🧬 Code Graph Analysis (4)
apps/website/src/components/terminal/index.tsx (3)
packages/components/src/button.tsx (1)
  • Button (56-56)
apps/website/src/components/editor/readonly.tsx (1)
  • ReadonlyEditor (8-23)
apps/website/src/components/terminal/html-preview.tsx (1)
  • HtmlPreview (6-45)
apps/browser-extension/src/background/index.ts (2)
packages/engine/src/runtimes/getters.ts (1)
  • getRuntimeDefaultFileName (42-45)
packages/engine/src/execute/fetch.ts (1)
  • executeCode (17-60)
apps/discord-bot/src/handlers/evaluate.ts (3)
packages/engine/src/runtimes/getters.ts (1)
  • getRuntimeDefaultFileName (42-45)
apps/discord-bot/src/utilities/make-url.ts (1)
  • makeEditCodeUrl (7-24)
apps/discord-bot/src/utilities/discord-formatting.ts (1)
  • codeBlock (71-89)
apps/discord-bot/src/utilities/make-url.ts (2)
packages/engine/src/runtimes/getters.ts (1)
  • getRuntimeDefaultFileName (42-45)
packages/engine/src/compress/index.ts (1)
  • compress (11-15)
🔇 Additional comments (16)
packages/components/package.json (1)

40-40: Tailwind versions consistent – manual config build check needed

All package.json files specify Tailwind CSS 4.1.x (no mismatched versions found):

  • packages/components/package.json → ^4.1.11
  • No other package.json files reference a different Tailwind CSS version

Please run your local Tailwind build (for example npx tailwindcss -c tailwind.config.js build) to confirm the config compiles cleanly without warnings.

package.json (1)

23-23: Turbo bump LGTM – remember to regenerate the lock-file

2.5.5 only contains bug-fixes, so no red flags. Just ensure pnpm-lock.yaml has been refreshed so CI picks up the new version.

apps/browser-extension/package.json (1)

35-35: @babel/traverse patch bump is safe

The 7.28 line only adds TS 5.4 nodes; nothing in the extension relies on internal Babel symbols, so runtime risk is minimal. ✔️

apps/website/package.json (1)

40-40: LGTM: Dependency version pinning for consistency

Pinning Next.js and bundle analyzer to exact versions ensures consistent builds across environments and aligns with the monorepo's version consistency strategy.

Also applies to: 58-58

apps/browser-extension/src/content-script/execution/dialog.tsx (1)

58-78: Good conditional rendering improvement

Wrapping the tabs in a results.length > 0 condition prevents unnecessary DOM rendering when there are no results and aligns with the dialog's open state logic.

apps/discord-bot/src/components/evaluate-modal.ts (1)

75-76: Good UX improvements for optional input fields

Changing to TextInputStyle.Short and minLength = 0 makes these optional fields more user-friendly. Single-line style is appropriate for command-line arguments, and allowing empty input aligns with their optional nature.

Also applies to: 85-86

apps/browser-extension/src/content-script/execution/result.tsx (3)

18-24: Excellent simplification of output logic

The refactored approach directly uses result.output with simple conditional overrides for timeout scenarios. This is much cleaner than the previous memoized display object approach and aligns well with the new execution result schema.


34-34: Improved placeholder text for better UX

The new placeholder message is more user-friendly, clearly explaining that successful execution without output is normal behaviour.


37-38: Good alignment with new schema properties

Using !result.success and result.output directly from the execution result schema is cleaner and more intuitive than the previous display object approach.

apps/browser-extension/src/background/index.ts (2)

73-77: Excellent improvement with dynamic filename determination

Using getRuntimeDefaultFileName(runtime.id) with a fallback to 'file.code' is much more accurate than hardcoding filenames. This ensures proper file extensions for different programming languages, which can be important for compilation and execution.


84-85: Good simplification of execution metrics

The new approach using result.compile?.success ?? null and result.success is cleaner and aligns with the new execution result schema. This is more intuitive than checking exit codes directly.

apps/website/src/components/terminal/index.tsx (1)

31-85: LGTM! Clean refactor to static tab structure.

The simplified static JSX structure improves readability and maintainability compared to the previous dynamic tab generation approach. The indicator dots provide clear visual feedback for output presence.

apps/discord-bot/src/utilities/make-url.ts (1)

7-41: LGTM! Well-structured URL generation utilities.

The functions appropriately handle runtime-specific and runtime-agnostic URL generation with consistent state compression logic.

packages/shapes/src/execute.ts (2)

36-47: LGTM! Clean phase result schema with useful derived properties.

The transform appropriately trims output and provides derived boolean flags for success and expiry status.


55-60: Verify the output selection logic.

The current logic shows compile output when compile.code > 0 (compile failure), otherwise shows run output. Is this the intended behaviour? Typically, compile errors should be shown when compilation fails, but the run output should be shown when execution completes (regardless of compile success).

Consider if this logic should be:

-    output: (r.compile?.code || 0) > 0 ? r.compile?.output : r.run?.output,
+    output: r.compile && !r.compile.success ? r.compile.output : r.run.output,
apps/discord-bot/src/handlers/evaluate.ts (1)

104-116: LGTM! Clean output handling with the new schema.

The simplified logic using the new expired flags and unified output property improves readability.

@k0d13 k0d13 merged commit 43bc693 into main Jul 18, 2025
4 checks passed
@k0d13 k0d13 deleted the refactor/execute-result branch July 18, 2025 00:39
@coderabbitai coderabbitai bot mentioned this pull request Oct 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants