Repository navigation
fix(gateway): store whole-millisecond session activity times so fractional Talk timestamps persist - #207876
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. |
|
Codex review: passed. What this changesThis PR truncates visible-reply activity timestamps to whole milliseconds before persisting session metadata. Example: A Talk reply has timestamp 1795914508633.935.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenancePossible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readiness✅ Ready for maintainer review This PR fixes a current-main persistence defect with a minimal change at the shared owner. No introduced defects were found; CI remains pending. Reviewed head: Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe Gateway derives session activity from the latest visible assistant message; Gateway lifecycle and agent-command completion writers consume that value to update durable session metadata. flowchart TD
A[Assistant transcript] --> B[Visible reply projection]
B --> C[Whole millisecond activity]
C --> D[Run completion writers]
D --> E[SQLite session metadata]
Technical reviewBest possible solution: Keep timestamp normalization in the existing shared activity reader so both completion writers receive values compatible with session storage. Do we have a high-confidence way to reproduce the issue? Source traces fractional transcript timestamps through both completion writers to strict INTEGER storage, matching the supplied SQLite failure log and reported red-on-main integration results; no reproduction was executed during this read-only review. Is this the best way to solve the issue? This is the smallest complete repair: normalize the shared activity value while preserving transcript precision, visibility rules, and existing storage contracts. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 3fa77b17a97d. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +2, Tests +32. Total +34 across 3 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed November 29, 2026, 6:04 AM ET / 11:04 UTC (Revision 2). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed in 7c0080f. The session's activity time now drops sub-millisecond precision from transcript timestamps, so fractional Talk reply timestamps no longer fail the integer |
…ional Talk timestamps persist (openclaw#207876) Related: openclaw#206321 ## What Problem This Solves When a chat's latest visible reply has a sub-millisecond timestamp, saving the session's activity time fails, so the reply never reaches the session history. iPhone Talk transcripts carry such timestamps (for example `1795914508633.935`). The run finishes and the user sees the answer live, but after a reload, or in the next call's starting history, that answer is missing. The Gateway log shows SQLite rejecting the value: a REAL written into the integer column `session_nodes.last_activity_at`. `readVisibleSessionActivityAt` (added in openclaw#204281) passes the transcript timestamp straight through. ## User Impact Talk replies can settle normally even when the transcript carries fractional milliseconds. No migration or user action is required. ## Why This Change Was Made `readVisibleSessionActivityAt` truncates the timestamp to whole milliseconds before it becomes the session row's activity time. Transcript timestamps themselves are unchanged. ## Evidence - A new test in `session-row-transcript-backfill.test.ts` uses a fractional assistant timestamp. It fails on main and passes with this change. - Found during live iPhone Talk testing for openclaw#206321: on a production build, the answer appeared live but was missing from history afterwards. The same fix is on that branch and is being removed from it in favor of this PR. openclaw#206321 depends on this fix landing first or alongside it. **Gateway integration proof (AI-assisted).** Ran the same regression cases against `origin/main` at `fa5df2fc8ec` and the patched branch. The in-process Gateway suite scripts only model execution. It runs the Talk consult, closes the call before or after the final reply, and exercises the real terminal persistence and SQLite database. The test reopens the database and queries `chat.history` through the Gateway handler. ```text origin/main — Tests 2 failed | 20 skipped (22) Caused by: Error: cannot store REAL value in INTEGER column session_nodes.last_activity_at SQLite: last_activity_at = NULL (expected whole milliseconds) patched — Tests 2 passed | 20 skipped (22) Both cases: terminal settlement succeeds; SQLite stores trunc(replyTimestamp) with typeof(last_activity_at) = 'integer'; reopened chat.history contains the reply once. ``` This fixture reproduces the terminal write failure, not the missing history: its scripted model appends the transcript before settlement, so history also contains the reply on main. The missing reply was observed separately in the original iPhone run. Its redacted Gateway log: ```text 2026-11-29T01:08:57.911Z [gateway] terminal session persistence failed session=[redacted] run=[redacted] error=Error: cannot store REAL value in INTEGER column session_nodes.last_activity_at: code=ERR_SQLITE_ERROR ``` The previous [check-lint failure](https://github.com/openclaw/openclaw/actions/runs/46211916112/job/141188208993) flagged formatting in this PR's test file, not a UI guard. The formatting is fixed and the local format check passes on all three PR files. Co-authored-by: Ayaan Zaidi <[email protected]>
Related: #206321
What Problem This Solves
When a chat's latest visible reply has a sub-millisecond timestamp, saving the session's activity time fails, so the reply never reaches the session history. iPhone Talk transcripts carry such timestamps (for example
1795914508633.935). The run finishes and the user sees the answer live, but after a reload, or in the next call's starting history, that answer is missing.The Gateway log shows SQLite rejecting the value: a REAL written into the integer column
session_nodes.last_activity_at.readVisibleSessionActivityAt(added in #204281) passes the transcript timestamp straight through.User Impact
Talk replies can settle normally even when the transcript carries fractional milliseconds. No migration or user action is required.
Why This Change Was Made
readVisibleSessionActivityAttruncates the timestamp to whole milliseconds before it becomes the session row's activity time. Transcript timestamps themselves are unchanged.Evidence
session-row-transcript-backfill.test.tsuses a fractional assistant timestamp. It fails on main and passes with this change.Gateway integration proof (AI-assisted). Ran the same regression cases against
origin/mainat7e676835a57and the patched branch. The in-process Gateway suite scripts only model execution. It runs the Talk consult, closes the call before or after the final reply, and exercises the real terminal persistence and SQLite database. The test reopens the database and querieschat.historythrough the Gateway handler.This fixture reproduces the terminal write failure, not the missing history: its scripted model appends the transcript before settlement, so history also contains the reply on main. The missing reply was observed separately in the original iPhone run. Its redacted Gateway log:
The previous check-lint failure flagged formatting in this PR's test file, not a UI guard. The formatting is fixed and the local format check passes on all three PR files.