Skip to content

Commit b44a7de

Browse files
committed
fix(credits-admin): address macroscope review (toast z-index, activity race, audit index)
- toast: add z-index:50 so grant/adjust success toasts render above the detail slide-over (scrim z-30 / panel z-40) instead of beneath it. - loadActivity: request-generation counter drops stale responses, fixing the facet-switch / rapid load-more race (wrong cursor / duplicate rows). - AdminAudit: add @@index([createdAt, id]) matching the global keyset order so /audit/recent stops seq-scanning the whole table as history grows.
1 parent 74b2be2 commit b44a7de

4 files changed

Lines changed: 7 additions & 1 deletion

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- CreateIndex
2+
CREATE INDEX "AdminAudit_createdAt_id_idx" ON "AdminAudit"("createdAt", "id");

prisma/schema.prisma

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ model AdminAudit {
499499
@@unique([accountId, idempotencyKey])
500500
@@index([accountId, createdAt])
501501
@@index([actorEmail, createdAt])
502+
@@index([createdAt, id])
502503
}
503504

504505
/// Per-PR agent variant (dev XMTP network only). A named bundle pinning an

src/api/v2/credits-admin/handlers/admin-page/script.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export const clientScript = (): string => `
5050
// --- stubs completed in later tasks ---
5151
var activityAction="all";
5252
var activityCursor=null;
53+
var activityGen=0;
5354
function renderActivityRows(rows, append){
5455
var tb=document.querySelector("#activity-table tbody");
5556
var html=rows.map(function(r){
@@ -64,8 +65,10 @@ export const clientScript = (): string => `
6465
}
6566
function loadActivity(reset){
6667
if(reset){ activityCursor=null; }
68+
var gen=++activityGen;
6769
var qs="?action="+encodeURIComponent(activityAction)+(activityCursor?("&cursor="+encodeURIComponent(activityCursor)):"");
6870
guardFetch("/audit/recent"+qs).then(function(r){ return r.json(); }).then(function(j){
71+
if(gen!==activityGen) return;
6972
renderActivityRows(j.rows||[], !reset);
7073
activityCursor=j.nextCursor;
7174
el("load-more").classList.toggle("hidden", !j.nextCursor);

src/api/v2/credits-admin/handlers/admin-page/styles.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const STYLES = `
4444
.spark .bar { flex:1 1 0; min-width:3px; min-height:2px; background:var(--brand); border-radius:2px 2px 0 0; }
4545
.card { background:var(--surface); border-radius:var(--radius); padding:16px; margin-bottom:14px; }
4646
.k { font-size:12px; color:var(--muted); margin-bottom:4px; }
47-
.toast { position:fixed; bottom:24px; right:24px; padding:12px 18px; border-radius:8px; color:#fff; opacity:0; transition:opacity .2s; pointer-events:none; }
47+
.toast { position:fixed; bottom:24px; right:24px; padding:12px 18px; border-radius:8px; color:#fff; opacity:0; transition:opacity .2s; pointer-events:none; z-index:50; }
4848
.toast.show { opacity:1; } .toast-success { background:var(--ok); } .toast-error { background:var(--bad); }
4949
5050
/* Detail slide-over */

0 commit comments

Comments
 (0)