diff --git a/frontend/src/app/x/ClipsPanel.tsx b/frontend/src/app/x/ClipsPanel.tsx index 3be2a14..686ce86 100644 --- a/frontend/src/app/x/ClipsPanel.tsx +++ b/frontend/src/app/x/ClipsPanel.tsx @@ -29,6 +29,7 @@ type XClipJob = { error?: string; x2_job_id?: string; tweet_id?: string; + account_username?: string; push_date?: string; created_at?: number; }; @@ -79,11 +80,10 @@ export function ClipsPanel({ const load = useCallback(async () => { try { const iso = todayBeijingISO(); - const acct = (accountUsername || "").trim().replace(/^@/, ""); - const q = acct ? `&account_username=${encodeURIComponent(acct)}` : ""; + // Always load full day list; filter client-side so legacy (no account) jobs stay visible const [status, jobData] = await Promise.all([ fetchJson("/api/x-clips/status"), - fetchJson(`/api/x-clips/jobs?push_date=${iso}&limit=40${q}`), + fetchJson(`/api/x-clips/jobs?push_date=${iso}&limit=80`), ]); setSt(status || null); const s = status?.settings || {}; @@ -93,7 +93,19 @@ export function ClipsPanel({ setTrigger(String(s.x_clips_trigger || "tagged")); setSampleAny(Boolean(s.x_clips_sample_any_live ?? true)); setAutoPost(Boolean(s.x_clips_auto_post ?? true)); - setJobs(jobData?.jobs || []); + const acct = (accountUsername || "").trim().replace(/^@/, "").toLowerCase(); + const all = (jobData?.jobs || []) as XClipJob[]; + setJobs( + acct + ? all.filter((j) => { + const own = String(j.account_username || "") + .trim() + .replace(/^@/, "") + .toLowerCase(); + return !own || own === acct; + }) + : all, + ); } catch (e) { toast((e as Error).message || "加载失败", "err"); } diff --git a/frontend/src/app/x/page.tsx b/frontend/src/app/x/page.tsx index 4bc1522..d3cc782 100644 --- a/frontend/src/app/x/page.tsx +++ b/frontend/src/app/x/page.tsx @@ -68,19 +68,18 @@ export default function XPage() { const [username, setUsername] = useState(""); - // Persist selected account across reloads + // Persist selected account across reloads ("" = 全部账号) useEffect(() => { try { - const saved = window.localStorage.getItem("x2_selected_account") || ""; - if (saved) setUsername(saved); + const saved = window.localStorage.getItem("x2_selected_account"); + if (saved !== null) setUsername(saved); } catch { /* ignore */ } }, []); useEffect(() => { try { - if (username) window.localStorage.setItem("x2_selected_account", username); - else window.localStorage.removeItem("x2_selected_account"); + window.localStorage.setItem("x2_selected_account", username); } catch { /* ignore */ } @@ -111,12 +110,15 @@ export default function XPage() { setUsername((cur) => { if (cur && accs.some((a) => String(a.username || "") === cur)) return cur; try { - const saved = window.localStorage.getItem("x2_selected_account") || ""; + const saved = window.localStorage.getItem("x2_selected_account"); + // Explicit empty string means「全部账号」 + if (saved === "") return ""; if (saved && accs.some((a) => String(a.username || "") === saved)) return saved; } catch { /* ignore */ } - return accs[0]?.username ? String(accs[0].username) : cur || ""; + // Default: 全部账号 — never hide history by auto-picking first account + return cur || ""; }); } catch (e: unknown) { toast.push((e as Error)?.message || "加载失败", "err"); diff --git a/frontend/src/lib/xOps.ts b/frontend/src/lib/xOps.ts index 9e3f207..f95279b 100644 --- a/frontend/src/lib/xOps.ts +++ b/frontend/src/lib/xOps.ts @@ -114,7 +114,9 @@ export function jobAccountHandle(job: XJob): string { return fromResult.toLowerCase(); } -/** Filter jobs by selected account. Empty selected = show all. */ +/** Filter jobs by selected account. Empty selected = show all. + * Legacy jobs without account attribution stay visible (do not hide history). + */ export function jobMatchesAccount(job: XJob, selectedUsername: string): boolean { const sel = String(selectedUsername || "") .trim() @@ -122,8 +124,7 @@ export function jobMatchesAccount(job: XJob, selectedUsername: string): boolean .toLowerCase(); if (!sel) return true; const own = jobAccountHandle(job); - // Unattributed legacy jobs: hide when a specific account is selected - if (!own) return false; + if (!own) return true; return own === sel; }