Files
Triple-C/app/src/components/settings/UpdateDialog.tsx
T
shadow-testandClaude Opus 5 d6f065a2b6 Fix HIGH and MEDIUM frontend defects
Files pane
- F16: a drag-out released back inside the app no longer re-imports its own
  staged copy over the container original. An in-flight flag (cleared from the
  drag plugin's `onEvent` channel, with a watchdog) suppresses the drop and the
  "Drop files into …" hint, and an exact staged-path filter is the second line
  of defence — the `path|size|modified` cache could otherwise write a
  minutes-old snapshot over a file an agent had since rewritten.
- F17: a slow upload/rename no longer yanks the user back to the directory the
  operation started in. Every operation captures its target path and re-lists
  only if the user is still there; failures go to the toast host either way.
- The grid keeps keyboard focus. Roving tabindex (one tab stop, not one per
  row) plus focus restore after navigation, rename commit/cancel and Escape.
- Transient failures now surface in `ToastHost` (z-[60], persistent aria-live)
  instead of a `role="alert"` 300 rows down a scroller or behind a modal
  overlay. The inline error is kept only for the listing failure.
- `navigate` is sequenced by generation; "Save to host…" sets `busy`.
- Grid a11y: column headers, a text affordance for folder vs file, a live
  region that is mounted empty and announces completion, Label-in-Name fixed.
- FileViewerModal: the blob URL is released only once its replacement exists;
  the preview is a focusable, named, scrollable region.

Native drop routing
- New `lib/dropTarget.ts`: the hit test now refuses a drop while any
  `[aria-modal="true"]` dialog or `[data-blocks-drop]` overlay is up, and
  checks z-order where the environment can answer it. Shared by FilesTab and
  TerminalView; App's shutdown overlay opts in.

Disk
- A partially failed reclaim says so in words ("… — 2 of 5 failed"), not by hue
  alone.
- The scan/reclaim race is closed: every mutation retires an in-flight scan, so
  a scan can no longer repaint a pre-reclaim report plus a clickable plan of
  objects that are gone. Scan is disabled while working; the status is a live
  region; a failed destructive action keeps its dialog open and reports there.
- The "unknown" layer count gets a screen-reader fallback; `--text-disabled`
  no longer carries live information.

Terminal / OAuth
- After the toast is dismissed, a truncated heuristic guess can no longer fill
  the slot that an exact OSC 8 or relay URL occupied — the detector remembers
  every exact URL and drops any candidate that is a strict prefix of one.
- The prompt is reachable by keyboard: Ctrl+Shift+O jumps to the default
  action, Escape dismisses, focus returns to the terminal, and auto-dismiss
  holds off while focus is inside. It deliberately does not steal focus.
- UrlToast renders through `ui/Button` and `--shadow-overlay`.

Elsewhere
- AuthBridgeRow: a pushed `auth-bridge-changed` status always outranks an older
  awaited toggle result.
- The last two ad-hoc byte formatters route through `lib/formatBytes`.

Contract for the backend agent: `upload_file_to_container` refusing to
overwrite must satisfy `isFileExistsError` in `src/lib/uploadErrors.ts` (marker
`FILE_EXISTS`) and accept an `overwrite` argument; the frontend turns that into
an `ui/Modal` Replace/Skip prompt rather than a raw error string.

Tests: 536 -> 627 passing. `npm run build` and `npx tsc --noEmit` green.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GBq2rGum6GX7xXgsas1fDc
2026-08-23 11:11:43 -07:00

95 lines
3.2 KiB
TypeScript

import { openUrl } from "@tauri-apps/plugin-opener";
import type { UpdateInfo } from "../../lib/types";
import Modal from "../ui/Modal";
import Button from "../ui/Button";
import { formatBytes } from "../../lib/formatBytes";
interface Props {
updateInfo: UpdateInfo;
currentVersion: string;
onDismiss: () => void;
onClose: () => void;
}
export default function UpdateDialog({
updateInfo,
currentVersion,
onDismiss,
onClose,
}: Props) {
const handleDownload = async (url: string) => {
try {
await openUrl(url);
} catch (e) {
console.error("Failed to open URL:", e);
}
};
return (
<Modal
title="Update Available"
onClose={onClose}
widthClassName="w-[30rem]"
footer={
<>
<Button
variant="ghost"
className="mr-auto text-[var(--accent)] hover:text-[var(--accent-hover)]"
onClick={() => handleDownload(updateInfo.release_url)}
>
View on Gitea
</Button>
<Button variant="ghost" onClick={onDismiss}>
Dismiss
</Button>
<Button onClick={onClose}>Close</Button>
</>
}
>
<div className="flex items-center gap-2 mb-4 text-[13px]">
<span className="text-[var(--text-secondary)] font-mono">{currentVersion}</span>
<span className="text-[var(--text-secondary)]">&rarr;</span>
<span className="text-[var(--accent)] font-semibold font-mono">
{updateInfo.version}
</span>
</div>
{updateInfo.body && (
<div className="mb-4">
<h3 className="text-[11px] font-semibold uppercase tracking-wide text-[var(--text-secondary)] mb-1">
Release notes
</h3>
<div className="text-xs text-[var(--text-primary)] whitespace-pre-wrap bg-[var(--bg-primary)] rounded-[var(--radius-control)] p-3 max-h-48 overflow-y-auto border border-[var(--border-color)]">
{updateInfo.body}
</div>
</div>
)}
{updateInfo.assets.length > 0 && (
<div className="space-y-1">
<h3 className="text-[11px] font-semibold uppercase tracking-wide text-[var(--text-secondary)] mb-1">
Downloads
</h3>
{updateInfo.assets.map((asset) => (
<button
key={asset.name}
type="button"
onClick={() => handleDownload(asset.browser_download_url)}
className="w-full flex items-center justify-between px-3 py-2 text-xs bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-[var(--radius-control)] hover:border-[var(--accent)] transition-colors"
>
<span className="truncate font-mono">{asset.name}</span>
<span className="text-[var(--text-secondary)] ml-2 flex-shrink-0">
{/* `binary` because a release asset's size is the ÷1024 figure
every OS file browser shows for the same download. This
used to be a local copy that rendered KB whole and stopped
the ladder at MB; see `formatBytes.ts`. */}
{formatBytes(asset.size, { binary: true })}
</span>
</button>
))}
</div>
)}
</Modal>
);
}