Files
deepseek-harness/packages/experimental/client-ui-forge/src/client/ChangeRequestCard.tsx
T
LegGasai 0c8078e196 feat(forge): name worktree branches, start them from remote branches, and show changes being read (#8536)
* feat(forge): name worktree branches, start them from remote branches, and show changes being read

The New Session worktree option's base menu now searches local branches and
each remote's branches, pins the current branch and every remote's default
branch, and names each remote group by its repository. Its last row opens a
dialog that names the new branch, starting from `worktreePrefix` and checking
Git's branch-name rules; the Host refuses an invalid or taken name. A request
records the full ref of its base and the optional name; every attempt uses the
name.

A remote-tracking base is fetched first: the worktree service gains a
`fetch` request field and a `fetch` phase, fetching only that branch without
tags. A failed fetch leaves the message waiting with Retry, Use the last
fetched version, and Continue without a worktree; a taken name offers Rename.

While the changes view reads changes it has not shown yet, it says
"Reading changes" above file card placeholders, and the files menu names no
count.

* fix(worktree): forward only the declared create_worktree arguments

The create_worktree parameter object is open, and the tool passed it to the
worktree runtime unchanged. Now that a runtime request can ask to fetch, an
undeclared `fetch: true` from the model would have fetched, or refused a local
`from`. The tool now forwards only `name` and `from`, so it never fetches.

* docs(forge): say that only generated worktree branch names come from the Session id

* fix(forge): keep the collapsed change request status on one line

In the Session panel the collapsed card's number line kept every part at
full width inside a clipping row, so a narrow panel cut the most urgent
flag off without an ellipsis, such as "有冲突" after "3 项检查失败".

The number and status now form one MarqueeText line as wide as the row.
While the line with failed checks does not fit, they take the shorter
wording without their count; a line that still does not fit ends in an
ellipsis and crawls into view with the title while the pointer rests on
the card's head. The line measures again when its width or the fonts
change. Expanded cards keep their branch names as before.

* fix(forge): hide remote credentials and read the branch a tag shares its name with

The base menu named an unrecognized remote's group by its fetch URL as
`git remote -v` prints it, so a token in the URL, such as
`https://oauth2:[email protected]/...`, reached the browser and showed
in the menu. The group now shows the URL without its user name and password.

Inspection read the checked-out branch with `symbolic-ref --short HEAD`,
which prints `heads/main` while a tag is also named `main`; the New Session
option then requested `refs/heads/heads/main` and every worktree attempt
failed. Inspection now reads the full ref and takes the name under
`refs/heads/`, so the option, the pinned current branch, and the checkout
row name `main`. HEAD that names a ref outside `refs/heads/` reads as no
branch.

* test(worktree): set up nested remotes and line endings the CI runners' Git accepts

Git 2.55 on the CI runners refuses `git remote add team` next to an
existing `team/fork` remote; the check runs only in `git remote add`, so
the longest-remote case now writes the second remote with `git config`, as
configuration written earlier or by hand holds it. The test clone also
turns off `core.autocrlf`, as `repository` does, because the Windows
runner's global setting checked the fetched file out with CRLF.
2026-11-16 16:13:00 +00:00

572 lines
24 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* One change request as a card: its one-line title links to the host and
* crawls into view while the pointer rests on the card's head, a one-line
* summary shows while collapsed, taking the short wording of failed checks
* while the full one does not fit and crawling with the title past that, and
* while expanded one row per fact (checks, review, merge state, the changed
* lines, which open its changes, and the linked issues) above the merge
* action. Opening, copying, viewing changes, marking a draft ready, and
* removing live in the card's actions menu.
*/
import { useEffect, useId, useLayoutEffect, useMemo, useRef, useState, type PointerEvent, type ReactNode, type RefObject } from 'react'
import clsx from 'clsx'
import {
Button, IconCheckCircleOutlineRegular, IconChevronDownOutlineRegular, IconCloseOutlineRegular, IconCopyOutlineRegular,
IconEllipsisOutlineRegular, IconFilesDiffOutlineRegular, IconRightUpOutlineRegular, IconTriangleRightFillRegular, MarqueeText, Menu,
MenuItemButton, StateDot, Tooltip, useHoverMarquee,
type MenuEntry, type MenuItem,
} from '@deepseek-ai/dsh-client-ui-primitives'
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'
import type {
ChangeRequestSnapshot, CheckState, ChecksRollup, ForgeFailure, MergeMethod, MergeRequest,
} from '@deepseek-ai/dsh-experimental-forge/types'
import type { ForgePanelChangeRequest } from '../types.ts'
import { ChecksRow, IssuesRow, MergeRow, ReviewRow, RowParts, ThreadGlyph, type OverviewActions } from './ChangeRequestOverview.tsx'
import { formatAgo } from './format.ts'
import { ChangeRequestGlyph, CheckGlyph } from './glyphs.tsx'
import type { ForgePanelKey, NS } from './locales.ts'
import type { ForgeChangeRequestCardActionsProps } from './slots.ts'
import { ciSummary, flagOf, numberOf, TONE_LABEL, toneOf } from './status.ts'
import css from './Forge.module.css'
type Translate = PropsLocale<typeof NS>['t']
/**
* What a card can do; a surface without a Session binding omits `remove`, `markReady`, `merge`, `viewChanges`, and the
* overview actions.
*/
export interface ChangeRequestActions extends OverviewActions {
/** Open a URL outside the app. */
readonly openLink: (url: string) => void
/** Copy a URL to the clipboard. */
readonly copyLink: (url: string) => void
/** Read the status again after a failed read. */
readonly retry: () => void
/** Remove the change request from its Session. */
readonly remove?: ((entry: ForgePanelChangeRequest) => void) | undefined
/** Mark a draft ready for review; settles once the outcome is reported. */
readonly markReady?: ((entry: ForgePanelChangeRequest) => Promise<void>) | undefined
/** Merge the change request as `request` describes; settles once the outcome is reported. */
readonly merge?: ((entry: ForgePanelChangeRequest, request: MergeRequest) => Promise<void>) | undefined
/** Load complete check details independently of polling; cancellation follows the open list. */
readonly readChecks?: ((url: string, headSha: string, signal: AbortSignal) => Promise<ChangeRequestSnapshot>) | undefined
/** Open the changes view of the change request. */
readonly viewChanges?: ((entry: ForgePanelChangeRequest) => void) | undefined
/** Draw the icon buttons plugins add to the card's head through `forge.change-request.card.actions`. */
readonly renderActions?: ((owner: ForgeChangeRequestCardActionsProps) => ReactNode) | undefined
}
/** Props of one change request card. */
export interface ChangeRequestCardProps {
/** Change request with its latest snapshot and polling result. */
readonly entry: ForgePanelChangeRequest
/** Whether the details show. */
readonly expanded: boolean
/** Show or hide the details. */
readonly onToggle: () => void
/** Current epoch milliseconds for relative times. */
readonly now: number
/** Card actions. */
readonly actions: ChangeRequestActions
/** Active UI language for numeric formatting. */
readonly locale: string
/** Forge panel copy. */
readonly t: Translate
}
const REVIEW: Record<ChangeRequestSnapshot['reviewDecision'], ForgePanelKey> = {
'approved': 'change.review.approved',
'changes-requested': 'change.review.changesRequested',
'review-required': 'change.review.required',
'none': 'change.review.none',
}
const FAILURE: Record<ForgeFailure['code'], ForgePanelKey> = {
'not-found': 'change.failure.notFound',
'unauthenticated': 'change.failure.unauthenticated',
'too-large': 'change.failure.unavailable',
'stale': 'change.failure.unavailable',
'unsupported': 'change.failure.unavailable',
'unavailable': 'change.failure.unavailable',
}
const ROLLUP: Record<ChecksRollup, CheckState> = {
none: 'neutral',
pending: 'pending',
success: 'success',
failure: 'failure',
}
/** The unresolved thread count, with `+` when the provider counted only some threads. */
function threadCount(snapshot: ChangeRequestSnapshot, locale: string): string {
const count = snapshot.unresolvedThreads.toLocaleString(locale)
return snapshot.threadsTruncated ? `${count}+` : count
}
function failureOf(entry: ForgePanelChangeRequest): ForgeFailure | undefined {
return entry.update !== null && 'failure' in entry.update ? entry.update.failure : undefined
}
function DiffSize({ snapshot, locale }: { readonly snapshot: ChangeRequestSnapshot; readonly locale: string }): ReactNode {
return (
<span className={css.diff}>
<span className={css.added}>{`+${snapshot.additions.toLocaleString(locale)}`}</span>
<span className={css.deleted}>{`−${snapshot.deletions.toLocaleString(locale)}`}</span>
</span>
)
}
/**
* The changed lines with the unresolved review thread count, as a row that opens the changes view when the provider
* serves the change request.
*/
function ChangesRow({ entry, snapshot, name, actions, locale, t }: {
readonly entry: ForgePanelChangeRequest
readonly snapshot: ChangeRequestSnapshot
readonly name: string
readonly actions: ChangeRequestActions
readonly locale: string
readonly t: Translate
}): ReactNode {
const { viewChanges } = actions
const described = useId()
const threads = snapshot.unresolvedThreads > 0 || snapshot.threadsTruncated ? threadCount(snapshot, locale) : undefined
const threadsText = threads === undefined ? undefined : t('change.threads', { count: threads })
const trailing = threadsText === undefined ? undefined : (
<Tooltip label={threadsText} side="top" delayMs={500}>
<span className={css.threads} data-forge-threads={threads} aria-hidden="true"><ThreadGlyph size={14} />{threads}</span>
</Tooltip>
)
const opens = viewChanges !== undefined && entry.ref !== null
// The count shows only a number, so the threads are named in full for assistive technology.
const parts = (
<>
<RowParts label={t('change.row.changes')} icon={<IconFilesDiffOutlineRegular size={16} />}
value={<DiffSize snapshot={snapshot} locale={locale} />} trailing={trailing} opens={opens} />
{threadsText !== undefined && <span id={described} className={css.visuallyHidden}>{threadsText}</span>}
</>
)
if (!opens) return <div className={css.row}>{parts}</div>
return (
<button
type="button"
className={clsx(css.row, css.rowButton)}
aria-label={t('change.viewChangesAria', {
name,
added: snapshot.additions.toLocaleString(locale),
deleted: snapshot.deletions.toLocaleString(locale),
})}
aria-describedby={threadsText === undefined ? undefined : described}
onClick={() => { viewChanges(entry) }}
>
{parts}
</button>
)
}
/** The merged or closed fact with its time, such as 已合并到 main · 2 小时前. */
function finished(snapshot: ChangeRequestSnapshot, now: number, t: Translate): string {
const state = snapshot.state === 'merged' ? t('change.mergedTo', { base: snapshot.baseBranch }) : t('change.state.closed')
const ago = snapshot.closedAt === null ? undefined : formatAgo(snapshot.closedAt, now, t)
return ago === undefined ? state : t('time.finished', { state, time: ago })
}
/**
* Collapsed status after the number: checks and the most urgent flag, the merge or close time, or a read in progress.
* With `short`, failed checks take the wording without their count.
*/
function Summary({ snapshot, now, short, t }: {
readonly snapshot: ChangeRequestSnapshot | null
readonly now: number
readonly short: boolean
readonly t: Translate
}): ReactNode {
if (snapshot === null) return <StateDot state="ongoing" size={11} />
if (snapshot.state !== 'open') {
return <span className={css.finished} data-tone={snapshot.state}>{finished(snapshot, now, t)}</span>
}
const ci = ciSummary(snapshot)
const flag = flagOf(snapshot)
return (
<>
<span className={css.ci} data-tone={ci.kind === 'failed' ? 'error' : undefined}>
{ci.kind !== 'none' && <CheckGlyph state={ci.kind === 'cancelled' ? 'cancelled' : ROLLUP[snapshot.checksRollup]} size={12} />}
{ci.kind === 'failed'
? ci.count > 0 && !short ? t('change.ci.failed', { count: ci.count }) : t('change.ci.failedUnlisted')
: ci.kind === 'cancelled' ? t('change.ci.cancelled', { count: ci.count }) : t(`change.ci.${ci.kind}`)}
</span>
{flag !== undefined && <span className={css.flag} data-flag={flag}>{t(`change.flag.${flag}`)}</span>}
</>
)
}
/**
* What the collapsed status line shows when its failed checks can take the shorter wording without their count: the full
* wording and the flag, which decide the line's width. Null for any other status, and where the language's short wording
* is no shorter.
* @param snapshot - change request status.
* @param t - copy.
* @returns the line's full text after the number, or null.
*/
function shortenable(snapshot: ChangeRequestSnapshot | null, t: Translate): string | null {
if (snapshot?.state !== 'open') return null
const ci = ciSummary(snapshot)
if (ci.kind !== 'failed' || ci.count === 0) return null
const full = t('change.ci.failed', { count: ci.count })
if (t('change.ci.failedUnlisted').length >= full.length) return null
const flag = flagOf(snapshot)
return flag === undefined ? full : `${full} ${t(`change.flag.${flag}`)}`
}
/**
* Whether the collapsed status line shows the short wording of failed checks: only while the line with the full wording
* does not fit. A change of the line's width, of the fonts, or of `full` shows the full wording again for one layout pass,
* which measures it and switches before the frame is painted.
* @param line - the clipping status line.
* @param full - the line's full text after the number, from {@link shortenable}; null measures nothing.
* @returns whether the line takes the short wording.
*/
function useShortWording(line: RefObject<HTMLElement | null>, full: string | null): boolean {
const [measured, setMeasured] = useState<{ readonly full: string | null; readonly short: boolean }>({ full: null, short: false })
const short = full !== null && measured.full === full && measured.short
useLayoutEffect(() => {
if (full === null || short) return
const element = line.current
/* v8 ignore next -- the status line is mounted whenever there is a full wording to measure */
if (element === null) return
if (element.scrollWidth > element.clientWidth) setMeasured({ full, short: true })
})
useEffect(() => {
if (full === null) return
const element = line.current
/* v8 ignore next -- the status line is mounted whenever there is a full wording to measure */
if (element === null) return
// A new object renders again even when the line already shows the full wording, so the layout effect measures.
const measure = (): void => { setMeasured({ full, short: false }) }
const observer = new ResizeObserver(measure)
observer.observe(element)
const fonts = document.fonts
fonts.addEventListener('loadingdone', measure)
return () => {
observer.disconnect()
fonts.removeEventListener('loadingdone', measure)
}
}, [line, full])
return short
}
/** Expanded identity after the number: draft state and the head and base branches. */
function Target({ snapshot, t }: { readonly snapshot: ChangeRequestSnapshot; readonly t: Translate }): ReactNode {
return (
<>
{snapshot.state === 'open' && snapshot.draft && <span>{t('change.state.draft')}</span>}
<span className={css.ellipsis}>{`${snapshot.headBranch} → ${snapshot.baseBranch}`}</span>
</>
)
}
/** The merge button and its menu: a title row, one row per method with the chosen one checked, and the confirmation. */
function MergeMenu({ snapshot, name, usual, busy, onMerge, t }: {
readonly snapshot: ChangeRequestSnapshot
readonly name: string
readonly usual: MergeMethod
readonly busy: boolean
readonly onMerge: (method: MergeMethod, headSha: string) => void
readonly t: Translate
}): ReactNode {
const [open, setOpen] = useState(false)
const [confirmedHead, setConfirmedHead] = useState(snapshot.headSha)
const [chosen, setChosen] = useState<string>(usual)
const stale = confirmedHead !== snapshot.headSha
// The methods can change between polls; a choice the repository no longer allows falls back to the usual one.
const method = snapshot.mergeMethods.find(entry => entry === chosen) ?? usual
const close = (): void => { setOpen(false) }
const base = snapshot.baseBranch
const items: MenuEntry[] = [
{ type: 'label', id: 'title', text: t('change.mergeTitle', { name, base }) },
...snapshot.mergeMethods.map(entry => ({
id: entry,
label: (
<span className={css.method}>
<span>{t(`change.mergeMethod.${entry}`)}</span>
<span className={css.methodNote}>{t(`change.mergeNote.${entry}`, { base })}</span>
</span>
),
})),
]
return (
<Menu
open={open}
onClose={close}
portal
align="end"
anchor={(
<Button
size="sm"
variant="primary"
className={clsx(css.primaryAction, css.mergeAction)}
aria-haspopup="menu"
aria-expanded={open}
disabled={busy}
onClick={() => {
if (!open) setConfirmedHead(snapshot.headSha)
setOpen(!open)
}}
>
{t('change.merge')}
<IconTriangleRightFillRegular size={10} className={clsx(css.mergeCaret, open && css.mergeCaretOpen)} />
</Button>
)}
items={items}
selectedId={method}
onSelect={setChosen}
>
<MenuItemButton
separatorBefore
disabled={stale}
onSelect={() => {
close()
onMerge(method, confirmedHead)
}}
>
{t(stale ? 'change.mergeChanged' : 'change.mergeConfirm')}
</MenuItemButton>
</Menu>
)
}
/** The footer with the merge action of an open change request the host would merge now. */
function Primary({ entry, snapshot, name, actions, t }: {
readonly entry: ForgePanelChangeRequest
readonly snapshot: ChangeRequestSnapshot
readonly name: string
readonly actions: ChangeRequestActions
readonly t: Translate
}): ReactNode {
// One request at a time: the action stays disabled until the previous one settles.
const [busy, setBusy] = useState(false)
const run = (action: () => Promise<void>): void => {
setBusy(true)
void action().finally(() => { setBusy(false) })
}
const { merge } = actions
if (snapshot.state !== 'open' || snapshot.draft) return null
const [usual] = snapshot.mergeMethods
if (!snapshot.mergeReady || usual === undefined || merge === undefined) return null
return (
<div className={css.footer}>
<MergeMenu
snapshot={snapshot}
name={name}
usual={usual}
busy={busy}
onMerge={(method, headSha) => { run(() => merge(entry, { method, headSha })) }}
t={t}
/>
</div>
)
}
/**
* The card's actions menu: open on the host, copy the link, view the changes
* of a served change request, mark an open draft ready, and remove the binding.
*/
function CardMenu({ entry, snapshot, name, url, actions, t }: {
readonly entry: ForgePanelChangeRequest
readonly snapshot: ChangeRequestSnapshot | null
readonly name: string
readonly url: string
readonly actions: ChangeRequestActions
readonly t: Translate
}): ReactNode {
const [open, setOpen] = useState(false)
// One ready request at a time: the item stays disabled until the previous one settles.
const [busy, setBusy] = useState(false)
const { remove, markReady, viewChanges } = actions
const ready = markReady !== undefined && snapshot?.state === 'open' && snapshot.draft
? () => {
setBusy(true)
void markReady(entry).finally(() => { setBusy(false) })
}
: undefined
// Each item carries the action it runs, so a selection never reaches another item's action.
const choices: { readonly item: MenuItem; readonly run: () => void }[] = [
{ item: { id: 'open', label: t('change.view'), icon: <IconRightUpOutlineRegular size={14} /> }, run: () => { actions.openLink(url) } },
{ item: { id: 'copy', label: t('change.copy'), icon: <IconCopyOutlineRegular size={14} /> }, run: () => { actions.copyLink(url) } },
...viewChanges !== undefined && snapshot !== null && entry.ref !== null ? [{
item: { id: 'changes', label: t('change.viewChanges'), icon: <IconFilesDiffOutlineRegular size={14} /> },
run: () => { viewChanges(entry) },
}] : [],
...ready === undefined ? [] : [{
item: { id: 'ready', label: t('change.markReady'), icon: <IconCheckCircleOutlineRegular size={14} />, disabled: busy },
run: ready,
}],
...remove === undefined ? [] : [{
item: { id: 'remove', label: t('change.remove'), icon: <IconCloseOutlineRegular size={14} />, danger: true },
run: () => { remove(entry) },
}],
]
// Removing sits apart from the other actions.
const items: MenuEntry[] = choices.flatMap(({ item }) => item.id === 'remove'
? [{ type: 'separator' as const, id: 'remove-separator' }, item] : [item])
const select = (id: string): void => {
setOpen(false)
for (const choice of choices) if (choice.item.id === id) choice.run()
}
return (
<Menu
open={open}
onClose={() => { setOpen(false) }}
portal
align="end"
anchor={(
<button
type="button"
className={`${css.iconButton} ${css.moreButton}`}
aria-label={t('change.actions', { name })}
aria-haspopup="menu"
aria-expanded={open}
onClick={() => { setOpen(!open) }}
>
<IconEllipsisOutlineRegular size={14} />
</button>
)}
items={items}
onSelect={select}
/>
)
}
function Details({ entry, snapshot, name, now, actions, locale, t }: {
readonly entry: ForgePanelChangeRequest
readonly snapshot: ChangeRequestSnapshot
readonly name: string
readonly now: number
readonly actions: ChangeRequestActions
readonly locale: string
readonly t: Translate
}): ReactNode {
const changes = <ChangesRow entry={entry} snapshot={snapshot} name={name} actions={actions} locale={locale} t={t} />
if (snapshot.state !== 'open') {
return (
<div className={css.rows}>
<div className={css.row}>
<RowParts label={undefined} icon={<ChangeRequestGlyph tone={snapshot.state} tinted={false} size={16} />}
value={finished(snapshot, now, t)} tone={snapshot.state} opens={false} />
</div>
{changes}
</div>
)
}
const review = t(REVIEW[snapshot.reviewDecision])
const reviewTone = snapshot.reviewDecision === 'changes-requested' ? 'error' : snapshot.reviewDecision === 'approved' ? 'success' : undefined
const merge = snapshot.mergeability === 'mergeable'
? t('change.merge.mergeable')
: snapshot.mergeability === 'conflicting' ? t('change.merge.conflicting', { base: snapshot.baseBranch }) : t('change.merge.unknown')
return (
<div className={css.rows}>
<ChecksRow key={snapshot.headSha} entry={entry} snapshot={snapshot} openLink={actions.openLink} readChecks={actions.readChecks}
rerunChecks={actions.rerunChecks} t={t} />
<ReviewRow entry={entry} snapshot={snapshot} tone={reviewTone} openLink={actions.openLink} value={review}
requestReviews={actions.requestReviews} reviewerCandidates={actions.reviewerCandidates} t={t} />
<MergeRow entry={entry} snapshot={snapshot} value={merge} updateBranch={actions.updateBranch}
icon={<ChangeRequestGlyph tone="merged" tinted={false} size={16} />}
tone={snapshot.mergeability === 'conflicting' ? 'error' : undefined} t={t} />
{changes}
<IssuesRow snapshot={snapshot} openLink={actions.openLink} t={t} />
</div>
)
}
/**
* Render one change request.
* @param props - change request, expansion, current time, actions, and copy.
* @returns the card.
*/
export function ChangeRequestCard({ entry, expanded, onToggle, now, actions, locale, t }: ChangeRequestCardProps): ReactNode {
const snapshot = entry.snapshot
const number = numberOf(entry)
const url = snapshot?.url ?? entry.url
const failure = failureOf(entry)
const notice = entry.ref === null ? 'change.unserved' : failure === undefined ? undefined : FAILURE[failure.code]
const tone = toneOf(snapshot)
const name = number === null ? snapshot?.title ?? url : t('change.number', { number })
const titleRef = useRef<HTMLSpanElement>(null)
const lineRef = useRef<HTMLSpanElement>(null)
const titleMarquee = useHoverMarquee(titleRef)
const lineMarquee = useHoverMarquee(lineRef)
// One hover on the head carries every text it clips: the title, and the collapsed number and status line.
const marquee = useMemo(() => ({
onPointerEnter: (event: PointerEvent): void => {
titleMarquee.onPointerEnter(event)
lineMarquee.onPointerEnter(event)
},
onPointerLeave: (): void => {
titleMarquee.onPointerLeave()
lineMarquee.onPointerLeave()
},
}), [titleMarquee, lineMarquee])
const short = useShortWording(lineRef, expanded || notice !== undefined ? null : shortenable(snapshot, t))
// A notice replaces the collapsed summary, so a failed read never shows its stale status beside it.
const meta = expanded
? snapshot === null ? null : <Target snapshot={snapshot} t={t} />
: notice === undefined ? <Summary snapshot={snapshot} now={now} short={short} t={t} /> : null
const parts = (
<>
{number !== null && <span>{t('change.number', { number })}</span>}
{number !== null && meta !== null && <span className={css.dot} aria-hidden="true">·</span>}
{meta}
</>
)
return (
<li className={css.change} data-forge-change={entry.url} data-expanded={expanded ? '' : undefined}>
<div className={css.changeHead} {...marquee}>
<ChangeRequestGlyph tone={tone} size={16} label={t('change.stateAria', { state: t(TONE_LABEL[tone]) })} />
<div className={css.headText}>
<a
className={css.changeTitle}
href={url}
target="_blank"
rel="noreferrer"
onClick={(event) => {
event.preventDefault()
actions.openLink(url)
}}
>
<MarqueeText ref={titleRef}>{snapshot?.title ?? url.replace(/^https?:\/\//i, '')}</MarqueeText>
</a>
{(number !== null || meta !== null) && (
<div className={css.meta}>
{expanded ? parts : <MarqueeText ref={lineRef} className={css.statusLine}>{parts}</MarqueeText>}
</div>
)}
</div>
{actions.renderActions?.({ url: entry.url, ref: entry.ref, headSha: snapshot?.headSha ?? null, state: snapshot?.state ?? null })}
<CardMenu entry={entry} snapshot={snapshot} name={name} url={url} actions={actions} t={t} />
<button
type="button"
className={css.iconButton}
aria-expanded={expanded}
aria-label={t(expanded ? 'change.collapse' : 'change.expand', { name })}
onClick={onToggle}
>
<IconChevronDownOutlineRegular size={12} className={clsx(css.chevron, expanded && css.chevronOpen)} />
</button>
</div>
{notice !== undefined && (
<div className={css.notice}>
<span>{t(notice)}</span>
{entry.ref === null
? <Button size="sm" variant="outline" onClick={() => { actions.openLink(url) }}>{t('change.view')}</Button>
: <Button size="sm" variant="outline" onClick={actions.retry}>{t('retry')}</Button>}
</div>
)}
{expanded && snapshot !== null && (
<Details entry={entry} snapshot={snapshot} name={name} now={now} actions={actions} locale={locale} t={t} />
)}
{expanded && snapshot !== null && <Primary entry={entry} snapshot={snapshot} name={name} actions={actions} t={t} />}
</li>
)
}