@startuml
title PCS Sync - Refresh Baseline

actor Engineer
participant "PCS TIA Sync Tool" as Gui
participant "pcs sync status --json" as Status
participant "Repository\n tia/exports" as Repo
participant "TIA Snapshot\n.pcs/sync/tia-snapshot/latest" as TiaSnapshot
participant "pcs sync baseline --force" as BaselineCommand
database "Base Snapshot\n.pcs/sync/base-hashes.json" as Base

Gui -> Status : refresh status
Status -> Repo : hash normalized repo sources
Status -> TiaSnapshot : hash normalized TIA snapshot
Status --> Gui : Repo == TIA and Base is older
Gui --> Engineer : Refresh Baseline now / Later

Engineer -> Gui : Refresh Baseline now
Gui -> BaselineCommand : write current repo hashes
BaselineCommand -> Repo : hash normalized repo sources
BaselineCommand -> Base : replace base-hashes.json
BaselineCommand --> Gui : baseline refreshed
Gui -> Status : refresh status
Status --> Gui : clean in Base, Repo, and TIA

@enduml
