Move harness profiles between host and Docker and stop silent draft retargeting
Native installs left Docker-era harness profiles in harnesses.json, so every authoring launch failed trying to reach a Docker service, and a retained draft bound to the old Docker server was silently projected onto the configured one. - harness: add Profile.Mode and VerifyDockerLink as the single mode/verification helpers. `harness setup --host` configures or converts a host profile and clears docker_directory; reconfiguring a Docker-linked profile re-verifies the recorded directory still owns compose.yaml and fails naming it instead of saving a link that cannot launch. Setup's summary and `harness list` (via the new List/ListView shape) report the resulting mode and, for Docker, the directory, without changing the stored Config schema. - setup-native.py: after build/install-skill it writes host (no docker_directory) profiles for the detected harnesses, defaulting to the detected OpenCode profile rather than a stale pi default, taking models from --model or the existing valid profile and never inventing one; it clears a stale Docker link and preserves unrelated keys/profiles. Detection-only: no harness install, upgrade or download. - draft: add Draft.Resolve, the shared mismatch helper, which projects a draft onto the configured server and returns a dual-URL notice. CLI validate/submit and the TUI draft browser use it so a foreign draft is never silently retargeted; the TUI pre-wraps the notice to the panel width. - Tests cover the Docker->host and host->host transitions, the missing-directory failure, installer write/migration (Python), and the CLI/TUI notice, using the real config file path in a temp dir. - Update help text, README, docs and the packaged authoring skill reference to describe host as the default and the Docker-linked case.
This commit is contained in:
@@ -191,3 +191,42 @@ func TestDraftBrowserAcceptsOtherServerAndKeepsUnnamedDraft(t *testing.T) {
|
||||
t.Fatal("unnamed draft submitted")
|
||||
}
|
||||
}
|
||||
|
||||
// TestDraftBrowserNoticeNamesBothServersForForeignDraft covers the stale 8081
|
||||
// draft case in the TUI: the selected foreign draft is projected onto the
|
||||
// configured server (create-only) and a notice names both endpoints instead of
|
||||
// silently retargeting it.
|
||||
func TestDraftBrowserNoticeNamesBothServersForForeignDraft(t *testing.T) {
|
||||
t.Setenv("PIPELINES_DRAFT_DIR", t.TempDir())
|
||||
foreign := "ws://127.0.0.1:8081/connect"
|
||||
configured := "ws://127.0.0.1:8080/connect"
|
||||
d, err := draft.Create("wrong", "source", foreign, true, 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
m := New(context.Background(), configured)
|
||||
updated, _ := m.openDrafts()
|
||||
m = updated.(Model)
|
||||
if !strings.Contains(m.draftNotice, foreign) || !strings.Contains(m.draftNotice, configured) {
|
||||
t.Fatalf("preview notice did not name both servers: %q", m.draftNotice)
|
||||
}
|
||||
// The notice must name both endpoints at any realistic panel width: an
|
||||
// unwrapped line is truncated by fitBlock and loses the configured URL.
|
||||
for _, width := range []int{60, 100} {
|
||||
view := m
|
||||
view.width, view.height = width, 24
|
||||
rendered := view.View()
|
||||
if !strings.Contains(rendered, foreign) || !strings.Contains(rendered, configured) {
|
||||
t.Fatalf("notice at width %d did not name both servers:\n%s", width, rendered)
|
||||
}
|
||||
}
|
||||
updated, _ = m.updateDrafts(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'s'}})
|
||||
m = updated.(Model)
|
||||
if !m.confirmOpen || m.pendingDraft == nil || !m.pendingDraft.createOnly || m.pendingDraft.baseVersion != 0 {
|
||||
t.Fatalf("foreign draft was not projected as create-only: %+v", m.pendingDraft)
|
||||
}
|
||||
if !strings.Contains(m.draftNotice, foreign) || !strings.Contains(m.draftNotice, configured) {
|
||||
t.Fatalf("submit lost the dual-URL notice: %q", m.draftNotice)
|
||||
}
|
||||
_ = d
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user