Use ChatGPT Codex for launcher questions

This commit is contained in:
rope 2026-09-17 17:49:24 +01:00
parent af95242b60
commit 4c6d610263
2 changed files with 40 additions and 94 deletions

View file

@ -344,19 +344,16 @@ in
'https://en.wikipedia.org/w/api.php?action=query&format=json&generator=search&gsrlimit=3&prop=extracts&exintro&explaintext&redirects=1'
'';
# Launcher LLM answers, via the mediaserver. The API key lives on the
# server ONLY — the desktops just pipe a question over the same SSH
# path the server monitor already uses, so no laptop ever holds a
# credential and there's one place to rotate it. The remote end is
# `qs-ask` in hosts/FredOS-Mediaserver.nix.
# Launcher LLM answers, via the mediaserver. Codex uses fred's ChatGPT
# login there; desktops only pipe questions over the existing SSH path.
# The remote end is `qs-ask` in hosts/FredOS-Mediaserver.nix.
#
# The query goes over STDIN, not as an argv element: `ssh host cmd arg`
# re-parses arg through the remote shell, so a question containing
# quotes would break. stdin sidesteps remote quoting entirely.
#
# Prints nothing when the key is missing, the server is unreachable, the
# call fails, or the model says it doesn't know — each of those falls
# through to the Wikipedia answer.
# Prints nothing when login is missing, the server is unreachable, the
# call fails, or the model says it doesn't know; Wikipedia then remains.
askFetchScript = pkgs.writeShellScript "ask-fetch" ''
q="$1"
[ -z "$q" ] && exit 0
@ -367,8 +364,7 @@ in
'';
# Launcher weather. Neither of the other two answer paths can serve
# this: qs-ask runs with no tools at all, so Claude has no live data and
# correctly refuses, and Wikipedia answers "weather in kristiansand"
# this: qs-ask has no live data, and Wikipedia answers "weather in kristiansand"
# with the city's founding date. open-meteo needs no key — geocode the
# place name, then read current conditions at those coordinates.
#
@ -2025,8 +2021,8 @@ in
// the slow paths count: Wikipedia lands inside the debounce
// and would just flicker the spinner.
readonly property bool answerPending: askProc.running || wxProc.running
readonly property string pendingSource: wxProc.running ? "open-meteo" : "Claude"
// Claude answered the current query, so the slower-arriving
readonly property string pendingSource: wxProc.running ? "open-meteo" : "ChatGPT"
// ChatGPT answered the current query, so the slower-arriving
// Wikipedia result must not overwrite it.
property bool askWon: false
property var answerCache: ({})
@ -2116,10 +2112,8 @@ in
}
}
// Claude, tried first. The script is the feature gate: with
// no API key it exits immediately and prints nothing, which
// is the same signal as a failed call — so the Wikipedia
// path stays the default with zero configuration.
// ChatGPT, tried alongside Wikipedia. Without a Codex login
// the script prints nothing and Wikipedia remains visible.
Process {
id: askProc
stdout: StdioCollector {
@ -2172,7 +2166,7 @@ in
return;
}
answerQuery = q;
// Weather takes the open-meteo path alone: Claude has no
// Weather takes the open-meteo path alone: ChatGPT has no
// network to look it up with, Wikipedia answers with the
// city's founding date, and the cache has no notion of
// age so it must not serve a temperature twice.
@ -2191,10 +2185,7 @@ in
return;
}
// Both at once. Wikipedia fills the card in well under a
// second; Claude takes ~6s through Claude Code and
// supersedes it on arrival. Racing them beats chaining:
// Claude-then-fallback would leave the card blank for
// six seconds on every question.
// second; ChatGPT supersedes it when Codex finishes.
askWon = false;
killAsk();
askProc.command = [Commands.askFetch, q];
@ -2218,7 +2209,7 @@ in
fact: text.slice(0, 400),
lead: "",
url: "", // nothing to open
source: "Claude"
source: "ChatGPT"
};
cacheAnswer(res);
// Typing may have moved on while the call was out.
@ -2365,7 +2356,7 @@ in
: "https://en.wikipedia.org/wiki/" + encodeURIComponent(title.replace(/ /g, "_")),
source: "Wikipedia"
};
// Claude already answered this query — don't overwrite
// ChatGPT already answered this query — don't overwrite
// the better answer in the cache or on screen.
if (askWon) return;
cacheAnswer(res);
@ -2801,7 +2792,7 @@ in
anchors.rightMargin: 14
spacing: 4
// Article title — Wikipedia only; a Claude
// Article title — Wikipedia only; a ChatGPT
// answer has no page behind it.
Row {
spacing: 8
@ -2842,12 +2833,12 @@ in
// Always say who answered — the two sources
// carry very different trust. The spinner
// runs for as long as Claude's ~6s call is
// runs for as long as the Codex call is
// out, which is the only cue that a
// Wikipedia answer already on screen is
// still provisional — and that a card that
// never changes was Claude declining, not
// Claude being slow.
// never changes was ChatGPT declining or
// the call failing.
Row {
spacing: 5
SIcon {