fix(ui): preserve time_updated when renaming session title#1263
Open
0xSkybreaker wants to merge 1 commit into
Open
fix(ui): preserve time_updated when renaming session title#12630xSkybreaker wants to merge 1 commit into
0xSkybreaker wants to merge 1 commit into
Conversation
The Drizzle ORM Timestamps definition uses $onUpdate(() => Date.now()), which automatically bumps time_updated on every row update. When renaming a session via the sessions dialog (ctrl+R), this caused the renamed session to move to "Today" in the session list because setTitle only passed the new title without preserving the original timestamp. Fix by reading the session first and explicitly passing the original time_updated value, which overrides the ORM auto-update. Fixes XiaomiMiMo#1257
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Drizzle ORM Timestamps definition uses
$onUpdate(() => Date.now()), which automatically bumpstime_updatedon every row update. When renaming a session via the sessions dialog (ctrl+R), this caused the renamed session to move to "Today" in the session list becausesetTitleonly passed the new title without preserving the original timestamp.Root Cause
time_updatedinpackages/opencode/src/storage/schema.sql.tshas.$onUpdate(() => Date.now()), which fires on every UPDATE to any table usingTimestamps. ThesetTitlemethod only patched{ title }, allowing the ORM to auto-settime_updatedto the current time.Fix
setTitlenow reads the session first and explicitly passes the originaltime_updatedvalue in the patch. Drizzle ORM's$onUpdateonly fires when no explicit value is provided, so this preserves the original timestamp.Reproduction
/sessions)ctrl+Rto rename itFixes #1257