Skip to content

Add 'View full screen' compare links in diff comments#7

Merged
ritikrishu merged 1 commit intomainfrom
feature/compare-viewer
Feb 21, 2026
Merged

Add 'View full screen' compare links in diff comments#7
ritikrishu merged 1 commit intomainfrom
feature/compare-viewer

Conversation

@ritikrishu
Copy link
Contributor

@ritikrishu ritikrishu commented Feb 21, 2026

Summary

  • Propagate jobId from diff API response through to comment builder
  • Pass serviceUrl into DiffCommentData for link generation
  • Add "View full screen" link next to each modified frame name in PR comments, linking to /compare/:jobId?frame=FrameName on the screenshot service

Depends on: RemoteState/pencil-screenshot-service#10

Test plan

  • npm run build passes
  • Modified frames in diff comments show "View full screen" link
  • Link opens compare page filtered to the correct frame
  • No link shown when serviceUrl is not configured

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Diff comments now include "View full screen" links for modified frames when comparison data is available, enabling quick access to detailed comparisons.

- Propagate jobId from fetchDiff() response
- Pass serviceUrl into DiffCommentData
- Add "View full screen" link next to each modified frame name
  linking to /compare/:jobId?frame=FrameName

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Feb 21, 2026

📝 Walkthrough

Walkthrough

The pull request extends diff comment functionality by adding serviceUrl and jobId fields to support per-file compare links. The serviceUrl is propagated from inputs through the comment data structure, while jobId is attached to the diff response from the service layer. The comment builder then uses these fields to conditionally render "View full screen" links for modified frames.

Changes

Cohort / File(s) Summary
Type Extensions
src/types.ts
Added optional jobId?: string to DiffResponse and optional serviceUrl?: string to DiffCommentData interfaces.
Service Data Enhancement
src/renderers/service.ts
Assigns the submitted diff job's ID to the response object after polling completes (result.jobId = submitData.jobId).
Input Propagation
src/main.ts
Passes inputs.serviceUrl to the DiffCommentData object, adding the serviceUrl field to the diff comment payload.
Comment Rendering
src/comment-builder.ts
Updated buildDiffFileSection signature to accept optional serviceUrl parameter and modified frame rendering to optionally display "View full screen" links when both serviceUrl and file.diff.jobId are present.

Sequence Diagram

sequenceDiagram
    participant Inputs
    participant Main as Main Handler
    participant Service as Service Renderer
    participant CommentBuilder as Comment Builder
    participant Output as Diff Comment

    Inputs->>Main: Provide serviceUrl input
    Main->>Service: Submit diff request
    Service->>Service: Poll diff completion
    Service->>Service: Attach jobId to response
    Main->>Main: Include serviceUrl in DiffCommentData
    Main->>CommentBuilder: Call buildDiffComment with serviceUrl
    CommentBuilder->>CommentBuilder: For each file, check jobId + serviceUrl availability
    alt serviceUrl and jobId present
        CommentBuilder->>CommentBuilder: Render "View full screen" link in frame names
    else
        CommentBuilder->>CommentBuilder: Render original frame names
    end
    CommentBuilder->>Output: Generate final diff comment
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🐰 A service URL hops through the data flow,
With jobId attached, the compare links glow.
Frame names now sparkle with "View full screen" cheer,
Diff comments refined—the moment is here! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding 'View full screen' compare links to diff comments, which is the primary feature across all modified files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/compare-viewer

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

@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

🤖 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/comment-builder.ts`:
- Around line 396-403: The generated compare URL can get a double slash and uses
redundant optional chaining; normalize serviceUrl by trimming any trailing slash
before building compareUrl and use the already-in-scope diff.jobId instead of
file.diff?.jobId. Locate where compareUrl is created (variable compareUrl in the
block that references serviceUrl, file.diff, mod.frameName and escapeMarkdown)
and replace construction to use a normalized serviceUrl (remove trailing '/' if
present) and diff.jobId for the path, keeping encodeURIComponent(mod.frameName)
and existing escapeMarkdown(mod.frameName) logic unchanged.

Comment on lines +396 to +403
const compareUrl = serviceUrl && file.diff?.jobId
? `${serviceUrl}/compare/${file.diff.jobId}?frame=${encodeURIComponent(mod.frameName)}`
: null;
lines.push(
compareUrl
? `**${escapeMarkdown(mod.frameName)}** · [View full screen](${compareUrl})`
: `**${escapeMarkdown(mod.frameName)}**`
);
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Normalize serviceUrl before URL construction; use diff.jobId instead of file.diff?.jobId.

Two issues:

  1. Trailing slash (minor): serviceUrl is the raw value from inputs.serviceUrl, passed through DiffCommentData without normalization. ServiceRenderer's constructor strips trailing slashes (service.ts:98), but that doesn't apply here. If a user configures serviceUrl as https://svc.example.com/, the generated link becomes https://svc.example.com//compare/... (double slash).

  2. Redundant optional chaining (nitpick): At this point the code is already inside if (file.diff) (line 377) with const diff = file.diff in scope. file.diff?.jobId should be diff.jobId.

🔧 Proposed fix
-        const compareUrl = serviceUrl && file.diff?.jobId
-          ? `${serviceUrl}/compare/${file.diff.jobId}?frame=${encodeURIComponent(mod.frameName)}`
-          : null;
+        const baseUrl = serviceUrl?.replace(/\/+$/, '');
+        const compareUrl = baseUrl && diff.jobId
+          ? `${baseUrl}/compare/${diff.jobId}?frame=${encodeURIComponent(mod.frameName)}`
+          : null;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/comment-builder.ts` around lines 396 - 403, The generated compare URL can
get a double slash and uses redundant optional chaining; normalize serviceUrl by
trimming any trailing slash before building compareUrl and use the
already-in-scope diff.jobId instead of file.diff?.jobId. Locate where compareUrl
is created (variable compareUrl in the block that references serviceUrl,
file.diff, mod.frameName and escapeMarkdown) and replace construction to use a
normalized serviceUrl (remove trailing '/' if present) and diff.jobId for the
path, keeping encodeURIComponent(mod.frameName) and existing
escapeMarkdown(mod.frameName) logic unchanged.

@ritikrishu ritikrishu merged commit b06fe05 into main Feb 21, 2026
1 check passed
@ritikrishu ritikrishu deleted the feature/compare-viewer branch February 21, 2026 18:07
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.

1 participant