Skip to content

Pets: a new name or photo reaches every copy of it - #325

Merged
renrenmimi merged 2 commits into
mainfrom
functions/pet-name-sync
Oct 14, 2026
Merged

renrenmimi merged 2 commits into
mainfrom
functions/pet-name-sync

Conversation

@renrenmimi

Copy link
Copy Markdown
Owner

Several places keep their own copy of a pet's name, and all but check-ins its photo, as they were when written:

  • posts;
  • followers' follow lists;
  • meetup rosters;
  • check-ins.

The apps show those copies, so a pet renamed or given a new photo went on showing the old ones everywhere but its own page. This was true on the web too. People's names have had onUserUpdated for this; pets had nothing. The owner approved the fix on 2026-10-14.

onPetUpdated runs when a pet's name or photo changes. It writes the pet's current values onto every copy:

Copy Fields Found by
posts petName, petAvatarUrl petId
follow lists petName, petAvatar followingPets collection group, petId
meetup rosters petName, petAvatar participants by userId over the pet's owners
check-ins petName checkins collection group, petId

How it behaves:

  • The values come from the pet as it is now, not from the event.
  • After writing, it looks at the pet again and goes round once more if the pet changed meanwhile. Two changes in quick succession, or copied out of order, therefore end with the latest.
  • A copy already up to date is not written.
  • A copy that went while the copies were being written (a follow undone) is left out, not written back.
  • A change to the pet's counts writes nothing.
  • Roster entries are found through the pet's owners. The index that exists is on userId, and deploying indexes from the file would remove production-only settings. An entry by someone who has since left the pet's family keeps its old copy.

Test project. The second commit adds onPetUpdated to the test project's entry, authorized with this change. The entry now expects 42 functions. It is deployed to petnote-devtest only.

Tests. Five new emulator tests:

  • a new name and photo reach all four kinds of copy, and another pet's post is left alone;
  • a change to the counts writes nothing;
  • an earlier change delivered last still ends with the latest name;
  • a rename during the copying is copied too;
  • a follow undone during the copying stays undone, and the rest are written.

Taking out the second look at the pet fails the fourth test; taking out the leaving-out fails the fifth. The full suite passes: 295 tests.

🤖 Generated with Claude Code

renrenmimi and others added 2 commits October 14, 2026 16:16
Posts, follow lists, meetup rosters and check-ins each keep the pet's
name, and all but check-ins its photo, as they were when written, and
the apps show those copies. A pet renamed or given a new photo went on
showing the old ones everywhere but its own page. People's names have
had onUserUpdated for this; pets had nothing.

onPetUpdated runs when a pet's name or photo changes and writes the
pet's current ones onto every copy, then looks at the pet again and goes
round once more if it changed in the meantime, so two changes in quick
succession end with the latest. A copy already up to date is not
written, and one that went while the copies were being written (a
follow undone) is left out rather than written back. Roster entries are
found through the pet's owners, on the index that exists.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Authorized by the owner on 2026-10-14 with the change that adds it, so
that it can be tested with many people on the test project. It binds no
secret, calls nothing outside and runs on no schedule; Firestore only.
The entry now expects 42 functions.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 14, 2026 23:20
@vercel

vercel Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
pet-note Ready Ready Preview Oct 14, 2026 11:20pm UTC

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-14T23:30:22.905998Z ffc651a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@renrenmimi
renrenmimi merged commit 6929c72 into main Oct 14, 2026
6 checks passed
@renrenmimi
renrenmimi deleted the functions/pet-name-sync branch October 14, 2026 23:28

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ffc651afbb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread functions/src/pets.ts
Comment on lines +794 to +795
db.collectionGroup("checkins").where("petId", "==", petId),
{ petName: name }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Provision the check-ins index before querying it

When onPetUpdated is deployed to petnote-devtest, every name or photo change executes this collection-group query, but STATUS.md:796-798 records that the test project deliberately does not have the checkins.petId single-field collection-group index. Its existing petId + createdAt DESC composite cannot satisfy this query's document-ID ordering, so the Promise.all rejects with FAILED_PRECONDITION and the trigger retries after potentially updating the other copy types. Provision the required index before exporting this trigger to the test project.

Useful? React with 👍 / 👎.

Comment thread functions/src/index.ts
createPetCallable,
deletePetCallable,
followPetCallable,
onPetUpdated,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Register the new trigger in the local acceptance shim

Exporting this trigger does not make it run in the repository's local acceptance environment: functions/scripts/callable-shim.mjs:278-298 manually enumerates every Firestore trigger and has no onPetUpdated entry. Consequently, editing a pet through the shim leaves posts, follows, rosters, and check-ins stale even though the same flow works after deployment, so local client-wiring acceptance cannot exercise the behavior introduced here. Add the pets collection update watcher alongside the export.

Useful? React with 👍 / 👎.

This branch was successfully deployed

1 active deployment
Preview — ffc651af Deployed Oct 14, 2026 by vercel[bot]
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