Skip to content

feat: add shared truncated address component - #463

Open
Godfrey-Delight wants to merge 2 commits into
Stellar-Ecosystem:mainfrom
Godfrey-Delight:feat/address-truncation-copy-component
Open

feat: add shared truncated address component#463
Godfrey-Delight wants to merge 2 commits into
Stellar-Ecosystem:mainfrom
Godfrey-Delight:feat/address-truncation-copy-component

Conversation

@Godfrey-Delight

@Godfrey-Delight Godfrey-Delight commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Adds a shared StellarAddress.tsx component with middle truncation (first 6/last 4 chars), an explorer link to Stellar Expert, a custom dark tooltip showing the full address on hover with select-all support, a one-click copy button that shows a "Copied" badge for 1.5s, and an sr-only label for screen readers. Integrates it into ServiceCard.tsx, AgentCard.tsx, and agents/[address]/page.tsx (both the profile header and the owner field), removing duplicate local truncation/copy helpers and clipboard state along the way. Fixes two pre-existing issues surfaced during integration: a missing makeAgent helper in sort.test.ts and a missing registered_at field in RegistryPage.test.tsx's mocked services.
Closes #395

Summary by CodeRabbit

  • New Features

    • Added a shared Stellar address display with truncated text, full-address accessibility support, explorer links, hover details, and copy-to-clipboard feedback.
    • Updated agent and service views to use the consistent address display.
    • Empty addresses are handled gracefully without rendering.
  • Tests

    • Added coverage for address formatting, accessibility, links, custom styling, clipboard behavior, and empty states.

Adds a shared StellarAddress.tsx component with middle truncation (first 6/last 4 chars), an explorer link to Stellar Expert, a custom dark tooltip showing the full address on hover with select-all support, a one-click copy button that shows a "Copied" badge for 1.5s, and an sr-only label for screen readers. Integrates it into ServiceCard.tsx, AgentCard.tsx, and agents/[address]/page.tsx (both the profile header and the owner field), removing duplicate local truncation/copy helpers and clipboard state along the way. Fixes two pre-existing issues surfaced during integration: a missing makeAgent helper in sort.test.ts and a missing registered_at field in RegistryPage.test.tsx's mocked services.
Closes Stellar-Ecosystem#395
@drips-wave

drips-wave Bot commented Jul 29, 2026

Copy link
Copy Markdown

@Godfrey-Delight Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 202bdeb9-3d20-4abe-9552-b2fbf151eef8

📥 Commits

Reviewing files that changed from the base of the PR and between 4969eac and 94e19a0.

📒 Files selected for processing (1)
  • frontend/components/ServiceCard.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/components/ServiceCard.tsx

📝 Walkthrough

Walkthrough

Changes

Stellar address display

Layer / File(s) Summary
StellarAddress component and coverage
frontend/components/StellarAddress.tsx, frontend/__tests__/StellarAddress.test.tsx
Adds truncated rendering, accessible full-address text, explorer linking, clipboard copying, temporary confirmation, and empty-address handling.
Agent and service integrations
frontend/app/agents/[address]/page.tsx, frontend/components/AgentCard.tsx, frontend/components/ServiceCard.tsx
Replaces duplicated address links and copy logic with StellarAddress. The agent metadata value accepts React nodes.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant StellarAddress
  participant Stellar Explorer
  participant Clipboard API
  User->>StellarAddress: View Stellar address
  StellarAddress->>Stellar Explorer: Open account URL
  User->>StellarAddress: Click copy button
  StellarAddress->>Clipboard API: Write full address
  Clipboard API-->>StellarAddress: Resolve copy request
  StellarAddress-->>User: Show Copied confirmation
Loading

Suggested reviewers: ritik4ever

🚥 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: adding a shared component for truncated addresses.
Linked Issues check ✅ Passed The changes satisfy issue #395 by adding consistent truncation, copy confirmation, explorer links, hover details, and screen-reader access.
Out of Scope Changes check ✅ Passed The changes remain within issue #395 scope and include shared-component tests plus required integrations.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
frontend/app/agents/[address]/page.tsx (1)

366-366: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Import ReactNode explicitly.

This module uses React.ReactNode but does not import the React global; relying on a UMD global in a module makes the API surface fragile. Use import type { ReactNode } from 'react' and value: ReactNode.

🤖 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 `@frontend/app/agents/`[address]/page.tsx at line 366, Update the MetaItem type
signature to use an explicitly imported ReactNode type: add a type-only
ReactNode import from react and replace React.ReactNode in the value prop with
ReactNode, without relying on the React global.
🤖 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 `@frontend/components/StellarAddress.tsx`:
- Around line 20-21: Update the copied-state logic in StellarAddress to store
the timeout in a single ref, clear any existing timer before scheduling a new
one, and clear the timer during unmount cleanup. Add a regression test that
performs repeated copy actions and verifies the newer “Copied” state is not
cleared by the earlier timer.
- Around line 51-52: Update the tooltip div in StellarAddress to remove the
pointer-events-none class, allowing the address span’s existing select-all
behavior to work while preserving the other styling and hover behavior.

---

Nitpick comments:
In `@frontend/app/agents/`[address]/page.tsx:
- Line 366: Update the MetaItem type signature to use an explicitly imported
ReactNode type: add a type-only ReactNode import from react and replace
React.ReactNode in the value prop with ReactNode, without relying on the React
global.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e25be92b-d57b-4511-950f-88fa8462e0cc

📥 Commits

Reviewing files that changed from the base of the PR and between a3fd824 and 4969eac.

⛔ Files ignored due to path filters (1)
  • frontend/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (7)
  • frontend/__tests__/RegistryPage.test.tsx
  • frontend/__tests__/StellarAddress.test.tsx
  • frontend/app/agents/[address]/page.tsx
  • frontend/components/AgentCard.tsx
  • frontend/components/ServiceCard.tsx
  • frontend/components/StellarAddress.tsx
  • frontend/lib/sort.test.ts

Comment thread frontend/components/StellarAddress.tsx
Comment thread frontend/components/StellarAddress.tsx
@ritik4ever

Copy link
Copy Markdown
Collaborator

Hi @Godfrey-Delight,

This PR could not be merged because it has merge conflicts with the target branch.

Please resolve the merge conflicts, push the updated changes, and the PR can be reviewed and merged.

Thank you!

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.

Frontend: provider and agent addresses are shown without truncation or copy affordance

2 participants