Skip to content

feat: add 'Fix with Doce' button to preview error state#46

Merged
pablopunk merged 8 commits intomainfrom
feature/fix-with-doce-button
Apr 23, 2026
Merged

feat: add 'Fix with Doce' button to preview error state#46
pablopunk merged 8 commits intomainfrom
feature/fix-with-doce-button

Conversation

@pablopunk
Copy link
Copy Markdown
Owner

@pablopunk pablopunk commented Apr 20, 2026

Closes #8

When the preview server fails to start, users can now click a 'Fix with Doce' button that automatically sends the error message to the AI chat for troubleshooting.

Changes

  • PreviewPanel.tsx: Added onFixWithDoce prop and button that appears on error state
  • ProjectContentWrapper.tsx: Wired up handleSend from useChatPanel to send formatted prompt to AI

How it works

  1. Preview server fails → error screen shows
  2. User clicks 'Fix with Doce'
  3. Prompt sent to AI: "The preview server failed to start with this error: [message] Please fix this issue."
  4. AI agent receives the message and can help diagnose/fix

Screenshot

Error state now shows two buttons:

  • Try Again (existing)
  • Fix with Doce (new)

Summary by CodeRabbit

  • New Features

    • Adds a visible "Fix with Doce" button in the preview error dialog to trigger an integrated assistant fix alongside the existing "Try Again" action.
  • UI Changes

    • Makes the chat panel's detach toggle visible where applicable.
  • Chores

    • CI workflow updated to disable action caching for deployment/teardown steps.

When the preview server fails to start, show a 'Fix with Doce' button
that sends the error message to the AI chat for automated troubleshooting.

- Add onFixWithDoce callback prop to PreviewPanel
- Wire up handleSend from useChatPanel in ProjectContentWrapper
- Send formatted prompt with error details to AI agent
@pablopunk pablopunk added the enhancement New feature or request label Apr 20, 2026
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 20, 2026

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

Project Deployment Actions Updated (UTC)
doce-dev-www Ready Ready Preview, Comment Apr 23, 2026 5:15pm

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 20, 2026

Warning

Rate limit exceeded

@pablopunk has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 47 minutes and 4 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 47 minutes and 4 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8d143c78-ca34-43ef-ac6e-68c649ac3992

📥 Commits

Reviewing files that changed from the base of the PR and between 533da00 and a9a8b70.

📒 Files selected for processing (2)
  • .github/workflows/pr-preview.yml
  • Dockerfile

Walkthrough

The changes add a "Fix with Doce" flow for preview errors. PreviewPanel gains an optional onFixWithDoce?: (errorMessage: string) => void prop and conditionally renders a "Fix with Doce" button next to "Try Again" when onFixWithDoce and an error message are present. ProjectContentWrapper wires useChatPanel into the UI, implements handleFixWithDoce to format the error prompt and call handleSend, and passes onFixWithDoce={handleFixWithDoce} to PreviewPanel. Streaming state updates are centralized through useChatPanel's onStreamingStateChange.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant PreviewPanel
    participant ProjectContentWrapper
    participant ChatPanel
    participant ChatAgent as Chat Agent

    User->>PreviewPanel: Click "Fix with Doce"
    PreviewPanel->>ProjectContentWrapper: onFixWithDoce(errorMessage)
    ProjectContentWrapper->>ProjectContentWrapper: Format prompt with context
    ProjectContentWrapper->>ChatPanel: handleSend(formattedPrompt)
    ChatPanel->>ChatAgent: Deliver prompt for analysis
    ChatAgent-->>ChatPanel: Analysis/response
    ChatPanel-->>ProjectContentWrapper: Response delivered
    ProjectContentWrapper-->>PreviewPanel: (optional) display result/update UI
