Skip to content

feat(prompt install button): add button to setup paykit via prompt#180

Open
Muhammad-Owais-Warsi wants to merge 4 commits into
getpaykit:mainfrom
Muhammad-Owais-Warsi:main
Open

feat(prompt install button): add button to setup paykit via prompt#180
Muhammad-Owais-Warsi wants to merge 4 commits into
getpaykit:mainfrom
Muhammad-Owais-Warsi:main

Conversation

@Muhammad-Owais-Warsi
Copy link
Copy Markdown

@Muhammad-Owais-Warsi Muhammad-Owais-Warsi commented May 16, 2026

closes: #90
Screenshot 2026-05-17 143619

image

Summary by CodeRabbit

Release Notes

  • New Features
    • Added an install button that copies the setup command to the clipboard with visual confirmation.
    • Replaced the inline ghost button with a dialog that displays the full setup command in a scrollable code view and provides a “Copy” action.
    • Enhanced visual feedback: hover animations and clear copied/confirmation states for the install flow.

Review Change Stack

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 16, 2026

@Muhammad-Owais-Warsi is attempting to deploy a commit to the maxktz Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 16, 2026

📝 Walkthrough

Walkthrough

The hero title section centralizes installation instructions in a new PROMPT constant, adds a HeroTitleInstallButton component that copies the install command with animated icons, and refactors HeroTitle to show the full PROMPT inside a Dialog with a footer copy button.

Changes

Hero Installation UI Refactoring

Layer / File(s) Summary
PROMPT constant definition
apps/web/src/lib/consts.ts
An exported PROMPT string constant containing multi-step authentication and component setup instructions is added.
HeroTitleInstallButton component with copy and animations
apps/web/src/components/web/hero-title-install-button.tsx
A new client-side component renders a styled button with the install command. It tracks copied and hovered states, copies the command to clipboard on click with a 1.5-second reset, and animates icon transitions (chevron → copy → check) using AnimatePresence and decorative background spans.
HeroTitle Dialog integration and layout update
apps/web/src/components/web/hero-title.tsx
HeroTitle imports are updated to use PROMPT and useCopyButton instead of local clipboard logic. The button layout is replaced with a "Read Docs" button and a Dialog displaying PROMPT in a scrollable code block with a footer copy button, while HeroTitleInstallButton is rendered in the button area.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A prompt in constants, neat and bright,
A button that copies with a tiny delight,
Chevrons and checks that flutter and sweep,
Dialogs that hold the command for keep,
Hooray — the hero's install is quick and light!

🚥 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
Title check ✅ Passed The title accurately summarizes the main change: adding a button component to enable PayKit setup via a prompt command. It is concise, specific, and directly reflects the primary modifications across the affected files.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

🧹 Nitpick comments (1)
apps/web/src/components/docs/package-command.tsx (1)

21-27: ⚡ Quick win

Narrow manager to a literal union for safer command generation.

At Lines 21 and 27, manager: string allows unsupported values and weakens compile-time checks. Derive a Manager type from the manager arrays to keep branches aligned as tabs evolve.

Suggested refactor
+type InstallManager = (typeof installManagers)[number];
+type RunManager = (typeof runManagers)[number];
 
