Skip to content

Commit 6518b81

Browse files
committed
style(ui): tighten the new frontend comments to stay inside the size budget
Rollup ships src/ comments verbatim in dist/index.js, and the bundle sits close to its 800 kB size-limit: 796.76 kB before this branch. The new comments alone pushed it to 800.61 kB and failed `pnpm size`. Condense them to the load-bearing reasoning — every "why" is kept, only restatement is dropped. Two blocks in SlotSetupWizard went entirely: the surrounding comments already said "any other resolved result proves the server answered", which covers the new not_found case. 799.34 kB.
1 parent 0845a97 commit 6518b81

6 files changed

Lines changed: 36 additions & 53 deletions

File tree

src/api/backend.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -443,10 +443,10 @@ export interface VersionInfo {
443443
* the picker renders nothing. When `true`, `versions` lists every version
444444
* (local + server-only) with markers; `server_query_failed` is `true` when the
445445
* live `sibling_roms` view could not be fetched, so the list is local-only
446-
* (partial-success carve-out). A definitive 404 on the bound id is NOT such a
447-
* failure — the server answered, it just no longer has that ROM — so the
448-
* local-only list comes back with `server_query_failed: false` and the picker
449-
* leaves the shared connection state alone (#1570).
446+
* (partial-success carve-out). A 404 on the bound id is NOT such a failure —
447+
* the server answered — so the local-only list comes back with
448+
* `server_query_failed: false` and the picker leaves the connection state
449+
* alone (#1570).
450450
*/
451451
export interface VersionList {
452452
multi_version: boolean;

src/components/CustomPlayButton.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -735,10 +735,9 @@ export const CustomPlayButton: FC<CustomPlayButtonProps> = ({ appId }) => { // N
735735
// believing the conflict was cleared. Surface it and stay in conflict,
736736
// exactly like the network-throw catch below (#1276).
737737
if (result.server_query_failed) {
738-
// Only an explicit unreachable verdict is a connectivity signal. A
739-
// definitive 404 means the server ANSWERED, so feeding the global
740-
// store off the bare flag would black out the whole UI over a ROM
741-
// the server merely no longer has (#1570) — see connectionState.ts.
738+
// Only an explicit unreachable verdict is a connectivity signal:
739+
// feeding the store off the bare flag blacked out the whole UI over a
740+
// ROM the server merely no longer has (#1570).
742741
if (result.server_query_reason === "server_unreachable") {
743742
reportServerReachable(false);
744743
}

src/components/SlotSetupWizard.tsx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -516,12 +516,10 @@ function useSaveSetupInfo(romId: number, onComplete: () => void) {
516516
if (cancelled) return;
517517
// Feed the shared store (#1345): a server_unreachable result is a
518518
// definitive offline signal; any other resolved result proves the
519-
// server answered. A throw is a bridge/unknown error, not a verdict —
520-
// the catch leaves the store untouched.
521-
// Only an explicit unreachable verdict means offline. A `not_found`
522-
// result PROVES the server answered, so it reports reachable and
523-
// leaves the reconnect gate disarmed — the wizard still holds, it
524-
// just doesn't wait for a connection that was never lost (#1570).
519+
// server answered — including a `not_found`, which still holds the
520+
// wizard but leaves the reconnect gate disarmed (#1570). A throw is a
521+
// bridge/unknown error, not a verdict — the catch leaves the store
522+
// untouched.
525523
const reachable = result.recommended_action !== "server_unreachable";
526524
reportServerReachable(reachable);
527525
offlineHeldRef.current = !reachable;
@@ -580,10 +578,6 @@ function useSaveSetupInfo(romId: number, onComplete: () => void) {
580578
// Same conservative feed as the initial load (#1345): the manual
581579
// Retry re-probes reachability, so a server_unreachable result
582580
// re-arms offline and any other result reports the server back.
583-
// Only an explicit unreachable verdict means offline. A `not_found`
584-
// result PROVES the server answered, so it reports reachable and
585-
// leaves the reconnect gate disarmed — the wizard still holds, it
586-
// just doesn't wait for a connection that was never lost (#1570).
587581
const reachable = result.recommended_action !== "server_unreachable";
588582
reportServerReachable(reachable);
589583
offlineHeldRef.current = !reachable;

src/components/saves/VersionHistoryPanel.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ export const VersionHistoryPanel: FC<VersionHistoryPanelProps> = ({
5151
// hidden for multi-file slots anyway; this is the defensive backstop.
5252
setVersions(result.versions);
5353
} else if (result.status === "not_found") {
54-
// The server answered: it has no such ROM / device id. Saying
55-
// "couldn't reach RomM" here would blame a connection that is
56-
// plainly working (#1570).
54+
// The server answered — blaming the connection here would be a lie (#1570).
5755
detach(debugLog(`VersionHistoryPanel: server has no such entry for ${filename}: ${result.message}`));
5856
setVersions(null);
5957
setLoadError("RomM no longer has this game's saves.");
@@ -156,9 +154,8 @@ export const VersionHistoryPanel: FC<VersionHistoryPanelProps> = ({
156154
// instead of telling the user the version is gone.
157155
toaster.toast({ title: "RomM Sync", body: "Couldn't reach RomM. Check your connection and try again." });
158156
} else if (result.status === "not_found") {
159-
// The mirror image of the branch above: RomM answered that it no
160-
// longer has this game's saves, so a retry cannot help and the
161-
// toast must not send the user off to check their connection (#1570).
157+
// Mirror of the branch above: RomM answered, so a retry cannot help
158+
// and the toast must not send the user to check their connection.
162159
toaster.toast({ title: "RomM Sync", body: "RomM no longer has this game's saves — nothing was restored." });
163160
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- exhaustive final branch of the 9-member RollbackStatus union; an explicit check (vs. plain `else`) keeps the per-status symmetry and leaves any future-added status unhandled instead of silently routing it to the "unsupported" toast
164161
} else if (result.status === "unsupported") {

src/types/saves.ts

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,9 @@ export interface SaveStatus {
9393
* and surface a misleading uploads-pending indicator on what is in
9494
* fact a connectivity blip. */
9595
server_query_failed?: boolean;
96-
/** Why that query failed, as a backend `classify_error` slug (`null` when
97-
* it didn't). The flag says the server's view is unknown — true for a
98-
* definitive 404 as much as for an outage — while this says *why*, so
99-
* only `"server_unreachable"` may drive the global connection store.
100-
* Feeding the store off the bare flag is the #1570 defect. */
96+
/** Why it failed (`null` when it didn't). The flag says the server's view is
97+
* unknown — true for a 404 as much as for an outage; this says why, so only
98+
* `"server_unreachable"` may drive the connection store (#1570). */
10199
server_query_reason?: RommErrorCode | null;
102100
/** True when the active slot's current save spans more than one distinct
103101
* file (e.g. Sega Saturn `.bkr`/`.bcr`/`.smpc`). Those siblings are
@@ -171,15 +169,15 @@ export interface SaveSetupInfo {
171169
default_slot: string;
172170
slot_confirmed: boolean;
173171
active_slot: string | null;
174-
// "server_unreachable" means the server-saves fetch failed — the wizard MUST
175-
// hold and offer a retry instead of treating the empty server_slots as
176-
// authoritative (auto-confirming default would clobber real server saves on
177-
// first sync). "not_found" is the same hold for a different cause: the
178-
// server ANSWERED that it has no such ROM or device id, so the wizard must
172+
// "server_unreachable" and "not_found" both mean the server-saves fetch
173+
// failed, so the wizard MUST hold and offer a retry instead of treating the
174+
// empty server_slots as authoritative (auto-confirming default would clobber
175+
// real server saves on first sync). They differ only in cause: "not_found"
176+
// is the server ANSWERING that it has no such ROM or device id, so it must
179177
// not report the server offline (#1570). See backend `get_save_setup_info`.
180178
recommended_action: "auto_confirm_default" | "show_wizard" | "server_unreachable" | "not_found";
181-
// True whenever the server-saves query failed, whichever way — an explicit
182-
// flag for call sites that route on the boolean rather than the enum.
179+
// True whenever that query failed, either way — for call sites routing on a
180+
// boolean rather than the enum.
183181
server_query_failed?: boolean;
184182
}
185183

@@ -235,9 +233,9 @@ export type RollbackStatus =
235233
| { status: "version_deleted" }
236234
| { status: "unsupported" }
237235
| { status: "server_unreachable"; message: string }
238-
// The server ANSWERED with a definitive 404 — it no longer has this ROM or
239-
// the registered device id. Distinct from `server_unreachable` (retryable)
240-
// and from `version_deleted` (one missing save inside a ROM it still has).
236+
// The server ANSWERED 404 — no such ROM or device id. Distinct from
237+
// `server_unreachable` (retryable) and `version_deleted` (one save missing
238+
// from a ROM it still has).
241239
| { status: "not_found"; message: string }
242240
| { status: "conflict_blocked"; conflicts: SyncConflict[] }
243241
| { status: "preflight_failed"; errors: string[] }
@@ -246,8 +244,8 @@ export type RollbackStatus =
246244
export type ListFileVersionsResult =
247245
| { status: "ok"; versions: SaveVersionEntry[] }
248246
| { status: "multi_file_unsupported"; versions: SaveVersionEntry[] }
249-
| { status: "server_unreachable"; message: string }
250247
// See RollbackStatus — the server answered, it just has no such entry.
248+
| { status: "server_unreachable"; message: string }
251249
| { status: "not_found"; message: string };
252250

253251
/** Discriminated-status result of `copySaveToSlot` — copies one server save into

src/utils/saveSetup.ts

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
* `recommended_action` carries the explicit failure mode from the backend (see
1010
* `get_save_setup_info`); the call site MUST NOT treat an empty `server_slots`
1111
* array as authoritative on either path or it risks clobbering real server
12-
* saves on first sync. The two hold identically and differ only in copy — one
13-
* blames the connection, the other says RomM could not find what setup needs.
12+
* saves on first sync. They hold identically and differ only in copy.
1413
*/
1514

1615
import type { SaveSetupInfo } from "../types";
@@ -26,9 +25,8 @@ export function resolveSaveSetupOutcome(info: SaveSetupInfo): SaveSetupOutcome {
2625
if (info.recommended_action === "server_unreachable") {
2726
return { kind: "server_unreachable" };
2827
}
29-
// The server answered that it has no such ROM or device id. Same hold as
30-
// above — an empty `server_slots` is no more authoritative here than on an
31-
// outage, so this must NOT fall through to the auto-confirm branch (#1570).
28+
// Same hold: an empty `server_slots` is no more authoritative on a 404 than
29+
// on an outage, so this must NOT fall through to auto-confirm (#1570).
3230
if (info.recommended_action === "not_found") {
3331
return { kind: "not_found" };
3432
}
@@ -55,11 +53,9 @@ export const SERVER_UNREACHABLE_WIZARD_MESSAGE =
5553
export const SERVER_UNREACHABLE_TOAST_BODY =
5654
"Cannot configure save slot — RomM server is not reachable. Open the Saves tab to retry.";
5755

58-
/** Copy for the `not_found` branch — the server answered, it just has no such
59-
* ROM or device id. Deliberately does NOT say the game has no saves: the 404
60-
* can come from this device's registration (a RomM database reset drops it),
61-
* so claiming the saves don't exist would swap one lie for a more specific
62-
* one. It states what RomM could not find, and that setup is on hold. */
56+
/** Copy for the `not_found` branch. Deliberately does NOT say the game has no
57+
* saves: the 404 can come from this device's registration (a RomM database
58+
* reset drops it), so that would swap one lie for a more specific one. */
6359
export const NOT_FOUND_WIZARD_MESSAGE =
6460
"RomM couldn't find the save data for this setup — setup paused. The game or this device may no longer be on the server.";
6561

@@ -107,8 +103,8 @@ export async function applyLaunchGateSetupOutcome(
107103
deps.dispatchSavesTab();
108104
return "abort";
109105
}
110-
// Same abort, honest cause. The launch must NOT proceed with save tracking
111-
// unconfigured just because the failure was a 404 rather than an outage.
106+
// Same abort, honest cause — a 404 must not let the launch proceed with save
107+
// tracking unconfigured.
112108
if (outcome.kind === "not_found") {
113109
deps.toast(NOT_FOUND_TOAST_BODY);
114110
deps.dispatchSavesTab();
@@ -173,7 +169,6 @@ export async function applyWizardInitialSetupResult(result: SaveSetupInfo, deps:
173169
return;
174170
}
175171
if (result.recommended_action === "not_found") {
176-
// Same hold, honest cause — never auto-confirm on an unproven server view.
177172
deps.setError(NOT_FOUND_WIZARD_MESSAGE);
178173
return;
179174
}

0 commit comments

Comments
 (0)