Skip to content

The only tool you need to know what is happening and how to fix it.

feat: better columns on the pages page

narrow-adventurebe3741e908b5
diff --git a/backend/app/controllers/page.controller.go b/backend/app/controllers/page.controller.go
index 26fc767d..d7571416 100644
--- a/backend/app/controllers/page.controller.go
+++ b/backend/app/controllers/page.controller.go
@@ -1,6 +1,7 @@
package controllers
import (
+ "database/sql"
"net/http"
"strconv"
"time"
@@ -27,14 +28,39 @@ type listPagesRequest struct {
// pageResponse decorates a page with the exception hash it was opened for
// (empty for pages not linked to an issue), so the dashboard can offer
-// archiving the issue when the page is resolved.
+// archiving the issue when the page is resolved, plus the display names of
+// the acknowledging/resolving users for the list columns.
type pageResponse struct {
*models.Page
- IssueHash string `json:"issueHash"`
+ IssueHash string `json:"issueHash"`
+ AcknowledgedByName string `json:"acknowledgedByName,omitempty"`
+ ResolvedByName string `json:"resolvedByName,omitempty"`
}
-func toPageResponse(page *models.Page) pageResponse {
- return pageResponse{Page: page, IssueHash: page.IssueHash()}
+func toPageResponse(page *models.Page, names map[int]string) pageResponse {
+ response := pageResponse{Page: page, IssueHash: page.IssueHash()}
+ if page.AcknowledgedBy != nil {
+ response.AcknowledgedByName = names[*page.AcknowledgedBy]
+ }
+ if page.ResolvedBy != nil {
+ response.ResolvedByName = names[*page.ResolvedBy]
+ }
+ return response
+}
+
+// memberNames maps the organization's member ids to display names; users no
+// longer in the organization simply stay absent (the frontend falls back to
+// "user #id").
+func memberNames(tx *sql.Tx, organizationId int) (map[int]string, error) {
+ members, err := transactional.OrganizationRepository.GetMembersWithDetails(tx, organizationId)
+ if err != nil {
+ return nil, err
+ }
+ names := make(map[int]string, len(members))
+ for _, member := range members {
+ names[member.Id] = member.Name
+ }
+ return names, nil
}
var validPageStatusFilters = map[string]bool{
@@ -70,9 +96,20 @@ func (c *pageController) List(ctx *gin.Context) {
ctx.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("failed to list pages: %w", err))
return
}
+ names := map[int]string{}
+ for _, page := range pages {
+ if page.AcknowledgedBy != nil || page.ResolvedBy != nil {
+ names, err = memberNames(tx, page.OrganizationId)
+ if err != nil {
+ ctx.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("failed to load members: %w", err))
+ return
+ }
+ break
+ }
+ }
items := make([]pageResponse, 0, len(pages))
for _, page := range pages {
- items = append(items, toPageResponse(page))
+ items = append(items, toPageResponse(page, names))
}
totalPages := int64(0)
@@ -105,17 +142,17 @@ func (c *pageController) Get(ctx *gin.Context) {
notifications = []*models.PageNotification{}
}
- users := map[string]string{}
- members, err := transactional.OrganizationRepository.GetMembersWithDetails(tx, page.OrganizationId)
+ names, err := memberNames(tx, page.OrganizationId)
if err != nil {
ctx.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("failed to load members: %w", err))
return
}
- for _, member := range members {
- users[strconv.Itoa(member.Id)] = member.Name
+ users := make(map[string]string, len(names))
+ for id, name := range names {
+ users[strconv.Itoa(id)] = name
}
- ctx.JSON(http.StatusOK, gin.H{"page": toPageResponse(page), "notifications": notifications, "users": users})
+ ctx.JSON(http.StatusOK, gin.H{"page": toPageResponse(page, names), "notifications": notifications, "users": users})
}
// Acknowledge deliberately has no write-access gate beyond project read
diff --git a/frontend/src/lib/state/oncall.svelte.ts b/frontend/src/lib/state/oncall.svelte.ts
index e79d94cf..b3ffb6b8 100644
--- a/frontend/src/lib/state/oncall.svelte.ts
+++ b/frontend/src/lib/state/oncall.svelte.ts
@@ -203,6 +203,8 @@ export interface OncallPage {
createdAt: string;
updatedAt: string;
issueHash: string;
+ acknowledgedByName?: string;
+ resolvedByName?: string;
}
export interface PageNotification {
diff --git a/frontend/src/routes/on-call/pages-tab.svelte b/frontend/src/routes/on-call/pages-tab.svelte
index 90038bc3..3a1e97f7 100644
--- a/frontend/src/routes/on-call/pages-tab.svelte
+++ b/frontend/src/routes/on-call/pages-tab.svelte
@@ -8,7 +8,7 @@
import { PaginationFooter } from '$lib/components/ui/pagination-footer';
import { Check, CheckCheck } from '@lucide/svelte';
import { api } from '$lib/api';
- import { formatRelativeTimeAgo } from '$lib/utils/formatters';
+ import { formatDateTime, formatRelativeTimeAgo } from '$lib/utils/formatters';
import { projectsState } from '$lib/state/projects.svelte';
import { type OncallPage } from '$lib/state/oncall.svelte';
import { runPageAction } from './page-actions';
@@ -60,8 +60,31 @@
const someSelected = $derived(selectedIds.size > 0 && selectedIds.size < pages.length);
const selectedPages = $derived(pages.filter((p) => selectedIds.has(p.id)));
const selectedOpenPages = $derived(selectedPages.filter((p) => p.status === 'open'));
+
+ // Columns vary by tab: active/open show Status + Actions, acknowledged
+ // swaps Status for who/when acknowledged, resolved drops Actions and shows
+ // both who/when columns.
+ const showStatus = $derived(statusFilter === 'active' || statusFilter === 'open');
+ const showAcknowledged = $derived(
+ statusFilter === 'acknowledged' || statusFilter === 'resolved'
+ );
+ const showResolved = $derived(statusFilter === 'resolved');
+ const showActions = $derived(statusFilter !== 'resolved');
const colCount = $derived(selectable ? 8 : 7);
+ function ackLabel(item: OncallPage): string {
+ if (item.acknowledgedBy !== null) {
+ const name = item.acknowledgedByName || `user #${item.acknowledgedBy}`;
+ return item.acknowledgedVia === 'link' ? `${name} (via link)` : name;
+ }
+ return 'Via ack link';
+ }
+
+ function resolvedLabel(item: OncallPage): string {
+ if (item.resolvedByName) return item.resolvedByName;
+ return item.resolvedBy !== null ? `user #${item.resolvedBy}` : '—';
+ }
+
let loadSeq = 0;
async function loadPages() {
@@ -271,8 +294,18 @@
<Table.Head>Level</Table.Head>
<Table.Head>Age</Table.Head>
<Table.Head>Events</Table.Head>
- <Table.Head>Status</Table.Head>
- <Table.Head class="text-right">Actions</Table.Head>
+ {#if showStatus}
+ <Table.Head>Status</Table.Head>
+ {/if}
+ {#if showAcknowledged}
+ <Table.Head>Acknowledged</Table.Head>
+ {/if}
+ {#if showResolved}
+ <Table.Head>Resolved</Table.Head>
+ {/if}
+ {#if showActions}
+ <Table.Head class="text-right">Actions</Table.Head>
+ {/if}
</Table.Row>
</Table.Header>
<Table.Body>
@@ -307,33 +340,61 @@
>{formatRelativeTimeAgo(item.createdAt)}</Table.Cell
>
<Table.Cell>{item.eventCount}</Table.Cell>
- <Table.Cell>
- <PageBadges status={item.status} />
- </Table.Cell>
- <Table.Cell class="text-right">
- <div class="flex justify-end gap-1">
- {#if item.status === 'open'}
- <Button
- variant="ghost"
- size="icon"
- title="Acknowledge"
- onclick={(e) => acknowledge(item, e)}
- >
- <Check class="h-4 w-4" />
- </Button>
+ {#if showStatus}
+ <Table.Cell>
+ <PageBadges status={item.status} />
+ </Table.Cell>
+ {/if}
+ {#if showAcknowledged}
+ <Table.Cell class="whitespace-nowrap">
+ {#if item.acknowledgedAt}
+ <div>{ackLabel(item)}</div>
+ <div class="text-xs text-muted-foreground">
+ {formatDateTime(item.acknowledgedAt, { format: 'short' })}
+ </div>
+ {:else}
+ <span class="text-muted-foreground">—</span>
{/if}
- {#if item.status !== 'resolved'}
- <Button
- variant="ghost"
- size="icon"
- title="Resolve"
- onclick={(e) => resolve(item, e)}
- >
- <CheckCheck class="h-4 w-4" />
- </Button>
+ </Table.Cell>
+ {/if}
+ {#if showResolved}
+ <Table.Cell class="whitespace-nowrap">
+ {#if item.resolvedAt}
+ <div>{resolvedLabel(item)}</div>
+ <div class="text-xs text-muted-foreground">
+ {formatDateTime(item.resolvedAt, { format: 'short' })}
+ </div>
+ {:else}
+ <span class="text-muted-foreground">—</span>
{/if}
- </div>
- </Table.Cell>
+ </Table.Cell>
+ {/if}
+ {#if showActions}
+ <Table.Cell class="text-right">
+ <div class="flex justify-end gap-1">
+ {#if item.status === 'open'}
+ <Button
+ variant="ghost"
+ size="icon"
+ title="Acknowledge"
+ onclick={(e) => acknowledge(item, e)}
+ >
+ <Check class="h-4 w-4" />
+ </Button>
+ {/if}
+ {#if item.status !== 'resolved'}
+ <Button
+ variant="ghost"
+ size="icon"
+ title="Resolve"
+ onclick={(e) => resolve(item, e)}
+ >
+ <CheckCheck class="h-4 w-4" />
+ </Button>
+ {/if}
+ </div>
+ </Table.Cell>
+ {/if}
</Table.Row>
{/each}
</Table.Body>