refine dashboard settings and inbox UX
This commit is contained in:
@@ -761,7 +761,7 @@ describe('web dashboard room activity data', () => {
|
||||
});
|
||||
|
||||
describe('web dashboard inbox data', () => {
|
||||
it('builds typed inbox items from pending rooms, paired tasks, and CI failures', () => {
|
||||
it('builds typed inbox items from pending rooms and paired tasks only', () => {
|
||||
const snapshots: StatusSnapshot[] = [
|
||||
{
|
||||
serviceId: 'codex-main',
|
||||
@@ -840,7 +840,6 @@ describe('web dashboard inbox data', () => {
|
||||
});
|
||||
|
||||
expect(overview.inbox.map((item) => item.kind)).toEqual([
|
||||
'ci-failure',
|
||||
'approval',
|
||||
'reviewer-request',
|
||||
'pending-room',
|
||||
@@ -866,18 +865,17 @@ describe('web dashboard inbox data', () => {
|
||||
occurredAt: '2026-04-26T05:03:00.000Z',
|
||||
}),
|
||||
);
|
||||
const ciFailure = overview.inbox.find((item) => item.kind === 'ci-failure');
|
||||
expect(ciFailure).toMatchObject({
|
||||
id: 'ci:ci-2',
|
||||
severity: 'error',
|
||||
occurrences: 2,
|
||||
source: 'scheduled-task',
|
||||
taskId: 'ci-2',
|
||||
lastOccurredAt: '2026-04-26T05:07:00.000Z',
|
||||
});
|
||||
expect(ciFailure?.summary).toContain('BOT_TOKEN=<redacted>');
|
||||
expect(ciFailure?.summary).not.toContain('plain-secret-value');
|
||||
expect(overview.inbox.some((item) => item.kind === 'ci-failure')).toBe(
|
||||
false,
|
||||
);
|
||||
expect(overview.inbox.some((item) => item.taskId === 'ci-1')).toBe(false);
|
||||
expect(overview.inbox.some((item) => item.taskId === 'ci-2')).toBe(false);
|
||||
expect(overview.inbox.some((item) => item.taskId === 'cron-1')).toBe(false);
|
||||
expect(overview.inbox.some((item) => item.taskId === 'done-1')).toBe(false);
|
||||
expect(overview.tasks.watchers).toEqual({
|
||||
active: 1,
|
||||
paused: 1,
|
||||
completed: 0,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -183,10 +183,6 @@ function buildPromptPreview(prompt: string): string {
|
||||
return truncateText(redactSensitiveText(prompt).replace(/\s+/g, ' ').trim());
|
||||
}
|
||||
|
||||
function buildInboxPreview(value: string): string {
|
||||
return truncateText(redactSensitiveText(value).replace(/\s+/g, ' ').trim());
|
||||
}
|
||||
|
||||
function buildRoomBody(value: string): string {
|
||||
return redactSensitiveText(value).trim();
|
||||
}
|
||||
@@ -254,14 +250,6 @@ function normalizeStructuredVisibleContent(value: string): {
|
||||
return splitLegacyImageTags(value);
|
||||
}
|
||||
|
||||
function stableHash(value: string): string {
|
||||
let hash = 0;
|
||||
for (let index = 0; index < value.length; index += 1) {
|
||||
hash = (hash * 31 + value.charCodeAt(index)) | 0;
|
||||
}
|
||||
return Math.abs(hash).toString(36);
|
||||
}
|
||||
|
||||
function collectUsageRows(snapshots: StatusSnapshot[]): UsageRowSnapshot[] {
|
||||
const rows: UsageRowSnapshot[] = [];
|
||||
const seen = new Set<string>();
|
||||
@@ -282,21 +270,6 @@ function collectUsageRows(snapshots: StatusSnapshot[]): UsageRowSnapshot[] {
|
||||
return rows;
|
||||
}
|
||||
|
||||
function failedTaskResult(task: ScheduledTask): string | null {
|
||||
if (!task.last_result) return null;
|
||||
const normalized = task.last_result.toLowerCase();
|
||||
if (
|
||||
normalized.includes('fail') ||
|
||||
normalized.includes('error') ||
|
||||
normalized.includes('timeout') ||
|
||||
normalized.includes('cancel') ||
|
||||
normalized.includes('reject')
|
||||
) {
|
||||
return buildInboxPreview(task.last_result);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function pairedTaskInboxKind(
|
||||
status: PairedTask['status'],
|
||||
): InboxItemKind | null {
|
||||
@@ -383,31 +356,6 @@ function collectInboxItems(args: {
|
||||
});
|
||||
}
|
||||
|
||||
for (const task of args.tasks) {
|
||||
if (!isWatchCiTask(task)) continue;
|
||||
const result = failedTaskResult(task);
|
||||
if (!result) continue;
|
||||
|
||||
items.push({
|
||||
id: `ci:${task.id}`,
|
||||
groupKey: `ci:${stableHash(result.toLowerCase())}`,
|
||||
kind: 'ci-failure',
|
||||
severity: task.status === 'paused' ? 'error' : 'warn',
|
||||
title: 'CI watcher failed',
|
||||
summary: result,
|
||||
occurredAt: task.last_run ?? task.created_at,
|
||||
lastOccurredAt: task.last_run ?? task.created_at,
|
||||
createdAt: args.createdAt,
|
||||
occurrences: 1,
|
||||
source: 'scheduled-task',
|
||||
roomJid: task.chat_jid,
|
||||
groupFolder: task.group_folder,
|
||||
serviceId: task.agent_type ?? undefined,
|
||||
taskId: task.id,
|
||||
taskStatus: task.status,
|
||||
});
|
||||
}
|
||||
|
||||
const severityRank: Record<InboxItemSeverity, number> = {
|
||||
error: 0,
|
||||
warn: 1,
|
||||
|
||||
Reference in New Issue
Block a user