fix(stage-6): dashboard hardening + audit Lows cherry-pick
Closes 4 dashboard hardening findings and 5 of the Lows from the audit. Dashboard hardening: - Subtabs no longer re-fetch the app via api.apps.get on every page load. users/files/dead-letters drop the fetch outright (the variable was set but never read); queues + queues/[name] now consume the layout's AppContext via getContext for the page title. The layout's reloadApp() owns the historical-slug redirect — subtab-local redirect blocks are removed so there's no race. - The global :global(details > summary::before) chevron is now scoped to details.chevron. The script editor's "Advanced sandbox" details and the inbound-email-shape help-text both opt in; the script exec-list logs no longer inherit a spurious chevron. - deriveTab now matches the path segment by anchored ===, so a future /apps/<slug>/queues-archived route wouldn't activate the queues tab. Lows cherry-pick: - ExecError gains Serialize/Deserialize derives + a snake_case tag so RemoteExecutorClient (cluster mode v1.3+) can round-trip the variant. - triggers_api rejects queue triggers whose visibility_timeout_secs is below the dispatcher's per-message executor budget; with no minimum the reclaim task races the handler and the queue silently double-delivers. Existing test using 5s updated to 30s. - New migration 0040: execution_logs.script_id cascade switched from ON DELETE CASCADE to ON DELETE SET NULL so deleting a script no longer wipes the forensic history that motivated the delete. - New migration 0041: dead_letters composite index on (app_id, created_at DESC) so the "list all" dashboard view stops falling back to seqscan + sort when unresolved=false. - Schema snapshot re-blessed. Deferred to v1.2: the ExecRequest principal serde(skip) marker (documented in-place; the cluster-mode PR will introduce the wire-safe snapshot at that point) and the `pic --help` mention of `picloud admin reset-password` (one-line follow-up). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -57,11 +57,24 @@
|
||||
if (pathname.endsWith(`/apps/${slug}`) || pathname.endsWith(`/apps/${slug}/`)) {
|
||||
return qpTab ?? 'scripts';
|
||||
}
|
||||
if (pathname.includes(`/apps/${slug}/users`)) return 'users';
|
||||
if (pathname.includes(`/apps/${slug}/files`)) return 'files';
|
||||
if (pathname.includes(`/apps/${slug}/queues`)) return 'queues';
|
||||
if (pathname.includes(`/apps/${slug}/dead-letters`)) return 'dead-letters';
|
||||
return 'scripts';
|
||||
// Anchored matches: only the named subtab *exactly* (followed by
|
||||
// `/` or end-of-string), so a hypothetical `/apps/<slug>/queues-archived`
|
||||
// route doesn't activate the `queues` tab. Audit hardening note.
|
||||
const root = `/apps/${slug}/`;
|
||||
const after = pathname.startsWith(root) ? pathname.slice(root.length) : '';
|
||||
const head = after.split('/', 1)[0];
|
||||
switch (head) {
|
||||
case 'users':
|
||||
return 'users';
|
||||
case 'files':
|
||||
return 'files';
|
||||
case 'queues':
|
||||
return 'queues';
|
||||
case 'dead-letters':
|
||||
return 'dead-letters';
|
||||
default:
|
||||
return 'scripts';
|
||||
}
|
||||
}
|
||||
|
||||
async function reloadApp() {
|
||||
|
||||
@@ -1281,7 +1281,7 @@
|
||||
<code>X-Picloud-Signature</code> HMAC-SHA256 (hex of the request body);
|
||||
leave it blank to accept unsigned POSTs (URL secrecy only).
|
||||
</p>
|
||||
<details class="muted small">
|
||||
<details class="muted small chevron">
|
||||
<summary>Expected inbound JSON shape</summary>
|
||||
<pre>{`{
|
||||
"from": "sender@external.com",
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
<script lang="ts">
|
||||
import { base } from '$app/paths';
|
||||
import { goto } from '$app/navigation';
|
||||
import { page } from '$app/state';
|
||||
import { api, ApiError, type App, type DeadLetterRow } from '$lib/api';
|
||||
import { api, ApiError, type DeadLetterRow } from '$lib/api';
|
||||
|
||||
let slug = $derived(page.params.slug ?? '');
|
||||
let app = $state<App | null>(null);
|
||||
let rows = $state<DeadLetterRow[]>([]);
|
||||
let unresolved = $state<number>(0);
|
||||
let loading = $state(true);
|
||||
@@ -13,16 +10,13 @@
|
||||
let unresolvedOnly = $state(true);
|
||||
let expandedId = $state<string | null>(null);
|
||||
|
||||
// The parent layout (apps/[slug]/+layout.svelte) already fetches the
|
||||
// app + drives the historical-slug redirect. This page only needs the
|
||||
// DL count and the row list — no duplicate api.apps.get().
|
||||
async function load() {
|
||||
loading = true;
|
||||
error = null;
|
||||
try {
|
||||
const a = await api.apps.get(slug);
|
||||
if (a.redirect_to && a.redirect_to !== slug) {
|
||||
await goto(`${base}/apps/${a.redirect_to}/dead-letters`, { replaceState: true });
|
||||
return;
|
||||
}
|
||||
app = a;
|
||||
const c = await api.deadLetters.count(slug);
|
||||
unresolved = c.unresolved;
|
||||
const r = await api.deadLetters.list(slug, { unresolved: unresolvedOnly, limit: 100 });
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
<script lang="ts">
|
||||
import { base } from '$app/paths';
|
||||
import { goto } from '$app/navigation';
|
||||
import { page } from '$app/state';
|
||||
import { api, ApiError, type App, type FileMeta } from '$lib/api';
|
||||
import { api, ApiError, type FileMeta } from '$lib/api';
|
||||
import ConfirmModal from '$lib/ConfirmModal.svelte';
|
||||
|
||||
let slug = $derived(page.params.slug ?? '');
|
||||
let app = $state<App | null>(null);
|
||||
let collection = $state('');
|
||||
let activeCollection = $state('');
|
||||
let files = $state<FileMeta[]>([]);
|
||||
@@ -21,19 +19,6 @@
|
||||
/// instead of having to guess.
|
||||
let collectionHints = $state<string[]>([]);
|
||||
|
||||
async function loadApp() {
|
||||
try {
|
||||
const fetched = await api.apps.get(slug);
|
||||
if (fetched.redirect_to && fetched.redirect_to !== slug) {
|
||||
await goto(`${base}/apps/${fetched.redirect_to}/files`, { replaceState: true });
|
||||
return;
|
||||
}
|
||||
app = fetched;
|
||||
} catch (e) {
|
||||
error = e instanceof ApiError ? e.message : String(e);
|
||||
}
|
||||
}
|
||||
|
||||
async function loadCollectionHints() {
|
||||
try {
|
||||
const r = await api.triggers.list(slug);
|
||||
@@ -51,7 +36,6 @@
|
||||
|
||||
$effect(() => {
|
||||
void slug;
|
||||
void loadApp();
|
||||
void loadCollectionHints();
|
||||
});
|
||||
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
<script lang="ts">
|
||||
import { base } from '$app/paths';
|
||||
import { goto } from '$app/navigation';
|
||||
import { page } from '$app/state';
|
||||
import { api, ApiError, type App, type QueueSummary } from '$lib/api';
|
||||
|
||||
import { onDestroy } from 'svelte';
|
||||
import { getContext, onDestroy } from 'svelte';
|
||||
import { api, ApiError, type QueueSummary } from '$lib/api';
|
||||
import { APP_CTX_KEY, type AppContext } from '../+layout.svelte';
|
||||
|
||||
let slug = $derived(page.params.slug ?? '');
|
||||
let app = $state<App | null>(null);
|
||||
// Read the layout's app store instead of re-fetching. The layout
|
||||
// already drives the historical-slug redirect, so we don't repeat
|
||||
// that here either.
|
||||
const ctx = getContext<AppContext>(APP_CTX_KEY);
|
||||
const appStore = ctx?.app;
|
||||
let appName = $derived($appStore?.name ?? slug);
|
||||
let queues = $state<QueueSummary[]>([]);
|
||||
let loading = $state(false);
|
||||
let error = $state<string | null>(null);
|
||||
@@ -16,22 +20,6 @@
|
||||
let autoRefresh = $state(false);
|
||||
let autoRefreshHandle: ReturnType<typeof setInterval> | null = null;
|
||||
|
||||
async function loadApp() {
|
||||
try {
|
||||
const fetched = await api.apps.get(slug);
|
||||
// Mirror apps/[slug]/+page.svelte:619-623. Without this, an
|
||||
// operator who bookmarks /admin/apps/oldslug/queues continues
|
||||
// to see the renamed app's queues under the stale URL.
|
||||
if (fetched.redirect_to && fetched.redirect_to !== slug) {
|
||||
await goto(`${base}/apps/${fetched.redirect_to}/queues`, { replaceState: true });
|
||||
return;
|
||||
}
|
||||
app = fetched;
|
||||
} catch (e) {
|
||||
error = e instanceof ApiError ? e.message : String(e);
|
||||
}
|
||||
}
|
||||
|
||||
async function loadQueues() {
|
||||
loading = true;
|
||||
error = null;
|
||||
@@ -63,13 +51,12 @@
|
||||
|
||||
$effect(() => {
|
||||
void slug;
|
||||
void loadApp();
|
||||
void loadQueues();
|
||||
});
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>Queues — {app?.name ?? slug} — PiCloud</title>
|
||||
<title>Queues — {appName} — PiCloud</title>
|
||||
</svelte:head>
|
||||
|
||||
<header class="panel-head">
|
||||
|
||||
@@ -1,29 +1,25 @@
|
||||
<script lang="ts">
|
||||
import { base } from '$app/paths';
|
||||
import { goto } from '$app/navigation';
|
||||
import { page } from '$app/state';
|
||||
import { api, ApiError, type App, type QueueDetail } from '$lib/api';
|
||||
import { getContext } from 'svelte';
|
||||
import { api, ApiError, type QueueDetail } from '$lib/api';
|
||||
import { APP_CTX_KEY, type AppContext } from '../../+layout.svelte';
|
||||
|
||||
let slug = $derived(page.params.slug ?? '');
|
||||
let name = $derived(page.params.name ?? '');
|
||||
let app = $state<App | null>(null);
|
||||
const ctx = getContext<AppContext>(APP_CTX_KEY);
|
||||
const appStore = ctx?.app;
|
||||
let appName = $derived($appStore?.name ?? slug);
|
||||
let detail = $state<QueueDetail | null>(null);
|
||||
let loading = $state(false);
|
||||
let error = $state<string | null>(null);
|
||||
|
||||
// The parent layout owns the historical-slug redirect — this page
|
||||
// just fetches its queue detail.
|
||||
async function load() {
|
||||
loading = true;
|
||||
error = null;
|
||||
try {
|
||||
const fetched = await api.apps.get(slug);
|
||||
if (fetched.redirect_to && fetched.redirect_to !== slug) {
|
||||
await goto(
|
||||
`${base}/apps/${fetched.redirect_to}/queues/${encodeURIComponent(name)}`,
|
||||
{ replaceState: true }
|
||||
);
|
||||
return;
|
||||
}
|
||||
app = fetched;
|
||||
detail = await api.queues.get(slug, name);
|
||||
} catch (e) {
|
||||
error = e instanceof ApiError ? e.message : String(e);
|
||||
@@ -44,7 +40,7 @@
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>{name} — Queues — {app?.name ?? slug} — PiCloud</title>
|
||||
<title>{name} — Queues — {appName} — PiCloud</title>
|
||||
</svelte:head>
|
||||
|
||||
<header class="panel-head">
|
||||
|
||||
@@ -1,17 +1,10 @@
|
||||
<script lang="ts">
|
||||
import { base } from '$app/paths';
|
||||
import { page } from '$app/state';
|
||||
import {
|
||||
api,
|
||||
ApiError,
|
||||
type App,
|
||||
type AppUser,
|
||||
type ResetPasswordResponse
|
||||
} from '$lib/api';
|
||||
import { api, ApiError, type AppUser, type ResetPasswordResponse } from '$lib/api';
|
||||
import ConfirmModal from '$lib/ConfirmModal.svelte';
|
||||
|
||||
let slug = $derived(page.params.slug ?? '');
|
||||
let app = $state<App | null>(null);
|
||||
let users = $state<AppUser[]>([]);
|
||||
let nextCursor = $state<string | null>(null);
|
||||
let loading = $state(false);
|
||||
@@ -38,14 +31,6 @@
|
||||
let resetToken = $state<ResetPasswordResponse | null>(null);
|
||||
let resetting = $state(false);
|
||||
|
||||
async function loadApp() {
|
||||
try {
|
||||
app = await api.apps.get(slug);
|
||||
} catch (e) {
|
||||
error = e instanceof ApiError ? e.message : String(e);
|
||||
}
|
||||
}
|
||||
|
||||
async function loadUsers(cursor?: string) {
|
||||
loading = true;
|
||||
error = null;
|
||||
@@ -66,7 +51,6 @@
|
||||
|
||||
$effect(() => {
|
||||
void slug;
|
||||
void loadApp();
|
||||
void loadUsers();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user