-function installCommand(pkg: string, manager: string) {
+function installCommand(pkg: string, manager: InstallManager) {
   if (manager === "prompt") return PROMPT;
   if (manager === "npm") return `npm install ${pkg}`;
   return `${manager} add ${pkg}`;
 }
 
-function runCommand(command: string, manager: string) {
+function runCommand(command: string, manager: RunManager) {
   if (manager === "pnpm") return `pnpm dlx ${command}`;
   if (manager === "bun") return `bunx ${command}`;
   return `npx ${command}`;
 }
🤖 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/src/components/docs/package-command.tsx` around lines 21 - 27,
Narrow the manager param types by introducing a Manager literal union derived
from the existing manager arrays and use it for installCommand(manager: Manager)
and runCommand(manager: Manager) so TypeScript enforces allowed values; update
any callers to satisfy the new type (or cast where necessary), and ensure the
existing branches in installCommand (checks for "prompt", "npm", and default
`${manager} add ${pkg}`) and runCommand align with the Manager union so no
unsupported strings can reach those functions.
🤖 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/src/components/docs/package-command.tsx`:
- Line 7: The shared managers constant (const managers = ["pnpm", "bun", "npm",
"prompt"] as const) is leaking the "prompt" option into PackageRun, causing an
invalid run-tab; update the code so PackageRun only uses a managers list without
"prompt" (e.g., create a separate managersRun = ["pnpm","bun","npm"] or filter
managers before rendering/use in PackageRun), and ensure runCommand only
receives those valid managers (runCommand) so the "prompt" tab is never rendered
or passed to runCommand.

---

Nitpick comments:
In `@apps/web/src/components/docs/package-command.tsx`:
- Around line 21-27: Narrow the manager param types by introducing a Manager
literal union derived from the existing manager arrays and use it for
installCommand(manager: Manager) and runCommand(manager: Manager) so TypeScript
enforces allowed values; update any callers to satisfy the new type (or cast
where necessary), and ensure the existing branches in installCommand (checks for
"prompt", "npm", and default `${manager} add ${pkg}`) and runCommand align with
the Manager union so no unsupported strings can reach those functions.
🪄 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: 6f1261a0-85e5-4fe6-a3a6-9afd110e9cea

📥 Commits

Reviewing files that changed from the base of the PR and between 55a0bda and 4584f29.

📒 Files selected for processing (1)
  • apps/web/src/components/docs/package-command.tsx

Comment thread apps/web/src/components/docs/package-command.tsx Outdated
@Muhammad-Owais-Warsi Muhammad-Owais-Warsi marked this pull request as draft May 16, 2026 10:12
@Muhammad-Owais-Warsi Muhammad-Owais-Warsi marked this pull request as ready for review May 17, 2026 09:05
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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/web/src/components/web/hero-title-install-button.tsx`:
- Around line 13-17: handleCopy starts a new timeout on every click which can
reset copied too early; store the timeout id in a ref (e.g., copyTimeoutRef) and
call clearTimeout(copyTimeoutRef.current) before creating a new setTimeout,
update copyTimeoutRef.current with the new id, and ensure you clear the timeout
on unmount (useEffect cleanup) so setCopied(false) cannot run after the
component is gone.

In `@apps/web/src/components/web/hero-title.tsx`:
- Around line 73-75: Update the dialog copy to accurately reflect what is being
copied: replace the current DialogTitle and DialogDescription text that refer to
an "install command" with wording that indicates the multi-step setup prompt
(the PROMPT payload) is being copied. Locate the DialogTitle/DialogDescription
elements in the hero-title component and change their text to something like
"Copy the setup prompt" and "Paste this multi-step setup prompt into your
terminal or chat to get started," ensuring any other dialog instance around
lines referencing PROMPT is updated likewise for consistency.
🪄 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: 6d87dace-4725-4626-b343-c2df0e7095f6

📥 Commits

Reviewing files that changed from the base of the PR and between 4584f29 and 1cb2bfe.

📒 Files selected for processing (3)
  • apps/web/src/components/web/hero-title-install-button.tsx
  • apps/web/src/components/web/hero-title.tsx
  • apps/web/src/lib/consts.ts

Comment on lines +13 to +17
const handleCopy = useCallback(() => {
void navigator.clipboard.writeText("npx paykitjs init");
setCopied(true);
setTimeout(() => setCopied(false), 1500);
}, []);
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

Clear previous reset timers before creating a new one.

Line 16 starts a new timer on every click, so rapid re-clicks can flip copied back to false too early.

Suggested fix
-import { useCallback, useState } from "react";
+import { useCallback, useEffect, useRef, useState } from "react";

 export default function HeroTitleInstallButton() {
   const [copied, setCopied] = useState(false);
   const [hovered, setHovered] = useState(false);
+  const resetTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);

   const handleCopy = useCallback(() => {
     void navigator.clipboard.writeText("npx paykitjs init");
     setCopied(true);
-    setTimeout(() => setCopied(false), 1500);
+    if (resetTimerRef.current) clearTimeout(resetTimerRef.current);
+    resetTimerRef.current = setTimeout(() => setCopied(false), 1500);
   }, []);
+
+  useEffect(() => {
+    return () => {
+      if (resetTimerRef.current) clearTimeout(resetTimerRef.current);
+    };
+  }, []);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const handleCopy = useCallback(() => {
void navigator.clipboard.writeText("npx paykitjs init");
setCopied(true);
setTimeout(() => setCopied(false), 1500);
}, []);
import { useCallback, useEffect, useRef, useState } from "react";
export default function HeroTitleInstallButton() {
const [copied, setCopied] = useState(false);
const [hovered, setHovered] = useState(false);
const resetTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const handleCopy = useCallback(() => {
void navigator.clipboard.writeText("npx paykitjs init");
setCopied(true);
if (resetTimerRef.current) clearTimeout(resetTimerRef.current);
resetTimerRef.current = setTimeout(() => setCopied(false), 1500);
}, []);
useEffect(() => {
return () => {
if (resetTimerRef.current) clearTimeout(resetTimerRef.current);
};
}, []);
🤖 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/src/components/web/hero-title-install-button.tsx` around lines 13 -
17, handleCopy starts a new timeout on every click which can reset copied too
early; store the timeout id in a ref (e.g., copyTimeoutRef) and call
clearTimeout(copyTimeoutRef.current) before creating a new setTimeout, update
copyTimeoutRef.current with the new id, and ensure you clear the timeout on
unmount (useEffect cleanup) so setCopied(false) cannot run after the component
is gone.

Comment thread apps/web/src/components/web/hero-title.tsx Outdated
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.

feat(ai): installation prompt via "copy prompt"

1 participant