[PR #5702] [MERGED] fix(conversation): keep last week's schedule instead of clearing it #6892

Closed
opened 2026-10-23 04:14:39 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5702
Author: @Gunterlie
Created: 8/31/2026
Status: ✅ Merged
Merged: 8/31/2026
Merged by: @Gunterlie

Base: staging ← Head: fix/schedule-persistence-5689


📝 Commits (4)

  • 9ce0b2d fix(conversation): keep last week's schedule instead of clearing it
  • e46342d fix(conversation): regenerate a stale schedule instead of waiting for the refresh button
  • e0f97e8 Merge branch 'staging' into fix/schedule-persistence-5689
  • f70b466 Merge branch 'staging' into fix/schedule-persistence-5689

📊 Changes

4 files changed (+73 additions, -56 deletions)

View changed files

📝 packages/client/src/components/chat/ConversationPresenceCard.tsx (+33 -5)
📝 packages/client/src/hooks/use-autonomous-messaging.ts (+0 -23)
📝 packages/server/src/services/storage/chats.storage.ts (+19 -28)
📝 scripts/regressions/character-schedule-ownership.regression.ts (+21 -0)

📄 Description

Closes #5689

Why

Users report that after upgrading to 2.4.4 their chat schedules were empty, and that a schedule regenerated on a Sunday was empty again the next morning.

Root cause: the read path treated "generated before this week's Monday" as "does not exist".

  • collectFreshConversationSchedules and collectConversationPresence skipped any card schedule where scheduleNeedsRefresh() was true.
  • resolveConversationSchedules then saw an empty result and actively wiped the chat's characterSchedules cache and scheduleWeekStart.
  • GET /conversation/status computes needsRefresh from the schedules that survived that same filter, so once every schedule went stale, needsRefresh was false — and the client's refresh button only regenerates when needsRefresh is true.

So a stale schedule was hidden, deleted from the cache, and then permanently unregenerable. The Sunday case is the sharpest version: getMonday() maps Sunday to the previous Monday, so a schedule generated on a Sunday is stale the very next day.

What

1. Stop discarding last week's schedule. The read path returns the card's schedule regardless of its weekStart. Days are keyed by weekday name, so last week's routine is still usable, presence keeps working, and needsRefresh correctly reports true — which is what drives regeneration.

2. Roll the week over automatically. Fixing needsRefresh repairs the refresh button, but nothing was regenerating on its own: useAutonomousMessaging exported an ensureSchedules helper that no component ever called, so the button was the only path and a routine silently stayed a week behind. ConversationPresenceCard now regenerates when the server reports needsRefresh, once per chat per session so a missing or failing connection cannot loop. The dead helper is removed.

scheduleNeedsRefresh itself is unchanged and still gates regeneration in POST /conversation/schedule/generate.

Behaviour note for review

Item 2 means a stale chat now spends one LLM call on open, without the user pressing anything. That matches what ensureSchedules was written to do and what the issue expects ("schedules should remain populated"), but it is a real change in when generation happens — worth a maintainer opinion. Chats with schedules switched off never report needsRefresh, so they never generate.

Test plan

  • pnpm check
  • node scripts/run-regressions.mjs (the character-schedule-ownership regression gains a case pinning that a last-week schedule still resolves; it fails on staging)
  • Manually open a conversation chat whose schedule went stale and verify the old schedule is shown rather than a blank panel
  • Manually verify a new schedule is then generated for the current week without pressing refresh
  • Manually verify only one generation runs — reopen the same chat and confirm it does not generate again
  • Manually verify that with no usable connection the chat keeps the old schedule and does not loop on failed requests
  • Manually verify presence status/activity is derived from the restored schedule
  • Manually verify a chat with schedules switched off shows nothing and never generates

Summary by CodeRabbit

  • Bug Fixes

    • Conversation schedules are now preserved even when they are from a previous week.
    • Chat presence can automatically refresh outdated schedules once per session when needed.
    • Schedule refreshes now avoid duplicate requests while one is already in progress.
  • Tests

    • Added regression coverage to verify stale schedules remain available for existing conversations.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/5702 **Author:** [@Gunterlie](https://github.com/Gunterlie) **Created:** 8/31/2026 **Status:** ✅ Merged **Merged:** 8/31/2026 **Merged by:** [@Gunterlie](https://github.com/Gunterlie) **Base:** `staging` ← **Head:** `fix/schedule-persistence-5689` --- ### 📝 Commits (4) - [`9ce0b2d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/9ce0b2da288452d3e601de80485849aa97a4f3a6) fix(conversation): keep last week's schedule instead of clearing it - [`e46342d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e46342df964baa27cd61383d99d2a6deb031f540) fix(conversation): regenerate a stale schedule instead of waiting for the refresh button - [`e0f97e8`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e0f97e89d4daaa5e22dc3d0421fd05ef52bcd643) Merge branch 'staging' into fix/schedule-persistence-5689 - [`f70b466`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f70b466e7d0a3da733f3f1158d41430179fcbd2d) Merge branch 'staging' into fix/schedule-persistence-5689 ### 📊 Changes **4 files changed** (+73 additions, -56 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/components/chat/ConversationPresenceCard.tsx` (+33 -5) 📝 `packages/client/src/hooks/use-autonomous-messaging.ts` (+0 -23) 📝 `packages/server/src/services/storage/chats.storage.ts` (+19 -28) 📝 `scripts/regressions/character-schedule-ownership.regression.ts` (+21 -0) </details> ### 📄 Description Closes #5689 ## Why Users report that after upgrading to 2.4.4 their chat schedules were empty, and that a schedule regenerated on a Sunday was empty again the next morning. Root cause: the read path treated "generated before this week's Monday" as "does not exist". - `collectFreshConversationSchedules` and `collectConversationPresence` skipped any card schedule where `scheduleNeedsRefresh()` was true. - `resolveConversationSchedules` then saw an empty result and actively wiped the chat's `characterSchedules` cache and `scheduleWeekStart`. - `GET /conversation/status` computes `needsRefresh` from the schedules that survived that same filter, so once every schedule went stale, `needsRefresh` was `false` — and the client's refresh button only regenerates when `needsRefresh` is `true`. So a stale schedule was hidden, deleted from the cache, and then permanently unregenerable. The Sunday case is the sharpest version: `getMonday()` maps Sunday to the *previous* Monday, so a schedule generated on a Sunday is stale the very next day. ## What **1. Stop discarding last week's schedule.** The read path returns the card's schedule regardless of its `weekStart`. Days are keyed by weekday name, so last week's routine is still usable, presence keeps working, and `needsRefresh` correctly reports `true` — which is what drives regeneration. **2. Roll the week over automatically.** Fixing `needsRefresh` repairs the refresh button, but nothing was regenerating on its own: `useAutonomousMessaging` exported an `ensureSchedules` helper that no component ever called, so the button was the only path and a routine silently stayed a week behind. `ConversationPresenceCard` now regenerates when the server reports `needsRefresh`, once per chat per session so a missing or failing connection cannot loop. The dead helper is removed. `scheduleNeedsRefresh` itself is unchanged and still gates regeneration in `POST /conversation/schedule/generate`. ### Behaviour note for review Item 2 means a stale chat now spends one LLM call on open, without the user pressing anything. That matches what `ensureSchedules` was written to do and what the issue expects ("schedules should remain populated"), but it is a real change in when generation happens — worth a maintainer opinion. Chats with schedules switched off never report `needsRefresh`, so they never generate. ## Test plan - [ ] `pnpm check` - [ ] `node scripts/run-regressions.mjs` (the `character-schedule-ownership` regression gains a case pinning that a last-week schedule still resolves; it fails on `staging`) - [ ] Manually open a conversation chat whose schedule went stale and verify the old schedule is shown rather than a blank panel - [ ] Manually verify a new schedule is then generated for the current week without pressing refresh - [ ] Manually verify only one generation runs — reopen the same chat and confirm it does not generate again - [ ] Manually verify that with no usable connection the chat keeps the old schedule and does not loop on failed requests - [ ] Manually verify presence status/activity is derived from the restored schedule - [ ] Manually verify a chat with schedules switched off shows nothing and never generates <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Conversation schedules are now preserved even when they are from a previous week. * Chat presence can automatically refresh outdated schedules once per session when needed. * Schedule refreshes now avoid duplicate requests while one is already in progress. * **Tests** * Added regression coverage to verify stale schedules remain available for existing conversations. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:14:39 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#6892
No description provided.