diff --git a/e2e/checks/workflow-phone-layout.cjs b/e2e/checks/workflow-phone-layout.cjs index 551cc0396..12819a5cb 100644 --- a/e2e/checks/workflow-phone-layout.cjs +++ b/e2e/checks/workflow-phone-layout.cjs @@ -6,23 +6,19 @@ const assert = require('node:assert/strict'); module.exports = async ({ page, go, shot, settled }) => { await page.setViewportSize({ width: 390, height: 844 }); - // The list is a page at phone width: rows open the workflow, and Enable or - // Disable is reachable from the row menu and from the workflow page. + // The list is a page at phone width: rows open the workflow, and the + // enabled switch is on the row and on the workflow page. await go('/workflows'); const row = page.getByRole('link', { name: /^implement/ }); await row.waitFor(); const listWidth = await page.evaluate(() => ({ scrollWidth: document.documentElement.scrollWidth, width: innerWidth })); assert.equal(listWidth.scrollWidth, listWidth.width, 'workflow list scrolls horizontally'); await shot('list'); - await page.getByRole('button', { name: 'implement actions' }).click(); - await page.getByRole('menuitem', { name: /^(Enable|Disable)$/ }).waitFor(); - await page.keyboard.press('Escape'); + await page.getByRole('switch', { name: 'implement enabled' }).waitFor(); await row.click(); await page.waitForURL(/\/workflows\/implement$/); await page.locator('.workflow-canvas').waitFor(); - await page.getByRole('button', { name: 'More', exact: true }).click(); - await page.getByRole('menuitem', { name: /^(Enable|Disable)$/ }).waitFor(); - await page.keyboard.press('Escape'); + await page.getByRole('switch', { name: 'implement enabled' }).waitFor(); await go('/workflows?workflow=implement'); assert.match(page.url(), /\/workflows\/implement$/, 'legacy ?workflow= link did not reach the workflow page'); for (const workflow of ['implement', 'feasibility']) { diff --git a/internal/contracts/state/v1/stats.pb.go b/internal/contracts/state/v1/stats.pb.go index 8d1b954f4..9e2c70970 100644 --- a/internal/contracts/state/v1/stats.pb.go +++ b/internal/contracts/state/v1/stats.pb.go @@ -9,6 +9,7 @@ package statev1 import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" reflect "reflect" sync "sync" unsafe "unsafe" @@ -35,8 +36,11 @@ type WorkflowStat struct { Completed int64 `protobuf:"varint,9,opt,name=completed,proto3" json:"completed,omitempty"` // running and last_status describe the newest runs, so a workflow whose // runs are older than a global task page still reports its real state. - Running int64 `protobuf:"varint,10,opt,name=running,proto3" json:"running,omitempty"` - LastStatus string `protobuf:"bytes,11,opt,name=last_status,json=lastStatus,proto3" json:"last_status,omitempty"` + Running int64 `protobuf:"varint,10,opt,name=running,proto3" json:"running,omitempty"` + LastStatus string `protobuf:"bytes,11,opt,name=last_status,json=lastStatus,proto3" json:"last_status,omitempty"` + // last_run_id and last_run_at name the newest run and when it was created. + LastRunId int64 `protobuf:"varint,12,opt,name=last_run_id,json=lastRunId,proto3" json:"last_run_id,omitempty"` + LastRunAt *timestamppb.Timestamp `protobuf:"bytes,13,opt,name=last_run_at,json=lastRunAt,proto3" json:"last_run_at,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -148,6 +152,20 @@ func (x *WorkflowStat) GetLastStatus() string { return "" } +func (x *WorkflowStat) GetLastRunId() int64 { + if x != nil { + return x.LastRunId + } + return 0 +} + +func (x *WorkflowStat) GetLastRunAt() *timestamppb.Timestamp { + if x != nil { + return x.LastRunAt + } + return nil +} + // StageStat mirrors storecontract.StageStat. type StageStat struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -812,7 +830,7 @@ var File_state_v1_stats_proto protoreflect.FileDescriptor const file_state_v1_stats_proto_rawDesc = "" + "\n" + - "\x14state/v1/stats.proto\x12\bstate.v1\"\xbf\x02\n" + + "\x14state/v1/stats.proto\x12\bstate.v1\x1a\x1fgoogle/protobuf/timestamp.proto\"\x9b\x03\n" + "\fWorkflowStat\x12\x1a\n" + "\bworkflow\x18\x01 \x01(\tR\bworkflow\x12\x12\n" + "\x04runs\x18\x02 \x01(\x03R\x04runs\x12\x16\n" + @@ -827,7 +845,9 @@ const file_state_v1_stats_proto_rawDesc = "" + "\arunning\x18\n" + " \x01(\x03R\arunning\x12\x1f\n" + "\vlast_status\x18\v \x01(\tR\n" + - "lastStatus\"\x80\x01\n" + + "lastStatus\x12\x1e\n" + + "\vlast_run_id\x18\f \x01(\x03R\tlastRunId\x12:\n" + + "\vlast_run_at\x18\r \x01(\v2\x1a.google.protobuf.TimestampR\tlastRunAt\"\x80\x01\n" + "\tStageStat\x12\x1a\n" + "\bworkflow\x18\x01 \x01(\tR\bworkflow\x12\x14\n" + "\x05stage\x18\x02 \x01(\tR\x05stage\x12\x12\n" + @@ -906,28 +926,30 @@ var file_state_v1_stats_proto_goTypes = []any{ (*UsageTotalsRequest)(nil), // 12: state.v1.UsageTotalsRequest (*UsageTotalsResponse)(nil), // 13: state.v1.UsageTotalsResponse nil, // 14: state.v1.StatusCountsResponse.CountsEntry + (*timestamppb.Timestamp)(nil), // 15: google.protobuf.Timestamp } var file_state_v1_stats_proto_depIdxs = []int32{ - 14, // 0: state.v1.StatusCountsResponse.counts:type_name -> state.v1.StatusCountsResponse.CountsEntry - 0, // 1: state.v1.WorkflowStatsResponse.stats:type_name -> state.v1.WorkflowStat - 1, // 2: state.v1.StageStatsResponse.stats:type_name -> state.v1.StageStat - 2, // 3: state.v1.TokensByDayResponse.tokens:type_name -> state.v1.DayTokens - 11, // 4: state.v1.UsageTotalsResponse.rows:type_name -> state.v1.UsageTotalRow - 3, // 5: state.v1.StatsService.StatusCounts:input_type -> state.v1.StatusCountsRequest - 5, // 6: state.v1.StatsService.WorkflowStats:input_type -> state.v1.WorkflowStatsRequest - 7, // 7: state.v1.StatsService.StageStats:input_type -> state.v1.StageStatsRequest - 9, // 8: state.v1.StatsService.TokensByDay:input_type -> state.v1.TokensByDayRequest - 12, // 9: state.v1.StatsService.UsageTotals:input_type -> state.v1.UsageTotalsRequest - 4, // 10: state.v1.StatsService.StatusCounts:output_type -> state.v1.StatusCountsResponse - 6, // 11: state.v1.StatsService.WorkflowStats:output_type -> state.v1.WorkflowStatsResponse - 8, // 12: state.v1.StatsService.StageStats:output_type -> state.v1.StageStatsResponse - 10, // 13: state.v1.StatsService.TokensByDay:output_type -> state.v1.TokensByDayResponse - 13, // 14: state.v1.StatsService.UsageTotals:output_type -> state.v1.UsageTotalsResponse - 10, // [10:15] is the sub-list for method output_type - 5, // [5:10] is the sub-list for method input_type - 5, // [5:5] is the sub-list for extension type_name - 5, // [5:5] is the sub-list for extension extendee - 0, // [0:5] is the sub-list for field type_name + 15, // 0: state.v1.WorkflowStat.last_run_at:type_name -> google.protobuf.Timestamp + 14, // 1: state.v1.StatusCountsResponse.counts:type_name -> state.v1.StatusCountsResponse.CountsEntry + 0, // 2: state.v1.WorkflowStatsResponse.stats:type_name -> state.v1.WorkflowStat + 1, // 3: state.v1.StageStatsResponse.stats:type_name -> state.v1.StageStat + 2, // 4: state.v1.TokensByDayResponse.tokens:type_name -> state.v1.DayTokens + 11, // 5: state.v1.UsageTotalsResponse.rows:type_name -> state.v1.UsageTotalRow + 3, // 6: state.v1.StatsService.StatusCounts:input_type -> state.v1.StatusCountsRequest + 5, // 7: state.v1.StatsService.WorkflowStats:input_type -> state.v1.WorkflowStatsRequest + 7, // 8: state.v1.StatsService.StageStats:input_type -> state.v1.StageStatsRequest + 9, // 9: state.v1.StatsService.TokensByDay:input_type -> state.v1.TokensByDayRequest + 12, // 10: state.v1.StatsService.UsageTotals:input_type -> state.v1.UsageTotalsRequest + 4, // 11: state.v1.StatsService.StatusCounts:output_type -> state.v1.StatusCountsResponse + 6, // 12: state.v1.StatsService.WorkflowStats:output_type -> state.v1.WorkflowStatsResponse + 8, // 13: state.v1.StatsService.StageStats:output_type -> state.v1.StageStatsResponse + 10, // 14: state.v1.StatsService.TokensByDay:output_type -> state.v1.TokensByDayResponse + 13, // 15: state.v1.StatsService.UsageTotals:output_type -> state.v1.UsageTotalsResponse + 11, // [11:16] is the sub-list for method output_type + 6, // [6:11] is the sub-list for method input_type + 6, // [6:6] is the sub-list for extension type_name + 6, // [6:6] is the sub-list for extension extendee + 0, // [0:6] is the sub-list for field type_name } func init() { file_state_v1_stats_proto_init() } diff --git a/internal/domain/storecontract/task.go b/internal/domain/storecontract/task.go index 32eac30df..d4a42bde7 100644 --- a/internal/domain/storecontract/task.go +++ b/internal/domain/storecontract/task.go @@ -191,6 +191,9 @@ type WorkflowStat struct { // are working, and how its newest one ended. Running int `json:"running"` LastStatus string `json:"last_status"` + // LastRunID and LastRunAt identify the newest run and when it was created. + LastRunID int64 `json:"last_run_id"` + LastRunAt time.Time `json:"last_run_at"` } // StageStat is average stage duration and failure counts per stage. diff --git a/internal/infrastructure/postgres/events.go b/internal/infrastructure/postgres/events.go index 70411ca17..6ce50bed8 100644 --- a/internal/infrastructure/postgres/events.go +++ b/internal/infrastructure/postgres/events.go @@ -129,6 +129,8 @@ func (s *Store) WorkflowStats(ctx context.Context) ([]storecontract.WorkflowStat TotalToken: int(r.TotalTokens), Running: int(r.Running), LastStatus: r.LastStatus, + LastRunID: r.LastRunID, + LastRunAt: r.LastRunAt, }) } return stats, nil diff --git a/internal/infrastructure/postgres/postgresdb/events.sql.go b/internal/infrastructure/postgres/postgresdb/events.sql.go index 4e7c929b3..e6de23312 100644 --- a/internal/infrastructure/postgres/postgresdb/events.sql.go +++ b/internal/infrastructure/postgres/postgresdb/events.sql.go @@ -385,6 +385,8 @@ SELECT workflow, COUNT(*) FILTER (WHERE status = 'parked')::int AS parked, COUNT(*) FILTER (WHERE status = 'running')::int AS running, COALESCE((ARRAY_AGG(status ORDER BY id DESC))[1], '')::text AS last_status, + MAX(id)::bigint AS last_run_id, + MAX(created_at)::timestamptz AS last_run_at, CAST(AVG(tokens_used) AS bigint) AS avg_tokens, AVG(iterations)::float8 AS avg_steps, SUM(tokens_used)::bigint AS total_tokens @@ -403,6 +405,8 @@ type WorkflowStatsRow struct { Parked int32 Running int32 LastStatus string + LastRunID int64 + LastRunAt time.Time AvgTokens int64 AvgSteps float64 TotalTokens int64 @@ -429,6 +433,8 @@ func (q *Queries) WorkflowStats(ctx context.Context, scopeOrg pgtype.Text) ([]Wo &i.Parked, &i.Running, &i.LastStatus, + &i.LastRunID, + &i.LastRunAt, &i.AvgTokens, &i.AvgSteps, &i.TotalTokens, diff --git a/internal/infrastructure/postgres/queries/events.sql b/internal/infrastructure/postgres/queries/events.sql index aec052ea5..c40d26831 100644 --- a/internal/infrastructure/postgres/queries/events.sql +++ b/internal/infrastructure/postgres/queries/events.sql @@ -56,6 +56,8 @@ SELECT workflow, COUNT(*) FILTER (WHERE status = 'parked')::int AS parked, COUNT(*) FILTER (WHERE status = 'running')::int AS running, COALESCE((ARRAY_AGG(status ORDER BY id DESC))[1], '')::text AS last_status, + MAX(id)::bigint AS last_run_id, + MAX(created_at)::timestamptz AS last_run_at, CAST(AVG(tokens_used) AS bigint) AS avg_tokens, AVG(iterations)::float8 AS avg_steps, SUM(tokens_used)::bigint AS total_tokens diff --git a/internal/infrastructure/staterpc/values.go b/internal/infrastructure/staterpc/values.go index 40d1e26be..2f45fa992 100644 --- a/internal/infrastructure/staterpc/values.go +++ b/internal/infrastructure/staterpc/values.go @@ -328,6 +328,7 @@ func workflowStatProto(w storecontract.WorkflowStat) *pb.WorkflowStat { Completed: int64(w.Completed), PrOpen: int64(w.PROpen), Parked: int64(w.Parked), AvgTokens: int64(w.AvgTokens), AvgSteps: w.AvgSteps, TotalTokens: int64(w.TotalToken), Running: int64(w.Running), LastStatus: w.LastStatus, + LastRunId: w.LastRunID, LastRunAt: timestamp(w.LastRunAt), } } @@ -340,6 +341,7 @@ func workflowStatValue(w *pb.WorkflowStat) storecontract.WorkflowStat { Completed: int(w.Completed), PROpen: int(w.PrOpen), Parked: int(w.Parked), AvgTokens: int(w.AvgTokens), AvgSteps: w.AvgSteps, TotalToken: int(w.TotalTokens), Running: int(w.Running), LastStatus: w.LastStatus, + LastRunID: w.LastRunId, LastRunAt: timeValue(w.LastRunAt), } } diff --git a/proto/state/v1/stats.proto b/proto/state/v1/stats.proto index 64e901e6c..bccfaad3d 100644 --- a/proto/state/v1/stats.proto +++ b/proto/state/v1/stats.proto @@ -2,6 +2,8 @@ syntax = "proto3"; package state.v1; +import "google/protobuf/timestamp.proto"; + service StatsService { rpc StatusCounts(StatusCountsRequest) returns (StatusCountsResponse); rpc WorkflowStats(WorkflowStatsRequest) returns (WorkflowStatsResponse); @@ -25,6 +27,9 @@ message WorkflowStat { // runs are older than a global task page still reports its real state. int64 running = 10; string last_status = 11; + // last_run_id and last_run_at name the newest run and when it was created. + int64 last_run_id = 12; + google.protobuf.Timestamp last_run_at = 13; } // StageStat mirrors storecontract.StageStat. message StageStat { diff --git a/ui/src/App.vue b/ui/src/App.vue index d568722bc..af6aa6c24 100644 --- a/ui/src/App.vue +++ b/ui/src/App.vue @@ -16,7 +16,7 @@ import SectionCrumb from "@/components/topbar/SectionCrumb.vue"; import Brand from "@/components/topbar/Brand.vue"; import Logo from "@/components/topbar/Logo.vue"; import ConnectionPill from "@/components/topbar/ConnectionPill.vue"; -import { Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbSeparator } from "@/components/ui/breadcrumb"; +import { Breadcrumb, BreadcrumbItem, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator } from "@/components/ui/breadcrumb"; import { Alert, AlertDescription } from "@/components/ui/alert"; import { Card } from "@/components/ui/card"; import { SidebarInset, SidebarProvider } from "@/components/ui/sidebar"; @@ -107,10 +107,10 @@ watch(() => accounts.status?.user, (user) => { - + diff --git a/ui/src/components/topbar/SectionCrumb.vue b/ui/src/components/topbar/SectionCrumb.vue index 718024949..5759c9aa0 100644 --- a/ui/src/components/topbar/SectionCrumb.vue +++ b/ui/src/components/topbar/SectionCrumb.vue @@ -19,7 +19,7 @@ import { useLiveResource } from "@/stores/session"; import { useTasksStore } from "@/stores/tasks"; import { useHoverOpen } from "./hover-open"; -const props = defineProps<{ hidden: string[] }>(); +const props = defineProps<{ hidden: string[]; link?: string }>(); const route = useRoute(); const store = useTasksStore(); @@ -44,7 +44,15 @@ const hover = useHoverOpen();