Skip to content

Use absolute paths in clipboard text instead of @.rfa prefix#86

Merged
fgilio merged 1 commit intomainfrom
claude/rfa-full-paths-9w8sB
May 5, 2026
Merged

Use absolute paths in clipboard text instead of @.rfa prefix#86
fgilio merged 1 commit intomainfrom
claude/rfa-full-paths-9w8sB

Conversation

@fgilio
Copy link
Copy Markdown
Owner

@fgilio fgilio commented May 5, 2026

Summary

Changed the clipboard text generation to use absolute file paths instead of the @.rfa/ prefix notation. This makes the exported paths more explicit and easier to work with in various contexts.

Key Changes

  • Modified clipboardText() method to accept the full file path instead of just the basename
  • Updated clipboard text templates to use the complete path directly rather than constructing @.rfa/{basename}
  • Updated all test assertions to verify the new absolute path format
  • Updated README documentation to reflect the new path format in examples

Implementation Details

  • The export() method now passes the full $path to clipboardText() instead of $basename
  • Clipboard text now includes the complete absolute path to the exported markdown file
  • Tests were refactored to be more maintainable by checking the prefix separately from the filename pattern, making them less brittle to path changes

https://claude.ai/code/session_01QsSDogBG9br2K8wUnsHjZN

Summary by CodeRabbit

  • Bug Fixes

    • Fixed exported review markdown paths to use absolute repository paths instead of relative references for improved clarity and consistency.
  • Documentation

    • Updated example instructions in README to reflect absolute path usage in export functionality.

The @-mention only resolved relative to the agent's current working
directory, which silently broke when the user pasted from a different
shell. Drop the @ and emit the full path so the file resolves no matter
where it's pasted.

https://claude.ai/code/session_01QsSDogBG9br2K8wUnsHjZN
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 5, 2026

📝 Walkthrough

Walkthrough

The export clipboard text now references the full file path instead of a basename-only reference. CommentExporter::clipboardText() was updated to accept and interpolate the complete path, and test assertions were tightened to verify the deterministic tmp directory prefix.

Changes

Export Path Clarity

Layer / File(s) Summary
Documentation
README.md
Example .md export instruction path changed from relative @.rfa/{timestamp}_comments_{hash}.md to absolute /absolute/path/to/repo/.rfa/{timestamp}_comments_{hash}.md.
Core Implementation
app/Services/CommentExporter.php
export() now passes full $path to clipboardText() instead of $basename; helper method signature updated to accept string $path and interpolate it directly in clipboard message templates.
Tests
tests/Unit/CommentExporterTest.php
Clipboard assertions replaced broad regex patterns with two-step checks: explicit toStartWith() for the deterministic tmp directory prefix, then regex match for the timestamped filename suffix.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • fgilio/rfa#40: Modifies the clipboard text content and format in the same CommentExporter export/clipboard generation logic.

Poem

Paths laid bare, no more disguise, ✨
Absolute truth replaces the lies,
From @.rfa to the real address shown—
Clarity reigns in each test now known. 📝

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the main change: switching from relative @.rfa prefix references to absolute file paths in clipboard text generation.
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.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
app/Services/CommentExporter.php (1)

24-29: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Absolute-path contract is not enforced at the exporter boundary.
$path is only as absolute as incoming $repoPath. If a caller passes a relative repo path, clipboard text becomes relative again, which conflicts with this PR’s stated behavior.

Proposed fix
 public function export(string $repoPath, array $comments, string $globalComment = '', array $diffContext = [], CommentExportKind $kind = CommentExportKind::Review): array
 {
+    if (! str_starts_with($repoPath, '/')) {
+        throw new RuntimeException("Repository path must be absolute: {$repoPath}");
+    }
+
     $basename = date('Ymd_His').'_comments_'.Str::random(8);
     $rfaDir = $repoPath.'/.rfa';
     $path = "{$rfaDir}/{$basename}.md";

Also applies to: 38-46

🤖 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 `@app/Services/CommentExporter.php` around lines 24 - 29, The export method
currently builds $rfaDir and $path directly from the incoming $repoPath, so a
relative $repoPath yields relative clipboard paths; fix by normalizing/enforcing
an absolute repo path at the start of export: resolve $repoPath with
realpath($repoPath) and if realpath returns false, prefix $repoPath with
getcwd() (or otherwise convert to an absolute path) before computing $rfaDir and
$path; apply the same normalization wherever $repoPath is used later in this
file (lines around the other $rfaDir/$path uses referenced in the comment).
Ensure you update the export method and any other functions in this file that
construct $rfaDir/$path so $path is always absolute.
🧹 Nitpick comments (1)
tests/Unit/CommentExporterTest.php (1)

53-59: ⚡ Quick win

Add a regression test for relative repoPath input.
These assertions validate the happy path, but not the contract edge case: passing a relative repository path should be rejected (or normalized), so clipboard output never regresses to relative paths.

As per coding guidelines, "tests/**/*.php: Every code change must be programmatically tested."

🤖 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 `@tests/Unit/CommentExporterTest.php` around lines 53 - 59, Add a regression
test in CommentExporterTest that verifies relative repoPath inputs are rejected:
create a new test (e.g., test('rejects relative repoPath', function () { ... }))
that calls $this->exporter->export('relative/path', [], 'test') and uses
$this->expectException(InvalidArgumentException::class) (or the project's
canonical validation exception) before invoking export; this ensures the
export(string $repoPath, ...) contract on the export method enforces
absolute/normalized paths and prevents clipboard output from containing relative
paths.
🤖 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.

Outside diff comments:
In `@app/Services/CommentExporter.php`:
- Around line 24-29: The export method currently builds $rfaDir and $path
directly from the incoming $repoPath, so a relative $repoPath yields relative
clipboard paths; fix by normalizing/enforcing an absolute repo path at the start
of export: resolve $repoPath with realpath($repoPath) and if realpath returns
false, prefix $repoPath with getcwd() (or otherwise convert to an absolute path)
before computing $rfaDir and $path; apply the same normalization wherever
$repoPath is used later in this file (lines around the other $rfaDir/$path uses
referenced in the comment). Ensure you update the export method and any other
functions in this file that construct $rfaDir/$path so $path is always absolute.

---

Nitpick comments:
In `@tests/Unit/CommentExporterTest.php`:
- Around line 53-59: Add a regression test in CommentExporterTest that verifies
relative repoPath inputs are rejected: create a new test (e.g., test('rejects
relative repoPath', function () { ... })) that calls
$this->exporter->export('relative/path', [], 'test') and uses
$this->expectException(InvalidArgumentException::class) (or the project's
canonical validation exception) before invoking export; this ensures the
export(string $repoPath, ...) contract on the export method enforces
absolute/normalized paths and prevents clipboard output from containing relative
paths.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 77c75cc7-a6e3-457d-afb0-abc1071c5ff6

📥 Commits

Reviewing files that changed from the base of the PR and between 2ce3bd2 and 8a607da.

📒 Files selected for processing (3)
  • README.md
  • app/Services/CommentExporter.php
  • tests/Unit/CommentExporterTest.php

@fgilio fgilio merged commit 8eb56d4 into main May 5, 2026
15 checks passed
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.

2 participants