Skip to content

fix(chat): open an agent started from the app on its greeting, with its model, at rest - #990

Merged
devswha merged 1 commit into
mainfrom
fix/first-chat-entry
Oct 13, 2026
Merged

devswha merged 1 commit into
mainfrom
fix/first-chat-entry

Conversation

@devswha

@devswha devswha commented Oct 13, 2026

Copy link
Copy Markdown
Owner

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:

  • Chat said "Conversation unavailable". Codex, Claude Code, OpenCode, gjc and Grok write no session before the first message, so paneConversation threw ConversationUnavailable and the chat fell back to the terminal. Only omo and omp answered a conversation not begun.
  • The message box named no model. With no transcript, metadata was null.
  • The pane read DONE. Five Codex panes started together all read working at about 4 s and done at about 5.5 s while drawing their start screen.

What changes:

  • server/launched-agents.ts remembers the panes agentLaunch started. 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:
    • paneConversation answers an empty conversation of the agent's source, so the chat shows the greeting over the composer;
    • settle reads herdr's working and done as idle, in the collector's onStatus and in the snapshot. A question asked at the start (Claude's folder question) stays blocked.
  • server/start-screen.ts reads 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.
  • A worktree's agent opens in the same lens a new workspace's does: Sidebar's onOpened now tells App through actions.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_started and 0.6 s of task_complete, so a 2 s poll would only lag it.

Validation

  • bun run check fast on macOS arm64, Bun 1.4.0: generated types, typecheck and build ok. Unit tests: every file passes except server/voice.test.ts ("streams deltas and the done text from a split SSE answer"), which fails the same way on main a4b2295 on this Mac. portal, plugin, install-star and ci-setup tests failed in a run that shared the PC with another full suite; each passes alone here and on main.
  • New unit tests: 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).
  • One-off scripts against the test herdr session, not committed:
    • before the change /api/pane/conversation answered scrollback for a fresh codex, claude, opencode, gjc and grok pane; after it, an empty conversation for each;
    • a browser on a fresh Codex and OpenCode pane shows the greeting and no fallback; Codex shows gpt-6-luna / Medium, Claude Haiku 5.5, gjc Opus 5.5 / Xhigh;
    • five Codex panes started together: herdr said working then done, every pane-status frame sent to the client said idle.
  • No HTTP or WS shape changes. Not run locally: the integration and browser lanes.

@coderabbitai

coderabbitai Bot commented Oct 13, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: devswha/herdr-web-ui/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 93c0a507-805f-423a-9a39-0ce96dd782e9
📥 Commits

Reviewing files that changed from the base of the PR and between a4b2295 and 461a798.

📒 Files selected for processing: 10
  • changelog.d/first-chat-of-a-started-agent.md
  • server/conversation.ts
  • server/index.ts
  • server/launched-agents.test.ts
  • server/launched-agents.ts
  • server/start-screen.test.ts
  • server/start-screen.ts
  • src/App.tsx
  • src/components/Sidebar.tsx
  • src/lib/actions.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devswha
devswha merged commit 42c6332 into main Oct 13, 2026
17 checks passed
@devswha
devswha deleted the fix/first-chat-entry branch October 13, 2026 22:28
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant