Skip to content

Conversation

@smankovsky
Copy link
Member

@smankovsky smankovsky commented Sep 15, 2025

User description

Screenshot 2025-09-15 at 20 23 37

PR Type

Enhancement


Description

  • Add processing page for file uploads

  • Improve transcript status handling

  • Unify processing experience

  • Fix redirection logic


Changes walkthrough 📝

Relevant files
Enhancement
page.tsx
Improve transcript status handling and UI                               

www/app/(app)/transcripts/[transcriptId]/page.tsx

  • Added 'uploaded' status to redirect conditions
  • Enhanced redirection logic based on transcript status
  • Added loading spinner UI for waiting state
  • Improved conditional routing based on source type
  • +54/-5   
    page.tsx
    Add new processing page component                                               

    www/app/(app)/transcripts/[transcriptId]/processing/page.tsx

  • Created new processing page component
  • Implemented status-based redirection logic
  • Added loading spinner and processing UI
  • Included navigation button to browse library
  • +97/-0   
    page.tsx
    Refactor upload page to use processing page                           

    www/app/(app)/transcripts/[transcriptId]/upload/page.tsx

  • Simplified upload page by removing processing UI
  • Added redirection to processing page after upload
  • Improved layout with minH property
  • Passed onUploadComplete callback to FileUploadButton
  • +18/-30 
    fileUploadButton.tsx
    Add completion callback to FileUploadButton                           

    www/app/(app)/transcripts/fileUploadButton.tsx

  • Added onUploadComplete callback prop
  • Trigger callback when upload is complete
  • +2/-0     

    Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • @vercel
    Copy link

    vercel bot commented Sep 15, 2025

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

    Project Deployment Preview Comments Updated (UTC)
    reflector Ready Ready Preview Comment Sep 15, 2025 7:30pm
    reflector-media Ready Ready Preview Comment Sep 15, 2025 7:30pm

    @pr-agent-monadical
    Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Inconsistent Messaging

    The processing page has a heading that specifically mentions "Processing recording" but this page is also used for file uploads. The text should be more generic to accommodate both recording and file upload processing.

      Processing recording
    </Heading>
    Potential Race Condition

    The useEffect hook that handles redirection checks transcript.data which might be null during initial render. While there's a guard condition, the logic might still cause issues if transcript.data changes from null to a value with a status that requires redirection.

      if (!waiting || !transcript.data) return;
    
      const status = transcript.data.status;
      let newUrl: string | null = null;
    
      if (status === "processing" || status === "uploaded") {
        newUrl = `/transcripts/${params.transcriptId}/processing`;
      } else if (status === "recording") {
        newUrl = `/transcripts/${params.transcriptId}/record`;
      } else if (status === "idle") {
        newUrl =
          transcript.data.source_kind === "file"
            ? `/transcripts/${params.transcriptId}/upload`
            : `/transcripts/${params.transcriptId}/record`;
      }
    
      if (newUrl) {
        // Shallow redirection does not work on NextJS 13
        // https://github.com/vercel/next.js/discussions/48110
        // https://github.com/vercel/next.js/discussions/49540
        router.replace(newUrl);
      }
    }, [waiting, transcript.data?.status, transcript.data?.source_kind]);
    Duplicate Redirection

    There are two different mechanisms that redirect to the processing page: one in the useEffect hook when status changes to "uploaded" or "processing", and another in the onUploadComplete callback of FileUploadButton. This could lead to multiple redirects.

    onUploadComplete={() =>
      router.replace(`/transcripts/${params.transcriptId}/processing`)
    }

    Comment on lines 54 to +77
    useEffect(() => {
    if (waiting) {
    const newUrl = "/transcripts/" + params.transcriptId + "/record";
    if (!waiting || !transcript.data) return;

    const status = transcript.data.status;
    let newUrl: string | null = null;

    if (status === "processing" || status === "uploaded") {
    newUrl = `/transcripts/${params.transcriptId}/processing`;
    } else if (status === "recording") {
    newUrl = `/transcripts/${params.transcriptId}/record`;
    } else if (status === "idle") {
    newUrl =
    transcript.data.source_kind === "file"
    ? `/transcripts/${params.transcriptId}/upload`
    : `/transcripts/${params.transcriptId}/record`;
    }

    if (newUrl) {
    // Shallow redirection does not work on NextJS 13
    // https://github.com/vercel/next.js/discussions/48110
    // https://github.com/vercel/next.js/discussions/49540
    router.replace(newUrl);
    // history.replaceState({}, "", newUrl);
    }
    }, [waiting]);
    }, [waiting, transcript.data?.status, transcript.data?.source_kind]);
    Copy link
    Contributor

    Choose a reason for hiding this comment

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

    Suggestion: Add router and params to the dependency array of the useEffect hook to ensure the effect runs when these dependencies change. [possible issue, importance: 8]

    Suggested change
    useEffect(() => {
    if (waiting) {
    const newUrl = "/transcripts/" + params.transcriptId + "/record";
    if (!waiting || !transcript.data) return;
    const status = transcript.data.status;
    let newUrl: string | null = null;
    if (status === "processing" || status === "uploaded") {
    newUrl = `/transcripts/${params.transcriptId}/processing`;
    } else if (status === "recording") {
    newUrl = `/transcripts/${params.transcriptId}/record`;
    } else if (status === "idle") {
    newUrl =
    transcript.data.source_kind === "file"
    ? `/transcripts/${params.transcriptId}/upload`
    : `/transcripts/${params.transcriptId}/record`;
    }
    if (newUrl) {
    // Shallow redirection does not work on NextJS 13
    // https://github.com/vercel/next.js/discussions/48110
    // https://github.com/vercel/next.js/discussions/49540
    router.replace(newUrl);
    // history.replaceState({}, "", newUrl);
    }
    }, [waiting]);
    }, [waiting, transcript.data?.status, transcript.data?.source_kind]);
    useEffect(() => {
    if (!waiting || !transcript.data) return;
    const status = transcript.data.status;
    let newUrl: string | null = null;
    if (status === "processing" || status === "uploaded") {
    newUrl = `/transcripts/${params.transcriptId}/processing`;
    } else if (status === "recording") {
    newUrl = `/transcripts/${params.transcriptId}/record`;
    } else if (status === "idle") {
    newUrl =
    transcript.data.source_kind === "file"
    ? `/transcripts/${params.transcriptId}/upload`
    : `/transcripts/${params.transcriptId}/record`;
    }
    if (newUrl) {
    // Shallow redirection does not work on NextJS 13
    // https://github.com/vercel/next.js/discussions/48110
    // https://github.com/vercel/next.js/discussions/49540
    router.replace(newUrl);
    }
    }, [waiting, transcript.data?.status, transcript.data?.source_kind, router, params]);

    Comment on lines +49 to +55
    if (transcript.isLoading) {
    return (
    <VStack align="center" py={8}>
    <Heading size="lg">Loading transcript...</Heading>
    </VStack>
    );
    }
    Copy link
    Contributor

    Choose a reason for hiding this comment

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

    Suggestion: The loading state check should also handle the case when transcript.data is undefined, as the useEffect logic depends on it. [possible issue, importance: 7]

    Suggested change
    if (transcript.isLoading) {
    return (
    <VStack align="center" py={8}>
    <Heading size="lg">Loading transcript...</Heading>
    </VStack>
    );
    }
    if (transcript.isLoading || !transcript.data) {
    return (
    <VStack align="center" py={8}>
    <Heading size="lg">Loading transcript...</Heading>
    </VStack>
    );
    }

    @smankovsky smankovsky changed the title Add proccessing page to file upload and reprocessing fix: add proccessing page to file upload and reprocessing Sep 15, 2025
    @tito tito changed the title fix: add proccessing page to file upload and reprocessing fix: add processing page to file upload and reprocessing Sep 16, 2025
    const status = transcript.data?.status;
    if (!status) return;

    if (status === "ended" || status === "error") {
    Copy link
    Contributor

    Choose a reason for hiding this comment

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

    logic dupe with www/app/(app)/transcripts/[transcriptId]/page.tsx - only allow dupes when it's different business processes


    type FileUploadButton = {
    transcriptId: string;
    onUploadComplete?: () => void;
    Copy link
    Contributor

    Choose a reason for hiding this comment

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

    nit: "onComplete" (we already know it's Upload from the name)

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

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    Accessing a transcript while reprocessing redirect you to /record

    3 participants