Skip to content

feat: add copy-to-clipboard functionality for answers#262

Merged
knoxiboy merged 1 commit into
knoxiboy:mainfrom
Owais-Siddique-11:feat/copy-to-clipboard
May 26, 2026
Merged

feat: add copy-to-clipboard functionality for answers#262
knoxiboy merged 1 commit into
knoxiboy:mainfrom
Owais-Siddique-11:feat/copy-to-clipboard

Conversation

@Owais-Siddique-11
Copy link
Copy Markdown
Contributor

Description

Added a copy-to-clipboard feature for answers/solutions to improve workflow efficiency and usability.

Changes Made

  • Added one-click copy button for answers
  • Integrated Clipboard API support
  • Added toast feedback after successful copy
  • Improved accessibility with proper labels
  • Maintained responsive and consistent UI styling

Closes #233

@vercel
Copy link
Copy Markdown

vercel Bot commented May 24, 2026

@Owais-Siddique-11 is attempting to deploy a commit to the Karan Mani Tripathi 's projects Team on Vercel.

A member of the Team first needs to authorize it.

@knoxiboy knoxiboy added gssoc'26 GSSoC program issue type:feature New feature level:intermediate Intermediate level task labels May 24, 2026
knoxiboy

This comment was marked as spam.

knoxiboy

This comment was marked as outdated.

Copy link
Copy Markdown
Owner

@knoxiboy knoxiboy left a comment

Choose a reason for hiding this comment

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

Technical Review

Hi @Owais-Siddique-11! Thank you for your contribution to DoubtDesk.

The code changes look good. Before we can complete the technical review, approve, and merge this pull request, we have one final requirement for all contributors: Please star the DoubtDesk repository.

Once you have starred the repository, please drop a comment here saying "done" (or we will automatically detect it) and we will proceed with approving and merging your PR. Thank you.

@knoxiboy knoxiboy self-requested a review May 24, 2026 12:28
@knoxiboy knoxiboy added gssoc and removed gssoc labels May 24, 2026
@knoxiboy knoxiboy requested a review from Copilot May 25, 2026 10:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds copy-to-clipboard functionality to the classroom Ask AI view (AskAIView). A local useCopyToClipboard hook wraps navigator.clipboard.writeText with Sonner toast feedback and a transient "copied" state, and two new buttons surface this — a "Copy All" button for the full AI response and a per-section "Copy" button placed alongside the existing "Generate Video" button.

Changes:

  • Introduce a useCopyToClipboard hook with success/error toasts and a per-id copied state.
  • Add a "Copy All" button above the parsed sections that copies the full raw response.
  • Add a per-section "Copy" button in each section header, grouped with the existing Generate Video action.
Comments suppressed due to low confidence (1)

components/AskAIView.tsx:358

  • The indentation in this JSX block is inconsistent with the rest of the file (which uses 4-space indentation matched to the JSX nesting). Lines 311–325 and lines 336–358 are flush-left or use 4-space top-level indentation while the surrounding JSX tree is nested several levels deeper. Please re-indent these blocks to match the existing nesting so the structure stays readable and git blame/diffs remain clean.
    <div className="space-y-4">
        <div className="flex justify-end">
            <button
                onClick={() => copy(response, "full-response")}
                className="flex items-center gap-2 px-4 py-2 bg-white/5 hover:bg-white/10 border border-white/10 rounded-xl font-bold uppercase tracking-tighter text-[9px] transition-all text-slate-400 hover:text-white"
                aria-label="Copy full response"
            >
                {copied === "full-response" ? (
                    <><Check className="w-3 h-3 text-green-400" /> All Copied!</>
                ) : (
                    <><Copy className="w-3 h-3" /> Copy All</>
                )}
            </button>
        </div>
        {sections.map((sec, idx) => {
                        const meta = SECTION_META[sec.title];
                        return (
                            <div key={idx} className="bg-white/60 dark:bg-slate-900/60 border border-slate-200 dark:border-white/8 rounded-3xl overflow-hidden shadow-lg">
                                <div className={`flex items-center gap-3 px-6 py-4 border-b border-slate-200 dark:border-white/5`}>
                                    {meta && (
                                        <div className={`flex items-center justify-center w-8 h-8 rounded-xl bg-slate-100 dark:bg-white/5 border ${meta.badge}`}>
                                            {meta.icon}
                                        </div>
                                    )}
                                    <h2 className="text-slate-900 dark:text-white font-black tracking-tight text-sm uppercase italic">{sec.title}</h2>
                                    <div className="ml-auto flex items-center gap-2">
    <button
        onClick={() => copy(sec.content, `section-${idx}`)}
        className="flex items-center gap-1.5 px-3 py-2 bg-white/5 hover:bg-white/10 border border-white/10 rounded-xl font-bold uppercase tracking-tighter text-[9px] transition-all text-slate-400 hover:text-white"
        aria-label="Copy section content"
        title="Copy to clipboard"
    >
        {copied === `section-${idx}` ? (
            <><Check className="w-3 h-3 text-green-400" /> Copied!</>
        ) : (
            <><Copy className="w-3 h-3" /> Copy</>
        )}
    </button>
    {idx === 0 && (
        <button
            onClick={handleGenerateVideo}
            disabled={isVideoLoading}
            className="flex items-center gap-2 px-4 py-2 bg-gradient-to-r from-blue-600 to-indigo-600 text-slate-900 dark:text-white rounded-xl font-bold uppercase tracking-tighter text-[9px] shadow-lg shadow-blue-500/20 active:scale-95 transition-all disabled:opacity-50"
        >
            {isVideoLoading ? <Loader2 className="w-3 h-3 animate-spin" /> : <Zap className="w-3 h-3 text-yellow-400 fill-yellow-400" />} {isVideoLoading ? "Generating..." : "Generate Video"}
        </button>
    )}
</div>

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread components/AskAIView.tsx
const [isVideoLoading, setIsVideoLoading] = useState(false);
const [videoUrl, setVideoUrl] = useState<string | null>(null);
const fileInputRef = useRef<HTMLInputElement>(null);
const { copied, copy } = useCopyToClipboard();
@knoxiboy knoxiboy added level:beginner Beginner level task good first issue Perfect for first-time contributors beginner friendly Friendly to beginners and removed level:intermediate Intermediate level task labels May 25, 2026
@Owais-Siddique-11
Copy link
Copy Markdown
Contributor Author

Hey I have started the repo
Now can you merge the PR

@knoxiboy knoxiboy merged commit ca700e2 into knoxiboy:main May 26, 2026
5 of 6 checks passed
@github-actions github-actions Bot added gssoc:approved Approved for GSSoC mentor:knoxiboy Reviewed by mentor knoxiboy quality:clean Clean code quality labels May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beginner friendly Friendly to beginners good first issue Perfect for first-time contributors gssoc:approved Approved for GSSoC gssoc'26 GSSoC program issue level:beginner Beginner level task mentor:knoxiboy Reviewed by mentor knoxiboy quality:clean Clean code quality type:feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Copy-to-Clipboard Support for Answers & Solutions

3 participants