Skip to content

feat: tell API clients which guild made a commit appear in Following - #1649

Open
shanesmithdev wants to merge 1 commit into
dev-null-sh:productionfrom
shanesmithdev:feat/api-following-joined-guild
Open

shanesmithdev wants to merge 1 commit into
dev-null-sh:productionfrom
shanesmithdev:feat/api-following-joined-guild

Conversation

@shanesmithdev

@shanesmithdev shanesmithdev commented Nov 19, 2026 •

Copy link
Copy Markdown

Summary

On the web, a commit that's in your Following log only because you joined a guild says "because you joined #handle". The signed API's Following log didn't carry that, so the apps couldn't have feature parity with that message.

Signed GET api/v1/log/following now gives each commit in data a joined_guild: the guild's handle, or null. It has the same name and meaning as on the web. It's null for commits by you or by people and organizations you follow, and null when guilds aren't available to you.

Trending, Latest, the suggestions on an empty Following log, and nested commits (reply previews, parents, quotes) don't change: they have no joined_guild key.

Changes

  • Api/LogController::show calls the web's GuildCommitsQuery::joinedFor() on the same page, for Log::Following only. It sets the result on each commit with setAttribute('joined_guild', …).
  • CommitResource sends it with whenHas('joined_guild'), the way Api/SuggestedUserController and UserResource handle is_followed. So the key only appears where the controller set it.
  • I left ShownStreams and ShownCommitResource alone because perf: paginate guild data without global preloads #1615 rewrites them. The one-line CommitResource addition merges cleanly with perf: paginate guild data without global preloads #1615's version of it, and it still works with perf: paginate guild data without global preloads #1615's GuildMentionCollection, which resolves each resource as before.
  • joinedFor() runs a fixed few queries per page. guild is already eager-loaded on log commits, so there's no per-commit query. A new test locks that in for Following.
  • KNOWLEDGE_BASE.md: one new line in the signed API's capability list.

Validation

Local only (macOS, PHP 8.5, Postgres 18 with pgvector and pg_trgm).

  • vendor/bin/pest tests/Feature/Controllers/Api/LogControllerTest.php: 27/27 on a clean production before the change, 33/33 after. The new tests cover:
    • a joined guild's board post → handle;
    • a joined guild's hashtag commit by someone you don't follow → handle;
    • commits by someone you follow, and your own → null;
    • a muted guild's commits are left out, and nothing left names a guild;
    • Trending and Latest have no joined_guild key;
    • guilds switched off → the handle shown before is gone and the key is null;
    • the Following query count stays flat from 2 to 10 guild commits.
  • composer test: passed. That's Pint, Rector, oxlint and formatting, PHPStan with 0 errors, TS types, 100% type coverage, Pest 6,493 passed with 100.0% line coverage, and the Bun unit tests, 1,106 passed.

Independent review

I reviewed each line of code again before submitting the PR and stand by them.

I also had a separate review agent (with no part in the changes) had a look at it:

  • Reviewer: Separate agent. It got the requirements and the code, not the implementation notes.
  • Base: 6d3a957013be5a7e75cf8e7b801acbee54f07800 (upstream production)
  • Head: 90094cee5727b2e9e9a5c3701ac6eafa2284d8b2, the reviewed working-tree diff with sha256 de713be257a401e37e762fde93e5c6964ac645e46c7fccefd5b7c5b2ecc8eeac
  • Verdict: CODE: PASS, with no blocking findings. An earlier pass on the previous revision also passed. Its suggestions led to a few test renames and the Following query-count test before I submitted the PR.
  • Limits: the reviewer ran the API log test file, Pint, Rector and PHPStan on the changed files, and a 3-way merge against perf: paginate guild data without global preloads #1615's CommitResource and API log tests. It didn't run the full suite or exercise a real app client.

Limitations

  • With guilds off, or a guild muted, Following already drops every commit that could carry a handle. So the guilds-off and muted tests show the endpoint's behavior (key present and null, muted commits absent), but they can't catch a regression inside joinedFor() alone. The web's guild tests cover joinedFor() directly.
  • The NativePHP app doesn't read joined_guild yet. That's a separate change that I'll implement once this is merged.

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features
    • Following log entries now identify the joined guild associated with each commit. Entries without a matching guild show no attribution, and muted guilds are excluded.
    • Guild attribution appears only in Following log responses; latest and trending logs do not include it.
  • Documentation
    • Signed API documentation now explains how to read guild attribution in Following logs.

@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The API now includes joined-guild attribution on commits in Following logs. Other log types do not receive this assignment. The signed commit resource returns joined_guild when the attribute is present.

Changes: Following Log Guild Attribution

Layer / File(s) Summary
Assign and return joined-guild attribution
app/Http/Controllers/Api/LogController.php, app/Http/Resources/CommitResource.php, tests/Feature/Controllers/Api/LogControllerTest.php, KNOWLEDGE_BASE.md
The controller loads joined-guild data for paginated Following commits and assigns a matching guild or null. The resource conditionally includes joined_guild. Tests cover attribution, muted guilds, other log types, feature settings, and query counts. The API capability list documents the attribution.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant LogController
  participant GuildCommitsQuery
  participant CommitResource
  Client->>LogController: Request Following log
  LogController->>GuildCommitsQuery: Load guilds for paginated commits
  GuildCommitsQuery-->>LogController: Return joined-guild data
  LogController->>LogController: Assign matching guild or null
  LogController->>CommitResource: Serialize commits
  CommitResource-->>Client: Return commits with joined_guild when present
Loading

Possibly related PRs

  • dev-null-sh/dev-null.sh#1576: Adds guild behavior that brings matching commits into Following, which this change annotates with the joined guild.

Suggested reviewers: simonhamp, paulinevos

Merge Risk: Minimal · up to 58acc

The change adds a joined_guild field to commits in the Following log. No concrete merge-blocking risk was found, and other log types are unaffected.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "feat: tell API clients which guild made a commit appear in Following" matches the main change. The PR adds a joined_guild field to the signed GET api/v1/log/following response. It names the…
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.
Full details: Title check

Explanation

The title "feat: tell API clients which guild made a commit appear in Following" matches the main change. The PR adds a joined_guild field to the signed GET api/v1/log/following response. It names the guild that brought a commit into Following, which is the core behavior in the summary, the objectives, and the tests. The title does not cover the null cases or the unchanged endpoints, which is expected for a short title.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 47c4519c-4a65-4d04-9057-78c4ce7da348
Commits

Reviewing files that changed from the base of the PR and between 65c386c and 58acc49.

Files selected for processing: 2

  • KNOWLEDGE_BASE.md
  • app/Http/Resources/CommitResource.php

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@paulinevos

Copy link
Copy Markdown
Contributor

lgtm just needs a merge now!

@shanesmithdev
shanesmithdev force-pushed the feat/api-following-joined-guild branch from 90094ce to 65c386c Compare November 20, 2026 12:25
@shanesmithdev

Copy link
Copy Markdown
Author

Rebased recent commits from production onto this branch.

The signed Following log now gives each commit a joined_guild: the
handle of the joined guild that brought that commit there, or null. This
matches how the web's "because you joined" message works.

Trending, Latest, suggestions and nested commits are unchanged.
@shanesmithdev
shanesmithdev force-pushed the feat/api-following-joined-guild branch from 65c386c to 58acc49 Compare November 20, 2026 12:30
@shanesmithdev

Copy link
Copy Markdown
Author

Sorry @paulinevos I didn't notice your comment approval until after I'd pushed a rebase, not sure if that undid anything.

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