Repository navigation
Split a bonus chore's Stars among several people - #407
Conversation
jherforth
left a comment
There was a problem hiding this comment.
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 |
- 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.
- 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.
- 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.
- #404 (who can take this) has merged. The split should check the chore's list (
choreClaimers.mayClaim, 403CHORE_NOT_OFFERED), and the picker should leave out people who aren't on it. - Control Limits. Something that changes chores this much should be hideable on a wall display, like Transfer (
isControlHidden). - 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_onas today, plus the people and their shares, for example asplit_user_ids/split_sharespair, 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_valueis 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.
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 🤖
f4c7eed to
6ff9fa8
Compare
jherforth
left a comment
There was a problem hiding this comment.
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
- 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/:idwithuser_idon 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.
- 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 (
- 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.
- Only people in the split can tick it. Today
POST /api/chores/completefrom someone not insplit_user_idsearns the full 10⭐ (splitShareForUserreturns 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.
|
All three are in (9821448):
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 |
jherforth
left a comment
There was a problem hiding this comment.
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:
hasOutstandingBonusChorecounts Ava's finished share as open, so she can't claim another bonus chore until Ben finishes his.splitHasTickedShareTodaydoesn'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_idkeeps 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)
|
All three are in (3620437):
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 |
…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.
|
@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:
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. |
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.
* 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>
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:
split_user_ids/split_shares(two parallel lists, modelled onprize_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.chore_history.clam_valueis already per-row), so Emma earns 8 Stars, not the chore's full 15.How to use 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:
CHORE_NOT_OFFERED, the same check the claim route runs. The picker leaves people who are not on the list out.core:splitChorein the control limits): hiding it removes the long-press and right-click entry points and closes an open picker.Verification
splitStarsunit tests.Generated with Muse AI 🤖