feat(ui): add maintenance page for task management
Some checks failed
CI / build-and-test (push) Failing after -31m53s
Some checks failed
CI / build-and-test (push) Failing after -31m53s
* Implement maintenance page with task and log display * Add backfill and metadata retry functionality * Integrate grid component for project display in thoughts page * Update types for maintenance tasks and logs * Enhance sidebar and shell for new maintenance navigation
This commit is contained in:
@@ -75,6 +75,9 @@ func (t *LearningsTool) Add(ctx context.Context, req *mcp.CallToolRequest, in Ad
|
||||
if summary == "" {
|
||||
return nil, AddLearningOutput{}, errRequiredField("summary")
|
||||
}
|
||||
if err := t.ensureConfigured(); err != nil {
|
||||
return nil, AddLearningOutput{}, err
|
||||
}
|
||||
|
||||
project, err := resolveProject(ctx, t.store, t.sessions, req, in.Project, false)
|
||||
if err != nil {
|
||||
@@ -113,6 +116,10 @@ func (t *LearningsTool) Add(ctx context.Context, req *mcp.CallToolRequest, in Ad
|
||||
}
|
||||
|
||||
func (t *LearningsTool) Get(ctx context.Context, _ *mcp.CallToolRequest, in GetLearningInput) (*mcp.CallToolResult, GetLearningOutput, error) {
|
||||
if err := t.ensureConfigured(); err != nil {
|
||||
return nil, GetLearningOutput{}, err
|
||||
}
|
||||
|
||||
learning, err := t.store.GetLearning(ctx, in.ID)
|
||||
if err != nil {
|
||||
return nil, GetLearningOutput{}, err
|
||||
@@ -121,6 +128,10 @@ func (t *LearningsTool) Get(ctx context.Context, _ *mcp.CallToolRequest, in GetL
|
||||
}
|
||||
|
||||
func (t *LearningsTool) List(ctx context.Context, req *mcp.CallToolRequest, in ListLearningsInput) (*mcp.CallToolResult, ListLearningsOutput, error) {
|
||||
if err := t.ensureConfigured(); err != nil {
|
||||
return nil, ListLearningsOutput{}, err
|
||||
}
|
||||
|
||||
project, err := resolveProject(ctx, t.store, t.sessions, req, in.Project, false)
|
||||
if err != nil {
|
||||
return nil, ListLearningsOutput{}, err
|
||||
@@ -146,6 +157,13 @@ func (t *LearningsTool) List(ctx context.Context, req *mcp.CallToolRequest, in L
|
||||
return nil, ListLearningsOutput{Learnings: items}, nil
|
||||
}
|
||||
|
||||
func (t *LearningsTool) ensureConfigured() error {
|
||||
if t == nil || t.store == nil {
|
||||
return errInvalidInput("learnings tool is not configured")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func defaultString(value string, fallback string) string {
|
||||
if value == "" {
|
||||
return fallback
|
||||
|
||||
70
internal/tools/learnings_test.go
Normal file
70
internal/tools/learnings_test.go
Normal file
@@ -0,0 +1,70 @@
|
||||
package tools
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"git.warky.dev/wdevs/amcs/internal/mcperrors"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
func TestLearningsAddRequiresSummary(t *testing.T) {
|
||||
tool := &LearningsTool{}
|
||||
|
||||
_, _, err := tool.Add(context.Background(), nil, AddLearningInput{})
|
||||
if err == nil {
|
||||
t.Fatal("Add() error = nil, want error")
|
||||
}
|
||||
|
||||
_, data := requireRPCError(t, err)
|
||||
if data.Field != "summary" {
|
||||
t.Fatalf("Add() error field = %q, want %q", data.Field, "summary")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLearningsMethodsRequireConfiguredStore(t *testing.T) {
|
||||
tool := &LearningsTool{}
|
||||
|
||||
t.Run("add", func(t *testing.T) {
|
||||
_, _, err := tool.Add(context.Background(), nil, AddLearningInput{Summary: "Keep this"})
|
||||
if err == nil {
|
||||
t.Fatal("Add() error = nil, want error")
|
||||
}
|
||||
_, data := requireRPCError(t, err)
|
||||
if data.Type != mcperrors.TypeInvalidInput {
|
||||
t.Fatalf("Add() data.type = %q, want %q", data.Type, mcperrors.TypeInvalidInput)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("get", func(t *testing.T) {
|
||||
_, _, err := tool.Get(context.Background(), nil, GetLearningInput{ID: uuid.New()})
|
||||
if err == nil {
|
||||
t.Fatal("Get() error = nil, want error")
|
||||
}
|
||||
_, data := requireRPCError(t, err)
|
||||
if data.Type != mcperrors.TypeInvalidInput {
|
||||
t.Fatalf("Get() data.type = %q, want %q", data.Type, mcperrors.TypeInvalidInput)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("list", func(t *testing.T) {
|
||||
_, _, err := tool.List(context.Background(), nil, ListLearningsInput{})
|
||||
if err == nil {
|
||||
t.Fatal("List() error = nil, want error")
|
||||
}
|
||||
_, data := requireRPCError(t, err)
|
||||
if data.Type != mcperrors.TypeInvalidInput {
|
||||
t.Fatalf("List() data.type = %q, want %q", data.Type, mcperrors.TypeInvalidInput)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestNormalizeStringSliceTrimsDedupesAndDropsEmpties(t *testing.T) {
|
||||
got := normalizeStringSlice([]string{" alpha ", "beta", "", "beta", "alpha"})
|
||||
if len(got) != 2 {
|
||||
t.Fatalf("normalizeStringSlice() len = %d, want 2", len(got))
|
||||
}
|
||||
if got[0] != "alpha" || got[1] != "beta" {
|
||||
t.Fatalf("normalizeStringSlice() = %#v, want [alpha beta]", got)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user