refactor(dashboard): rethink settings, split out subreddits and accounts
The settings page had accumulated five tabs whose names no longer matched their contents, three different save models, and the whole subreddit configuration buried under a tab named after a checkbox. Structure: - Subreddits becomes its own page: a list showing each community's mode, tone, computed share of polling, and live sent/reply stats, with one subreddit edited at a time in a drawer. - Accounts becomes its own page. It is session lifecycle, not config. - Settings collapses to one scrolling page: Safety, Pacing (Monitoring and Rate limits merged), Targeting, Notifications, Advanced. - The sidebar is grouped, having gone from 9 to 11 destinations. Saving: - Every section owns its own draft, validation, risk gate and save via useConfigCard, submitting only the keys it owns. A syntax error in the advanced JSON can no longer block a rate-limit change, and enabling an autonomous policy is its own deliberate commit. - UnsavedChangesProvider restores the leave-page guard across cards that no longer share a draft. Subreddit editing: - Errors are keyed by field name instead of array index, removing the defensive invalidation that existed because row indices shifted on add and remove. Confirming an autonomous mode can no longer be attributed to the wrong row. - Weight is shown as the share it actually produces, live while editing. - Bulk actions cover start/pause polling, tone, policy and removal, because production runs 30-40 subreddits and per-row editing does not scale. Bulk policy changes name every subreddit turning autonomous, and normalise the hybrid mode's turn budget, which has no form to catch it. Physique targeting moves into its own Targeting card. It sends only reddit.physiqueTargeting, which the config route applies independently, so it cannot clobber the pacing card's fields. Turning screening on now warns that it will reduce how many posts qualify. Also surfaces the effective sending rate, since the hourly limit and the minimum delay both throttle and only the binding one matters. Legacy ?section= links redirect or resolve to anchors. Fixes found while verifying in a browser: a radio-card rule was shrinking nested number inputs; .share-preview had no styles; the throughput readout reported a rate from a blank field; and the reconcile logic warned about a server change whenever a sibling card saved. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
11b6300113
commit
c43e534cf1
36 files changed
+4414
-1632
No files matched your search
@@ -0,0 +1,114 @@
|
||||
import type { ConfigResponse } from '../../../../../packages/api-contracts/src/index.js';
|
||||
import { conversationModes, type ConversationMode, type SubredditConfig } from './subreddit-model.js';
|
||||
|
||||
interface SubredditBulkBarProps {
|
||||
selected: readonly SubredditConfig[];
|
||||
/** True when a bulk write is in flight. */
|
||||
isBusy: boolean;
|
||||
/** Set when removing the selection is not allowed, explaining why. */
|
||||
removeBlockedReason?: string;
|
||||
tones: ConfigResponse['tones'];
|
||||
onClear(): void;
|
||||
onRemove(): void;
|
||||
onSetEnabled(enabled: boolean): void;
|
||||
onSetPolicy(mode: ConversationMode): void;
|
||||
onSetTone(tone: ConfigResponse['tones'][number]): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Acts on many subreddits at once. With dozens configured, opening each row to
|
||||
* change one shared field is the slowest possible path.
|
||||
*/
|
||||
export function SubredditBulkBar({
|
||||
isBusy,
|
||||
onClear,
|
||||
onRemove,
|
||||
onSetEnabled,
|
||||
onSetPolicy,
|
||||
onSetTone,
|
||||
removeBlockedReason,
|
||||
selected,
|
||||
tones,
|
||||
}: SubredditBulkBarProps) {
|
||||
const pausedCount = selected.filter((subreddit) => !subreddit.enabled).length;
|
||||
const pollingCount = selected.length - pausedCount;
|
||||
|
||||
return (
|
||||
<div aria-label="Bulk actions" className="bulk-bar" role="region">
|
||||
<div className="bulk-bar-count" aria-live="polite">
|
||||
<strong>{selected.length} selected</strong>
|
||||
<small>{pollingCount} polling, {pausedCount} paused</small>
|
||||
</div>
|
||||
|
||||
<div className="bulk-bar-actions">
|
||||
<button
|
||||
className="button secondary"
|
||||
disabled={isBusy || pausedCount === 0}
|
||||
onClick={() => onSetEnabled(true)}
|
||||
type="button"
|
||||
>
|
||||
Start polling
|
||||
</button>
|
||||
<button
|
||||
className="button secondary"
|
||||
disabled={isBusy || pollingCount === 0}
|
||||
onClick={() => onSetEnabled(false)}
|
||||
type="button"
|
||||
>
|
||||
Pause polling
|
||||
</button>
|
||||
|
||||
{/* Value resets to the placeholder each render: these are actions, not
|
||||
a field showing the current shared value (there may not be one). */}
|
||||
<label className="bulk-select">
|
||||
<span className="sr-only">Set tone for the selected subreddits</span>
|
||||
<select
|
||||
aria-label="Set tone for the selected subreddits"
|
||||
disabled={isBusy}
|
||||
onChange={(event) => {
|
||||
if (event.target.value === '') return;
|
||||
onSetTone(event.target.value as ConfigResponse['tones'][number]);
|
||||
event.target.value = '';
|
||||
}}
|
||||
value=""
|
||||
>
|
||||
<option value="">Set tone…</option>
|
||||
{tones.map((tone) => <option key={tone} value={tone}>{tone}</option>)}
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<label className="bulk-select">
|
||||
<span className="sr-only">Set conversation policy for the selected subreddits</span>
|
||||
<select
|
||||
aria-label="Set conversation policy for the selected subreddits"
|
||||
disabled={isBusy}
|
||||
onChange={(event) => {
|
||||
if (event.target.value === '') return;
|
||||
onSetPolicy(event.target.value as ConversationMode);
|
||||
event.target.value = '';
|
||||
}}
|
||||
value=""
|
||||
>
|
||||
<option value="">Set policy…</option>
|
||||
{conversationModes.map((mode) => (
|
||||
<option key={mode.value} value={mode.value}>{mode.label}</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<button
|
||||
className="button danger"
|
||||
disabled={isBusy || Boolean(removeBlockedReason)}
|
||||
onClick={onRemove}
|
||||
title={removeBlockedReason}
|
||||
type="button"
|
||||
>
|
||||
Remove
|
||||
</button>
|
||||
<button className="button secondary" disabled={isBusy} onClick={onClear} type="button">
|
||||
Clear
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user