"Saved" is a moment, top-right, and gone in five seconds

it was a permanent line under the controls saying "Saved." — which said nothing,
because everything on this screen has been saved, all the time. it looked exactly
like feedback, so the one moment it actually meant something was indistinguishable
from every moment it did not.

now it appears when a save LANDS and clears itself. top-right of the block, beside
the title rather than in the flow: it is a remark about the block, not part of what
you are doing, and inline it pushes everything below down a line and then pulls it
back up — a layout that jumps every time somebody saves.

"Not set yet" stays. that IS a state, and it is the one worth knowing; it goes when
it stops being true rather than being replaced by a line that never changes.

the timer is a ref and is cleared before each new one. without that, saving twice
in quick succession leaves the first timeout running and it fires against the
second save — the confirmation vanishing a moment after appearing, which reads as
the second save failing.

Block moved to its own file and each setting now renders its own. the status belongs
to the setting that produced it, and lifting one block's timer into the panel would
put it in a component with nothing to do with it. that is also what made the
top-right slot possible without absolutely positioning anything.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-29 00:44:46 +01:00
co-authored by Claude Opus 5
parent df52045eaa
commit 9cbbc28c82
6 changed files with 141 additions and 58 deletions
+1 -1
View File
@@ -35,7 +35,7 @@ import type { PluginManifest } from '@@/plugins/manifest';
*/ */
export const manifest: PluginManifest = { export const manifest: PluginManifest = {
publisher: 'officerdev', publisher: 'officerdev',
version: '2026.08.29.08', version: '2026.08.29.09',
platform: '>=1.0.0', platform: '>=1.0.0',
label: 'Fofos', label: 'Fofos',
+11 -47
View File
@@ -1,62 +1,26 @@
import { Database, FolderRoot } from 'lucide-react';
import { RootLocationBlock } from './RootLocationBlock'; import { RootLocationBlock } from './RootLocationBlock';
import { DatabaseBlock } from './DatabaseBlock';
/** /**
* Administration — this plugin's own machinery, not the client's site. * Administration — this plugin's own machinery, not the client's site.
* *
* ── It is a list of blocks ── * A list of blocks, and nothing else. Each one owns its own heading, its own state and its own status
* message; this file decides only which of them exist and in what order.
* *
* Not one form. Administration holds several unrelated settings, and giving each its own titled block * The order is the order things are needed in: where the site is on this machine, then how to read its
* means adding the next one moves nothing — as against a single form that has to be broken up the * data.
* first time anything joins it. The second block cost one entry, which is the point.
*
* The order is the order things are needed in: where the site is on disk, then how to read its data.
* *
* ── What used to be here ── * ── What used to be here ──
* *
* An address and a token: where fofos is, over HTTP. That is gone. It has NOT been replaced yet, so * An address and a token: where fofos is, over HTTP. That is gone from the screen. The server half is
* nothing can currently configure this plugin — which is why `useReady` stays hardcoded false and * untouched — `/_config` still stores a URL and a token, and the proxy in `api/router.ts` still reads
* every other section stays locked. The two are the same change and neither is finished. * them — but nothing can set them, which is why `useReady` stays hardcoded false and every other
* * section stays locked. The two are the same unfinished change.
* The server half is untouched: `/_config` still stores a URL and a token, and the proxy in
* `api/router.ts` still reads them. Only the way in from the screen is gone.
*/ */
/** One titled block. The shape every Administration setting gets, so the second one costs nothing. */
const Block = ({
icon: Icon,
title,
hint,
children,
}: {
icon: typeof Database;
title: string;
hint: string;
children?: React.ReactNode;
}) => (
<section className="flex flex-col gap-3 rounded-lg border border-border p-4">
<div className="space-y-1">
<h3 className="flex items-center gap-2 text-sm font-medium">
<Icon className="size-4" />
{title}
</h3>
<p className="text-xs text-muted-foreground">{hint}</p>
</div>
{children}
</section>
);
export const AdministrationPanel = () => ( export const AdministrationPanel = () => (
<div className="flex size-full flex-col gap-4 overflow-auto p-5"> <div className="flex size-full flex-col gap-4 overflow-auto p-5">
<Block icon={FolderRoot} title="Root location" hint="Where the fofos site is on this machine."> <RootLocationBlock />
<RootLocationBlock /> <DatabaseBlock />
</Block>
<Block icon={Database} title="Database" hint="Where the fofos site's own data lives.">
{/* Deliberately empty. The block exists so the shape is settled and so the screen says what is
coming rather than looking like a section nobody finished — but nothing is decided about what
goes in it, and guessing at fields would be a decision made in the wrong place. */}
<p className="text-xs text-muted-foreground/70">Nothing to set yet.</p>
</Block>
</div> </div>
); );
+48
View File
@@ -0,0 +1,48 @@
import type { LucideIcon } from 'lucide-react';
/**
* One titled block of Administration.
*
* Every setting gets one, so the second and third cost nothing to add — as against a single form that
* has to be broken up the first time anything joins it.
*
* ── `status` is top-right, and it is for things that come and go ──
*
* Beside the title rather than under the controls: it is a remark about the block, not part of what
* you are doing, and put in the flow it pushes everything below it down by a line and then pulls it
* back up — a layout that jumps every time somebody saves.
*
* Each block renders its OWN Block, rather than the panel wrapping them. The status belongs to the
* setting that produced it, and lifting that state up to the panel would put one block's timer in a
* component that has nothing to do with it.
*/
export const Block = ({
icon: Icon,
title,
hint,
status,
children,
}: {
icon: LucideIcon;
title: string;
hint: string;
/** Top-right. Usually ephemeral — see `useFlash`. */
status?: React.ReactNode;
children?: React.ReactNode;
}) => (
<section className="flex flex-col gap-3 rounded-lg border border-border p-4">
<div className="flex items-start justify-between gap-3">
<div className="min-w-0 space-y-1">
<h3 className="flex items-center gap-2 text-sm font-medium">
<Icon className="size-4" />
{title}
</h3>
<p className="text-xs text-muted-foreground">{hint}</p>
</div>
{/* Reserves nothing when empty. The status is short and the title is not, so there is no reflow
to guard against — and an always-present placeholder would read as a field. */}
{status && <div className="shrink-0">{status}</div>}
</div>
{children}
</section>
);
+15
View File
@@ -0,0 +1,15 @@
import { Database } from 'lucide-react';
import { Block } from './Block';
/**
* Where the fofos site's own data lives.
*
* Deliberately empty. The block exists so the shape is settled and so the screen says what is coming
* rather than looking like a section nobody finished — but nothing is decided about what goes in it,
* and inventing fields to fill the space would be deciding it in the wrong place.
*/
export const DatabaseBlock = () => (
<Block icon={Database} title="Database" hint="Where the fofos site's own data lives.">
<p className="text-xs text-muted-foreground/70">Nothing to set yet.</p>
</Block>
);
+33 -10
View File
@@ -1,14 +1,24 @@
import { useCallback, useEffect, useRef, useState } from 'react'; import { useCallback, useEffect, useRef, useState } from 'react';
import { Check, Loader2, Pencil } from 'lucide-react'; import { Check, FolderRoot, Loader2, Pencil } from 'lucide-react';
import { useClient } from 'hooks/useClient'; import { useClient } from 'hooks/useClient';
import { Button } from '@/components/ui/button'; import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input'; import { Input } from '@/components/ui/input';
import { readableError } from './errors'; import { readableError } from './errors';
import { DirectoryPicker } from './DirectoryPicker'; import { DirectoryPicker } from './DirectoryPicker';
import { Block } from './Block';
import { useFlash } from './useFlash';
/** /**
* Where the fofos site is on this machine. * Where the fofos site is on this machine.
* *
* ── "Saved" is a moment, not a state ──
*
* It appears top-right when a save actually lands and is gone five seconds later. As a permanent line
* it said nothing — everything on this screen has been saved, all the time — while looking exactly
* like feedback, so the one moment it meant something was indistinguishable from the rest.
*
* "Not set yet" is the opposite and stays: that IS a state, and it is the one worth knowing.
*
* ── The default is a suggestion until it is saved ── * ── The default is a suggestion until it is saved ──
* *
* An unset root reports `<owner home>/fofos` and says so. It is not written to the database by being * An unset root reports `<owner home>/fofos` and says so. It is not written to the database by being
@@ -48,6 +58,7 @@ export const RootLocationBlock = () => {
const [busy, setBusy] = useState(false); const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null); const [error, setError] = useState<string | null>(null);
const [forbidden, setForbidden] = useState(false); const [forbidden, setForbidden] = useState(false);
const [flashing, flash] = useFlash();
const load = useCallback(async () => { const load = useCallback(async () => {
try { try {
@@ -76,6 +87,7 @@ export const RootLocationBlock = () => {
setValue(result.rootPath); setValue(result.rootPath);
setEditing(false); setEditing(false);
setPicking(false); setPicking(false);
flash();
} catch (failure) { } catch (failure) {
setError(readableError(failure)); setError(readableError(failure));
} finally { } finally {
@@ -83,12 +95,18 @@ export const RootLocationBlock = () => {
} }
}; };
const shell = (children: React.ReactNode, status?: React.ReactNode) => (
<Block icon={FolderRoot} title="Root location" hint="Where the fofos site is on this machine." status={status}>
{children}
</Block>
);
if (forbidden) { if (forbidden) {
return <p className="text-xs text-muted-foreground">Only the owner can change where the site lives.</p>; return shell(<p className="text-xs text-muted-foreground">Only the owner can change where the site lives.</p>);
} }
if (!saved) { if (!saved) {
return <p className="text-xs text-muted-foreground">Loading…</p>; return shell(<p className="text-xs text-muted-foreground">Loading…</p>);
} }
const dirty = value.trim() !== saved.rootPath; const dirty = value.trim() !== saved.rootPath;
@@ -102,7 +120,7 @@ export const RootLocationBlock = () => {
setError(null); setError(null);
}; };
return ( return shell(
<div className="flex flex-col gap-3"> <div className="flex flex-col gap-3">
{editing ? ( {editing ? (
<Input <Input
@@ -134,11 +152,10 @@ export const RootLocationBlock = () => {
{error && <p className="text-xs text-destructive">{error}</p>} {error && <p className="text-xs text-destructive">{error}</p>}
{/* Says which of the two states this is in. "Not set" reading identically to "set to exactly the {/* Only the state worth knowing. Once it is set, this line has nothing to say and goes. */}
default" is how somebody comes to believe they configured something they did not. */} {!saved.isSet && (
<p className="text-xs text-muted-foreground/80"> <p className="text-xs text-muted-foreground/80">Not set yet — this is the default until you save it.</p>
{saved.isSet ? 'Saved.' : 'Not set yet — this is the default until you save it.'} )}
</p>
{/* The block's bottom row. Everything you can DO is here, on its own line, so the path above it {/* The block's bottom row. Everything you can DO is here, on its own line, so the path above it
gets the full width. */} gets the full width. */}
@@ -163,6 +180,12 @@ export const RootLocationBlock = () => {
</Button> </Button>
)} )}
</div> </div>
</div> </div>,
flashing ? (
<span className="flex items-center gap-1 text-xs text-success">
<Check className="size-3.5" />
Saved
</span>
) : null,
); );
}; };
+33
View File
@@ -0,0 +1,33 @@
import { useCallback, useEffect, useRef, useState } from 'react';
/**
* A message that shows itself and then goes away — "Saved", and whatever joins it.
*
* ── Why this is not a piece of state somebody sets and clears ──
*
* The timer is held in a ref and CLEARED before each new one is set. Without that, saving twice in
* quick succession leaves the first timeout running, and it fires against the second save — the
* confirmation vanishes a moment after appearing, which looks like the second save failed.
*
* The cleanup on unmount matters for the same reason it always does: this lives in a panel that is
* swapped out whenever the nav moves, and a timeout that outlives its component sets state on nothing.
*/
export const useFlash = (ms = 5000) => {
const [showing, setShowing] = useState(false);
const timer = useRef<ReturnType<typeof setTimeout> | null>(null);
const clear = () => {
if (timer.current) clearTimeout(timer.current);
timer.current = null;
};
const flash = useCallback(() => {
clear();
setShowing(true);
timer.current = setTimeout(() => setShowing(false), ms);
}, [ms]);
useEffect(() => clear, []);
return [showing, flash] as const;
};