package dashboard

import (
	"context"

	"github.com/tidbcloud/AgentTeam/desktop/internal/profile"
	"github.com/tidbcloud/AgentTeam/desktop/internal/wire/manager"
)

type dashboardTestTransition struct{}

func (dashboardTestTransition) Complete()   {}
func (dashboardTestTransition) FailClosed() {}

type dashboardTestRuntimeParticipant struct {
	connections *manager.Manager
}

func (p dashboardTestRuntimeParticipant) BeginServerTransition(string) profile.ServerTransition {
	return dashboardTestTransition{}
}

func (p dashboardTestRuntimeParticipant) ReconcileServer(
	_ context.Context,
	previous, current *profile.AgentTeamServer,
) error {
	return p.connections.Reconcile(previous, current)
}

func (p dashboardTestRuntimeParticipant) RepairServer(
	ctx context.Context,
	current profile.AgentTeamServer,
) error {
	return p.connections.RepairServer(ctx, current)
}

func (dashboardTestRuntimeParticipant) InvalidateServer(string) {}

func activateDashboardTestRuntime(servers *profile.ServerManager, connections *manager.Manager) {
	_ = servers.PrepareRuntimeMode()
	_ = servers.ActivateRuntimeMode(dashboardTestRuntimeParticipant{connections: connections})
}
