Skip to content

Add username + profile link to sidebar#1138

Open
matmanna wants to merge 6 commits intohackclub:mainfrom
matmanna:profile-links
Open

Add username + profile link to sidebar#1138
matmanna wants to merge 6 commits intohackclub:mainfrom
matmanna:profile-links

Conversation

@matmanna
Copy link
Copy Markdown
Member

@matmanna matmanna commented Apr 6, 2026

Before:

image

After:

image

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 6, 2026

Greptile Summary

This PR adds the current user's username to the Inertia sidebar nav props in InertiaController, and conditionally renders a clickable @username profile link in AppLayout that opens the user's public hackati.me profile in a new tab.

  • Adds username to inertia_nav_current_user in InertiaController — clean, one-line addition
  • Conditionally renders a profile link in AppLayout when username is non-null, with correct null-guarding in both the TypeScript type (username?: string | null) and the Svelte template ({#if layout.nav.current_user.username})
  • The URL format https://hackati.me/@${username} is consistent with route definitions in config/routes.rb (/@:username)
  • Using an <a> tag (rather than Inertia's <Link />) is appropriate here since hackati.me is an external domain
  • No tests were added for the new nav prop
  • This PR's correct URL format surfaces a pre-existing bug in app/controllers/settings/base_controller.rb:164 where profile_url omits the @ prefix, which would cause 404s for users navigating from the settings badge page

Confidence Score: 4/5

Safe to merge — small, well-guarded UI change with no logic risk

The change is minimal and correct: username is properly nil-guarded in Svelte, the URL format matches the app routes, and the TypeScript type is accurate. Minor concerns: no tests for the new nav prop, and a pre-existing profile URL bug in settings/base_controller.rb is surfaced (but not introduced) by this PR.

No files in this PR need special attention; the pre-existing URL bug is in app/controllers/settings/base_controller.rb (not part of this diff)

Important Files Changed

Filename Overview
app/controllers/inertia_controller.rb Adds username field to inertia_nav_current_user hash — straightforward one-line addition with no side effects
app/javascript/layouts/AppLayout.svelte Wraps display name in a flex column and conditionally renders a profile link using the correct @username URL format; no test coverage added

Sequence Diagram

sequenceDiagram
    participant B as Browser
    participant IC as InertiaController
    participant AL as AppLayout (Svelte)
    participant H as hackati.me

    B->>IC: GET page request
    IC->>AL: Inertia props (nav.current_user includes username)
    AL->>B: Renders sidebar with @username profile link
    B->>H: User clicks → GET /@username
    H->>B: Returns public profile page
Loading
Prompt To Fix All With AI
This is a comment left during a code review.
Path: app/javascript/layouts/AppLayout.svelte
Line: 317-318

Comment:
**Inconsistent profile URL format elsewhere in codebase**

This PR correctly uses `https://hackati.me/@${username}` which matches the `/@:username` route pattern defined in `config/routes.rb:309`. However, `app/controllers/settings/base_controller.rb:164` builds `profile_url` without the `@`:

```ruby
profile_url: (@user.username.present? ? "https://hackati.me/#{@user.username}" : nil)
```

This produces `https://hackati.me/username` (no `@` prefix), which doesn't match any defined route and would result in a 404. That line should be updated to:

```ruby
profile_url: (@user.username.present? ? "https://hackati.me/@#{@user.username}" : nil)
```

This is a pre-existing bug surfaced by this PR's addition of the correct URL format.

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: app/controllers/inertia_controller.rb
Line: 138

Comment:
**No tests for new nav prop**

The PR adds `username` to the Inertia nav props but doesn't include any tests verifying that this field is present and correctly passed through. Per project conventions, new functionality should include test coverage. A basic controller or integration test asserting `username` is present in the nav props would improve confidence in this change.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "feat: show username in sidebar" | Re-trigger Greptile

Comment thread app/javascript/layouts/AppLayout.svelte Outdated
Comment thread app/controllers/inertia_controller.rb
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