mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-01 12:02:05 +00:00
Single-scoped helpers/sub-files were sitting flat in shared/grab-bag dirs.
Fold each family into its own folder (index = the export, dir resolution keeps
public import paths intact), dropping the now-redundant filename prefix:
- session/hooks/use-prompt-actions.ts (+ -utils, + tests)
-> use-prompt-actions/{index,utils}.ts (+ tests)
- components/assistant-ui/thread* + assistant/system/user message renderers
-> assistant-ui/thread/{index,content,status,message-parts,timestamp,types,
list,timeline,timeline-data,assistant-message,system-message,user-message,
user-edit-composer,user-message-text} (+ tests)
- components/assistant-ui/tool-fallback(+model)/tool-approval
-> assistant-ui/tool/{fallback,fallback-model,approval} (+ tests)
Pure move + import rewrites; no behaviour change. App-wide shared primitives
(markdown-text, directive-text, tooltip-icon-button, clarify-tool, ansi-text,
message-render-boundary) stay flat. desktop-controller intentionally left in
app/ (route root; foldering would churn ~80 relative imports for no gain).
36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import { formatMessageTimestamp } from './timestamp'
|
|
|
|
const labels = {
|
|
today: (time: string) => `Today at ${time}`,
|
|
yesterday: (time: string) => `Yesterday at ${time}`
|
|
}
|
|
|
|
describe('formatMessageTimestamp', () => {
|
|
it('returns an empty string for missing values', () => {
|
|
expect(formatMessageTimestamp(undefined, labels)).toBe('')
|
|
expect(formatMessageTimestamp('not-a-date', labels)).toBe('')
|
|
})
|
|
|
|
it('uses the today label for timestamps earlier today', () => {
|
|
const now = new Date()
|
|
const earlierToday = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 30)
|
|
expect(formatMessageTimestamp(earlierToday, labels)).toMatch(/^Today at /)
|
|
})
|
|
|
|
it('uses the yesterday label for timestamps the prior day', () => {
|
|
const now = new Date()
|
|
const yesterday = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 8, 0)
|
|
yesterday.setDate(yesterday.getDate() - 1)
|
|
expect(formatMessageTimestamp(yesterday, labels)).toMatch(/^Yesterday at /)
|
|
})
|
|
|
|
it('falls back to an absolute format for older timestamps', () => {
|
|
const old = new Date(2020, 0, 15, 9, 30)
|
|
const out = formatMessageTimestamp(old, labels)
|
|
expect(out).not.toMatch(/^Today at /)
|
|
expect(out).not.toMatch(/^Yesterday at /)
|
|
expect(out.length).toBeGreaterThan(0)
|
|
})
|
|
})
|