Skip to content

Split a bonus chore's Stars among several people - #407

Merged
jherforth merged 5 commits into
jherforth:mainfrom
adamecker:feature/bonus-chore-split-assign
Nov 30, 2026
Merged

jherforth merged 5 commits into
jherforth:mainfrom
adamecker:feature/bonus-chore-split-assign

Conversation

@adamecker

@adamecker adamecker commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

What this does

A bonus chore in the pool can now be split among several people instead of going to one person. Long-press (or right-click) a bonus chore card to open the picker, tick at least two people, and confirm — the chore is shared, and each person ticks their own share.

How the Stars split: each person gets the floor of the total over the number of people, and the leftover Stars go one each to the first people picked — 10 over 2 is [5, 5], 7 over 2 is [4, 3], 10 over 3 is [4, 3, 3]. The picker shows each person's share live before confirming, so what you see is what each person gets.

How it works:

  • The split rides on the one pool schedule as split_user_ids / split_shares (two parallel lists, modelled on prize_offers.split_user_ids), so the chore keeps its definition, icon, follow-ups, claimers list and history. Nothing is copied and the original is never deleted.
  • The card shows in each selected person's column, stamped with their share — Emma sees "+8 ⭐" and Liam sees "+7 ⭐" for a 15-Star chore split 8/7.
  • Each person ticks their own share. Completing writes their share to their history row (chore_history.clam_value is already per-row), so Emma earns 8 Stars, not the chore's full 15.
  • The nightly return clears the split along with the claim marker, so tomorrow it is one chore in the pool again. A share already ticked stays earned.
  • Back to the pool releases the whole split at once: transferring the chore back returns every part, while shares already ticked stay earned. Handing it to one person instead gives them the whole chore at its full Stars.

How to use it:

  • Long-press (touch) or right-click a bonus chore card in the Chores widget.
  • Tick at least two people; each selected person's share shows next to their name.
  • Confirm with Split. The dialog shows the result (each person and their Stars) and how to undo it.

Undo: transfer the chore back to the bonus pool — the whole split comes back, and any share already ticked stays earned.

Limits and checks:

  • A split is refused when any share would be 0 Stars (more people than Stars), so nobody gets a 0-Star chore that counts toward their daily bonus and never returns to the pool. The picker stops offering more people once the count reaches the Stars.
  • The split respects the chore's "who can take this" list: everyone in it must be on the list, or the split is refused with CHORE_NOT_OFFERED, the same check the claim route runs. The picker leaves people who are not on the list out.
  • The split respects the one-open-bonus-chore rule: a person who already has an open bonus chore — assigned or holding a split share — cannot be picked, the same check the claim route runs, so a second display cannot race past it. The picker disables those people. The one-open-bonus check is now one shared helper used by the claim and split routes.
  • The split control is hideable on a display like Transfer is (core:splitChore in the control limits): hiding it removes the long-press and right-click entry points and closes an open picker.
  • The nightly prune only takes a split once every share is ticked: one person's completion no longer prunes the schedule out from under the others. A partially done split returns to the pool; a fully done one is pruned like any completed one-time chore.

Verification

  • Server suite: 855 pass, 0 fail. Client suite: 104 files, 1130 tests, all pass. Client build passes. i18n check passes (2067/2067 keys).
  • 14 server tests cover the new shape: the one schedule kept with its split lists, remainder order, validation, the 0-Star refusal, the claimers-list 403, the one-open-bonus rule, each person earning only their share, a split share counting as an outstanding bonus chore, back-to-pool releasing the whole split, a completed share staying earned, the nightly return clearing the split, the prune waiting for every share, and a non-split return unchanged. Client tests cover the split helpers and the split-aware outstanding check, plus the existing splitStars unit tests.
  • Verified in a headless browser: a true long-press (held past the 450 ms threshold) opens the picker; picking Emma and Liam for a 15-Star chore shows 8 and 7 with "Splitting 15 ⭐ between 2 people"; confirming shows "Split 15 ⭐" with Emma 8 and Liam 7 plus the undo hint. After closing, the card shows in Emma's column with "+8 ⭐" and Liam's with "+7 ⭐", and the pool no longer lists it. Ticking Emma's share writes an 8-Star completion to her history and moves her total from 21 to 29. Transferring the chore back to the pool from Liam's still-open card releases the whole split — the schedule is one 15-Star pool chore again — while Emma's earned 8 stays in her history and her total stays 29. Splitting again and running the nightly job clears the split (the nightly result reports one split schedule returned) so it is one pool chore again, with Emma's earned 8 still in her history.

Generated with Muse AI 🤖

@jherforth jherforth left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks for this. Splitting a bonus chore is a good idea, and the picker and the share rule are nicely done. But making a copy of the chore for each person ends up changing the household's chore list for good, so I'd like to change the approach before this goes in.

What happens on a real server

A daily 10⭐ "Sweep" with an icon and a follow-up, split between Ava and Liam, then the nightly job (GET /api/system/backgroundTasks):

Chore definitions Pool
Before Sweep 10⭐, with its follow-up Sweep 10⭐
After the split the original, plus two copies at 5⭐ (no follow-up) empty
After one night the original is deleted (the orphaned-chore prune); two 5⭐ copies remain two separate "Sweep 5⭐" chores, every day from now on
  1. One split changes the chore list for good.
    • The original definition is pruned the first night, with its follow-up and its "who can take this" list (#404).
    • Each copy carries pool_claimed_on, so the nightly job returns it to the pool as its own smaller chore. A recurring chore never comes back as one.
    • Undo returns the parts separately too.
    • History keyed by chore (the 7-day row, one person's history of a chore) is spread across the new chore ids.
  2. Shares can be 0⭐. 3⭐ split four ways gave one person a 0⭐ copy. A chore worth 0⭐ isn't a bonus chore, so that copy becomes an ordinary chore assigned to them: it counts toward their daily bonus, logs misses, and, if it repeats, never goes back to the pool. A split should be refused when there are more people than Stars.
  3. Undo reaches other people's chores. One child transferring their part back to the pool also takes the other children's open parts from them.
  4. #404 (who can take this) has merged. The split should check the chore's list (choreClaimers.mayClaim, 403 CHORE_NOT_OFFERED), and the picker should leave out people who aren't on it.
  5. Control Limits. Something that changes chores this much should be hideable on a wall display, like Transfer (isControlHidden).
  6. Conflicts with main: five client files conflict with #404, and #404 took migration 44, so this one becomes 45.

A shape that fits HomeGlow's model

The prize store already splits without copying anything: prize_offers.split_user_ids lists the people sharing a cost. The same idea works for chores:

  • Keep the one pool schedule. A split claims it for several people: it carries pool_claimed_on as today, plus the people and their shares, for example a split_user_ids / split_shares pair, or one JSON column.
  • The card shows in each person's column, and each person ticks their own share.
  • Completion writes that person's history row with their share. chore_history.clam_value is already per row, so nothing new is needed there.
  • The nightly return clears the split along with the claim marker, so tomorrow it's one chore in the pool again.
  • "Back to the pool" releases the whole split, with no copies to collect. A share already ticked stays earned.

The chore keeps its definition, icon, follow-ups, list and history. Your picker, splitStars and most of the dialog carry over as they are.

While you're in there

  • The one-open-bonus check is now copied in three places: claim, split, and the client. A small hasOutstandingBonusChore(userId, today) on the server would keep them from drifting.
  • The routine check is good. Keep it.

Happy to talk through the data shape here before you rework it.

adamecker added 3 commits November 29, 2026 01:28
Long-press (or right-click) a bonus chore card to open a picker of
household users. Tick at least two people and each gets their share of
the chore's Stars — floor(N/k) each, with the leftover Stars going one
each to the first people picked. Confirming creates one copy of the
chore per person, worth that person's share, and consumes the pool
chore; each copy carries a shared split_group_id so the split can be
undone by transferring any part back to the pool (every still-open
part comes back as its own pool chore).

- POST /api/chore-schedules/:id/split-assign validates the pool bonus
  chore, the users, and the one-open-bonus rule, then creates the
  copies in a transaction.
- PATCH returning a split part to the pool returns all still-open
  parts of that split group; completed parts stay completed.
- Migration schema44 adds chore_schedules.split_group_id.
- Client: press-and-hold (touch and mouse) on bonus cards via the
  shared createPressHold util, a picker dialog with a live per-person
  preview, and the split result shown in the dialog.
- Tests: 8 new server tests (splits, remainders, validation, the
  one-open-bonus rule, group return on undo) and splitStars unit tests.

Generated with Muse AI 🤖
The result view renders each person's share in a ListItem, but
ListItem was never imported — confirming a split threw
ReferenceError: ListItem is not defined and the dialog closed
without showing the result. The split itself succeeded
server-side; only the result display crashed.

Generated with Muse AI 🤖
The split now rides on the one pool schedule as split_user_ids /
split_shares (modelled on prize_offers.split_user_ids) instead of
copying the chore per person. The card shows in each selected person's
column, each person ticks their own share, and completing writes their
share to their history row — so the chore keeps its definition, icon,
follow-ups, list and history. The nightly return clears the split, so
tomorrow it is one chore again, and back to the pool releases the whole
split while shares already ticked stay earned. A split is refused when
any share would be 0 Stars, everyone in it must be on the chore's
claimers list, the split control is hideable like Transfer, and the
one-open-bonus check is one shared helper used by the claim and split
routes. The nightly prune only takes a split once every share is ticked.

Generated with Muse AI 🤖
@adamecker
adamecker force-pushed the feature/bonus-chore-split-assign branch from f4c7eed to 6ff9fa8 Compare November 29, 2026 01:52

@jherforth jherforth left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks, Adam. This rework is exactly the shape we talked about. The one pool schedule carries the split, nothing is copied or deleted, each person earns only their share, and the nightly return makes it one chore again. Everything from the first review is in: no 0⭐ shares, the "who can take this" list, the shared one-open-bonus check (counting split shares), Control Limits, and rebased onto main with migration 46.

I ran it on a real server, and a split that's partly ticked can still pay out more than the chore is worth. There are three things to fix before it goes in.

What happens

A 10⭐ daily chore split between Ava and Ben (5 + 5), all on the same day:

Case Result
Ava ticks her 5⭐, then Ben's card is transferred to Cal PATCH user_id: Cal clears the split and gives Cal the whole chore. Cal ticks it and earns 10⭐: 15⭐ paid for a 10⭐ chore.
Ava ticks her 5⭐, then Ben's card goes back to the pool It's in the pool at the full 10⭐ again (split_user_ids null). Cal claims and ticks it: 15⭐.
A one-time 10⭐ chore; only Ava ticks Night 1: back in the pool, split cleared. Night 2, untouched: pruned. Ava's completion still counts as "done" for a one-time chore, because the prune looks at any completion on the schedule.

Both of the first two can be reached from the dashboard: a split card in Ben's column is drawn with user_id: Ben, so its menu offers Transfer to other people and to the pool.

What to change

  1. Once any share is ticked, the split is locked.
    • Refuse releasing it to the pool, or handing it to one person, while any member has a completion for today. Do it on the server (PATCH /api/chore-schedules/:id with user_id on a split schedule → 409) and hide it in the widget.
    • Before anyone has ticked, releasing the whole split as you have it is fine.
    • If changing who does an open share matters, make it a swap of that one share (replace the member, same share) rather than a takeover of the whole chore. Leaving it out is fine too.
  2. A half-done one-time split stays with the people who haven't ticked.
    • Don't return it to the pool at night while any share is done. Keep the split until every share is ticked, then let the prune take it, as it already does.
    • Returning it untouched (nobody ticked) is fine.
  3. Only people in the split can tick it. Today POST /api/chores/complete from someone not in split_user_ids earns the full 10⭐ (splitShareForUser returns null). That's only reachable through the API, since the card is no longer in the pool, but a 409 there closes it.

A test for each would be great: the two 15⭐ cases refused, the one-time split surviving night 2 with Ben's share still open, and a non-member's completion refused.

Not yours to fix

An ordinary claimed bonus chore has a version of this on main too: tick it, transfer it, and it can be ticked again for full Stars. That predates this PR and will be handled separately, so you don't need to cover it here.

The rest reads well. Ask here if anything's unclear.

…refuse non-members (issue jherforth#407)

- PATCH /api/chore-schedules/:id with user_id on a split schedule
  answers 409 once any share is ticked, and the widget hides Transfer
  for it; before anyone ticks, moving the split is unchanged.
- The nightly return leaves a half-done one-time split split until
  every share is ticked, when the prune takes it; untouched splits
  and recurring splits still return to the pool.
- POST /api/chores/complete from someone not in the split answers 409.
@adamecker

Copy link
Copy Markdown
Contributor Author

All three are in (9821448):

  1. Split locks once a share is ticked. PATCH /api/chore-schedules/:id with user_id on a split schedule answers 409 once any share is ticked, and the widget hides Transfer for the card. Before anyone ticks, releasing the split or handing it to one person works as before. One deliberate widening: the lock counts any completion by a split member since the split was made (date >= pool_claimed_on), not just today. With fix 2 keeping a half-done one-time split past midnight, a today-only lock would leave the same 15⭐ hole open the next day.
  2. Half-done one-time splits stay split. The nightly return skips a one-time split while any share is ticked; once every share is ticked the prune takes it as before, and an untouched split still returns. A recurring split still returns every night — tomorrow is a new day of the chore.
  3. Only split members can tick it. POST /api/chores/complete from someone not in split_user_ids answers 409.

Tests for each, as asked: both 15⭐ moves refused (to the pool and to one person), the one-time split surviving night 2 with the second share still open (then pruned once it is ticked), and a non-member's completion refused. Server 857/857, client 1131/1131, build and i18n pass. Docs in backend-api.md updated for the two new 409s and the nightly rule.

@jherforth jherforth left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks, Adam. All three are in, and they hold on a real server. With a fresh household for each case:

Case Before Now
Ava ticks her 5⭐, Ben's share handed to Cal 15⭐ 409, 5⭐ paid
Ava ticks her 5⭐, released to the pool 15⭐ 409, 5⭐ paid
Cal, not in the split, ticks it 10⭐ 409
One-time split, only Ava ticks pruned on night 2 kept on nights 1 and 2, pruned once Ben ticks

Counting the lock from the split's date instead of today is the right call, for the reason you gave. Client 1131/1131 and check:i18n pass here too.

Keeping the one-time split overnight opens one new hole, though, and two smaller things turned up around it. They're all small.

1. Ava can tick her share again the next day

The one-time 10⭐ split from above: Ava ticks today, the split is kept overnight, and tomorrow she ticks again. The server accepts it, and Ben ticks his share: 15⭐ for a 10⭐ chore.

It's reachable from the dashboard. The card's done state comes from today's history (getUserChoresForToday), so on day 2 Ava's card shows as not done. The duplicate check in completeChoreSchedule is per date, so it lets the tick through.

The same blind spot causes two smaller problems on day 2:

  • hasOutstandingBonusChore counts Ava's finished share as open, so she can't claim another bonus chore until Ben finishes his.
  • splitHasTickedShareToday doesn't see yesterday's tick, so the widget offers Transfer and the server refuses it.

Suggestion: one rule for "this member's share is done": a completion by them on this schedule on or after pool_claimed_on. That's the rule splitHasTickedShare already uses.

  • Completing: refuse a member whose share is already done (409).
  • hasOutstandingBonusChore: treat their share as done.
  • The dashboard: attach it to the schedule rows, say split_done_user_ids, and have the widget use it for the card's done state and for the Transfer lock in place of today's history.

A recurring split is cleared every night, so for it this is the same as today.

2. A stale display can claim a chore that was just split

The pool hides split chores, but POST /api/chore-schedules/:id/claim doesn't check for a split. Picture two displays: one splits the chore between Ava and Ben, while the other, not yet refreshed, still shows it in the pool, and Cal claims it there. The claim succeeds:

split Ava/Ben: 200
Cal claims it: 200  {"user_id":3,"split":[1,2],"pool_claimed_on":"…"}
Cal ticks: 409
after the night:         {"user_id":null,"split":[1,2],"pool_claimed_on":null}
after another night:     {"user_id":null,"split":[1,2],"pool_claimed_on":null}

Cal is left holding a chore he can't tick. Then the nightly claimed-bonus return clears user_id and pool_claimed_on but leaves the split, and the split return only looks at rows with pool_claimed_on set. So the chore never goes back to the pool. Ava and Ben keep it as an open bonus chore every day until an admin steps in.

Suggestion: have the claim route answer 409 for a schedule with split_user_ids, as it does for one already assigned.

3. Saving a split chore in Admin → Schedules

The schedule dialog sends user_id with every save: null for a pool chore. So the PATCH route reads every save as a move:

  • An untouched split: saving it, even just to change its due time, quietly ends the split. That came in with the last round.
  • A split with a ticked share: the same save answers 409 "This split chore cannot be moved…", though nobody moved it. The visibility toggle still works, because it sends only visible.

Suggestion: count user_id as a move only when it differs from the schedule's current one, for both the lock and the clearing of the split.

Tests

One for each would be great:

  • a second tick by the same member on a later date is refused;
  • claiming a split chore is refused;
  • an admin PATCH that resends the same user_id keeps the split and isn't refused.

The rest looks good. Ask here if anything's unclear.

…r re-split; admin saves do not move a split (issue jherforth#407)
@adamecker

Copy link
Copy Markdown
Contributor Author

All three are in (3620437):

  1. A share stays done past midnight. One rule for "this member's share is done" (splitDoneUserIds): a completion by them on this schedule on or after pool_claimed_on. Completing refuses a member whose share is already done (409), hasOutstandingBonusChore treats their share as done, and schedule rows carry split_done_user_ids, which the widget uses for the card's done state and the Transfer lock — today's history alone cannot see yesterday's tick. A recurring split is cleared every night, so for it this is the same as today.
  2. A stale display cannot claim a split chore. POST /api/chore-schedules/:id/claim answers 409 for a schedule with split_user_ids. One extra in the same class, not asked for: splitting an already-split chore is refused the same way — a re-split would reset the claim date and reopen ticked shares.
  3. An admin save is not a move. PATCH counts user_id as a move only when it differs from the schedule's current one, so resending it while changing the due time keeps the split, and is not refused once a share is ticked. One subtlety: 0 still counts as a move — it is the Transfer dialog's explicit "back to the pool", while the schedule dialog sends null for no assignee. The daily-bonus re-check on a move follows the same test.

Tests for each, as asked: a second tick by the same member on a later date refused (Ben can still tick his share that day), claiming a split chore refused, an admin PATCH resending the same user_id keeps the split and is not refused (a real move after a tick still is), plus the re-split refusal. Server 861/861, client 1134/1134, build and i18n pass. Docs in backend-api.md updated for the new 409s and the move rule.

@jherforth
jherforth merged commit f6f103e into jherforth:main Nov 30, 2026
4 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in HomeGlow Kanban Nov 30, 2026
@jherforth jherforth added the enhancement New feature or request label Nov 30, 2026
@jherforth jherforth added this to the 2.1 milestone Nov 30, 2026
adamecker pushed a commit to adamecker/HomeGlow that referenced this pull request Nov 30, 2026
…jherforth#407)

Upstream's choreSplit migration ships as 46, but the prod line already
has its own 46 (oneTimeAfter), so it lands here as 52 — the same
renumbering as poolClaimedOn and pluginPermissionGrants. The
anyDayChores latest-schema assertion moves 51 -> 52.
@mrramam

mrramam commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

@adamecker still a bug in there other than what J called out... a half-done split on an any-day chore never expires. Reproduced on f6f103e with a fresh database:

  • Weekly any-day 5⭐ bonus chore, card due Saturday. Split Ava + Ben, Ava ticks.
  • After Saturday, the nightly job keeps the card: still visible with the split a week and two weeks later.
  • The chore gets no new weekly card. An unsplit any-day chore left undone rolls to a new card every week.
  • Ben can still tick the stale card after its due date and is paid.
  • Ben's open share blocks his bonus claims (409 "already has an outstanding bonus chore" 15 days later).

Cause: the prune filter in the nightly job skips a split until every share is ticked, and the split return keeps a one-time split with a ticked share. An expired any-day card is one-time, so neither lets it go.

Suggestion: let the any-day expiry prune a split card regardless of its ticks, since a ticked share stays earned in history.

adamecker pushed a commit to adamecker/HomeGlow that referenced this pull request Dec 1, 2026
The nightly-job description still said a half-done one-time split
stays split until every share is ticked (issue jherforth#407), with no
exception for any-day cards. PR jherforth#410 prunes those when their period
ends, split or not: a ticked share stays earned, and the next period
starts with a fresh card.
jherforth pushed a commit that referenced this pull request Dec 2, 2026
* fix(chores): prune a half-done split once its any-day period ends

A split on an any-day card never expired: the nightly prune only took
a split once every share was ticked, and the split return kept a
one-time split with a ticked share, so an expired any-day card stayed
visible for weeks — its open share could still be ticked and paid, and
it blocked its holder's bonus claims.

The period ending now prunes the card regardless of its ticks: a ticked
share stays earned in history, and the next period rolls a fresh card
like an unsplit any-day chore.

Regression test: a half-done split on an any-day chore expires with its
period (server/tests/bonusChoreSplitAssign.test.js).

* docs(chores): an any-day split card goes when its period ends

The nightly-job description still said a half-done one-time split
stays split until every share is ticked (issue #407), with no
exception for any-day cards. PR #410 prunes those when their period
ends, split or not: a ticked share stays earned, and the next period
starts with a fresh card.

---------

Co-authored-by: adamecker <eckerpad@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants