Skip to content

fix(ui): preserve time_updated when renaming session title#1263

Open
0xSkybreaker wants to merge 1 commit into
XiaomiMiMo:mainfrom
0xSkybreaker:fix/issue-1257-session-rename-moves-to-today
Open

fix(ui): preserve time_updated when renaming session title#1263
0xSkybreaker wants to merge 1 commit into
XiaomiMiMo:mainfrom
0xSkybreaker:fix/issue-1257-session-rename-moves-to-today

Conversation

@0xSkybreaker

Copy link
Copy Markdown

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.

Root Cause

time_updated in packages/opencode/src/storage/schema.sql.ts has .$onUpdate(() => Date.now()), which fires on every UPDATE to any table using Timestamps. The setTitle method only patched { title }, allowing the ORM to auto-set time_updated to the current time.

Fix

setTitle now reads the session first and explicitly passes the original time_updated value in the patch. Drizzle ORM's $onUpdate only fires when no explicit value is provided, so this preserves the original timestamp.

Reproduction

  1. Open the sessions dialog (/sessions)
  2. Select a session from a previous day
  3. Press ctrl+R to rename it
  4. The renamed session no longer moves to Today

Fixes #1257

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

重命名过去session时会将重命名的会话移到今天

1 participant