Skip to content

fix(chat): find the conversation of a Gajae Code or omp pane on a Windows PC - #264

Merged
devswha merged 5 commits into
mainfrom
fix/windows-gjc-omp-transcripts
Oct 1, 2026
Merged

devswha merged 5 commits into
mainfrom
fix/windows-gjc-omp-transcripts

Conversation

@devswha

@devswha devswha commented Oct 1, 2026 •

Copy link
Copy Markdown
Owner

What was wrong

On a Windows PC added through Add PC, the chat lens showed no conversation for a Gajae Code pane or an omp pane and fell back to the screen text.

  • gjc: the lookup counted gjc as running only when herdr's pane.process_info named it. On Windows herdr names only the pane's shell (fix(session): start Gajae Code from New session on a Windows PC #251), so the lookup gave up before the screen-text match. That match would have failed too: the store checks used ${root}/ and split on /, and Windows paths have backslashes.
  • omp: the path herdr reports had to start with join(HOME, ".omp", "agent", "sessions") + "/", which a Windows path never does.

What changed

  • storeRelative(root, file, paths) in server/gjc-runtime.ts answers "is this file inside this store" through path.relative with the platform's own rules. gjcSessionFile, gjcDisplayCandidates and the omp check use it.
  • On Windows, gjcTranscriptForPane looks for the gjc process among the descendants of the pane's shell_pid (gjcPidUnderShell, reusing server/windows-processes.ts from fix(session): start Gajae Code from New session on a Windows PC #251). The screen-text match then picks the session.
  • The pane keeps its session (boundGjcTranscript): once the screen picked a session file, the pane answers with it while the same gjc process runs under its shell. The screen still wins when it shows another session; a different or missing gjc process drops the binding; a pane is never bound on cwd or recency. forgetTranscriptState() clears it.
  • The process table is shared (recentProcessTable): read at most once in 5 s, so a 2 s chat poll normally starts no PowerShell. A table that could not be read is not kept.
  • ompSessionPath accepts an absolute .jsonl path inside the user's own store in the PC's native form.
  • The containment check is stricter than before on every platform: a path that leaves the store through .. was accepted by the old prefix test (…/sessions/../../etc/x.jsonl) and is now refused. Sibling names (sessions-evil), another drive and a UNC share are refused.
  • Linux and macOS lookups are otherwise unchanged: they bind by open file or breadcrumb, and the process table is never asked there.

Real Windows PC (scenario S7)

Windows PC with herdr 0.9.3, gjc 0.16.4, PowerShell 5.1 as the pane shell; a separate herdr session, a bundle built from origin/main and one from this branch, the same live gjc pane, GET /api/pane/conversation (the route the chat lens polls).

main this branch
after one prompt {"source":"scrollback","turns":[]} gjc-transcript, 2 turns
after a second prompt gjc-transcript, 4 turns, also while gjc was working
during and 30 s after a 150-line answer (no answer tail on screen) gjc-transcript on every poll (before the binding: scrollback for the 150 s watched)
time per call about 0.8 s on every call before the shared table; now about 10 ms, with one call of about 0.75 s every 5 s

Facts the code depends on, observed there: the pane's agent is gjc 11 s after gjc starts and after each prompt (gjc reports itself to herdr on Windows too), and the pane cwd herdr reports equals the cwd in the session file's header byte for byte.

Tests

  • RED on the unchanged code: gjcSessionFile returned null for a Windows store path, the omp check refused a Windows path, and the old prefix test accepted a .. escape. RED for the binding: the session was lost as soon as the screen match failed, and the table was read on every call.
  • GREEN: HERDR_TEST_MODE=unit bun test ./server/gjc-runtime.test.ts ./server/conversation.test.ts — 47 pass. Cases use path.win32 paths and a Windows-shaped process table; the binding cases cover kept while off screen, replaced by the screen, dropped on another pid, dropped when gjc is gone, cleared by forgetTranscriptState().
  • bun test ./server/gjc.contract.test.ts — 5 pass (the real conversation route on Linux, unchanged behavior).
  • bun run typecheck, bun run test:unit (688 pass), bun run build — green.

Limits

  • The first binding of a pane still needs a recent answer's tail on the screen; restarting the bridge loses the bindings until the next such answer.
  • After /new or /resume inside one gjc process the lens shows the old session until an answer of the new one is on screen.
  • A gjc that left its pane can count as running for up to 5 s.
  • That a binding is dropped when the gjc process is gone or replaced is proven by unit tests; on the PC herdr dropped the pane's agent label at /exit, so the route fell back before that code was reached.
  • omp is not installed on that PC. The omp path check is proven by unit tests only; that herdr reports an omp session as a native absolute path is still the issue's assumption.
  • The unit tests cannot run the Windows branch of gjcTranscriptForPane itself on Linux; the real-PC run above is its proof.

The gjc sidebar mark already shows on Windows (it is the pane's agent). codex's /proc fallback is not part of this PR.

Windows PCs get the fix only with the next remote bundle (#256).

Closes #260

…dows PC

Both lookups compared paths with a literal '/', and Gajae Code was looked for only among the processes herdr names, which on Windows is the pane's shell alone.

Containment now goes through path.relative with the platform's own rules, so a Windows store is read and a path that leaves the store through '..' or a sibling name is refused everywhere. On Windows, Gajae Code is found among the pane shell's descendants (windows-processes.ts), and the screen-text match then picks the session.

Closes #260
@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Repository: devswha/herdr-web-ui/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: fc1a6b79-0ccf-4bce-90fb-236b072b1cea

📥 Commits

Reviewing files that changed from the base of the PR and between 589cd6a and 7a86d43.

📒 Files selected for processing (1)
  • CHANGELOG.md
 ____________________________
< Copilot has nothing on me. >
 ----------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: devswha/herdr-web-ui/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: f8dd6edc-c5e7-4f08-baf1-18b13ec2d768

📥 Commits

Reviewing files that changed from the base of the PR and between e0ce717 and 589cd6a.

📒 Files selected for processing (5)
  • CHANGELOG.md
  • server/conversation.test.ts
  • server/conversation.ts
  • server/gjc-runtime.test.ts
  • server/gjc-runtime.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.


📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • Improved chat-lens conversation detection on Windows, including matching sessions to the correct running process and retaining the conversation while that process remains active.
    • Improved session path validation across platforms to reject paths that escape the session store.
    • Reduced repeated process checks while monitoring sessions.

Walkthrough

The change adds platform-aware validation for OMP and GJC session paths. GJC transcript lookup can find a process beneath a Windows pane shell, match screen text, and retain a pane’s transcript while that process remains the same.

Changes

Windows chat-lens transcript detection

Layer / File(s) Summary
Platform-aware transcript paths
server/gjc-runtime.ts, server/conversation.ts, server/conversation.test.ts, server/gjc-runtime.test.ts
OMP and GJC paths use platform-aware containment checks. Tests cover Unix and Windows paths, including traversal and out-of-store paths.
GJC process lookup and transcript binding
server/gjc-runtime.ts, server/conversation.ts, server/gjc-runtime.test.ts, CHANGELOG.md
GJC lookup reads a cached process table, searches below the pane shell, and uses screen-text matching with per-pane transcript bindings. State cleanup clears the bindings and process-table cache.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: yoonwoo-ha

Merge Risk: ⚪ Minimal · up to 589cd

The change supports Windows transcript paths and shell-based GJC detection without an established merge-blocking issue. Real-PC validation remains advisable, but its absence alone does not establish a regression.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 589cd

Path validation becomes stricter, and no new external API is added. The remaining risk is bounded: cached process IDs can allow an earlier conversation to remain associated with a pane after its process changes. Exposure is limited by the existing pane lookup and user-local transcript store.

Retained concerns

  • Low · security · inferred: A retained Windows transcript binding identifies its owner only by pane ID and numeric GJC PID. After an initial legitimate match, a stale process-table result or PID reuse without an intervening invalidation can cause a failed screen match to return the previous session's transcript. The base Windows fallback returned no transcript in this case. This is a bounded conversation-attribution and privacy risk; crossing a principal or tenant boundary has not been demonstrated.
Security review details

Security Blast Radius

  • inferred — The identified ownership risk is scoped to a Windows pane and a transcript previously selected from that server user's GJC store. The traced response can include conversation turns and metadata. The evidence does not establish cross-user, cross-tenant, arbitrary-file, or elevated-privilege exposure.

Security Findings and Attack Paths

  • inferred — A conditional stale-attribution path is supported: first establish a legitimate pane binding, then change the process lifecycle while cached rows still identify the old descendant, or reuse its PID without a poll observing invalidation. If screen matching returns no path, the old binding is reused and returned by the pane conversation request. Exploitation across an authorization boundary is not demonstrated.

Trust Boundaries and Controls

  • observed — A running descendant alone cannot establish an initial transcript binding. The screen matcher requires exactly one candidate with substantial assistant-text overlap; candidates must be canonicalized files inside the GJC store with matching cwd. Pane IDs are also checked against the session snapshot before conversation reads.

Resilience and Maintainability Implications

  • observed — Missing or changed PIDs invalidate bindings, and a new successful screen match replaces the remembered session. These controls cover ordinary turnover, but binding writes occur after an awaited match without an invalidation-generation check; an in-flight match can repopulate state after a concurrent reset.

Hardening Proposals

  • proposed — Strengthen retained ownership with a process-generation identity, such as creation time, and commit asynchronous matches only while the pane's binding generation remains current. Define explicitly whether cached ownership may survive process exit or a same-process session switch.
🚥 Pre-merge checks | ✅ 4 | ❓ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Linked Issues check ❓ Inconclusive The PR implements the requested #260 code paths. storeRelative and ompSessionPath use platform-native containment. gjcPidUnderShell searches Windows shell descendants, and screen matching plus p… Provide reviewable Windows evidence for the conversation route. Confirm that herdr reports the expected omp session path and that a gjc pane reaches the screen-text match with the reported shell process data.
✅ Passed checks (4 passed)
Check name Status Explanation
Out of Scope Changes check ✅ Passed The changes stay within #260. The added tests, process-table cache, lifecycle reset, path validation, and changelog entry support Windows transcript lookup. No unrelated product behavior is demonstrat…
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 4 files. (1 skipped: 1…
Title check ✅ Passed The title clearly identifies the primary change: fixing chat conversation detection for Gajae Code and omp panes on Windows.
Description check ✅ Passed The description is substantially complete. It explains the problem, implementation, validation results, real-world evidence, limitations, and linked issue. It uses headings different from the template…
Full details: Linked Issues check

Explanation

The PR implements the requested #260 code paths. storeRelative and ompSessionPath use platform-native containment. gjcPidUnderShell searches Windows shell descendants, and screen matching plus per-pane binding supports transcript lookup. Unit tests cover Windows path, process-tree, binding, and cache cases. However, the reviewed evidence does not establish the result on a real Windows PC. The PR did not test the conversation route there, and the reported omp path format and gjc cwd/header match remain unverified.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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

…ts answers are off screen

On a Windows PC the text on screen is the only evidence of a pane's session, and a long list or tool output pushes every answer's tail off it: on a real PC the chat fell back for the whole of such an answer, and each poll started a PowerShell process-table query (about 0.8 s).

The session the screen once showed is now kept per pane while the same gjc process runs under the pane's shell; the screen still wins when it shows another session, and a pane is never bound without it. The process table is read at most once in 5 s and shared by the polls in between.
@devswha
devswha marked this pull request as ready for review October 1, 2026 12:25
@devswha
devswha merged commit 87ba715 into main Oct 1, 2026
10 of 11 checks passed
@devswha
devswha deleted the fix/windows-gjc-omp-transcripts branch October 1, 2026 12:52
devswha added a commit that referenced this pull request Oct 1, 2026
Release v0.3.40: moves the Unreleased notes under 0.3.40 and bumps
`package.json` and `herdr-plugin.toml`.

What's in it:
- Fixes from #249, #251, #252, #263, #264, #265, #267.
- The iPhone CJK and text-symbol fix (#272).
- Emoji cell widths matching herdr (#273).

Every changelog entry already ends with its PR link. All these PRs are
by @devswha, so no credits to add.

No remote bundle change: `REMOTE_BUNDLE_VERSION` stays 9. The Windows PC
part of #264 and #265 reaches a PC with the next remote bundle, as its
changelog entry says.
devswha added a commit that referenced this pull request Oct 1, 2026
Fixes #256.

Raises `REMOTE_BUNDLE_VERSION` from 9 to 10, so that remote PCs (Windows
PCs included) get the bridge-side fixes merged since `remote-v9`: #235,
#243, #249, #251, #264, #265, #267, #278, #281 and the rest of `git log
remote-v9..main -- server shared`.

`server/machines.test.ts` named the `remote-v9` directory literally and
failed on the new number; it now reads the constant.

## Order, from docs/remote-pcs.md
1. Merge this.
2. Push the `remote-v10` tag on `main`: the Remote PC bundles workflow
builds, smoke-tests and publishes the five archives and `manifest.json`.
3. Only then release the app: an app that carries the new number finds
no `remote-v10` manifest before step 2, and every connected PC's bridge
counts as incompatible until it is updated.

## Checked
`bun run typecheck`, `bun run test:unit` (734 pass). The bundle build
and smoke run in this PR's Remote PC bundles checks.
devswha added a commit that referenced this pull request Oct 1, 2026
…r /new or /resume (#285)

Fixes #270.

## What was wrong
On a Windows PC the chat finds a Gajae Code pane's session by an answer
it can see on the screen, and keeps it for the pane while the same gjc
process runs there (#264). Two cases kept the old conversation, both
measured on a real PC (Windows 11, herdr 0.9.3, gjc 0.16.4) with a
bundle built from `main`:

- `/new`, then a one-word answer: the chat API kept answering the
previous session's turns. A short answer never anchors, so nothing
replaced the kept binding.
- A later gjc in the pane that Windows gives the same process number
would inherit the old session.

A process query that timed out also read as "no gjc" and dropped a
correct binding.

## What changes
- gjc prints its own line when it switches session: `✔ New session
started` after `/new`, `Resumed session` after `/resume`. A new such
line on screen ends the kept binding; the chat then shows nothing until
an answer of the new session binds it, rather than the wrong
conversation.
- A process is its number and its start time (`CreationDate` in the
process table), so a reused number is another process.
- A process table that could not be read leaves the binding as it was.

## Checked on the Windows PC (bundle from this branch, its own herdr
session beside the default bridge)
| Step | Chat API (`/api/pane/conversation`) |
|---|---|
| a long answer | the session (`gjc-transcript`) |
| `/new` | `scrollback`, no turns (before: the previous session) |
| a one-word answer | `scrollback`, no turns (before: the previous
session) |
| `/resume` back to the first session | that session again |

The process table script was run on the PC and returns the start time
for gjc. The bridge, its herdr session, the work folder and gjc's
session files were removed afterwards.

## Tests
`bun run typecheck`, `bun run test:unit`; `server/gjc-runtime.test.ts`
and `server/shell-agent.test.ts` cover the switch line, a reused number,
an unreadable table and the start time in the table.

## Not covered
A new session whose answers are all short stays without a chat until one
answer is long enough; that is the same rule as before this change, now
without showing the wrong conversation meanwhile.
devswha added a commit that referenced this pull request Oct 2, 2026
…nd when the Windows-only paths break (#293)

## Change

Closes #271. Tests and CI only; nothing shipped changes.

Three fixes were proven only by a one-off run on a real machine, and
removing them kept every check green. Each now has a check that fails
without it:

| Fix | Check | Fails without the fix? |
|---|---|---|
| #265: the PTY sidecar's Node is looked up on the PATH the spawn
inherits | `scripts/remote-bundle-smoke.ts` runs the bundle with every
PATH entry that holds a `node` left out, and asserts `terminal_attach:
true` | Yes: with a bare `Bun.which("node")` the smoke fails on that
assertion (run locally) |
| the same, end to end | the smoke now opens a live terminal: herdr's
own attach on Linux and macOS (no `pane-geometry` with `fixed: true`), a
mirror on Windows, and typing whose output comes back either way | - |
| #265, over SSH | `scripts/ssh-integration.ts` asserts the remote
terminal is attached, not mirrored (it accepted any `pty-data`, which a
mirror also sends) | - |
| #267, #269: a pasted block is shaped for an agent on a mirrored pane,
on the `input` frame and from the input line |
`server/submit.contract.test.ts`: `cat -v` on a mirrored pane shows
`^[[200~…^[[201~` once herdr names an agent there, and bare lines before
| Yes: with the `mirrorInput` call of the `input` path removed the test
fails (run locally) |
| #264: the Windows process table and the store-containment check with
native paths | `server/windows-native.test.ts`, run on the Windows
runner of the remote-bundle workflow: this PC's own process table (this
process, its parent, its start time) and a session store on a real
Windows file system | runs on Windows only; skipped elsewhere |

The smoke sets `SHELL=/bin/sh` for the pane: a login shell with an empty
HOME can stop to ask how to be set up (zsh did here).

Not covered: a Node older than 18 first on PATH still counts as a usable
sidecar (noted in the issue as related).

## Validation

- Local: the smoke on Linux (attach, no Node on PATH), both mutations
above, the contract test, `bun run typecheck`.
- CI: this PR runs the remote-bundle workflow (Linux, macOS, Windows
runners) and the integration job.
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.

Windows: gjc and omp panes get no chat transcript; the lookups rely on /proc and '/' separators

1 participant