Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
9ddbdef
refactor(web): migrate server state from Zustand to TanStack Query (w…
claude May 28, 2026
2268454
feat(ws): add per-connection event accounting (Phase 1)
carlosflorencio May 28, 2026
51cc44a
docs(ws-event-accounting): Phase 2 plan for delegation
carlosflorencio May 28, 2026
412ac88
feat(ws): bridge audit instrumentation (Workstream 0)
carlosflorencio May 28, 2026
473c182
feat(ws): per-session sequencing (Workstream 1)
carlosflorencio May 28, 2026
f0ce0ca
fix(web): migrate chat message-list to useQuery
carlosflorencio May 28, 2026
6e76598
refactor(web): migrate kanban consumers to useQuery
carlosflorencio May 28, 2026
e9d761f
refactor(web): migrate office tasks list to useInfiniteQuery
carlosflorencio May 28, 2026
f801ac4
fix(web): infinite render loop in useLazyLoadMessages
carlosflorencio May 28, 2026
2fc954a
fix(web): close WS bridge-audit gaps for strict mode
carlosflorencio May 29, 2026
4a94469
test(e2e): settle WS drop checks to absorb in-flight events
carlosflorencio May 29, 2026
5ae4173
fix(web): count invalidation as bridge handling; allowlist file.changes
carlosflorencio May 29, 2026
974840b
fix(web): fold workflow step/state through stale-timestamp task.updated
carlosflorencio May 29, 2026
51a0952
test(e2e): drive live message so per-session WS buckets populate
carlosflorencio May 29, 2026
f582c8f
ci(e2e): enforce WS event accounting (KANDEV_E2E_WS_ASSERT=1) on shards
carlosflorencio May 29, 2026
6acfe85
test(web): cover flattenTasksPaginated + tasksPaginated invalidation
carlosflorencio May 29, 2026
9f3bee4
fix(ws): remove unused stampAndMarshal wrapper
carlosflorencio May 29, 2026
8d5166e
docs(ws-event-accounting): record first strict-mode CI run outcome
carlosflorencio May 29, 2026
481a7f9
docs(ws-event-accounting): conclude shard failures are pre-existing c…
carlosflorencio May 29, 2026
5dac44e
docs(ws-event-accounting): record docker e2e flake sweep + classifica…
carlosflorencio May 29, 2026
73e509a
docs(web): document WS event accounting, docker e2e, flake triage
carlosflorencio May 30, 2026
7697f04
feat(e2e): managed runner script (auto docker/host, sharding, teardown)
carlosflorencio May 30, 2026
d6ba3ed
fix(e2e): preserve multi-word args + don't shadow /bin in runner
carlosflorencio May 30, 2026
3dd3668
perf(web): unwrap stream handlers from bridge audit; O(1) audit buffer
carlosflorencio May 30, 2026
cda456a
test(web): add coverage and fix conventions per PR review
carlosflorencio May 30, 2026
4c0dd52
docs(e2e): update reference to sanitizeInheritedEnv after main merge
carlosflorencio May 30, 2026
4ddfebf
fix(web): derive sidebar pending indicators from TQ message cache
carlosflorencio May 30, 2026
231676a
test(ws): deterministic hub registration via synctest
carlosflorencio May 30, 2026
480347d
fix(web): read prepare-progress setup steps from TQ message cache
carlosflorencio May 30, 2026
d80187a
fix(web): derive active turn in turns query for correct elapsed timer
carlosflorencio May 30, 2026
1764935
refactor(web): read github from TQ, drop Zustand mirror
carlosflorencio May 30, 2026
97fe024
refactor(web): read office from TQ, drop Zustand mirror
carlosflorencio May 31, 2026
a861b34
refactor(web): read workspace from TQ, drop Zustand mirror
carlosflorencio May 31, 2026
2c287b3
refactor(web): read kanban from TQ, drop Zustand mirror
carlosflorencio May 31, 2026
8f8c72f
refactor(web): read settings from TQ, drop Zustand mirror
carlosflorencio May 31, 2026
74797a8
refactor(web): add session byId cache + live state-change bridge
carlosflorencio May 31, 2026
9a9327a
refactor(web): flip session-domain hooks and panels to TQ byId cache
carlosflorencio May 31, 2026
04e7506
refactor(web): read session taskSessions from TQ, drop Zustand mirror
carlosflorencio May 31, 2026
5eabc27
refactor(web): read session-runtime from TQ, drop Zustand mirror
carlosflorencio May 31, 2026
5492bf9
fix(web): derive task_id from cached session for agentctl replay events
carlosflorencio May 31, 2026
6ffd0b7
chore: remove migration.md task notes
carlosflorencio May 31, 2026
61ba57e
refactor(web): read prepareProgress from TQ, drop Zustand mirror
carlosflorencio May 31, 2026
4a521fc
refactor(web): read sessionAgentctl status from TQ, drop Zustand mirror
carlosflorencio May 31, 2026
d5444e6
refactor(web): derive worktrees from TaskSession TQ cache, drop Zusta…
carlosflorencio May 31, 2026
f3e4cd6
refactor(web): bridge task.plan.* WS events into TQ plans cache
carlosflorencio May 31, 2026
d5c1ca3
refactor(web): read taskPlans server state from TQ, drop Zustand mirror
carlosflorencio May 31, 2026
cadea2c
chore: remove migration workflow scripts
carlosflorencio May 31, 2026
5163363
fix(web): reconcile rebase onto main with TQ migration
carlosflorencio May 31, 2026
a75f6ad
fix: restore main fixes dropped by rebase (resume broadcast, git-stat…
carlosflorencio May 31, 2026
ce9cdb4
test(web): wrap task-switcher test in QueryClientProvider after rebase
carlosflorencio May 31, 2026
2c7a74f
fix(web): fix e2e desyncs from TQ migration (plan indicator, sidebar …
carlosflorencio May 31, 2026
e93193b
fix(web): fix e2e desyncs (recent-task workflow badge, passthrough te…
carlosflorencio May 31, 2026
765a38a
fix(web): fetch workspace PRs on mobile surfaces (PR CI chip, changes…
carlosflorencio May 31, 2026
326fb5f
fix(web): exclude office-style workflows from settings list and export
carlosflorencio May 31, 2026
a2eca95
fix(web): re-integrate idle-input + terminal-busy fixes after rebase …
carlosflorencio Jun 1, 2026
50ee027
fix(web): re-integrate voice-mode onto TQ user-settings after rebase
carlosflorencio Jun 1, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
13 changes: 13 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ jobs:
run: pnpm install --frozen-lockfile

- name: Build backend and web
# NEXT_PUBLIC_KANDEV_E2E_MOCK=true bakes the WS event-accounting hook
# into the FE bundle (see lib/ws/client.ts). Next.js inlines NEXT_PUBLIC_*
# at build time, so without this flag the hook dead-eliminates and the
# fixture's WS-drop check has nothing to read.
env:
NEXT_PUBLIC_KANDEV_E2E_MOCK: "true"
run: make build-backend build-web

# Linux/amd64 helper binaries (agentctl + mock-agent) bind-mounted into
Expand Down Expand Up @@ -133,6 +139,13 @@ jobs:
# previously ran on.
env:
NODE_OPTIONS: --dns-result-order=ipv4first
# Enforce WS event accounting: any event the backend sent that the FE
# never processed (per-connection or per-session seq gap), and any
# session-routed event a bridge handler failed to apply to the TQ cache,
# fails the test that observed it. Requires the FE bundle built with
# NEXT_PUBLIC_KANDEV_E2E_MOCK=true (see the build job) so the accounting
# hooks are present. See docs/specs/ws-event-accounting/plan.md.
KANDEV_E2E_WS_ASSERT: "1"
strategy:
fail-fast: false
matrix:
Expand Down
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
```
apps/
├── backend/ # Go backend (orchestrator, lifecycle, agentctl, WS gateway)
├── web/ # Next.js frontend (SSR + WS + Zustand)
├── web/ # Next.js frontend (SSR + WS + TanStack Query + Zustand)
├── cli/ # CLI tool (TypeScript)
├── landing/ # Landing page
└── packages/ # Shared packages/types
Expand Down Expand Up @@ -37,7 +37,7 @@ Architecture notes and per-area conventions live alongside the code they describ
- `apps/backend/internal/agentctl/AGENTS.md` — agentctl HTTP server: route groups, adapter model, ACP protocol.
- `apps/backend/internal/agentctl/server/api/AGENTS.md` — reverse-proxy body rewriting (`Accept-Encoding`), iframe-blocking header stripping.
- `apps/backend/internal/integrations/AGENTS.md` — adding a new third-party integration (Jira/Linear pattern, both backend and frontend halves). The `/add-integration` skill mirrors this for scaffolding new integrations.
- `apps/web/AGENTS.md` — Next.js frontend: shadcn imports, SSR-hydrate-store data flow, store slice structure (incl. `office`), WS format, component conventions, TS lint limits.
- `apps/web/AGENTS.md` — Next.js frontend: shadcn imports, TanStack Query data flow (queries + WS→cache bridges + ring-buffered streams), client-only Zustand slices (transitional mirrors), WS format, component conventions, TS lint limits.

---

Expand Down
93 changes: 87 additions & 6 deletions apps/backend/cmd/kandev/e2e_reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,36 @@ import (
"context"
"net/http"
"os"
"strconv"
"strings"

"github.com/gin-gonic/gin"
"go.uber.org/zap"

"github.com/kandev/kandev/internal/automation"
"github.com/kandev/kandev/internal/common/logger"
gateways "github.com/kandev/kandev/internal/gateway/websocket"
sqliterepo "github.com/kandev/kandev/internal/task/repository/sqlite"
taskservice "github.com/kandev/kandev/internal/task/service"
)

// errorField is the JSON key for error responses across every E2E endpoint.
// Extracted to satisfy goconst; the value is part of the public contract with
// the FE test harness so don't rename without updating the consumers.
const errorField = "error"

// errUnknownConnection is the 404 message body for connection-id lookups
// against the WS gateway's ring buffer. Extracted to satisfy goconst.
const errUnknownConnection = "unknown connection_id"

// registerE2EResetRoutes registers the E2E test-only endpoints.
// The endpoints are available when KANDEV_MOCK_AGENT is "true" or "only" (dev/E2E modes).
func registerE2EResetRoutes(
router *gin.Engine,
repo *sqliterepo.Repository,
taskSvc *taskservice.Service,
automationSvc *automation.Service,
hub *gateways.Hub,
log *logger.Logger,
) {
mockMode := os.Getenv("KANDEV_MOCK_AGENT")
Expand All @@ -35,10 +47,79 @@ func registerE2EResetRoutes(
// workflow path (e.g. improve-kandev) without depending on the real
// bootstrap endpoint, which clones from GitHub and shells out to gh.
api.POST("/hidden-workflow", handleE2ECreateHiddenWorkflow(taskSvc, log))
// WS send-log inspector: lets E2E tests diff what the BE sent vs what
// the FE received per WS connection. Gaps in the FE-side seq sequence
// against this server-of-record indicate a real WS regression rather
// than a noisy UI test.
api.GET("/ws-sent", handleE2EWsSent(hub))

log.Info("registered E2E endpoints (test-only)")
}

// e2eWsSentResponse matches the contract the FE-side accountant consumes.
// Keep field names stable — changes here require a matching FE update.
type e2eWsSentResponse struct {
ConnectionID string `json:"connection_id"`
Events []gateways.WsSentEvent `json:"events"`
MaxSeq int64 `json:"max_seq"`
}

func handleE2EWsSent(hub *gateways.Hub) gin.HandlerFunc {
return func(c *gin.Context) {
connectionID := c.Query("connection_id")
if connectionID == "" {
c.JSON(http.StatusBadRequest, gin.H{errorField: "connection_id is required"})
return
}
var sinceSeq int64
if raw := c.Query("since_seq"); raw != "" {
parsed, err := strconv.ParseInt(raw, 10, 64)
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{errorField: "since_seq must be an integer"})
return
}
sinceSeq = parsed
}

// Optional per-session filter (Workstream 1): when set, returns only
// entries whose stamped SessionID matches, sorted by SessionSeq
// ascending. MaxSeq in the response then carries the max SessionSeq
// for the filter (the per-session counter, not per-connection). The
// FE per-session diff uses this to catch cross-session misrouting
// that per-connection seq alone cannot detect.
if sessionID := c.Query("session_id"); sessionID != "" {
events, maxSessionSeq, ok := hub.GetSentEventsForSession(connectionID, sessionID)
if !ok {
c.JSON(http.StatusNotFound, gin.H{errorField: errUnknownConnection})
return
}
if events == nil {
events = []gateways.WsSentEvent{}
}
c.JSON(http.StatusOK, e2eWsSentResponse{
ConnectionID: connectionID,
Events: events,
MaxSeq: maxSessionSeq,
})
return
}

events, maxSeq, ok := hub.GetSentEventsFor(connectionID, sinceSeq)
if !ok {
c.JSON(http.StatusNotFound, gin.H{errorField: errUnknownConnection})
return
}
if events == nil {
events = []gateways.WsSentEvent{}
}
c.JSON(http.StatusOK, e2eWsSentResponse{
ConnectionID: connectionID,
Events: events,
MaxSeq: maxSeq,
})
}
}

func handleE2EReset(
repo *sqliterepo.Repository,
taskSvc *taskservice.Service,
Expand Down Expand Up @@ -96,7 +177,7 @@ func handleE2EReset(
tasks, total, err := repo.ListTasksByWorkspace(ctx, workspaceID, "", "", "", 1, resetPageSize, true, true, false, false)
if err != nil {
log.Error("e2e reset: failed to list tasks", zap.Error(err))
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
c.JSON(http.StatusInternalServerError, gin.H{errorField: err.Error()})
return
}
if total > resetPageSize {
Expand All @@ -116,7 +197,7 @@ func handleE2EReset(
// would create orphan rows visible to subsequent tests.
log.Error("e2e reset: failed to delete task",
zap.String("task_id", t.ID), zap.Error(err))
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
c.JSON(http.StatusInternalServerError, gin.H{errorField: err.Error()})
return
}
deletedTasks++
Expand All @@ -125,14 +206,14 @@ func handleE2EReset(
deletedWorkflows, err := repo.DeleteWorkflowsByWorkspace(ctx, workspaceID, keepWorkflowIDs)
if err != nil {
log.Error("e2e reset: failed to delete workflows", zap.Error(err))
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
c.JSON(http.StatusInternalServerError, gin.H{errorField: err.Error()})
return
}

deletedAutomations, autoErr := deleteAutomationsForReset(ctx, automationSvc, workspaceID)
if autoErr != nil {
log.Error("e2e reset: failed to delete automations", zap.Error(autoErr))
c.JSON(http.StatusInternalServerError, gin.H{"error": autoErr.Error()})
c.JSON(http.StatusInternalServerError, gin.H{errorField: autoErr.Error()})
return
}

Expand Down Expand Up @@ -164,7 +245,7 @@ func handleE2ECreateHiddenWorkflow(taskSvc *taskservice.Service, log *logger.Log
return func(c *gin.Context) {
var body e2eHiddenWorkflowRequest
if err := c.ShouldBindJSON(&body); err != nil || body.WorkspaceID == "" || body.Name == "" {
c.JSON(http.StatusBadRequest, gin.H{"error": "workspace_id and name are required"})
c.JSON(http.StatusBadRequest, gin.H{errorField: "workspace_id and name are required"})
return
}
workflow, err := taskSvc.CreateWorkflow(c.Request.Context(), &taskservice.CreateWorkflowRequest{
Expand All @@ -174,7 +255,7 @@ func handleE2ECreateHiddenWorkflow(taskSvc *taskservice.Service, log *logger.Log
})
if err != nil {
log.Error("e2e: failed to create hidden workflow", zap.Error(err))
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
c.JSON(http.StatusInternalServerError, gin.H{errorField: err.Error()})
return
}
c.JSON(http.StatusCreated, gin.H{
Expand Down
Loading
Loading