Skip to content

fix(ide): show toast errors when code view cannot open element#3106

Open
guangyang1206 wants to merge 1 commit into
onlook-dev:mainfrom
guangyang1206:fix/ide-toast-feedback-no-metadata-318
Open

fix(ide): show toast errors when code view cannot open element#3106
guangyang1206 wants to merge 1 commit into
onlook-dev:mainfrom
guangyang1206:fix/ide-toast-feedback-no-metadata-318

Conversation

@guangyang1206
Copy link
Copy Markdown

@guangyang1206 guangyang1206 commented May 9, 2026

When 'View in Code' was clicked and the underlying metadata lookup failed (no active branch, missing branch data, or element metadata not yet indexed), the IdeManager silently logged console warnings and returned with no user feedback — leaving users confused about why nothing happened.

Add actionable toast.error() messages for each early-return path so users receive clear feedback:

  • 'no active branch' → prompt to wait for project load
  • 'no branch data' → prompt branch data unavailable
  • 'no element metadata' → prompt project may still be indexing

Fixes #318

Description

When users click the "View in Code" button (or right-click → "View instance code") and the underlying
metadata lookup fails, IdeManager.openCodeBlock() silently logs a console.warn and returns —
leaving users with zero feedback about why nothing happened. This is the core of the UX problem
reported in #318 (originally about detecting missing VS Code / Cursor; the equivalent silent-failure
issue in the current web-based code panel is metadata being unavailable).

Changes

apps/web/client/src/components/store/editor/ide/index.ts

  • Import toast from @onlook/ui/sonner
  • Replace the three silent return early-exits with toast.error(…) messages:
    • No active branch → "Cannot open code view — no active branch is loaded yet."
    • No branch data → "Cannot open code view — branch data is unavailable."
    • No element metadata → "Cannot open code view — element metadata not found. The project may still be indexing; try again in a moment."

Why this matters

Users coming from component selection to code navigation have no indication when the code view
fails silently. The toast gives actionable context ("project may still be indexing") and matches
the UX pattern already used elsewhere in the store layer (e.g., branch/manager.ts).

Related Issues

Fixes #318

Type of Change

  • Bug fix

Testing

  1. Open a project where indexing hasn't completed yet (e.g., right after import).
  2. Select any element on the canvas and click the code icon (top-right of the element overlay).
  3. A toast should now appear: "Cannot open code view — element metadata not found. The project may still be indexing; try again in a moment."
  4. Once the project is fully indexed, the same click opens the code panel normally.

Summary by CodeRabbit

  • Bug Fixes
    • Added user-facing error notifications for code editor operations that fail due to missing branch data, unavailable project information, or indexing issues. Users now receive clear feedback when these conditions occur instead of experiencing silent failures.

When 'View in Code' was clicked and the underlying metadata lookup failed
(no active branch, missing branch data, or element metadata not yet indexed),
the IdeManager silently logged console warnings and returned with no user
feedback — leaving users confused about why nothing happened.

Add actionable toast.error() messages for each early-return path so users
receive clear feedback:
- 'no active branch' → prompt to wait for project load
- 'no branch data' → prompt branch data unavailable
- 'no element metadata' → prompt project may still be indexing

Fixes onlook-dev#318
@vercel
Copy link
Copy Markdown

vercel Bot commented May 9, 2026

@guangyang1206 is attempting to deploy a commit to the Onlook Team on Vercel.

A member of the Team first needs to authorize it.

@vercel vercel Bot temporarily deployed to Preview – docs-onlook May 9, 2026 04:13 Inactive
@vercel
Copy link
Copy Markdown

vercel Bot commented May 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs-onlook Skipped Skipped May 9, 2026 4:13am

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 9, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

IdeManager.openCodeBlock() now displays user-facing error toasts for three failure cases: when no active branch exists, when branch data is unavailable, and when JSX element metadata cannot be found (with an indexing suggestion). Early returns now follow the toast notifications instead of silent console logging only.

Changes

Error Notification Enhancement

