8c1eea53a9
Exchange a build/protocol identity so an older CLI can no longer talk to a newer native server silently: - protocol carries ProtocolVersion and every server frame (including the unsolicited welcome) is stamped with the server build and protocol, so a client that never pings still learns the server identity. - buildinfo.Compare classifies the relationship as InSync/Warn/Refuse and names both builds; the client Watch reports one warning per connection and returns a hard error when the server speaks a newer, uninterpretable protocol so the caller never acts on the frame. - client.ReceiveNotice decodes the raw frame so an unmodeled top-level field produces a one-time "unrecognized field(s)" notice instead of being dropped silently (the case that hid the artifacts field). - CLI routes warnings to stderr, keeps machine JSON stdout clean and fails non-zero on a refused mismatch; ping/connection print the client/server relationship. The TUI surfaces the same notices through the shared log. - scripts/setup-native.py now warns when an older `pipelines` earlier on PATH shadows prefix/bin/pipelines, naming both paths and versions, without installing or modifying anything else. - Docs, the packaged debugging skill reference and README no longer imply the installed CLI always matches the server. Tests cover the comparison table, unknown-field detection and caching, the server identity stamping on pong and welcome, the CLI/TUI reporting paths and the installer PATH shadowing warning.
45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
package tui
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"git.a-wan.net/alan/pipelines/internal/buildinfo"
|
|
)
|
|
|
|
// noticeSink collects build/protocol notices from a short-lived client so a TUI
|
|
// command can surface them through the shared notice path instead of dropping
|
|
// them. It implements client.Reporter.
|
|
type noticeSink struct {
|
|
mu sync.Mutex
|
|
notices []string
|
|
}
|
|
|
|
func (s *noticeSink) report(relationship buildinfo.Relationship) {
|
|
if relationship.Message == "" {
|
|
return
|
|
}
|
|
s.mu.Lock()
|
|
s.notices = append(s.notices, relationship.Message)
|
|
s.mu.Unlock()
|
|
}
|
|
|
|
// drain returns the notices collected so far and resets the sink.
|
|
func (s *noticeSink) drain() []string {
|
|
s.mu.Lock()
|
|
defer s.mu.Unlock()
|
|
notices := s.notices
|
|
s.notices = nil
|
|
return notices
|
|
}
|
|
|
|
// appendNotices is the single TUI notice path: every server relationship or
|
|
// unrecognized-field notice is rendered as one warning line, whether it came
|
|
// from the long-lived read loop or a short-lived command client.
|
|
func (m *Model) appendNotices(notices []string) {
|
|
for _, notice := range notices {
|
|
if notice != "" {
|
|
m.appendLine("warning: " + notice)
|
|
}
|
|
}
|
|
}
|