Repository navigation
fix(chat): open an agent started from the app on its greeting, with its model, at rest - #990
Merged
Merged
Conversation
…ts model, at rest
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 11 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
devswha
added a commit
that referenced
this pull request
Oct 26, 2026
## Problem Typing `codex` in a Herdr terminal and opening Chat before the first message said "Conversation unavailable", while a Codex started from New workspace, New tab or New worktree showed its greeting (#990). Codex writes no session before the first message (0.163 makes no `state_5.sqlite` at all until then), and herdr reports none, so nothing tied the pane to a transcript. Fixes #1191 ## Fix #990 left terminal launches out because they may resume a conversation. Chat now greets one only when every fact says it has begun none, and otherwise keeps the terminal fallback as before (`codexFreshSession` in `server/codex.ts`, called from the `no_session_path` fallback in `paneConversation`): - **Screen**: Codex's start screen with nothing said (`codexStartScreenUnused`, `server/start-screen.ts`, sharing the footer rule the model is read by). Under the last banner line (`>_ OpenAI Codex (v…)`, boxed or not, never an answer that only mentions it) the composer is the first prompt line, and no prompt, answer, warning or error cell follows it. None may sit above the banner either: that would be a command's card or a second session in the same terminal. - **Command line**: no `resume` or `fork` on the argv of the pane's Codex processes. - **Store**: no interactive thread with a first message, for any folder the pane names (the shell's and the foreground process's, as given and as they resolve), begun or written since those processes started (a lower bound of their start, less a second), in the store the pane's Codex writes to. A missing store holds none. That store must be placed for certain on every platform (`certainProcessCodexHome`): the `CODEX_HOME` directory each Codex's environment names, or `.codex` in the `HOME` its environment names when it names none (never the server's own home). An environment that cannot be read (another user's process, a gone one, Windows), a `CODEX_HOME` that is relative or not a directory, and on macOS a command line that spells `CODEX_HOME=` or `HOME=`, no `HOME` or a relative one, or a `ps -E` line with no environment all say no, as do a store or a start time that cannot be read. - **Status**: the pane is not working or blocked. The answer is a conversation not begun, as for an app launch, with the model and effort the status line states. Its history id names the pane and its Codex processes, with no time in it (a start time read on macOS moves between reads), so the first message's transcript replaces it whole. A resumed session still shows its saved messages through the existing lookup. Anything this cannot identify keeps "Conversation unavailable". A launcher that picks another `CODEX_HOME` works because the pane's own Codex home is the one checked. ## Verification - **Unit** (`server/conversation.test.ts`, `server/start-screen.test.ts`): a Codex at its start screen gets the greeting with no store, and with a store whose threads of the folder all ended before it started. Each of these keeps "unavailable": a `resume` or `fork` command line, something said on screen, a pane at work, a thread of the folder (or of its resolved path, or of the foreground folder) with a first message begun or written since, and an unreadable store. A thread in another folder, a subagent's, a `codex exec` run's, or one with no first message does not count. The screen cases cover a draft in the composer, an answer quoting the banner, a boxed banner and a conversation above the banner. A second test starts real child processes with the `CODEX_HOME` under test (server default store isolated): an absolute home greets; a relative one whose store holds a conversation begun now, a non-directory, and a second Codex with a relative home do not. With no `CODEX_HOME`, the store follows the child's own `HOME`; with no `HOME` there is no greeting. Each child says it runs before it is read, so the test does not race its exec (0 failures in 30 runs). 163/163 pass on Linux and on macOS 27 (the test MacBook Air, fresh clone). Restoring the default-store fallback, or the server's `homedir()`, fails the test on both. - **Real surface**: real `codex` 0.163.0 typed in a pane of the isolated test herdr session (throwaway `CODEX_HOME`, closed provider), with Chat opened in headless Chrome: - At 1440 px and 390 px, the greeting "What should Codex do in proj?" shows with the GPT-6-Sol / Medium chip, and the frame shows no "Conversation unavailable". `GET /api/pane/conversation` answers 200 with `history_id: unwritten:codex:…`, no turns, and model `gpt-6-sol` / `medium`. - After a first message the greeting is gone, and Chat shows the terminal fallback as on main while the turn runs. - `bun run check fast` on d12ff6d: green (unit 7191 pass, 0 fail, 24 skip; typecheck, build, generated types and themes, workflow syntax ok). ## Reviews - **omo-native-code-reviewer**: approve. Its one MEDIUM (the symlinked-folder assertion could not fail, because the foreground folder still matched) is fixed: the case now names the link as both folders, and dropping the `realpathSync` in `codexFreshSession` fails it. LOWs left as follow-ups: - A fresh Codex that draws a start-up warning cell (an MCP server failing to start) keeps "Conversation unavailable", as on main: a warning counts as something said. - Windows never greets a terminal-started Codex: there is no process start time or environment to read. - Its other two LOWs (a relative `CODEX_HOME` guard on Linux only, and the fallback listing the pane's Codex processes twice) went away with the merge-pass fix below, which places the store itself. - **Codex (gpt-6.1-sol)**: no HIGH, MEDIUM or LOW on the rebased commit; it checked the greeting against main's newer lookups (#1941 loaded threads, #1790 title candidates, #1750 the pane's Codex home), which all run before it. Two earlier rounds on the pre-rebase version found a HIGH (answer text taken for the banner) and MEDIUMs (symlinked folder, relative `CODEX_HOME`, macOS start time, foreground folder), all fixed. - **Merge pass (Astra gate)** on 9cc35fa: one blocker. On macOS a relative `CODEX_HOME` fell back to the server's default store, so a false greeting was possible. Fixed in c1b4e8d: the store is now placed for certain on every platform, as described under **Store**. Its re-review of c1b4e8d found a HIGH (with no `CODEX_HOME`, the store came from the server's home rather than the Codex's own `HOME`) and a MEDIUM (the new test raced its child's exec), both fixed in d12ff6d and 11d7b71. --------- Co-authored-by: mp <mp@local>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change
An agent started from New workspace, New tab or New worktree opened badly until its first message. Measured on herdr 0.9.3 with the real CLIs:
paneConversationthrewConversationUnavailableand the chat fell back to the terminal. Only omo and omp answered a conversation not begun.metadatawas null.workingat about 4 s anddoneat about 5.5 s while drawing their start screen.What changes:
server/launched-agents.tsremembers the panesagentLaunchstarted. Until the first turn (the agent at work or asking after it was seen at rest, or 30 s), a found transcript, or the pane's end:paneConversationanswers an empty conversation of the agent's source, so the chat shows the greeting over the composer;settlereads herdr'sworkinganddoneasidle, in the collector'sonStatusand in the snapshot. A question asked at the start (Claude's folder question) staysblocked.server/start-screen.tsreads the model off the agent's own start screen for a conversation not begun, also for the agents that already answered one: Claude Code's model under its title, and the model and effort from Codex's and gjc's status line. A name becomes the id its transcript will record only by the vendor's regular rule; anything else stays unknown.Sidebar'sonOpenednow tells App throughactions.agentStarted, as New workspace already did.An agent started in a terminal is not covered: nothing says it resumed nothing.
Transcript turn records were measured as a status source and left out: for a real Codex turn herdr was within 0.1 s of
task_startedand 0.6 s oftask_complete, so a 2 s poll would only lag it.Validation
bun run check faston macOS arm64, Bun 1.4.0: generated types, typecheck and build ok. Unit tests: every file passes exceptserver/voice.test.ts("streams deltas and the done text from a split SSE answer"), which fails the same way onmaina4b2295 on this Mac.portal,plugin,install-starandci-setuptests failed in a run that shared the PC with another full suite; each passes alone here and onmain.server/launched-agents.test.ts,server/start-screen.test.ts(the screens are the ones captured from Claude Code 2.1.296, Codex 0.162.1 and gjc 0.17.7)./api/pane/conversationansweredscrollbackfor a fresh codex, claude, opencode, gjc and grok pane; after it, an empty conversation for each;gpt-6-luna/ Medium, ClaudeHaiku 5.5, gjcOpus 5.5/ Xhigh;workingthendone, everypane-statusframe sent to the client saididle.