Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions web/src/pages/admin-backups/RestoreChoose.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { SettingFieldStatus } from "@/pages/admin-settings/SettingField";

import { OmittedAccounts } from "./BackupWarningDetails";
import { Disclosure } from "./Disclosure";
import { PlanSentences } from "./RestoreReview";
import { ItemRow, SameRow, type ToggleKeys } from "./RestoreRows";
import { AccountRow, DataTypesPanel } from "./RestoreUsers";
import {
Expand Down Expand Up @@ -240,13 +241,20 @@ function LibraryGroupRows({
open={open}
onOpenChange={setOpen}
controls={listId}
className="text-foreground gap-1.5 text-[13px] font-medium"
className="text-foreground max-w-full gap-1.5 text-[13px] font-medium"
>
{/* One run of text, so the count follows the name's last word. A name
with no spaces still breaks to fit. The name keeps its own direction,
so a name in another script can't pull the count across it. The count
is an inline block, so it moves to the next line whole. */}
<span className="wrap-anywhere">
is an inline block, so it moves to the next line whole. The button and
the text stay within the row, which clips sideways the part of a name
that can't wrap, such as one long run of joined emoji. The 0.25em of
padding, offset by a negative margin, keeps letters whole whose ink
reaches past their edge. */}
<span
title={name}
className="-mx-[0.25em] min-w-0 overflow-x-clip px-[0.25em] wrap-anywhere"
>
{/* eslint-disable-next-line formatjs/no-literal-string-in-jsx -- a space, not text */}
<span className="bidi-text me-1">{name}</span>{" "}
<span className="text-muted-foreground inline-block font-normal tabular-nums">
Expand Down Expand Up @@ -669,10 +677,12 @@ export function RestoreChoose({
background playback bar, and for the 6rem of page padding below this
grid: without that, the end of the page pushes the panel back up
under the control. A longer summary scrolls on its own, above
Review. */}
Review. min-w-0: on a narrow screen the summary shares the sections'
column, so a sentence it can't wrap would otherwise widen every
section past the screen. */}
<aside
aria-labelledby="restore-summary-heading"
className="surface-panel-subtle h-fit space-y-4 rounded-xl p-5 lg:sticky lg:top-[calc(4rem+var(--impersonation-banner-height))] lg:flex lg:max-h-[calc(100dvh-10rem-var(--impersonation-banner-height)-var(--playback-bar-clearance,0px))] lg:flex-col"
className="surface-panel-subtle h-fit min-w-0 space-y-4 rounded-xl p-5 lg:sticky lg:top-[calc(4rem+var(--impersonation-banner-height))] lg:flex lg:max-h-[calc(100dvh-10rem-var(--impersonation-banner-height)-var(--playback-bar-clearance,0px))] lg:flex-col"
>
{/* The 4px inset keeps the section buttons' focus rings clear of this
box's clipping edge. The fade covers only the box's bottom padding,
Expand All @@ -690,15 +700,7 @@ export function RestoreChoose({
{t("web.admin.backups.restore.choose.nothingChosen")}
</p>
) : (
<ul className="list-disc space-y-1.5 ps-5 text-sm">
{plan.flatMap((group) =>
group.sentences.map((sentence, position) => (
<li key={`${group.section}-${position}`}>
{t("web.admin.backups.restore.plan.sentence", { sentence })}
</li>
)),
)}
</ul>
<PlanSentences sentences={plan.flatMap((group) => group.sentences)} />
)}
<p className="text-muted-foreground text-[13px] leading-relaxed">
{t("web.admin.backups.restore.choose.recoveryPoint")}
Expand Down
47 changes: 40 additions & 7 deletions web/src/pages/admin-backups/RestoreReview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Button } from "@/components/ui/button";
import { Checkbox } from "@/components/ui/checkbox";
import { Label } from "@/components/ui/label";
import { useT } from "@/i18n";
import { cn } from "@/lib/utils";
import { FieldGroup } from "@/pages/admin-settings/FieldGroup";

import { restoreCaveats, restorePlan, type SelectionKeys } from "./restoreModel";
Expand Down Expand Up @@ -37,6 +38,36 @@ export interface RestoreReviewProps {
*/
const REFUSAL_ACTION = "h-auto min-h-8 max-w-full py-1 text-balance whitespace-normal";

/**
* The plan's sentences as a bulleted list, here and in the Choose step's summary. The part
* of a name that can't wrap, such as one long run of joined emoji, is clipped sideways at
* the list's edge; the words around it still wrap. The clip has 0.25em of padding, offset by
* a negative margin, so letters whose ink reaches past their edge stay whole. It sits on the
* end side only: the start padding already gives that room and holds the bullets, which
* clipping each item would cut off.
*/
export function PlanSentences({
sentences,
className,
}: {
sentences: readonly string[];
className?: string;
}) {
const t = useT();
return (
<ul
className={cn(
"-me-[0.25em] list-disc space-y-1.5 overflow-x-clip ps-5 pe-[0.25em] text-sm wrap-anywhere",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

S1 (P3) — Keep clipped names distinguishable in the restore plan

At a 1024 px viewport with default Text Size, two library names made from 41 joined emoji that differ only in the last emoji render identically in both Choose and Review. In a Chromium fixture using the app CSS, main’s Choose summary could scroll 474 px sideways to reveal the difference. With this change it has zero horizontal scroll, and neither plan displays the differing character. An admin can no longer tell those entries apart by reading the plan before restoring.

Keep the list inside its column and offer a keyboard- and touch-accessible way to read the full name when a line clips. Limit that reveal to clipped names so ordinary sentences don’t gain tooltips.

className,
)}
>
{sentences.map((sentence, position) => (
<li key={position}>{t("web.admin.backups.restore.plan.sentence", { sentence })}</li>
Comment on lines +60 to +65

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kody code-review Bug medium

Clipped plan names cannot be inspected in the summary or review

Users cannot distinguish selected plans with the same visible prefix when their names are clipped. Provide an accessible way to reveal the full sentence on Choose and Review.

Prompt for LLM
File web/src/pages/admin-backups/RestoreReview.tsx, lines 60-65:

Clipped plan names cannot be inspected in the summary or review

Clipping the plan sentence without exposing the original text prevents users from identifying the full selected name on both Choose and Review, including when two names share the same visible prefix. Provide an accessible way to reveal the complete sentence or name without relying on the clipped text.

Suggested code:

<li key={position} title={sentence}>{t("web.admin.backups.restore.plan.sentence", { sentence })}</li>

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

))}
</ul>
);
}

/** Step 2: the whole plan in sentences, what it leaves out, and the button. */
export function RestoreReview({
set,
Expand All @@ -58,25 +89,27 @@ export function RestoreReview({
<div className="max-w-[70rem] space-y-5">
{plan.map((group) => (
<FieldGroup key={group.section} label={group.title}>
<ul className="list-disc space-y-1.5 py-3.5 ps-5 text-sm wrap-anywhere">
{group.sentences.map((sentence, position) => (
<li key={position}>{t("web.admin.backups.restore.plan.sentence", { sentence })}</li>
))}
</ul>
<PlanSentences sentences={group.sentences} className="py-3.5" />
</FieldGroup>
))}
{caveats.length > 0 ? (
<FieldGroup
label={t("web.admin.backups.restore.review.leftOut")}
description={t("web.admin.backups.restore.review.leftOutDescription")}
>
<ul className="space-y-2 py-3.5 text-sm wrap-anywhere">
{/* Clips a name that can't wrap like PlanSentences, but on both sides: this list
has no start padding or bullets. The name's title shows it in full. */}
<ul className="-mx-[0.25em] space-y-2 overflow-x-clip px-[0.25em] py-3.5 text-sm wrap-anywhere">
{caveats.map((caveat) => (
<li key={caveat.key}>
{t("web.admin.backups.restore.review.caveat", {
label: caveat.label,
text: caveat.text,
b: (chunks) => <span className="font-medium">{chunks}</span>,
b: (chunks) => (
<span title={caveat.label} className="font-medium">
{chunks}
</span>
),
muted: (chunks) => <span className="text-muted-foreground">{chunks}</span>,
})}
</li>
Expand Down
17 changes: 13 additions & 4 deletions web/src/pages/admin-backups/RestoreRun.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,30 @@ function ReportRow({ item }: { item: RestoreReportItem }) {
? t("web.admin.backups.restore.run.restart")
: null,
].filter((detail): detail is string => Boolean(detail));
const label = displayLabel(item);
return (
<li className="border-border/60 flex items-start gap-3 border-b py-3 last:border-b-0">
<outcome.Icon aria-hidden="true" className={cn("mt-0.5 size-4 shrink-0", outcome.tone)} />
<div className="min-w-0 flex-1">
{/* Part of a name that can't wrap, such as one long run of joined emoji, is clipped
sideways at the row's edge, in the item's line and in its profiles' lines; the words
around it still wrap. The 0.25em of padding, offset by a negative margin, keeps
letters whole whose ink reaches past their edge. */}
<div className="-mx-[0.25em] min-w-0 flex-1 overflow-x-clip px-[0.25em]">

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kody code-review Bug medium

Report row clipping hides portions of restore diagnostics

Users can lose diagnostic details in unbreakable text from item.error, item.message, notes, and profile diagnostics. Restrict clipping to name-bearing lines or provide a way to inspect the full text.

Prompt for LLM
File web/src/pages/admin-backups/RestoreRun.tsx, line 99:

Report row clipping hides portions of restore diagnostics

The new clipping container also truncates unbreakable runs in `item.error`, `item.message`, notes, and profile diagnostics, none of which have a title or other full-text view. Restrict clipping to the name-bearing lines or provide a way to inspect the complete diagnostic text.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

<p className="text-sm wrap-anywhere">
{t("web.admin.backups.restore.run.itemLine", {
label: displayLabel(item),
label,
section: t(SECTION_TITLES[item.section]),
// The status stays whole: no break at its spaces or between its Chinese, Japanese,
// or Korean characters. One wider than the line still breaks, through
// `wrap-anywhere`. (An inline block would let the line break before it, leaving
// the message's "·" at the end of a line.) <bdi> keeps the direction isolation a
// string value gets in right-to-left languages.
outcome: <bdi className="break-keep">{nonBreaking(t(outcome.label))}</bdi>,
b: (chunks) => <span className="font-medium">{chunks}</span>,
b: (chunks) => (
<span title={label} className="font-medium">
{chunks}
</span>
),
muted: (chunks) => (
<span className="text-muted-foreground">{keepSeparatorsWithNext(chunks)}</span>
),
Expand Down Expand Up @@ -172,7 +181,7 @@ function AccountReport({
<span className="me-1.5 font-medium">
{/* <bdi> isolates the name's direction. It sits inside the span, so the
margin follows the page's direction, not the name's. */}
<bdi>{profile.label}</bdi>
<bdi title={profile.label}>{profile.label}</bdi>
</span>
<wbr />
<span className="text-muted-foreground inline-block">
Expand Down
Loading