Skip to content

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

feat: better index + pages allow automatic issue resolutions when connected

narrow-adventure609b6ecaae1d
diff --git a/backend/app/controllers/exception_stack_trace.controller.go b/backend/app/controllers/exception_stack_trace.controller.go
index a1e7615f..9d5ce1a3 100644
--- a/backend/app/controllers/exception_stack_trace.controller.go
+++ b/backend/app/controllers/exception_stack_trace.controller.go
@@ -11,9 +11,12 @@ import (
"strings"
"time"
+ "github.com/tracewayapp/traceway/backend/app/db"
"github.com/tracewayapp/traceway/backend/app/middleware"
"github.com/tracewayapp/traceway/backend/app/models"
+ "github.com/tracewayapp/traceway/backend/app/oncall"
"github.com/tracewayapp/traceway/backend/app/repositories/telemetry"
+ "github.com/tracewayapp/traceway/backend/app/repositories/transactional"
"github.com/tracewayapp/traceway/backend/app/storage"
"github.com/gin-gonic/gin"
@@ -35,6 +38,9 @@ type ExceptionSearchRequest struct {
type ArchiveRequest struct {
Hashes []string `json:"hashes"`
+ // ResolvePages also resolves any unresolved on-call pages that were opened
+ // for these issues (archive path only, confirmed by the user in the dialog).
+ ResolvePages bool `json:"resolvePages"`
}
type ExceptionDetailRequest struct {
@@ -229,7 +235,36 @@ func (e exceptionStackTraceController) ArchiveExceptions(c *gin.Context) {
return
}
- c.JSON(http.StatusOK, gin.H{"archived": len(request.Hashes)})
+ resolvedPages := 0
+ if request.ResolvePages {
+ userId := middleware.GetUserId(c)
+ now := time.Now().UTC()
+ resolvedPages, err = db.ExecuteTransaction(func(tx *sql.Tx) (int, error) {
+ resolved := 0
+ for _, hash := range request.Hashes {
+ pages, err := transactional.PageRepository.FindUnresolvedByIssueHash(tx, projectId, hash)
+ if err != nil {
+ return 0, err
+ }
+ for _, page := range pages {
+ ok, err := oncall.ResolvePage(tx, page.Id, userId, now)
+ if err != nil {
+ return 0, err
+ }
+ if ok {
+ resolved++
+ }
+ }
+ }
+ return resolved, nil
+ })
+ if err != nil {
+ c.AbortWithError(500, traceway.NewStackTraceErrorf("error resolving pages for archived issues %s: %w", strings.Join(request.Hashes, ","), err))
+ return
+ }
+ }
+
+ c.JSON(http.StatusOK, gin.H{"archived": len(request.Hashes), "resolvedPages": resolvedPages})
}
func (e exceptionStackTraceController) UnarchiveExceptions(c *gin.Context) {
diff --git a/backend/app/controllers/page.controller.go b/backend/app/controllers/page.controller.go
index c79693e7..26fc767d 100644
--- a/backend/app/controllers/page.controller.go
+++ b/backend/app/controllers/page.controller.go
@@ -9,6 +9,7 @@ import (
"github.com/tracewayapp/traceway/backend/app/middleware"
"github.com/tracewayapp/traceway/backend/app/models"
"github.com/tracewayapp/traceway/backend/app/oncall"
+ "github.com/tracewayapp/traceway/backend/app/repositories/telemetry"
"github.com/tracewayapp/traceway/backend/app/repositories/transactional"
"github.com/gin-gonic/gin"
@@ -24,6 +25,18 @@ type listPagesRequest struct {
Pagination PaginationParams `json:"pagination" binding:"required"`
}
+// 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.
+type pageResponse struct {
+ *models.Page
+ IssueHash string `json:"issueHash"`
+}
+
+func toPageResponse(page *models.Page) pageResponse {
+ return pageResponse{Page: page, IssueHash: page.IssueHash()}
+}
+
var validPageStatusFilters = map[string]bool{
"": true, "active": true,
models.PageStatusOpen: true, models.PageStatusAcknowledged: true, models.PageStatusResolved: true,
@@ -57,16 +70,17 @@ func (c *pageController) List(ctx *gin.Context) {
ctx.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("failed to list pages: %w", err))
return
}
- if pages == nil {
- pages = []*models.Page{}
+ items := make([]pageResponse, 0, len(pages))
+ for _, page := range pages {
+ items = append(items, toPageResponse(page))
}
totalPages := int64(0)
if request.Pagination.PageSize > 0 {
totalPages = (int64(total) + int64(request.Pagination.PageSize) - 1) / int64(request.Pagination.PageSize)
}
- ctx.JSON(http.StatusOK, PaginatedResponse[*models.Page]{
- Data: pages,
+ ctx.JSON(http.StatusOK, PaginatedResponse[pageResponse]{
+ Data: items,
Pagination: Pagination{
Page: request.Pagination.Page,
PageSize: request.Pagination.PageSize,
@@ -101,7 +115,7 @@ func (c *pageController) Get(ctx *gin.Context) {
users[strconv.Itoa(member.Id)] = member.Name
}
- ctx.JSON(http.StatusOK, gin.H{"page": page, "notifications": notifications, "users": users})
+ ctx.JSON(http.StatusOK, gin.H{"page": toPageResponse(page), "notifications": notifications, "users": users})
}
// Acknowledge deliberately has no write-access gate beyond project read
@@ -131,6 +145,10 @@ func (c *pageController) Acknowledge(ctx *gin.Context) {
ctx.JSON(http.StatusOK, gin.H{"message": "Page acknowledged"})
}
+type resolvePageRequest struct {
+ ArchiveIssue bool `json:"archiveIssue"`
+}
+
func (c *pageController) Resolve(ctx *gin.Context) {
tx := db.GetTx(ctx)
userId := middleware.GetUserId(ctx)
@@ -138,6 +156,11 @@ func (c *pageController) Resolve(ctx *gin.Context) {
if !ok {
return
}
+ // The body is optional: the endpoint historically took none, so a missing
+ // or empty body just means no archive.
+ var request resolvePageRequest
+ _ = ctx.ShouldBindJSON(&request)
+
resolved, err := oncall.ResolvePage(tx, page.Id, userId, time.Now().UTC())
if err != nil {
ctx.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("failed to resolve page: %w", err))
@@ -147,7 +170,186 @@ func (c *pageController) Resolve(ctx *gin.Context) {
ctx.JSON(http.StatusConflict, gin.H{"error": "Page is already resolved", "status": models.PageStatusResolved})
return
}
- ctx.JSON(http.StatusOK, gin.H{"message": "Page resolved"})
+
+ archived := false
+ if request.ArchiveIssue {
+ hash := page.IssueHash()
+ if hash == "" {
+ ctx.JSON(http.StatusUnprocessableEntity, gin.H{"error": "This page is not linked to an issue"})
+ return
+ }
+ // Resolving deliberately has no write gate, but archiving an issue is
+ // a write: enforce the effective project role in-handler. Aborting
+ // rolls the resolve back with it, keeping the action all-or-nothing.
+ role, err := transactional.ProjectRepository.GetEffectiveRole(tx, page.ProjectId, userId)
+ if err != nil {
+ ctx.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("failed to resolve effective role: %w", err))
+ return
+ }
+ if role == "readonly" || role == "" {
+ ctx.AbortWithStatusJSON(http.StatusForbidden, gin.H{"error": "Read-only access. Archiving the issue is not permitted."})
+ return
+ }
+ if err := telemetry.ExceptionStackTraceRepository.ArchiveByHashes(ctx, page.ProjectId, []string{hash}); err != nil {
+ ctx.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("failed to archive issue %s for page %d: %w", hash, page.Id, err))
+ return
+ }
+ archived = true
+ }
+ ctx.JSON(http.StatusOK, gin.H{"message": "Page resolved", "archivedIssue": archived})
+}
+
+type bulkAcknowledgeRequest struct {
+ Ids []int `json:"ids"`
+}
+
+// BulkAcknowledge acknowledges every selected page that is still open. Pages
+// from other projects or in another state are skipped, not errors: bulk
+// actions race the escalator and other responders by nature.
+func (c *pageController) BulkAcknowledge(ctx *gin.Context) {
+ tx := db.GetTx(ctx)
+ userId := middleware.GetUserId(ctx)
+ projectId, err := middleware.GetProjectId(ctx)
+ if err != nil {
+ ctx.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("RequireProjectAccess middleware must be applied: %w", err))
+ return
+ }
+ var request bulkAcknowledgeRequest
+ if err := ctx.ShouldBindJSON(&request); err != nil || len(request.Ids) == 0 {
+ ctx.JSON(http.StatusBadRequest, gin.H{"error": "ids array is required"})
+ return
+ }
+
+ now := time.Now().UTC()
+ acknowledged := 0
+ for _, id := range request.Ids {
+ page, err := transactional.PageRepository.FindById(tx, id)
+ if err != nil {
+ ctx.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("failed to load page %d: %w", id, err))
+ return
+ }
+ if page == nil || page.ProjectId != projectId {
+ continue
+ }
+ ok, err := oncall.AcknowledgePage(tx, page.Id, &userId, oncall.AckViaDashboard, now)
+ if err != nil {
+ ctx.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("failed to acknowledge page %d: %w", id, err))
+ return
+ }
+ if ok {
+ acknowledged++
+ }
+ }
+ ctx.JSON(http.StatusOK, gin.H{"acknowledged": acknowledged})
+}
+
+type bulkResolveRequest struct {
+ Ids []int `json:"ids"`
+ ArchiveIssues bool `json:"archiveIssues"`
+}
+
+// BulkResolve resolves every selected page that is not already resolved,
+// optionally archiving the distinct issues the selected pages were opened
+// for. Issue hashes are collected from the whole valid selection, not just
+// the pages this call transitioned: a page someone else resolved a moment
+// earlier was still selected with the intent to archive its issue.
+func (c *pageController) BulkResolve(ctx *gin.Context) {
+ tx := db.GetTx(ctx)
+ userId := middleware.GetUserId(ctx)
+ projectId, err := middleware.GetProjectId(ctx)
+ if err != nil {
+ ctx.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("RequireProjectAccess middleware must be applied: %w", err))
+ return
+ }
+ var request bulkResolveRequest
+ if err := ctx.ShouldBindJSON(&request); err != nil || len(request.Ids) == 0 {
+ ctx.JSON(http.StatusBadRequest, gin.H{"error": "ids array is required"})
+ return
+ }
+
+ now := time.Now().UTC()
+ resolved := 0
+ hashSet := map[string]bool{}
+ for _, id := range request.Ids {
+ page, err := transactional.PageRepository.FindById(tx, id)
+ if err != nil {
+ ctx.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("failed to load page %d: %w", id, err))
+ return
+ }
+ if page == nil || page.ProjectId != projectId {
+ continue
+ }
+ ok, err := oncall.ResolvePage(tx, page.Id, userId, now)
+ if err != nil {
+ ctx.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("failed to resolve page %d: %w", id, err))
+ return
+ }
+ if ok {
+ resolved++
+ }
+ if request.ArchiveIssues {
+ if hash := page.IssueHash(); hash != "" {
+ hashSet[hash] = true
+ }
+ }
+ }
+
+ archivedIssues := 0
+ if len(hashSet) > 0 {
+ // Resolving deliberately has no write gate, but archiving issues is a
+ // write: enforce the effective project role in-handler. Aborting rolls
+ // the resolves back with it, keeping the action all-or-nothing.
+ role, err := transactional.ProjectRepository.GetEffectiveRole(tx, projectId, userId)
+ if err != nil {
+ ctx.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("failed to resolve effective role: %w", err))
+ return
+ }
+ if role == "readonly" || role == "" {
+ ctx.AbortWithStatusJSON(http.StatusForbidden, gin.H{"error": "Read-only access. Archiving the issues is not permitted."})
+ return
+ }
+ hashes := make([]string, 0, len(hashSet))
+ for hash := range hashSet {
+ hashes = append(hashes, hash)
+ }
+ if err := telemetry.ExceptionStackTraceRepository.ArchiveByHashes(ctx, projectId, hashes); err != nil {
+ ctx.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("failed to archive issues for resolved pages: %w", err))
+ return
+ }
+ archivedIssues = len(hashes)
+ }
+ ctx.JSON(http.StatusOK, gin.H{"resolved": resolved, "archivedIssues": archivedIssues})
+}
+
+type pagesForIssuesRequest struct {
+ Hashes []string `json:"hashes" binding:"required"`
+}
+
+// UnresolvedForIssues reports how many unresolved pages were opened for the
+// given exception hashes, so the archive dialog can offer resolving them.
+func (c *pageController) UnresolvedForIssues(ctx *gin.Context) {
+ tx := db.GetTx(ctx)
+ projectId, err := middleware.GetProjectId(ctx)
+ if err != nil {
+ ctx.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("RequireProjectAccess middleware must be applied: %w", err))
+ return
+ }
+ var request pagesForIssuesRequest
+ if err := ctx.ShouldBindJSON(&request); err != nil {
+ ctx.JSON(http.StatusBadRequest, gin.H{"error": "Invalid request body"})
+ return
+ }
+
+ count := 0
+ for _, hash := range request.Hashes {
+ pages, err := transactional.PageRepository.FindUnresolvedByIssueHash(tx, projectId, hash)
+ if err != nil {
+ ctx.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("failed to find pages for issue %s: %w", hash, err))
+ return
+ }
+ count += len(pages)
+ }
+ ctx.JSON(http.StatusOK, gin.H{"count": count})
}
func (c *pageController) OpenCount(ctx *gin.Context) {
diff --git a/backend/app/controllers/routes.go b/backend/app/controllers/routes.go
index 75f82cb2..cb0109f4 100644
--- a/backend/app/controllers/routes.go
+++ b/backend/app/controllers/routes.go
@@ -244,6 +244,9 @@ func RegisterControllers(router *gin.RouterGroup) {
router.DELETE("/organizations/:organizationId/escalation-policies/:id", middleware.UseAppAuth, middleware.RequireAdminAccess, middleware.Transactional, EscalationPolicyController.Delete)
router.POST("/pages", middleware.UseAppAuth, middleware.RequireProjectAccess, middleware.Transactional, PageController.List)
+ router.POST("/pages/for-issues", middleware.UseAppAuth, middleware.RequireProjectAccess, middleware.Transactional, PageController.UnresolvedForIssues)
+ router.POST("/pages/bulk-acknowledge", middleware.UseAppAuth, middleware.RequireProjectAccess, middleware.Transactional, PageController.BulkAcknowledge)
+ router.POST("/pages/bulk-resolve", middleware.UseAppAuth, middleware.RequireProjectAccess, middleware.Transactional, PageController.BulkResolve)
router.GET("/pages/open-count", middleware.UseAppAuth, middleware.RequireProjectAccess, middleware.Transactional, PageController.OpenCount)
router.GET("/pages/:id", middleware.UseAppAuth, middleware.RequireProjectAccess, middleware.Transactional, PageController.Get)
router.POST("/pages/:id/acknowledge", middleware.UseAppAuth, middleware.RequireProjectAccess, middleware.Transactional, PageController.Acknowledge)
diff --git a/backend/app/migrations/pg/0102_create_pages_project_active_idx.up.sql b/backend/app/migrations/pg/0102_create_pages_project_active_idx.up.sql
new file mode 100644
index 00000000..3b5ed76e
--- /dev/null
+++ b/backend/app/migrations/pg/0102_create_pages_project_active_idx.up.sql
@@ -0,0 +1 @@
+CREATE INDEX IF NOT EXISTS pages_project_active_idx ON pages (project_id, created_at DESC) WHERE status <> 'resolved'
diff --git a/backend/app/migrations/sqlite/0063_create_pages_project_active_idx.up.sql b/backend/app/migrations/sqlite/0063_create_pages_project_active_idx.up.sql
new file mode 100644
index 00000000..3b5ed76e
--- /dev/null
+++ b/backend/app/migrations/sqlite/0063_create_pages_project_active_idx.up.sql
@@ -0,0 +1 @@
+CREATE INDEX IF NOT EXISTS pages_project_active_idx ON pages (project_id, created_at DESC) WHERE status <> 'resolved'
diff --git a/backend/app/models/escalation.model.go b/backend/app/models/escalation.model.go
index 402b52e8..e9a5eceb 100644
--- a/backend/app/models/escalation.model.go
+++ b/backend/app/models/escalation.model.go
@@ -1,6 +1,7 @@
package models
import (
+ "strings"
"time"
"github.com/google/uuid"
@@ -53,6 +54,20 @@ type Page struct {
UpdatedAt time.Time `json:"updatedAt" lit:"updated_at"`
}
+// IssueHash returns the exception hash a page was opened for, or "" when the
+// page is not issue-linked. New-error and regression rules carry the hash as
+// the dedup token after the "ruleId|" prefix (see oncall.pageDedupKey).
+func (p *Page) IssueHash() string {
+ if p.RuleType != "new_error" && p.RuleType != "error_regression" {
+ return ""
+ }
+ _, hash, found := strings.Cut(p.DedupKey, "|")
+ if !found {
+ return ""
+ }
+ return hash
+}
+
type UserContactMethod struct {
Id int `json:"id" lit:"id"`
UserId int `json:"userId" lit:"user_id"`
diff --git a/backend/app/repositories/transactional/pg/page.repository.go b/backend/app/repositories/transactional/pg/page.repository.go
index 4293e5ce..83c16834 100644
--- a/backend/app/repositories/transactional/pg/page.repository.go
+++ b/backend/app/repositories/transactional/pg/page.repository.go
@@ -65,6 +65,18 @@ func (r *pageRepository) FindDue(tx *sql.Tx, now time.Time) ([]*models.Page, err
)
}
+// FindUnresolvedByIssueHash returns the unresolved pages opened for one
+// exception hash: new-error/regression pages carry the hash as the dedup token
+// after the "ruleId|" prefix, so the suffix match is exact for those rule
+// types. Served by the pages_project_active_idx partial index.
+func (r *pageRepository) FindUnresolvedByIssueHash(tx *sql.Tx, projectId uuid.UUID, hash string) ([]*models.Page, error) {
+ return lit.SelectNamed[models.Page](
+ tx,
+ "SELECT "+pageColumns+" FROM pages WHERE project_id = :project_id AND status <> 'resolved' AND (rule_type = 'new_error' OR rule_type = 'error_regression') AND dedup_key LIKE ('%|' || :hash)",
+ lit.P{"project_id": projectId, "hash": hash},
+ )
+}
+
func (r *pageRepository) FindByProject(tx *sql.Tx, projectId uuid.UUID, status string, limit int, offset int) ([]*models.Page, error) {
return lit.SelectNamed[models.Page](
tx,
diff --git a/backend/app/repositories/transactional/sqlite/page.repository.go b/backend/app/repositories/transactional/sqlite/page.repository.go
index ac3ea207..f35f648d 100644
--- a/backend/app/repositories/transactional/sqlite/page.repository.go
+++ b/backend/app/repositories/transactional/sqlite/page.repository.go
@@ -65,6 +65,18 @@ func (r *pageRepository) FindDue(tx *sql.Tx, now time.Time) ([]*models.Page, err
)
}
+// FindUnresolvedByIssueHash returns the unresolved pages opened for one
+// exception hash: new-error/regression pages carry the hash as the dedup token
+// after the "ruleId|" prefix, so the suffix match is exact for those rule
+// types. Served by the pages_project_active_idx partial index.
+func (r *pageRepository) FindUnresolvedByIssueHash(tx *sql.Tx, projectId uuid.UUID, hash string) ([]*models.Page, error) {
+ return lit.SelectNamed[models.Page](
+ tx,
+ "SELECT "+pageColumns+" FROM pages WHERE project_id = :project_id AND status <> 'resolved' AND (rule_type = 'new_error' OR rule_type = 'error_regression') AND dedup_key LIKE ('%|' || :hash)",
+ lit.P{"project_id": projectId, "hash": hash},
+ )
+}
+
func (r *pageRepository) FindByProject(tx *sql.Tx, projectId uuid.UUID, status string, limit int, offset int) ([]*models.Page, error) {
return lit.SelectNamed[models.Page](
tx,
diff --git a/frontend/src/lib/components/archive-confirmation-dialog.svelte b/frontend/src/lib/components/archive-confirmation-dialog.svelte
index 0dd909ca..85da0bf5 100644
--- a/frontend/src/lib/components/archive-confirmation-dialog.svelte
+++ b/frontend/src/lib/components/archive-confirmation-dialog.svelte
@@ -1,22 +1,52 @@
<script lang="ts">
import * as AlertDialog from "$lib/components/ui/alert-dialog";
import { Button } from "$lib/components/ui/button";
+ import { Checkbox } from "$lib/components/ui/checkbox";
import { Archive } from "lucide-svelte";
+ import { api } from "$lib/api";
+ import { projectsState } from "$lib/state/projects.svelte";
interface Props {
open: boolean;
onOpenChange: (open: boolean) => void;
count: number;
- onConfirm: () => Promise<void>;
+ hashes: string[];
+ onConfirm: (resolvePages: boolean) => Promise<void>;
}
- let { open, onOpenChange, count, onConfirm }: Props = $props();
+ let { open, onOpenChange, count, hashes, onConfirm }: Props = $props();
let loading = $state(false);
+ let linkedPages = $state(0);
+ let resolvePages = $state(true);
+
+ // On-call pages opened for these issues (new-error/regression rules) can be
+ // resolved together with the archive; the option only shows when some exist.
+ $effect(() => {
+ if (open) {
+ resolvePages = true;
+ linkedPages = 0;
+ loadLinkedPages(hashes);
+ }
+ });
+
+ async function loadLinkedPages(forHashes: string[]) {
+ if (forHashes.length === 0) return;
+ try {
+ const res = await api.post(
+ '/pages/for-issues',
+ { hashes: forHashes },
+ { projectId: projectsState.currentProjectId ?? undefined }
+ );
+ linkedPages = res.count ?? 0;
+ } catch {
+ linkedPages = 0;
+ }
+ }
async function handleConfirm() {
loading = true;
try {
- await onConfirm();
+ await onConfirm(linkedPages > 0 && resolvePages);
onOpenChange(false);
} catch (e) {
// Error handling done in parent, just reset loading
@@ -41,6 +71,18 @@
Archived issues will be hidden from the main issues list.
</AlertDialog.Description>
</AlertDialog.Header>
+ {#if linkedPages > 0}
+ <label class="flex cursor-pointer items-center gap-2 text-sm">
+ <Checkbox
+ checked={resolvePages}
+ onCheckedChange={(checked) => (resolvePages = checked === true)}
+ disabled={loading}
+ aria-label="Also resolve linked on-call pages"
+ />
+ Also resolve {linkedPages} open on-call page{linkedPages > 1 ? 's' : ''} for
+ {count > 1 ? 'these issues' : 'this issue'}
+ </label>
+ {/if}
<AlertDialog.Footer>
<Button variant="outline" onclick={handleCancel} disabled={loading}>
Cancel
diff --git a/frontend/src/lib/state/oncall.svelte.ts b/frontend/src/lib/state/oncall.svelte.ts
index 28b5e2c1..e79d94cf 100644
--- a/frontend/src/lib/state/oncall.svelte.ts
+++ b/frontend/src/lib/state/oncall.svelte.ts
@@ -202,6 +202,7 @@ export interface OncallPage {
resolvedAt: string | null;
createdAt: string;
updatedAt: string;
+ issueHash: string;
}
export interface PageNotification {
diff --git a/frontend/src/routes/issues/+page.svelte b/frontend/src/routes/issues/+page.svelte
index c3f14137..32857116 100644
--- a/frontend/src/routes/issues/+page.svelte
+++ b/frontend/src/routes/issues/+page.svelte
@@ -279,7 +279,7 @@
}
// Archive handler
- async function archiveSelected() {
+ async function archiveSelected(resolvePages: boolean) {
if (selectedHashes.size === 0) return;
archiving = true;
@@ -287,7 +287,8 @@
await api.post(
'/exception-stack-traces/archive',
{
- hashes: Array.from(selectedHashes)
+ hashes: Array.from(selectedHashes),
+ resolvePages
},
{ projectId: projectsState.currentProjectId ?? undefined }
);
@@ -525,5 +526,6 @@
open={showArchiveDialog}
onOpenChange={(open) => (showArchiveDialog = open)}
count={selectedCount}
+ hashes={Array.from(selectedHashes)}
onConfirm={archiveSelected}
/>
diff --git a/frontend/src/routes/issues/[exceptionHash]/+page.svelte b/frontend/src/routes/issues/[exceptionHash]/+page.svelte
index 32c048fb..68eea6f1 100644
--- a/frontend/src/routes/issues/[exceptionHash]/+page.svelte
+++ b/frontend/src/routes/issues/[exceptionHash]/+page.svelte
@@ -117,12 +117,12 @@
}
}
- async function archiveIssue() {
+ async function archiveIssue(resolvePages: boolean) {
archiving = true;
try {
await api.post(
'/exception-stack-traces/archive',
- { hashes: [exceptionHash] },
+ { hashes: [exceptionHash], resolvePages },
{ projectId: projectsState.currentProjectId ?? undefined }
);
toast.success('Successfully archived the Issue', { position: 'top-center' });
@@ -212,5 +212,6 @@
open={showArchiveDialog}
onOpenChange={(open) => (showArchiveDialog = open)}
count={1}
+ hashes={[exceptionHash]}
onConfirm={archiveIssue}
/>
diff --git a/frontend/src/routes/issues/[exceptionHash]/[exceptionId]/+page.svelte b/frontend/src/routes/issues/[exceptionHash]/[exceptionId]/+page.svelte
index 7dbead0a..ac940ea7 100644
--- a/frontend/src/routes/issues/[exceptionHash]/[exceptionId]/+page.svelte
+++ b/frontend/src/routes/issues/[exceptionHash]/[exceptionId]/+page.svelte
@@ -124,12 +124,12 @@
}
}
- async function archiveIssue() {
+ async function archiveIssue(resolvePages: boolean) {
archiving = true;
try {
await api.post(
'/exception-stack-traces/archive',
- { hashes: [data.exceptionHash] },
+ { hashes: [data.exceptionHash], resolvePages },
{ projectId: projectsState.currentProjectId ?? undefined }
);
toast.success('Successfully archived the Issue', { position: 'top-center' });
@@ -213,5 +213,6 @@
open={showArchiveDialog}
onOpenChange={(open) => showArchiveDialog = open}
count={1}
+ hashes={[data.exceptionHash]}
onConfirm={archiveIssue}
/>
diff --git a/frontend/src/routes/issues/[exceptionHash]/events/+page.svelte b/frontend/src/routes/issues/[exceptionHash]/events/+page.svelte
index 9f5150d0..16f50a50 100644
--- a/frontend/src/routes/issues/[exceptionHash]/events/+page.svelte
+++ b/frontend/src/routes/issues/[exceptionHash]/events/+page.svelte
@@ -115,12 +115,12 @@
loadData();
}
- async function archiveIssue() {
+ async function archiveIssue(resolvePages: boolean) {
archiving = true;
try {
await api.post(
'/exception-stack-traces/archive',
- { hashes: [page.params.exceptionHash] },
+ { hashes: [page.params.exceptionHash], resolvePages },
{ projectId: projectsState.currentProjectId ?? undefined }
);
toast.success('Successfully archived the Issue', { position: 'top-center' });
@@ -279,5 +279,6 @@
open={showArchiveDialog}
onOpenChange={(open) => showArchiveDialog = open}
count={1}
+ hashes={page.params.exceptionHash ? [page.params.exceptionHash] : []}
onConfirm={archiveIssue}
/>
diff --git a/frontend/src/routes/on-call/acknowledge-pages-dialog.svelte b/frontend/src/routes/on-call/acknowledge-pages-dialog.svelte
new file mode 100644
index 00000000..f9913718
--- /dev/null
+++ b/frontend/src/routes/on-call/acknowledge-pages-dialog.svelte
@@ -0,0 +1,60 @@
+<script lang="ts">
+ import * as AlertDialog from '$lib/components/ui/alert-dialog';
+ import { Button } from '$lib/components/ui/button';
+ import { Check } from '@lucide/svelte';
+ import { type OncallPage } from '$lib/state/oncall.svelte';
+ import { runBulkPageAction } from './page-actions';
+
+ interface Props {
+ open: boolean;
+ pages: OncallPage[];
+ onAcknowledged: () => void;
+ }
+
+ let { open = $bindable(), pages, onAcknowledged }: Props = $props();
+ let loading = $state(false);
+
+ async function handleConfirm() {
+ if (pages.length === 0) return;
+ loading = true;
+ try {
+ const ok = await runBulkPageAction(
+ pages.map((p) => p.id),
+ 'acknowledge'
+ );
+ if (ok) {
+ open = false;
+ onAcknowledged();
+ }
+ } finally {
+ loading = false;
+ }
+ }
+
+ function handleCancel() {
+ if (!loading) {
+ open = false;
+ }
+ }
+</script>
+
+<AlertDialog.Root bind:open>
+ <AlertDialog.Content>
+ <AlertDialog.Header>
+ <AlertDialog.Title>Acknowledge Page{pages.length > 1 ? 's' : ''}</AlertDialog.Title>
+ <AlertDialog.Description>
+ Are you sure you want to acknowledge {pages.length === 1
+ ? 'this page'
+ : `${pages.length} pages`}? Acknowledging pauses escalation until the
+ {pages.length > 1 ? 'pages are' : 'page is'} resolved.
+ </AlertDialog.Description>
+ </AlertDialog.Header>
+ <AlertDialog.Footer>
+ <Button variant="outline" onclick={handleCancel} disabled={loading}>Cancel</Button>
+ <Button onclick={handleConfirm} disabled={loading}>
+ <Check class="h-4 w-4" />
+ {loading ? 'Acknowledging...' : `Acknowledge Page${pages.length > 1 ? 's' : ''}`}
+ </Button>
+ </AlertDialog.Footer>
+ </AlertDialog.Content>
+</AlertDialog.Root>
diff --git a/frontend/src/routes/on-call/page-actions.ts b/frontend/src/routes/on-call/page-actions.ts
index 2d2558f7..a139e33a 100644
--- a/frontend/src/routes/on-call/page-actions.ts
+++ b/frontend/src/routes/on-call/page-actions.ts
@@ -34,3 +34,45 @@ export async function runPageAction(id: number, action: 'acknowledge' | 'resolve
}
oncallState.refreshOpenCount();
}
+
+function pluralPages(n: number): string {
+ return n === 1 ? 'page' : 'pages';
+}
+
+// Runs a bulk acknowledge/resolve with shared toasts and badge refresh.
+// Returns true when the call succeeded (even if every page was skipped), so
+// dialogs know whether to close.
+export async function runBulkPageAction(
+ ids: number[],
+ action: 'acknowledge' | 'resolve',
+ options: { archiveIssues?: boolean } = {}
+): Promise<boolean> {
+ const done = action === 'acknowledge' ? 'acknowledged' : 'resolved';
+ try {
+ const res = await api.post(
+ `/pages/bulk-${action}`,
+ action === 'resolve' ? { ids, archiveIssues: options.archiveIssues ?? false } : { ids },
+ { projectId: projectsState.currentProjectId ?? undefined }
+ );
+ const count = (action === 'acknowledge' ? res.acknowledged : res.resolved) ?? 0;
+ const archived = res.archivedIssues ?? 0;
+ if (count === 0 && archived === 0) {
+ toast.error(
+ ids.length === 1 ? `Page was already ${done}` : `Pages were already ${done}`,
+ { position: 'top-center' }
+ );
+ } else {
+ let message = count === 1 && ids.length === 1 ? `Page ${done}` : `${count} ${pluralPages(count)} ${done}`;
+ if (archived > 0) {
+ message += ` and ${archived} issue${archived === 1 ? '' : 's'} archived`;
+ }
+ toast.success(message, { position: 'top-center' });
+ }
+ oncallState.refreshOpenCount();
+ return true;
+ } catch {
+ toast.error(`Failed to ${action} ${pluralPages(ids.length)}`, { position: 'top-center' });
+ oncallState.refreshOpenCount();
+ return false;
+ }
+}
diff --git a/frontend/src/routes/on-call/page-detail-sheet.svelte b/frontend/src/routes/on-call/page-detail-sheet.svelte
index 36f18bce..17435e2b 100644
--- a/frontend/src/routes/on-call/page-detail-sheet.svelte
+++ b/frontend/src/routes/on-call/page-detail-sheet.svelte
@@ -10,6 +10,7 @@
import { formatDateTime, formatRelativeTimeAgo } from '$lib/utils/formatters';
import { runPageAction } from './page-actions';
import PageBadges from './page-badges.svelte';
+ import ResolvePageDialog from './resolve-page-dialog.svelte';
import EscalationChain from '$lib/components/traceway/escalation-chain.svelte';
interface Props {
@@ -85,14 +86,23 @@
});
}
- async function performAction(action: 'acknowledge' | 'resolve') {
+ let resolveDialogOpen = $state(false);
+
+ async function acknowledge() {
if (!pageData) return;
actionLoading = true;
- await runPageAction(pageData.id, action);
+ await runPageAction(pageData.id, 'acknowledge');
actionLoading = false;
await loadDetail(pageData.id);
onChanged();
}
+
+ async function onResolved() {
+ if (pageData) {
+ await loadDetail(pageData.id);
+ }
+ onChanged();
+ }
</script>
<Sheet.Root bind:open>
@@ -277,11 +287,11 @@
{#if pageData.status !== 'resolved'}
<Sheet.Footer class="flex-row justify-end border-t px-6">
{#if pageData.status === 'open'}
- <Button variant="outline" onclick={() => performAction('acknowledge')} disabled={actionLoading}>
+ <Button variant="outline" onclick={acknowledge} disabled={actionLoading}>
<Check class="mr-1 h-4 w-4" /> Acknowledge
</Button>
{/if}
- <Button onclick={() => performAction('resolve')} disabled={actionLoading}>
+ <Button onclick={() => (resolveDialogOpen = true)} disabled={actionLoading}>
<CheckCheck class="mr-1 h-4 w-4" /> Resolve
</Button>
</Sheet.Footer>
@@ -289,3 +299,9 @@
{/if}
</Sheet.Content>
</Sheet.Root>
+
+<ResolvePageDialog
+ bind:open={resolveDialogOpen}
+ pages={pageData ? [pageData] : []}
+ onResolved={onResolved}
+/>
diff --git a/frontend/src/routes/on-call/pages-tab.svelte b/frontend/src/routes/on-call/pages-tab.svelte
index 43a28634..90038bc3 100644
--- a/frontend/src/routes/on-call/pages-tab.svelte
+++ b/frontend/src/routes/on-call/pages-tab.svelte
@@ -1,6 +1,7 @@
<script lang="ts">
import { onMount } from 'svelte';
import { Button } from '$lib/components/ui/button';
+ import { Checkbox } from '$lib/components/ui/checkbox';
import * as Table from '$lib/components/ui/table';
import { LoadingCircle } from '$lib/components/ui/loading-circle';
import { TableEmptyState } from '$lib/components/ui/table-empty-state';
@@ -13,6 +14,8 @@
import { runPageAction } from './page-actions';
import PageBadges from './page-badges.svelte';
import PageDetailSheet from './page-detail-sheet.svelte';
+ import ResolvePageDialog from './resolve-page-dialog.svelte';
+ import AcknowledgePagesDialog from './acknowledge-pages-dialog.svelte';
interface Props {
deepLinkPageId?: number | null;
@@ -48,6 +51,17 @@
let sheetOpen = $state(false);
let selectedPageId = $state<number | null>(null);
+ // Bulk selection: resolved pages have no actions, so the resolved tab has
+ // no checkboxes at all.
+ let selectedIds = $state<Set<number>>(new Set());
+ const selectable = $derived(statusFilter !== 'resolved');
+ const selectedCount = $derived(selectedIds.size);
+ const allSelected = $derived(pages.length > 0 && selectedIds.size === pages.length);
+ 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'));
+ const colCount = $derived(selectable ? 8 : 7);
+
let loadSeq = 0;
async function loadPages() {
@@ -67,6 +81,7 @@
pages = res.data || [];
total = res.pagination?.total || 0;
totalPages = res.pagination?.totalPages || 0;
+ selectedIds = new Set();
} catch (e: unknown) {
if (seq !== loadSeq) return;
error = e instanceof Error ? e.message : 'Failed to load pages';
@@ -118,10 +133,42 @@
loadPages();
}
- async function resolve(item: OncallPage, e: Event) {
+ let resolveDialogOpen = $state(false);
+ let resolveTargets = $state<OncallPage[]>([]);
+ let ackDialogOpen = $state(false);
+
+ function resolve(item: OncallPage, e: Event) {
e.stopPropagation();
- await runPageAction(item.id, 'resolve');
- loadPages();
+ resolveTargets = [item];
+ resolveDialogOpen = true;
+ }
+
+ function openBulkResolve() {
+ resolveTargets = selectedPages;
+ resolveDialogOpen = true;
+ }
+
+ // Selection handlers
+ function toggleSelectAll() {
+ if (allSelected) {
+ selectedIds = new Set();
+ } else {
+ selectedIds = new Set(pages.map((p) => p.id));
+ }
+ }
+
+ function toggleSelect(id: number) {
+ const newSet = new Set(selectedIds);
+ if (newSet.has(id)) {
+ newSet.delete(id);
+ } else {
+ newSet.add(id);
+ }
+ selectedIds = newSet;
+ }
+
+ function isSelected(id: number): boolean {
+ return selectedIds.has(id);
}
function openDetail(item: OncallPage) {
@@ -152,12 +199,40 @@
{/each}
</div>
+ <!-- Bulk actions toolbar - shown when items selected -->
+ {#if selectable && selectedCount > 0}
+ <div
+ class="flex animate-in items-center gap-3 rounded-md border bg-muted/50 p-3 duration-200 fade-in slide-in-from-top-1"
+ >
+ <span class="text-sm font-medium"
+ >{selectedCount} page{selectedCount === 1 ? '' : 's'} selected</span
+ >
+ <Button
+ variant="outline"
+ size="sm"
+ onclick={() => (ackDialogOpen = true)}
+ disabled={selectedOpenPages.length === 0}
+ class="gap-1.5"
+ >
+ <Check class="h-4 w-4" />
+ Acknowledge
+ </Button>
+ <Button variant="outline" size="sm" onclick={openBulkResolve} class="gap-1.5">
+ <CheckCheck class="h-4 w-4" />
+ Resolve
+ </Button>
+ <Button variant="ghost" size="sm" onclick={() => (selectedIds = new Set())}>
+ Clear selection
+ </Button>
+ </div>
+ {/if}
+
<div class="overflow-hidden rounded-md border">
<Table.Root>
{#if loading}
<Table.Body>
<Table.Row>
- <Table.Cell colspan={7} class="h-48">
+ <Table.Cell colspan={colCount} class="h-48">
<div class="flex h-full items-center justify-center">
<LoadingCircle size="xlg" />
</div>
@@ -167,7 +242,7 @@
{:else if error}
<Table.Body>
<Table.Row>
- <Table.Cell colspan={7} class="h-48">
+ <Table.Cell colspan={colCount} class="h-48">
<div class="flex h-full flex-col items-center justify-center gap-3">
<p class="text-sm text-destructive">{error}</p>
<Button variant="outline" size="sm" onclick={() => loadPages()}>Retry</Button>
@@ -177,11 +252,20 @@
</Table.Body>
{:else if pages.length === 0}
<Table.Body>
- <TableEmptyState colspan={7} message={emptyMessages[statusFilter]} />
+ <TableEmptyState colspan={colCount} message={emptyMessages[statusFilter]} />
</Table.Body>
{:else}
<Table.Header>
<Table.Row>
+ {#if selectable}
+ <Table.Head class="w-[40px] pl-4">
+ <Checkbox
+ checked={allSelected ? true : someSelected ? 'indeterminate' : false}
+ onCheckedChange={toggleSelectAll}
+ aria-label="Select all"
+ />
+ </Table.Head>
+ {/if}
<Table.Head>Severity</Table.Head>
<Table.Head>Subject</Table.Head>
<Table.Head>Level</Table.Head>
@@ -193,7 +277,20 @@
</Table.Header>
<Table.Body>
{#each pages as item (item.id)}
- <Table.Row class="cursor-pointer" onclick={() => openDetail(item)}>
+ <Table.Row
+ class="cursor-pointer"
+ data-state={selectable && isSelected(item.id) ? 'selected' : undefined}
+ onclick={() => openDetail(item)}
+ >
+ {#if selectable}
+ <Table.Cell class="pl-4" onclick={(e) => e.stopPropagation()}>
+ <Checkbox
+ checked={isSelected(item.id)}
+ onCheckedChange={() => toggleSelect(item.id)}
+ aria-label="Select row"
+ />
+ </Table.Cell>
+ {/if}
<Table.Cell>
<div class="flex items-center gap-1">
<PageBadges severity={item.severity} urgency={item.urgency} fallback />
@@ -256,3 +353,5 @@
</div>
<PageDetailSheet bind:open={sheetOpen} pageId={selectedPageId} onChanged={loadPages} />
+<ResolvePageDialog bind:open={resolveDialogOpen} pages={resolveTargets} onResolved={loadPages} />
+<AcknowledgePagesDialog bind:open={ackDialogOpen} pages={selectedOpenPages} onAcknowledged={loadPages} />
diff --git a/frontend/src/routes/on-call/resolve-page-dialog.svelte b/frontend/src/routes/on-call/resolve-page-dialog.svelte
new file mode 100644
index 00000000..afb131ac
--- /dev/null
+++ b/frontend/src/routes/on-call/resolve-page-dialog.svelte
@@ -0,0 +1,94 @@
+<script lang="ts">
+ import * as AlertDialog from '$lib/components/ui/alert-dialog';
+ import { Button } from '$lib/components/ui/button';
+ import { Checkbox } from '$lib/components/ui/checkbox';
+ import { CheckCheck } from '@lucide/svelte';
+ import { projectsState } from '$lib/state/projects.svelte';
+ import { type OncallPage } from '$lib/state/oncall.svelte';
+ import { runBulkPageAction } from './page-actions';
+
+ interface Props {
+ open: boolean;
+ pages: OncallPage[];
+ onResolved: () => void;
+ }
+
+ let { open = $bindable(), pages, onResolved }: Props = $props();
+ let loading = $state(false);
+ let archiveIssues = $state(true);
+
+ const linkedIssueCount = $derived(
+ new Set(pages.map((p) => p.issueHash).filter(Boolean)).size
+ );
+ // Archiving is a write on the issues while resolving is not, so the option
+ // is only offered when pages are issue-linked and the user can write.
+ const canArchiveIssues = $derived(linkedIssueCount > 0 && projectsState.canWriteCurrentProject);
+
+ $effect(() => {
+ if (open) {
+ archiveIssues = true;
+ }
+ });
+
+ async function handleConfirm() {
+ if (pages.length === 0) return;
+ loading = true;
+ try {
+ const ok = await runBulkPageAction(
+ pages.map((p) => p.id),
+ 'resolve',
+ { archiveIssues: canArchiveIssues && archiveIssues }
+ );
+ if (ok) {
+ open = false;
+ onResolved();
+ }
+ } finally {
+ loading = false;
+ }
+ }
+
+ function handleCancel() {
+ if (!loading) {
+ open = false;
+ }
+ }
+</script>
+
+<AlertDialog.Root bind:open>
+ <AlertDialog.Content>
+ <AlertDialog.Header>
+ <AlertDialog.Title>Resolve Page{pages.length > 1 ? 's' : ''}</AlertDialog.Title>
+ <AlertDialog.Description>
+ {#if pages.length > 1}
+ Are you sure you want to resolve {pages.length} pages?
+ {:else if pages[0]?.subject}
+ Are you sure you want to resolve the page "{pages[0].subject}"?
+ {:else}
+ Are you sure you want to resolve this page?
+ {/if}
+ Resolving stops all escalations for {pages.length > 1 ? 'them' : 'it'}.
+ </AlertDialog.Description>
+ </AlertDialog.Header>
+ {#if canArchiveIssues}
+ <label class="flex cursor-pointer items-center gap-2 text-sm">
+ <Checkbox
+ checked={archiveIssues}
+ onCheckedChange={(checked) => (archiveIssues = checked === true)}
+ disabled={loading}
+ aria-label="Also archive the linked issues"
+ />
+ {linkedIssueCount > 1
+ ? `Also archive the ${linkedIssueCount} linked issues`
+ : 'Also archive the linked issue'}
+ </label>
+ {/if}
+ <AlertDialog.Footer>
+ <Button variant="outline" onclick={handleCancel} disabled={loading}>Cancel</Button>
+ <Button onclick={handleConfirm} disabled={loading}>
+ <CheckCheck class="h-4 w-4" />
+ {loading ? 'Resolving...' : `Resolve Page${pages.length > 1 ? 's' : ''}`}
+ </Button>
+ </AlertDialog.Footer>
+ </AlertDialog.Content>
+</AlertDialog.Root>