Skip to content

chore: add required auth dialog for playground canvas - #2307

Merged
smakosh merged 4 commits into
theopenco:mainfrom
amelitoalcuitas:chore/canvas-sign-in
May 17, 2026
Merged

smakosh merged 4 commits into
theopenco:mainfrom
amelitoalcuitas:chore/canvas-sign-in

Conversation

@amelitoalcuitas

@amelitoalcuitas amelitoalcuitas commented May 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Dedicated prompt input with submit and stop controls; disables while generation runs
    • Authentication dialog now appears when needed
  • Refactor

    • More reliable streamed generation with cancel support and improved buffering
    • Centralized spec/editor state handling and memoized derived values
  • Bug Fixes

    • Better error reporting and fallback handling for generation results

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 17, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: c27c4953-8440-4ef0-a3b1-f9269bf0ce5a

📥 Commits

Reviewing files that changed from the base of the PR and between 93ba90b and 57f4b08.

📒 Files selected for processing (1)
  • apps/playground/src/components/playground/canvas-page-client.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/playground/src/components/playground/canvas-page-client.tsx

Walkthrough

The canvas page client extracts prompt input into a memoized component, integrates authentication dialog rendering, refactors generation to accept a prompt with abortable streaming and incremental compilation, and adds memoized spec-derived values for JSON UI provider key.

Changes

Canvas Page Client Refactoring

Layer / File(s) Summary
Imports and Dependencies Setup
apps/playground/src/components/playground/canvas-page-client.tsx
React hook imports expanded to include memo, useCallback, useMemo, useRef, useState and usePathname; AuthDialog and useUser are imported for authentication support.
CanvasPromptInput Component Extraction
apps/playground/src/components/playground/canvas-page-client.tsx
New memoized CanvasPromptInput owns local prompt state, invokes onGenerate(prompt), supports onStop, and is keyed by promptResetKey to reset its textarea; replaces inline PromptInput rendering.
Authentication State and Dialog Integration
apps/playground/src/components/playground/canvas-page-client.tsx
useUser() and usePathname() compute showAuthDialog once loading completes when no user exists; AuthDialog is rendered with returnUrl={pathname}.
Generation Flow with Prompt Parameter and Stream Handling
apps/playground/src/components/playground/canvas-page-client.tsx
handleGenerate now accepts a prompt, guards against empty/concurrent generations, uses an AbortController to cancel, streams from /api/canvas/generate, incrementally runs compileSpecStream on buffered chunks, finalizes by compiling or JSON.parseing remaining buffer, and reports errors via toast.
Performance Optimization with Memoized Derived Values
apps/playground/src/components/playground/canvas-page-client.tsx
Adds memoized hasSpec, isDefaultSpec, and specStateKey; handleResetCanvas increments promptResetKey; JSONUIProvider key now uses specStateKey.

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: adding authentication dialog to the playground canvas component. It is specific, concise, and clearly describes the primary modification.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 3

🤖 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/playground/src/components/playground/canvas-page-client.tsx`:
- Around line 212-224: handleStop currently sets setIsGenerating(false) and
clears abortRef.current too early; move generation cleanup into the request's
finally and guard against clearing a newer request: create a local controller
from abortRef.current at start of handleGenerate (the fetch block), perform all
cleanup (setIsGenerating(false) and abortRef.current = null) inside the fetch's
finally, and before clearing abortRef.current verify that abortRef.current ===
localController so you don't clear a later request; update other similar blocks
(lines noted around 288-290 and 296-299) to use the same pattern and only let
the finally block own toggling setIsGenerating and nulling abortRef.current.
- Around line 93-97: The prompt state is kept inside CanvasPromptInput so parent
resets don't clear it; make the prompt controlled by lifting state or forcing
CanvasPromptInput to reset: change CanvasPromptInput to accept value and
onChange props (bind to parent prompt/setPrompt used in canvas-page-client where
prompt, setPrompt and handleSubmit exist) or add a reset/key prop from the
parent reset/new-canvas flow so the parent can clear prompt by setting prompt=""
or changing the key; ensure handleSubmit still calls onGenerate(prompt) from the
parent-controlled prompt.
- Around line 264-279: The final completion branch currently assigns the
compiled spec unconditionally and the JSON fallback silently ignores invalid
shapes; update the completion handling in the compileSpecStream try/catch so
that after obtaining compiled (from compileSpecStream) you validate its shape
(e.g., compiled.root and compiled.elements) before calling setSpec and
setEditorValue, and if validation fails setParseError("Failed to parse AI
response as a valid spec"); likewise, in the JSON.parse fallback (parsed) apply
the same shape guard and setParseError when the parsed object is not a valid
Spec, using the same functions (compileSpecStream, specStreamBuffer, compiled,
parsed, setSpec, setEditorValue, setParseError) to locate and modify the logic.
🪄 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: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 562e33ff-9b59-4431-8115-836bad396eea

📥 Commits

Reviewing files that changed from the base of the PR and between 574af63 and 93ba90b.

📒 Files selected for processing (1)
  • apps/playground/src/components/playground/canvas-page-client.tsx

Comment thread apps/playground/src/components/playground/canvas-page-client.tsx
Comment thread apps/playground/src/components/playground/canvas-page-client.tsx
Comment thread apps/playground/src/components/playground/canvas-page-client.tsx Outdated
@smakosh
smakosh added this pull request to the merge queue May 17, 2026
Merged via the queue into theopenco:main with commit 1e9e40a May 17, 2026
8 checks passed
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