🐛 Match version preview banner text to History sidebar labels (#9697)

The version preview banner in `enter-preview` derives its title from
`(:label snapshot)` directly. For system-created autosaves that
field is the internal snapshot label (e.g. `internal/snapshot/20`),
so the banner shows the raw internal string while the History sidebar
already renders the same autosave through `workspace.versions.autosaved.version`
plus a localized date. The mismatch makes it hard to be sure which
sidebar entry you're previewing, especially when several autosaves
sit close together (#9503).

Switch the label resolution to mirror the sidebar's `snapshot-entry*`:
- `:created-by "system"` snapshots format the label as
  `(tr "workspace.versions.autosaved.version" (ct/format-inst ...
   :localized-date))` — the exact same translation key + date format
  the sidebar's autosave group already uses
- `:created-by "user"` (pinned) versions keep their custom `:label`
  with the existing `unnamed` fallback

No behavior change for pinned/user-named versions or for the
restore/exit dialog buttons.

Closes #9503.

Co-authored-by: Andrey Antukh <niwi@niwi.nz>
This commit is contained in:
Milos Milic 2026-05-28 15:26:15 +02:00 committed by GitHub
parent bda977202a
commit 09c274bd92
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -274,8 +274,24 @@
features (features/get-enabled-features state team-id)
snapshot (->> (dm/get-in state [:workspace-versions :data])
(d/seek #(= id (:id %))))
label (or (:label snapshot)
(tr "workspace.versions.preview.unnamed"))
;; Match the History sidebar's identifying text so the
;; preview banner and the sidebar entry "speak the same
;; language" (#9503):
;; - user-created (pinned) versions keep the user's custom
;; label; if absent, fall back to "unnamed"
;; - system-created autosaves use the same auto-generated
;; label the sidebar's `snapshot-entry*` already renders
;; via `workspace.versions.autosaved.version` + a
;; localized date, instead of the internal snapshot
;; label (e.g. `internal/snapshot/20`).
label (cond
(= "system" (:created-by snapshot))
(tr "workspace.versions.autosaved.version"
(ct/format-inst (:created-at snapshot) :localized-date))
:else
(or (:label snapshot)
(tr "workspace.versions.preview.unnamed")))
output-s (rx/subject)]
(rx/merge
output-s