BYO AI settings: custom instructions, model picker, key show/hide
release gate / check (push) Failing after 6m26s
release / smoke (push) Successful in 10m16s
release / publish (push) Failing after 9m57s

Mirrors the BYOK dialog suggested in issue #2:
- UserAiConfig gains an optional instructions column (schema.sql +
  migration 016); PUT validates (<=4000 chars) and full-replaces it.
- Instructions ride along on the assistant chat system prompt only
  (chatSystemWith); the automation compiler and page-extraction prompts
  stay server-owned contracts.
- Settings -> AI: labeled fields, per-provider suggested-model dropdown
  with a custom-model escape hatch, API key show/hide toggle, and the
  instructions textarea.
- Tests: projection echo, omission clears, cap validation, and the
  system-prompt assertion via a recorded fake provider body.
This commit is contained in:
Andrew S Erwin
2026-10-31 19:09:44 -05:00
parent 1dfd41986c
commit 09f8a5d933
10 changed files with 272 additions and 81 deletions
+15 -5
View File
@@ -15,11 +15,12 @@ import (
// fakeOpenAI is a loopback OpenAI-compatible chat-completions server with a
// programmable reply, standing in for OpenRouter in tests.
type fakeOpenAI struct {
ln net.Listener
srv *http.Server
mu sync.Mutex
next string // canned assistant message content
hits int
ln net.Listener
srv *http.Server
mu sync.Mutex
next string // canned assistant message content
lastBody string // raw JSON of the most recent request body
hits int
}
func newFakeOpenAI(t *testing.T) *fakeOpenAI {
@@ -38,6 +39,7 @@ func newFakeOpenAI(t *testing.T) *fakeOpenAI {
body, _ := io.ReadAll(r.Body)
f.mu.Lock()
f.hits++
f.lastBody = string(body)
reply := f.next
f.mu.Unlock()
if strings.Contains(string(body), "extract one fact") || strings.Contains(string(body), "You extract one fact") {
@@ -65,6 +67,14 @@ func (f *fakeOpenAI) setReply(s string) {
f.mu.Unlock()
}
// lastRequest returns the raw JSON body of the most recent completion
// request (system-prompt assertions read it).
func (f *fakeOpenAI) lastRequest() string {
f.mu.Lock()
defer f.mu.Unlock()
return f.lastBody
}
// fakeWatchTarget serves a fixed "flights" page for url_watch evaluation.
func fakeWatchTarget(t *testing.T) string {
t.Helper()