Layer / File(s) Summary
Toast Dependency
apps/web/client/src/components/store/editor/ide/index.ts
Toast component imported for error notifications.
Error Case Notifications
apps/web/client/src/components/store/editor/ide/index.ts
Three failure cases in openCodeBlock now display error toasts: missing active branch, unavailable branch data, and unfound JSX element metadata with indexing guidance.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A toast to better warnings bright,
When branches fail or metadata's lost sight,
No more silent stumbles in the dark,
The user now knows what's gone awry, hark!
Errors speak up, loud and clear. 🌟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding toast error feedback when code view fails to open.
Description check ✅ Passed The description is comprehensive with clear context, specific changes, reasoning, related issues link, type of change, and testing steps.
Linked Issues check ✅ Passed The PR addresses #318 by implementing user-facing toast notifications for silent failures, aligning with the issue's request for detection and warning when actions fail.
Out of Scope Changes check ✅ Passed All changes are scoped to the IdeManager toast feedback feature; no unrelated modifications are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Copy link
Copy Markdown

@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

🤖 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 `@apps/web/client/src/components/store/editor/ide/index.ts`:
- Around line 23-39: Replace the three hardcoded toast.error strings with
localized next-intl message keys (e.g., ide.noActiveBranch, ide.noBranchData,
ide.noElementMetadata) by using the injected translator/util in this component
(or inject one if missing) instead of raw text; update the calls around
this.editorEngine.branches.getBranchDataById(activeBranchId) and
branchData.codeEditor.getJsxElementMetadata(oid) to call the translator (e.g.,
t('ide.noActiveBranch')) and pass those results into toast.error, and add the
corresponding keys to the next-intl messages for the component.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 06e6f9ea-f6af-4208-a06f-933d09b6c117

📥 Commits

Reviewing files that changed from the base of the PR and between a242be5 and e1af241.

📒 Files selected for processing (1)
  • apps/web/client/src/components/store/editor/ide/index.ts

Comment on lines +23 to 39
toast.error('Cannot open code view — no active branch is loaded yet.');
return;
}

const branchData = this.editorEngine.branches.getBranchDataById(activeBranchId);
if (!branchData) {
console.warn(`[IdeManager] No branch data found for branchId: ${activeBranchId}`);
toast.error('Cannot open code view — branch data is unavailable.');
return;
}

// Get element metadata
const metadata = await branchData.codeEditor.getJsxElementMetadata(oid);
if (!metadata) {
console.warn(`[IdeManager] No metadata found for OID: ${oid}`);
toast.error('Cannot open code view — element metadata not found. The project may still be indexing; try again in a moment.');
return;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Replace hardcoded toast messages with localized next-intl keys.

Lines 23, 30, and 38 introduce hardcoded user-facing copy. Please source these messages from next-intl (via injected translator/util), so they’re localizable and consistent with app i18n.

Suggested direction
- toast.error('Cannot open code view — no active branch is loaded yet.');
+ toast.error(t('ide.openCodeBlock.noActiveBranch'));

- toast.error('Cannot open code view — branch data is unavailable.');
+ toast.error(t('ide.openCodeBlock.noBranchData'));

- toast.error('Cannot open code view — element metadata not found. The project may still be indexing; try again in a moment.');
+ toast.error(t('ide.openCodeBlock.metadataNotFound'));

As per coding guidelines, "Avoid hardcoded user-facing text; use next-intl messages/hooks instead".

🤖 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 `@apps/web/client/src/components/store/editor/ide/index.ts` around lines 23 -
39, Replace the three hardcoded toast.error strings with localized next-intl
message keys (e.g., ide.noActiveBranch, ide.noBranchData, ide.noElementMetadata)
by using the injected translator/util in this component (or inject one if
missing) instead of raw text; update the calls around
this.editorEngine.branches.getBranchDataById(activeBranchId) and
branchData.codeEditor.getJsxElementMetadata(oid) to call the translator (e.g.,
t('ide.noActiveBranch')) and pass those results into toast.error, and add the
corresponding keys to the next-intl messages for the component.

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.

[bug] Should detect when vscode or cursor is not installed

1 participant