Loading
🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR partially addresses issue #8 by implementing the 'Fix with Doce' button feature but does not implement the check for whether the agent is currently building/modifying code. Add validation to prevent sending error messages to the agent while code modifications are in progress, as specified in issue #8's requirement about checking agent build state.
Out of Scope Changes check ⚠️ Warning The GitHub Actions workflow changes in pr-preview.yml (disabling Tailscale action caching) appear unrelated to the primary objective of adding the 'Fix with Doce' button feature. Either move the Tailscale caching changes to a separate PR or provide context explaining their relationship to the 'Fix with Doce' feature implementation.
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 (2 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 primary change: adding a 'Fix with Doce' button to the preview error state UI component.

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


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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/components/preview/PreviewPanel.tsx`:
- Around line 679-691: The error state is rendering duplicate retry CTAs: the
centered "Try Again" uses handleRetry and onFixWithDoce/message, while the
header also renders a "Retry" button; update PreviewPanel so only one retry CTA
shows by removing or conditionally hiding the header Retry button when the
centered error actions are displayed (use the same error/state that triggers
rendering of the centered block—i.e., the presence of message or the error
flag). Specifically, locate the header Retry button in PreviewPanel and wrap it
in the inverse condition of the centered error actions (or remove it entirely)
so that handleRetry appears only once alongside onFixWithDoce when message is
present.

In `@src/components/projects/ProjectContentWrapper.tsx`:
- Around line 61-74: Guard handleFixWithDoce to avoid sending while the agent is
streaming: update the handleFixWithDoce function to check the isStreaming flag
(already in ProjectContentWrapper) and return early when true before calling
handleSend; additionally consider passing isStreaming into PreviewPanel and
disabling the "Fix with Doce" button there so the UI reflects the same state.
Ensure you reference handleFixWithDoce, isStreaming, handleSend, and
PreviewPanel when making the changes.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 482143c0-fa1f-41ae-ad53-045dd52a7461

📥 Commits

Reviewing files that changed from the base of the PR and between 1cc3134 and 8e6748a.

📒 Files selected for processing (2)
  • src/components/preview/PreviewPanel.tsx
  • src/components/projects/ProjectContentWrapper.tsx

Comment on lines +679 to +691
<div className="flex items-center gap-2">
<Button variant="outline" onClick={handleRetry}>
Try Again
</Button>
{onFixWithDoce && message && (
<Button
variant="default"
onClick={() => onFixWithDoce(message)}
>
Fix with Doce
</Button>
)}
</div>
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

Avoid showing duplicate retry CTAs in the error state.

This adds Try Again in the error panel while the header still renders Retry for the same error state at Lines 575-579. The resulting UI can show three actions instead of the intended “Try Again” + “Fix with Doce”.

Suggested cleanup
-									<div className="flex items-center gap-2">
+									<div className="flex items-center gap-2">
 										<Button variant="outline" onClick={handleRetry}>
 											Try Again
 										</Button>

Also remove or hide the header retry button when the centered error actions are shown.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/preview/PreviewPanel.tsx` around lines 679 - 691, The error
state is rendering duplicate retry CTAs: the centered "Try Again" uses
handleRetry and onFixWithDoce/message, while the header also renders a "Retry"
button; update PreviewPanel so only one retry CTA shows by removing or
conditionally hiding the header Retry button when the centered error actions are
displayed (use the same error/state that triggers rendering of the centered
block—i.e., the presence of message or the error flag). Specifically, locate the
header Retry button in PreviewPanel and wrap it in the inverse condition of the
centered error actions (or remove it entirely) so that handleRetry appears only
once alongside onFixWithDoce when message is present.

Comment on lines +61 to +74
// Get chat send function for "Fix with Doce" feature
const { handleSend } = useChatPanel({
projectId,
models,
onStreamingStateChange: (count, streaming) => {
setUserMessageCount(count);
setIsStreaming(streaming);
},
});

const handleFixWithDoce = (errorMessage: string) => {
const prompt = `The preview server failed to start with this error:\n\n${errorMessage}\n\nPlease fix this issue.`;
void handleSend(prompt);
};
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 | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Verify whether `useChatPanel` owns per-hook local state and find all active hook instances.

# Inspect the hook implementation for local state/subscriptions around items, handleSend, and streaming.
fd -i '^useChatPanel\.ts$' --exec sed -n '1,240p' {}

# Inspect call sites to confirm whether ProjectContentWrapper and rendered chat panels create separate hook instances.
rg -nP -C4 '\buseChatPanel\s*\(' --type=ts --type=tsx

Repository: pablopunk/doce.dev

Length of output: 6293


🏁 Script executed:

#!/bin/bash
# Find and inspect useChatStore implementation
fd -i 'chatstore' --type f | head -20

Repository: pablopunk/doce.dev

Length of output: 127


🏁 Script executed:

#!/bin/bash
# Search for handleFixWithDoce call sites and surrounding context
rg -n 'handleFixWithDoce' -A 5 -B 5

Repository: pablopunk/doce.dev

Length of output: 2808


🏁 Script executed:

#!/bin/bash
# Inspect the useChatStore hook to understand state sharing
fd 'useChatStore' -type f -name '*.ts' -o -name '*.tsx' | xargs cat | head -150

Repository: pablopunk/doce.dev

Length of output: 232


🏁 Script executed:

#!/bin/bash
cat src/stores/useChatStore.ts | head -100

Repository: pablopunk/doce.dev

Length of output: 2199


🏁 Script executed:

#!/bin/bash
# Find ChatPanel component and check if it calls useChatPanel
rg -n 'useChatPanel' src/components/chat/ChatPanel.tsx -A 3 -B 3

Repository: pablopunk/doce.dev

Length of output: 596


🏁 Script executed:

#!/bin/bash
# Check where onFixWithDoce is actually invoked - look for click handlers or error handlers
rg -n 'onFixWithDoce' --type ts --type tsx -B 5

Repository: pablopunk/doce.dev

Length of output: 89


🏁 Script executed:

#!/bin/bash
# Search for onFixWithDoce usage and invocation points
rg 'onFixWithDoce' -A 5 -B 5

Repository: pablopunk/doce.dev

Length of output: 4273


🏁 Script executed:

#!/bin/bash
# Look at useChatStore initialization to confirm singleton behavior
cat src/stores/useChatStore.ts | tail -50

Repository: pablopunk/doce.dev

Length of output: 1201


Guard handleFixWithDoce to prevent sending while the agent is streaming/building.

The handler currently sends the diagnostic prompt unconditionally, even when isStreaming is true. This conflicts with the linked issue requirement to avoid transient errors while code is actively changing. Since isStreaming is already available in ProjectContentWrapper, add a guard before calling handleSend:

const handleFixWithDoce = (errorMessage: string) => {
    if (isStreaming) return; // Ignore while agent is busy
    const prompt = `The preview server failed to start with this error:\n\n${errorMessage}\n\nPlease fix this issue.`;
    void handleSend(prompt);
};

Alternatively or additionally, disable the "Fix with Doce" button in PreviewPanel when the agent is streaming by passing isStreaming to the component and conditionally disabling the button.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/projects/ProjectContentWrapper.tsx` around lines 61 - 74,
Guard handleFixWithDoce to avoid sending while the agent is streaming: update
the handleFixWithDoce function to check the isStreaming flag (already in
ProjectContentWrapper) and return early when true before calling handleSend;
additionally consider passing isStreaming into PreviewPanel and disabling the
"Fix with Doce" button there so the UI reflects the same state. Ensure you
reference handleFixWithDoce, isStreaming, handleSend, and PreviewPanel when
making the changes.

@github-actions
Copy link
Copy Markdown

Preview deployment failed.

Check the workflow logs for details.

@github-actions
Copy link
Copy Markdown

🚀 Preview deployed!

Open preview environment

Note: Accessible via Tailscale network

ℹ️ This preview will be automatically cleaned up when the PR is closed.

@pablopunk pablopunk merged commit a9a8b70 into main Apr 23, 2026
8 checks passed
@github-actions
Copy link
Copy Markdown

Preview deployment failed.

Check the workflow logs for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Custom error boundary

1 participant