Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apps/web/client/src/components/store/editor/ide/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { EditorMode, type CodeNavigationTarget } from "@onlook/models";
import { toast } from "@onlook/ui/sonner";
import { makeAutoObservable } from "mobx";
import type { EditorEngine } from "../engine";

Expand All @@ -19,19 +20,22 @@ export class IdeManager {
const activeBranchId = this.editorEngine.branches.activeBranch?.id;
if (!activeBranchId) {
console.warn('[IdeManager] No active branch found');
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;
Comment on lines +23 to 39
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.

}

Expand Down