* 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.
70 lines
2.7 KiB
TypeScript
70 lines
2.7 KiB
TypeScript
/** The changes view's body while it reads: a status line above file cards drawn as skeletons. */
|
|
|
|
import clsx from 'clsx'
|
|
import type { ReactNode } from 'react'
|
|
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'
|
|
import type { NS } from './locales.ts'
|
|
import css from './ChangesLoading.module.css'
|
|
|
|
/** Widths, in percent of a line, that the skeleton's code bars cycle through. */
|
|
const CODE_WIDTHS = [62, 48, 74, 35, 81, 56, 44, 69, 28, 52, 77, 39] as const
|
|
|
|
/**
|
|
* The skeleton cards: a changed file shown in two columns when the view splits sides, an added file, and two
|
|
* collapsed files. `path` is the path bar's width in percent of the header.
|
|
*/
|
|
const FILES = [
|
|
{ path: 46, lines: 7, sides: 2 },
|
|
{ path: 34, lines: 4, sides: 1 },
|
|
{ path: 52, lines: 0, sides: 1 },
|
|
{ path: 28, lines: 0, sides: 1 },
|
|
] as const
|
|
|
|
function Column({ lines, offset }: { readonly lines: number; readonly offset: number }): ReactNode {
|
|
return (
|
|
<div className={css.column}>
|
|
{Array.from({ length: lines }, (_, index) => (
|
|
<div key={index} className={css.line}>
|
|
<span className={clsx(css.fill, css.number)} />
|
|
<span className={clsx(css.fill, css.code)} style={{ width: `${CODE_WIDTHS[(index + offset) % CODE_WIDTHS.length]}%` }} />
|
|
</div>
|
|
))}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
/**
|
|
* Render the reading state of the changes view. The status line is the only text and announces itself politely;
|
|
* the cards are hidden from assistive technology.
|
|
* @param props - whether changed files show their sides in two columns, and copy.
|
|
* @returns the status line and the skeleton cards.
|
|
*/
|
|
export function ChangesLoading({ split, t }: { readonly split: boolean } & PropsLocale<typeof NS>): ReactNode {
|
|
return (
|
|
<>
|
|
<div className={css.status} role="status">{t('diff.loading')}</div>
|
|
<div aria-hidden="true" data-forge-changes-skeleton="">
|
|
{FILES.map((file, index) => {
|
|
const columns = split && file.sides === 2
|
|
return (
|
|
<div key={index} className={clsx(css.file, file.lines === 0 && css.folded)}>
|
|
<div className={css.header}>
|
|
<span className={clsx(css.fill, css.icon)} />
|
|
<span className={clsx(css.fill, css.path)} style={{ width: `${file.path}%` }} />
|
|
<span className={clsx(css.fill, css.counts)} />
|
|
<span className={clsx(css.fill, css.box)} />
|
|
</div>
|
|
{file.lines > 0 && (
|
|
<div className={clsx(css.lines, columns && css.split)}>
|
|
<Column lines={file.lines} offset={index * 5} />
|
|
{columns && <Column lines={file.lines} offset={index * 5 + 4} />}
|
|
</div>
|
|
)}
|
|
</div>
|
|
)
|
|
})}
|
|
</div>
|
|
</>
|
|
)
|
|
}
|