Files
deepseek-harness/packages/experimental/client-ui-forge/src/client/format.ts
T
Yichen Jiang fc43a2d507 feat(forge): add the pull request panel and worktree Sessions
The forge panel shows the pull requests a Session created or pushed in a
right-sidebar tab, with a Session header button and branch label, and lets
a new Session start in its own Git worktree from the New Session options
row. The forge bundle ships the panel with the forge registry, the GitHub
provider, the Session bindings, and an isolated worktree service.

The panel listens to the agent-controller/admission stage. It holds the
first message of a Session with a worktree request while it creates and
enters the worktree as Agent maintenance, and refuses messages while the
worktree the Session works in is gone. A failed or stopped creation
returns the message to the composer: the card above the composer shows the
failure, sending again retries with a new branch name, and Continue
without a worktree withdraws the request. A removed worktree can be
checked out again or left for the source checkout. A message that enters
without admission still gets its worktree at the first step proposal.
2026-10-20 11:49:51 +08:00

38 lines
1.3 KiB
TypeScript

/** Localized durations and relative times shown on change request cards. */
import { relativeTime } from '@deepseek-ai/dsh-client-ui-primitives'
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'
import type { NS } from './locales.ts'
type Translate = PropsLocale<typeof NS>['t']
/**
* Format an elapsed time as hours and minutes, minutes and seconds, or seconds.
* @param ms - elapsed milliseconds.
* @param t - forge panel copy.
* @returns the localized duration.
*/
export function formatDuration(ms: number, t: Translate): string {
const total = Math.round(ms / 1000)
const hours = Math.floor(total / 3600)
const minutes = Math.floor(total % 3600 / 60)
const seconds = total % 60
if (hours > 0) return t('duration.hours', { hours, minutes })
if (minutes > 0) return t('duration.minutes', { minutes, seconds })
return t('duration.seconds', { seconds })
}
/**
* Format how long ago an ISO 8601 time was.
* @param iso - the time.
* @param now - current epoch milliseconds.
* @param t - forge panel copy.
* @returns the localized relative time, or undefined when `iso` does not parse.
*/
export function formatAgo(iso: string, now: number, t: Translate): string | undefined {
const at = Date.parse(iso)
if (!Number.isFinite(at)) return undefined
const { unit, n } = relativeTime(at, now)
return t(`time.${unit}`, { n })
}