Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/status/status-page.node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ test('status page renders components, incidents, unknown state, and escapes deta
expect(healthy).toContain('99.98% uptime')
expect(healthy).toContain('http-equiv="refresh"')
expect(healthy).toMatch(/operational|All systems/i)
// Mobile phones cannot fit 90×2px bars + gaps; bars must be allowed to shrink.
expect(healthy).toMatch(/\.bar\s*\{[^}]*min-width:\s*0/)
expect(healthy).toMatch(/\.bars\s*\{[^}]*overflow:\s*hidden/)
expect(healthy).not.toMatch(/\.bar\s*\{[^}]*min-width:\s*2px/)

const down = renderStatusPage(
snapshot({
Expand Down
32 changes: 28 additions & 4 deletions packages/status/status-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,45 @@ h1 { font-size: 1.5rem; margin: 0; }
border-radius: 0.75rem;
padding: 1rem 1.25rem;
margin-bottom: 1rem;
overflow: hidden;
min-width: 0;
}
.component { display: flex; flex-direction: column; gap: 0.5rem; }
.component { display: flex; flex-direction: column; gap: 0.5rem; min-width: 0; }
.component-header { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.component-name { font-weight: 600; }
.component-meta { color: var(--muted); font-size: 0.85rem; }
.dot { display: inline-block; width: 0.6rem; height: 0.6rem; border-radius: 50%; margin-right: 0.5rem; vertical-align: baseline; }
.dot.operational { background: var(--ok); }
.dot.down { background: var(--down); }
.dot.unknown { background: var(--unknown); }
.bars { display: flex; gap: 2px; height: 2rem; align-items: stretch; }
.bar { flex: 1 1 0; border-radius: 1px; background: var(--ok); min-width: 2px; }
/* 90 day bars: allow shrink below 2px so the row fits phone content widths
* (iPhone ~321px after padding; min-width:2px + gaps overflowed). */
.bars {
display: flex;
gap: 2px;
height: 2rem;
align-items: stretch;
min-width: 0;
overflow: hidden;
}
.bar {
flex: 1 1 0;
border-radius: 1px;
background: var(--ok);
min-width: 0;
}
.bar.empty { background: var(--border); }
.bar.partial { background: var(--partial); }
.bar.bad { background: var(--down); }
.bars-legend { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.75rem; }
.bars-legend {
display: flex;
justify-content: space-between;
gap: 0.5rem;
color: var(--muted);
font-size: 0.75rem;
min-width: 0;
}
.bars-legend span { min-width: 0; overflow-wrap: anywhere; }
.incident { border-left: 3px solid var(--down); padding-left: 0.75rem; margin: 0.75rem 0; }
.incident.resolved { border-left-color: var(--ok); }
.incident-title { font-weight: 600; }
Expand Down
7 changes: 5 additions & 2 deletions packages/worker/src/email/inbound-due-owners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,11 @@ export async function loadInboundDueOwnersHealth(input: {
}
}

export function getMailboxInboundDueAt(sql: SqlStorage): string | null {
const nowMs = Date.now()
export function getMailboxInboundDueAt(
sql: SqlStorage,
now?: Date,
): string | null {
const nowMs = (now ?? new Date()).getTime()
const candidates: Array<string> = []
const stale = sql
.exec<{
Expand Down
1 change: 1 addition & 0 deletions packages/worker/src/email/mailbox-do.ts
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,7 @@ class MailboxBase extends DurableObject<Env> implements MailboxRpc {

async getInboundDueWorkHint(input: {
ownerId: string
now?: string
}): Promise<{ dueAt: string | null }> {
return this.inbound.getInboundDueWorkHint(input)
}
Expand Down
9 changes: 8 additions & 1 deletion packages/worker/src/email/mailbox-inbound-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,13 @@ export class MailboxInboundCommands {
input: Parameters<MailboxRpc['getInboundDueWorkHint']>[0],
) {
this.store.assertOwner(input.ownerId)
return { dueAt: getMailboxInboundDueAt(this.ctx.storage.sql) }
let now: Date | undefined
if (input.now != null) {
const parsed = Date.parse(input.now)
if (Number.isFinite(parsed)) now = new Date(parsed)
}
return {
dueAt: getMailboxInboundDueAt(this.ctx.storage.sql, now),
}
}
}
5 changes: 4 additions & 1 deletion packages/worker/src/email/mailbox-maintenance-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ export class MailboxMaintenanceCommands {
}

private nextAlarmDueAtMs(nowMs: number = Date.now()) {
const inboundDueAt = getMailboxInboundDueAt(this.ctx.storage.sql)
const inboundDueAt = getMailboxInboundDueAt(
this.ctx.storage.sql,
new Date(nowMs),
)
const inboundDueAtMs =
inboundDueAt == null ? null : Date.parse(inboundDueAt)
const dueTimes = [
Expand Down
2 changes: 2 additions & 0 deletions packages/worker/src/email/mailbox-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,8 @@ type MailboxCoreRpc = {
}) => Promise<MailboxRunRetentionNowResult>
getInboundDueWorkHint: (input: {
ownerId: string
/** Optional clock for due-at clamping; defaults to wall clock. */
now?: string
}) => Promise<{ dueAt: string | null }>
purge: () => Promise<{ ok: true }>
}
Expand Down
5 changes: 4 additions & 1 deletion packages/worker/src/email/reconcile-inbound-deliveries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,10 @@ export async function sweepStaleInboundDeliveries(input: {
const hint = await mailboxRpc({
env: input.env,
userId,
}).getInboundDueWorkHint({ ownerId: userId })
}).getInboundDueWorkHint({
ownerId: userId,
now: now.toISOString(),
})
await replaceInboundDueOwnerHint({
db: input.env.APP_DB,
userId,
Expand Down
Loading