Skip to content

feat(workbench): show compact relative timestamps in desktop sidebar conversation rows - #7243

Open
YayoiNanoka wants to merge 1 commit into
apache:mainfrom
YayoiNanoka:feat/sidebar-relative-time
Open

YayoiNanoka wants to merge 1 commit into
apache:mainfrom
YayoiNanoka:feat/sidebar-relative-time

Conversation

@YayoiNanoka

@YayoiNanoka YayoiNanoka commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Problem

In Maka's desktop left sidebar (WorkspaceBrowser.tsx), idle and read conversation rows currently leave their trailing slot empty until hovered or selected. Users scanning a busy sidebar have no at-a-glance recency cue for older conversations, and any naive inline timestamp either shifts conversation titles horizontally on hover or spawns per-row timers that scale poorly with long conversation histories.

Solution

  • Compact, width-stable relative time formatting (products/maka/workbench/app/sidebarRelativeTime.ts, products/maka/workbench/locales/*.json): Formats session.updatedAt (ms) against an injectable clock with localized sub-minute labels across all 12 workbench locales (now in en, 刚刚 in zh-CN, 剛剛 in zh-TW/zh-HK, 今 in ja, 방금 in ko, jetzt in de, ahora in es, <1m in fr, ora in it, agora in pt-BR, сейч. in ru), deterministic floored compact units (1m–59m, 1h–23h, 1d–29d, 1mo–11mo, 1y+), future clock-skew clamping to now, and empty-string degradation for invalid or non-positive timestamps.
  • Single shared minute-aligned clock (WorkspaceBrowser.tsx): Maintains one shared relativeTimeNow signal per WorkspaceBrowser gated on platform.idiom !== 'terminal' && lifecycle() === 'active', aligned to wall-clock minute boundaries via nextMinuteTickDelay, cleaned up on unmount/background, and immediately refreshed on return to active. Because lane() does not depend on the clock signal, minute ticks update only visible idle-time <Text> bindings in place (O(1) timer regardless of list length).
  • Zero-layout-shift trailing slot & keyboard focus hygiene (WorkspaceBrowser.tsx, DESIGN.md): Shares the desktop row's right-aligned trailing slot (right: 8, aligned with the 32 pt ⋯ icon spine) with strict mutual exclusion (actionsShown > working spinner > hasUnread dot > relative timestamp), reuses menuDetailTextStyle (12/16 pt) with tabular-nums, scales trailing title clearance (16 pt at default text size, 24 pt when fontScale() > 1) so '11mo' never clips or collides with titles or desktopCaption() even at BROWSER_MIN = 192 pt and maxTextSize (1.3×), and tracks native onFocusIn/onFocusOut on the row container so keyboard focus on the conversation row or ⋯ button cleanly reveals ⋯ and suppresses the overlaid timestamp with zero overlap or layout shift.
点击展开中文

要解决的问题

在 Rust Maka 桌面端左侧边栏(WorkspaceBrowser.tsx)中,处于空闲且已读状态的对话行在未悬停、未选中时,右侧尾部槽位完全空白,用户浏览对话列表时缺少直观的活跃时间提示;如果直接内联渲染时间戳,容易在悬停切换 ⋯ 菜单按钮时引发标题水平抖动,或为每行创建独立定时器造成性能浪费。

当前解决方案

  • 紧凑且宽度稳定的相对时间格式化(sidebarRelativeTime.ts、products/maka/workbench/locales/*.json):小于 1 分钟或存在未来时钟偏差时显示 12 语言本地化短标签(en: now、zh-CN: 刚刚、zh-TW/zh-HK: 剛剛、ja: 今、ko: 방금 等);1 分钟及以上使用宽度稳定的紧凑单位(1m–59m、1h–23h、1d–29d、1mo–11mo、1y+);无效或非正时间戳静默降级为空字符串。
  • 全局单一共享时钟(WorkspaceBrowser.tsx):在 WorkspaceBrowser 作用域维护唯一的分钟对齐共享时钟信号(O(1) 定时器),仅在桌面端且 lifecycle() === 'active' 时运行,后台自动暂停、回到前台立即追平、卸载时通过 cleanup 清理,且每分钟跳变仅就地更新可见空闲行的文本绑定。
  • 零水平位移尾部槽位与键盘焦点无重叠(WorkspaceBrowser.tsx、DESIGN.md):桌面端行尾固定槽位按严格互斥优先级展示:actionsShown(⋯ 按钮)> working 加载指示器 > hasUnread 未读圆点 > 紧凑相对时间。时间标签复用 menuDetailTextStyle(12/16 pt)与等宽数字(tabular-nums),与行尾 8 pt 图标基准线对齐,标题按钮根据 fontScale() 预留 16 pt / 24 pt 右侧净空,确保在最窄侧边栏(192 pt)与最大字号(1.3×)下不裁剪、不与标题或 desktopCaption() 重叠,且在空闲/未读/运行中/悬停/键盘聚焦/选中态之间标题位置保持零位移;同时通过行容器原生 onFocusIn/onFocusOut 确保键盘 Tab 聚焦到行或 ⋯ 按钮时隐藏时间标签,避免图标与文字重叠。

验证情况

  • node scripts/i18n/check.mjs:通过(全部 12 个语言目录校验通过,zh-HK.json 遵循 overlay 继承规则)。
  • node --test products/maka/workbench/tests/*.test.mjs:324/324 通过(含 sidebar-relative-time.test.mjs 全部边界、时钟偏差、无效输入与分钟对齐测试)。
  • cargo test --locked -p maka-workbench --lib:100/100 通过(含行为级无头布局测试 sidebar_relative_time_shares_trailing_slot_without_layout_shift,验证窄侧边栏与 1.0×/1.3× 字号下全部 11 种本地化 "now" 标签、标题与 desktopCaption() 无重叠零位移、冒泡等待子会话不显示冗余时间戳、键盘 Tab onFocusIn/onFocusOut 及共享时钟后台暂停/前台追平)。
  • cargo fmt --all -- --check、biome format plugins/ products/、node scripts/asf-license-headers.mjs check、tsc -p products/maka/bundle/tsconfig.json、node scripts/ci.mjs run contracts、node scripts/ci.mjs run product 全部通过。
  • 已在真实 macOS AppKit native-desktop 渲染器中截取改动前后对比图(Dark / Light 主题),确认实际视觉排版、对齐与对比度表现一致。

Verification

Before After
Before (Dark) After (Dark)
Before (Light) After (Light)

Automated checks run locally (rebased onto origin/main):

  • cargo fmt --all -- --check — passed
  • npx biome format plugins/ products/ — passed
  • node scripts/asf-license-headers.mjs check — passed
  • node scripts/i18n/check.mjs — passed (12 locales)
  • npx tsc -p products/maka/bundle/tsconfig.json — passed
  • node --test products/maka/workbench/tests/*.test.mjs — 324 passed, 0 failed
  • cargo test --locked -p maka-workbench --lib — 100 passed, 0 failed (1 unrelated ignored)
  • node scripts/ci.mjs run contracts — passed (includes ui_types + tsc)
  • node scripts/ci.mjs run product — passed

AI use

Select exactly one:

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: Antigravity (Gemini) assisted with implementing the compact relative-time formatter, 12-locale catalog entries, shared minute-aligned clock, trailing-slot layout updates, unit and headless layout tests, and PR documentation.

Checklist

  • Tests cover the change and fail without it
  • Format, typecheck and the affected suites pass locally

Does this PR entail a breaking change or persisted-data migration?

  • Yes — describe user/data impact, in-place migration, and upgrade_compat.rs coverage under Summary above
  • No

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

@github-actions github-actions Bot added the effort/L Under 1000 readable lines label Nov 24, 2026
@YayoiNanoka
YayoiNanoka force-pushed the feat/sidebar-relative-time branch from 7352dfa to a417d84 Compare November 27, 2026 04:55
…conversation rows

Display compact, width-stable relative timestamps (now / 刚刚 / 剛剛, m, h, d, mo, y) in the trailing slot of idle, read desktop sidebar conversation rows using a single shared minute-aligned clock and zero-layout-shift geometry.

Generated-by: Antigravity (Gemini)
@YayoiNanoka
YayoiNanoka force-pushed the feat/sidebar-relative-time branch from a417d84 to d2fae11 Compare November 28, 2026 08:28
@YayoiNanoka
YayoiNanoka marked this pull request as ready for review November 28, 2026 08:38

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/L Under 1000 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant