dbus: emit ConfigChanged on agent switch, fix agent default override
- Add agent watcher goroutine that emits ConfigChanged(session, key, value) D-Bus signal when the per-session agent name changes - Add ConfigChanged to introspection XML - Fix CreateSession: only apply OLLIE_DEFAULT_AGENT when no agent arg was explicitly provided. Previously, passing agent=default would trigger the env override, making it impossible to select a specific agent from the GUI.
This commit is contained in:
parent
f0942e81ba
commit
2d4ce13272
14
dbus.go
14
dbus.go
|
|
@ -151,6 +151,19 @@ func (a *DBusAdapter) startWatcher(id string, sess *session.Session) {
|
|||
}
|
||||
}()
|
||||
|
||||
// Agent watcher — emits ConfigChanged when the agent name changes
|
||||
go func() {
|
||||
current := sess.Core.AgentName()
|
||||
for {
|
||||
next, ok := sess.Core.WaitChange(ctx, agent.WatchAgent, current)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
current = next
|
||||
a.conn.Emit(busPath, busIface+".ConfigChanged", id, "agent", current)
|
||||
}
|
||||
}()
|
||||
|
||||
// Chat watcher (polls log version)
|
||||
go func() {
|
||||
var lastLen int
|
||||
|
|
@ -751,5 +764,6 @@ var introspectXML = `<node>
|
|||
<signal name="ChatUpdated"><arg type="s" name="sessionID"/><arg type="x" name="offset"/><arg type="s" name="text"/></signal>
|
||||
<signal name="ProcessDetached"><arg type="s" name="sessionID"/></signal>
|
||||
<signal name="ProcessExited"><arg type="s" name="sessionID"/><arg type="i" name="pid"/><arg type="i" name="exitCode"/></signal>
|
||||
<signal name="ConfigChanged"><arg type="s" name="sessionID"/><arg type="s" name="key"/><arg type="s" name="value"/></signal>
|
||||
</interface>
|
||||
</node>`
|
||||
|
|
|
|||
|
|
@ -1060,7 +1060,7 @@ func (s *Manager) CreateSession(args []string) (string, error) {
|
|||
name := ""
|
||||
backendOverride := ""
|
||||
modelOverride := ""
|
||||
agentName := "default"
|
||||
agentName := ""
|
||||
cwd := ""
|
||||
remoteTarget := ""
|
||||
systemPromptOverride := ""
|
||||
|
|
@ -1091,9 +1091,11 @@ func (s *Manager) CreateSession(args []string) (string, error) {
|
|||
return "", fmt.Errorf("unknown option %q (valid: name, backend, model, agent, cwd, remote, system_prompt)", k)
|
||||
}
|
||||
}
|
||||
if agentName == "default" {
|
||||
if agentName == "" {
|
||||
if v := os.Getenv("OLLIE_DEFAULT_AGENT"); v != "" {
|
||||
agentName = v
|
||||
} else {
|
||||
agentName = "default"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Reference in New Issue