Skip to content

fix(session-history): show native Pi labels in Earlier sessions - #2377

Merged
devswha merged 15 commits into
devswha:mainfrom
IdrisGit:fix/pi-session-labels
Oct 29, 2026
Merged

devswha merged 15 commits into
devswha:mainfrom
IdrisGit:fix/pi-session-labels

Conversation

@IdrisGit

Copy link
Copy Markdown
Contributor

Issue

Ovis opens Earlier sessions when /resume is used from Chat, but its Pi reader only inspected the first 64 KiB of each transcript.

Pi appends session names as metadata, so a name can appear much later in the file. The first user message can also fall beyond that limit when large system prompts or extension records come first. Ovis therefore missed readable labels and fell back to session IDs, even when Pi’s native picker displayed the sessions correctly.

Reading more history also needs to remain practical for folders containing many long conversations, without blocking the server or retaining entire transcripts.

What changed

Pi now uses a dedicated asynchronous streaming metadata reader instead of the head-only path.

The reader follows Pi’s native naming rules:

  • Use the latest trimmed session_info.name.
  • Treat an empty name as clearing an earlier name.
  • Otherwise, use the first user message containing usable text.
  • Join Pi text blocks with spaces, ignoring image blocks and unrelated extension titles.

Every listing reads metadata fresh. There is no result cache, shared in-flight answer, or retained scan progress, so reopening the list sees later renames and cleared names.

How it stays bounded and safe

  • Reads in 64 KiB chunks and retains only bounded header and label metadata—not whole records or conversations.
  • Validates ordinary string spans in bulk, reducing the per-character overhead of large system, extension, image, and tool-output payloads.
  • Limits concurrent readers and waiting work, with an independent two-second metadata deadline per listing.
  • Returns an explicit retryable error when a scan cannot complete, rather than presenting incomplete labels as successful results.
  • Preserves checked-descriptor reads, canonical path containment, file-identity checks, permission guards, and safe cleanup after cancellation.
  • Rejects oversized cwd/ID metadata rather than using truncated values as session identities.

Other providers keep their existing head-bounded readers, and the successful row format and resume commands remain unchanged.

Read Pi metadata afresh in bounded asynchronous chunks so late names
and first prompts remain visible. Preserve explicit name clears,
checked-descriptor safeguards, independent deadlines and shutdown
cleanup without retaining a metadata cache.

Add unit regressions for malformed and oversized records, EOF decoding,
file changes, bounded readers, cancellation and failure-safe test cleanup.
Exercise late names, first-prompt fallback, renames and explicit clears
through the history endpoint and rendered session list. Cover the busy
error envelope and settle initial menu focus before keyboard navigation.
Describe native naming semantics, fresh scans, resource limits and
retry behavior. Add the user-visible session-label fix fragment.
Propagate the task-owned cancellation and deadline guard through the
production open and identity-stat boundaries. Close late descriptors
without issuing another filesystem operation, and report late opener
errors as busy rather than silently omitting a session.

Exercise the actual filesystem callbacks under shutdown and expiry,
including an opener error delivered after its deadline.
Guard environment mutation and all fallible fixture setup. Keep server
stop, environment restoration, workspace closure and directory removal
independent so one cleanup failure does not skip the remaining steps.

Inject workspace creation, server creation, server stop and workspace
close failures against the isolated test session and verify cleanup.
Update the original investigation with the approved uncached design,
resolved review findings, resource tradeoffs and verification evidence.
Add a root-level handoff for the next agent to receive the user's new
manual-testing findings before making further changes.

Record local-only commit state and the unrelated fast-check failure
without claiming that the pending testing findings are resolved.
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: devswha/ovis
  • Branch: main
  • File: .coderabbit.yaml
  • Commit: c5851e7
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9789e6de-7107-457d-bfc9-847f3a8ac2de

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: devswha/ovis
  • Branch: main
  • File: .coderabbit.yaml
  • Commit: c5851e7
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 20df7dee-e1b1-468d-a359-8a30a109ae11
Commits

Reviewing files that changed from the base of the PR and between c5851e7 and 21c533e.

Files selected for processing: 13
  • changelog.d/pi-session-labels.md
  • docs/development.md
  • scripts/session-history-browser-qa.ts
  • server/api.contract.test.ts
  • server/index.ts
  • server/pi-session-label.ts
  • server/pi-session-metadata.test.ts
  • server/pi-session-metadata.ts
  • server/session-history-routes.ts
  • server/session-history.test.ts
  • server/session-history.ts
  • shared/session-history.ts
  • src/lib/api.ts

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

📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • Pi’s Earlier sessions list now shows session names and first prompts, including details recorded deep in long transcripts.
    • Session names update when renamed and revert to the first prompt when cleared.
    • When session history can’t be read completely, the app reports that it’s temporarily unavailable instead of showing an incomplete list.
  • Documentation
    • Added guidance on Pi session labels and history availability.

Pi session history now reads transcript metadata to show the latest session name or first user message. Bounded asynchronous scans reject incomplete results with a retryable 503 response. Server lifecycle handling, tests, browser QA, and documentation cover the updated path.

Changes: Pi session history

Layer / File(s) Summary
Parse Pi session labels
server/pi-session-label.ts, server/pi-session-metadata.test.ts
A streaming parser extracts session headers, the latest name, and the first user message. It bounds retained data and handles malformed records, UTF-8, and chunk boundaries.
Read and filter Pi session files
server/pi-session-metadata.ts, server/session-history.ts, server/session-history.test.ts, server/pi-session-metadata.test.ts
Pi listings use asynchronous descriptor-based reads with reader and queue limits, deadlines, and file-change checks. Listing filters, sorting, and row limits are covered by tests.
Handle busy scans and server lifecycle
server/session-history-routes.ts, server/index.ts, server/api.contract.test.ts, server/pi-session-metadata.test.ts
The route returns a no-store 503 with Retry-After: 1 when a Pi scan is busy or incomplete. The server creates and closes the reader. Contract and integration tests cover fresh labels, large stores, responsiveness, and cleanup.
Verify and document Pi history behavior
scripts/session-history-browser-qa.ts, docs/development.md, shared/session-history.ts, src/lib/api.ts, changelog.d/pi-session-labels.md
Browser QA checks busy responses and fresh label updates. Documentation and the changelog describe label selection, scan limits, and error behavior.

Priority: Pending latest changes

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Bug fix

Possibly related PRs

  • devswha/ovis#869: Both changes address fixed-size limits that affect Pi transcripts. This PR streams session metadata; #869 changes conversation paging.

Suggested reviewers: devswha

Merge Risk: Minimal · previous review 21c53

Pi's Earlier sessions list now shows native names and first prompts, and it returns a retryable 503 instead of incomplete labels when a scan cannot finish. No concrete merge-blocking defect was established. Maintainers may want to watch how often very large Pi stores hit the two-second scan deadline after release.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Description check Warning The description clearly explains the problem, behavior, implementation, safety limits, and compatibility impact. However, it does not include the required Validation section with executed checks, skip… Add a ## Validation section. List each check or test command that was run, its result, skipped checks, and the contract-test coverage for the session-history API changes.
Docstring Coverage Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: showing native Pi labels in Earlier sessions.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description clearly explains the problem, behavior, implementation, safety limits, and compatibility impact. However, it does not include the required Validation section with executed checks, skipped checks, results, and HTTP/WS contract-test coverage.

Resolution

Add a ## Validation section. List each check or test command that was run, its result, skipped checks, and the contract-test coverage for the session-history API changes.

Full details: Docstring Coverage

Explanation

Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 9 functions across 11 files. (2 skipped: 2 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • 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 commented Oct 29, 2026

Copy link
Copy Markdown
Owner

Pushed 2b35c58: busy Pi listings now recover automatically with bounded Retry-After retries, then offer Retry instead of a hard error or an empty list. A 256-entry LRU keyed by absolute path and descriptor dev/ino/size/mtime/ctime reuses clipped labels for unchanged files, refreshes appended names/clears/prompts, and drops deleted entries. The development guide now describes the cache and the same-tick rewrite limitation.

Synthetic 50-session, 200 MiB store on this shared host (listing / maximum event-loop lag):

  • Main 4fbc3e4: 42.1 ms / 42.5 ms.
  • PR first open: 1348.7 ms / 6.3 ms.
  • PR repeat open: 7.6 ms / 1.8 ms, zero transcript reads.

Validation: 144 targeted tests passed; the session-history browser QA passed automatic recovery, persistent busy + Retry, and existing scenarios (390/1440, light/dark captures inspected); bun run check fast passed (8,711 unit tests passed, 0 failed, 35 skipped).

(merge-pass review: a busy listing should recover like file_busy, not show an error)

@devswha

devswha commented Oct 29, 2026

Copy link
Copy Markdown
Owner

Merging 2b35c58, thank you @IdrisGit! Pi's Earlier sessions only read the first 64 KiB of each transcript, so names set later and first prompts after a long system prompt fell back to session ids. A new async streaming metadata reader now follows Pi's own rules (latest trimmed session_info.name, an empty one clears it, else the first user text blocks joined by spaces) with a bounded JSON projection, at most two readers and 32 waiting, a 2 s deadline per listing, and a 503 session_history_busy refusal (Retry-After: 1, no-store) instead of incomplete rows. Two changes by the merge pass on the branch (2b35c58): Earlier sessions now recovers from session_history_busy by itself (five bounded retries honouring Retry-After, a loading state meanwhile, a Retry button only once they run out, never an error or an empty list), and a 256-entry label cache keyed by path, device, inode, size and mtime/ctime means an unchanged transcript is never read twice (a rename, clear or new prompt changes the key; deleted files drop out; only clipped labels are kept). Measured on a synthetic 50-session, 200 MiB Pi store (listing time / max event-loop lag): main 42.1 ms / 42.5 ms with the late labels missing; this PR first open 1348.7 ms / 6.3 ms, repeat open 7.6 ms / 1.8 ms with zero transcript reads. Strict review: path and descriptor safety, bounded parser, FIFO admission, deadlines, shutdown and fd cleanup clean; delta re-review PASS.

@devswha
devswha merged commit 1db9c72 into devswha:main Oct 29, 2026
19 checks passed
devswha added a commit that referenced this pull request Oct 29, 2026
…2391)

## What

The sidebar footer no longer shows **Install app** or the help line it
opened. **Settings → Phone & devices → Install** stays as it was: an
**Install app** button while the browser holds an install prompt, the
browser's install steps otherwise, and **Installed** once the app is
installed. `src/lib/install.ts` is unchanged.

## Why

Users kept seeing Install app after installing. A page can only tell it
is installed from inside the app's own window (or, in Chromium 140+,
through `getInstalledRelatedApps()`), so every browser tab of an
installed app, and every browser that never prompts (Safari, Firefox),
kept showing the row. The owner chose to remove it from the sidebar and
keep installing in Settings. No issue was filed; this is the owner's
decision relayed through Dori.

Design: like the Claude web app, which offers its apps from the account
menu rather than a sidebar row. DESIGN.md's sidebar footer entry says
so.

## Changes

- `src/components/MachineSidebar.tsx`: the button, its help state and
the `useInstallPrompt`/`Download` imports are removed. `Sidebar.css`:
`.sidebar-install-help` is removed.
- The "Install app" translations move from the base dictionaries to
`src/lib/i18n/settings.{ko,ja,zh}.ts`, since Settings is now their only
user (the i18n part test requires this).
- `scripts/install-state-demo-regression.ts` (CI browser lane) is
rewritten. Through a real CDP `PWA.install`/`launch`/`uninstall`, it
checks that no sidebar Install app appears at any step. It also checks
Settings → Install: the exact Chromium steps without a prompt, a button
that calls `prompt()` once when a prompt is held, Installed in the app
window and in a tab of the same origin, and the steps again after
uninstall.
- DESIGN.md, docs/guide.md (two passages that pointed at Install) and
docs/development.md are updated, plus a changelog fragment.

## Validation

- Fail first: the rewritten regression fails on the unchanged sidebar
(`the sidebar offers no Install app: 1 !== 0`), then passes every step
(a, a2, b, c, d, cleanup) on the head.
- `bun test src/lib/i18n.test.ts src/lib/install.test.ts`: 43 pass.
- `bun run check fast`: green on fe50407 and again on 99d4d22 (unit
8680 pass, 0 fail; typecheck, build, generated files ok).
- CI's first Fast checks run (on fe50407 merged with main) failed only
in `server/pi-session-metadata.test.ts` "lists the newest 50 long
sessions within the deadline" (6.6 s), a test #2377 added to main after
this branch was cut. This PR touches no server code, and the test passed
3 out of 3 times locally on the same merge. 99d4d22 (a docs fix for
CodeRabbit's comment) starts a fresh run.
- Screenshots of the sidebar footer before and after, at 1280 and 390,
dark and light, were taken from the demo build (not attached here).
- Reviews: omo-native-code-reviewer and Codex Sol 6.1 Fast (xhigh).
Round 1 found a HIGH/MEDIUM (the i18n key ownership above) and a MEDIUM
on the regression's assertions; both are fixed, and round 2 PASSes from
both.

## Known LOW (not fixed)

- The regression copies Chromium's install-steps text from
`installHelp()`. Rewording it in `install.ts` fails the browser test
loudly until the copy is updated.
- The sidebar check matches any button named `/install/i` inside
`.sidebar-shell`. A future sidebar control with "install" in its name
would trip it, again loudly.
devswha added a commit that referenced this pull request Oct 29, 2026
…s instead of racing 2 s (#2402)

Found by the flake-hunt lane, with a Dori pin. The Pi listing tests
added by #2377 raced the two-second production deadline on busy runners:
- **`server/pi-session-metadata.test.ts`** "lists the newest 50 long
sessions within the deadline and reads zero bytes on repeat":
- #2391's Fast checks (run 40955829630): 6.6 s, "Pi sessions could not
be read right now".
  - #2397's Fast checks (run 40960224000): 8.96 s.
  - Both passed on rerun.
- **`server/api.contract.test.ts`** "lists a 202-session Pi store with
50 long transcripts through the real API without timing out": #2395's
Integration run (job 123744721790), a 503 for the same reason.

## Cause (test flake)

Both tests list about 200 MiB of Pi transcripts and check what is
listed:
- the newest 50 rows, with their titles and first prompts;
- zero bytes read on a repeat listing;
- chunk-sized reads, and an empty queue;
- a later rename (API test).

They did this under the listing's real deadline, `PI_READ_DEADLINE_MS`
(2 s of wall clock, queue time included). On a loaded runner, reading
200 MiB takes longer than that.

## Change

The deadline is injected rather than raced:

- **Reader:** `PiSessionReader` takes an optional `deadlineMs` beside
its existing `read` test seam and exposes it as `listingDeadlineMs`.
`piSessions` uses that for the listing's deadline. Unset, it is still
`PI_READ_DEADLINE_MS`.
- **Server:** `createServer` gets a test option, `piSessionDeadlineMs`,
passed to its reader. It is next to the other `*Ms` test options, such
as `attachHoldMs`.
- **The two tests:** each passes 120 s, past its own timeout. The unit
test's timeout is 30 s; the API case's goes from 20 s to 60 s. The "zero
bytes on repeat" and chunk assertions stay.
- **Docs and changelog:** `docs/development.md` and the changelog
fragment say this.

The shared two-second deadline is still covered, with a fake clock:
aggregate expiry, independent deadlines, queued expiry and FIFO
admission, in `pi-session-metadata.test.ts:484-505`, `:585` and `:627`.
Those tests also assert that the default is `PI_READ_DEADLINE_MS`. The
API's 503 shape is still checked by its own case.

## Proof

- **Fail-first (unit test):** with every 64 KiB read delayed 1 ms
(scratch), the old test failed 2/2 with the CI error ("could not be read
right now"), and the new one passed 3/3.
- **Wiring (API test):** with `piSessionDeadlineMs: 1` (scratch), the
API case fails with CI's 503, so the option reaches the listing.
- **Runs:** the API case passed 3/3 (`bun run check run bun test
./server/api.contract.test.ts -t lists.a.202-session`). The unit file
passed 5/5, then 39/39 again after the wording edits.
- **Local checks:** `bun run check fast` ok.

## Reviews

The PR changes product code (the reader and server test seams, with no
production behaviour change), so both reviewers ran.
- **omo-native-code-reviewer:** APPROVE (CLEAR) on both rounds. It
confirmed that no production caller sets the option:
`server/index.ts:738`, `server/remote-entry.ts:88`, the default reader,
and the QA script.
- LOWs fixed: the test name had claimed the shared-budget proof, and the
comment said "a bound no slow runner reaches". Both now describe what
the test checks.
- LOW, follow-up only: the neighbouring API case "streams ..." reads
about 17 MiB under the real 2 s deadline. That is about 0.7 s at CI's
worst rate, and it has never failed. If it ever does, it can pass the
same option.
- LOW, style: the docs paragraph's wording, and the fixture helper's
argument order.
- **Codex Sol 6.1 Fast xhigh:** APPROVE on both rounds.
- Round 1's LOW: the docs still said "under the ordinary deadline".
Fixed.
  - Round 2: no findings.
devswha added a commit that referenced this pull request Oct 30, 2026
…ans hit the deadline (#2410)

Found by the flake-hunt lane while it fixed the #2377 timing flakes
(#2402); Dori decided to fix it in its own PR. On a slow PC, **Earlier
sessions** for Pi could become an error that never cleared.

## The bug (MEDIUM, user-visible)

@IdrisGit's streaming reader (#2377) reads each Pi transcript in full,
so native names and first prompts show even when they sit deep in the
file. A listing has one shared two-second deadline. By design, a scan
that cannot finish returned a retryable error, never incomplete labels:

- **On a deadline:** the API answered 503 `session_history_busy`. The
client retried up to six times, then emptied the list and showed "Pi
sessions could not be read right now. Try again." with a Retry button.
- **Finished files:** their labels were cached, so retries usually got
further.
- **Partial scans:** these were discarded. One transcript whose scan
alone takes more than two seconds on a slow disk never finished, so
Earlier sessions showed the error on every open.

## Why "never incomplete labels" is relaxed

#2377's rule kept a half-read file from showing a wrong label. What it
actually cost was the whole list. This PR keeps the part that matters
and drops the part that hurt:
- A label from a torn or unfinished read is still never shown.
- A session whose label is not known yet is listed with its session ID,
the same fallback a session with no name has always had.
- Its label fills in on a later open, because the scan resumes where it
stopped.

So the list can be incomplete in its labels, but never wrong, and never
empty because one file is slow.

## Design

Credit to @IdrisGit: #2377's bounded streaming reader is kept whole. Its
64 KiB chunks, checked descriptors, stat-keyed cache, EOF validation and
queue limits all stay. This PR changes what a deadline does and adds
resumable progress:

- **Rows before labels:** a header pass establishes the newest rows (up
to 50) before any label budget is spent. Completed cached labels show at
once; unfinished ones use the session-ID fallback. The header pass has
its own 10-second deadline and reads at most one 64 KiB chunk per
candidate per open. If it expires, the rows already checked are kept.
Only when no header at all could be checked does it still return the
retryable 503, rather than a false empty list.
- **Resumable progress:** parser progress for long headers and
transcripts is kept per file, keyed by its stat identity. Any change,
append, truncation, rewrite or replacement discards it. A huge
transcript therefore gets its label after a few opens. Headers from
other folders are refused before caching, so they cannot evict that
progress.
- **No whole-list 503 for one file:** a label-pass error keeps the rows
and withholds only that file's label. The errors are a file changing
mid-scan (a running Pi agent appending), a read failure, and deletion or
replacement. 503 remains only for a full queue and a stopped reader.
- **Windows:** folder eligibility is checked once, in the header pass.
- **Small files** are finished during the header pass, at no extra I/O.

## Proof

- **Fail-first:** the original five deadline regressions failed on
origin/main (0 passed, 5 failed, `PiMetadataBusy`). Each review finding
was reproduced as a test before its fix:

| Case | Before | After |
|---|---:|---:|
| Expiry before any header / older rows hidden (round 1) | failed |
passed |
| Long header, malformed or incomplete preamble | 3 failed | 3 passed |
| Foreign-header cache churn evicting progress | 1 failed | 1 passed |
| Windows identity checked twice | 1 failed | 1 passed |
| Label append, read error, deletion, replacement | 4 failed | 4 passed
|
| Active or queued header past its deadline | 2 failed | 2 passed |
| 257 headers over 64 KiB churning the cache (round 3) | 1 failed | 1
passed |

- **Tests:** the Pi reader suite passed 65, the reader and history
suites together 159, and the isolated history API cases 7. `bun run
check fast` passed (8,810 unit tests).
- **Browser, before and after:** a fictional bridge drove the real
components, with one transcript whose scan exceeds an injected deadline,
at desktop (1440) and phone (390) widths.
- **Before (origin/main):** only "Pi sessions could not be read right
now. Try again." and Retry.
  - **After:** every row, with the slow one shown by its ID.
  - **After a reopen:** every row labelled.

### Browser, before and after (one transcript's scan exceeds an injected
deadline)

| | Desktop (1440) | Phone (390) |
|---|---|---|
| Before (origin/main) | <img
src="https://gist.githubusercontent.com/devswha/da985201e11483e9528eaf74e324799b/raw/b17fc96fae8baf717ddc1358b72c4cd4448a152d/pifix-before-origin-main-error-1440.png"
width="420"> | <img
src="https://gist.githubusercontent.com/devswha/da985201e11483e9528eaf74e324799b/raw/b17fc96fae8baf717ddc1358b72c4cd4448a152d/pifix-before-origin-main-error-390.png"
width="180"> |
| After: every row, the slow one shown by its ID | <img
src="https://gist.githubusercontent.com/devswha/da985201e11483e9528eaf74e324799b/raw/b17fc96fae8baf717ddc1358b72c4cd4448a152d/pifix-after-all-rows-slow-unlabeled-1440.png"
width="420"> | <img
src="https://gist.githubusercontent.com/devswha/da985201e11483e9528eaf74e324799b/raw/b17fc96fae8baf717ddc1358b72c4cd4448a152d/pifix-after-all-rows-slow-unlabeled-390.png"
width="180"> |
| After a reopen: labels filled in | <img
src="https://gist.githubusercontent.com/devswha/da985201e11483e9528eaf74e324799b/raw/b17fc96fae8baf717ddc1358b72c4cd4448a152d/pifix-after-reopen-labels-1440.png"
width="420"> | <img
src="https://gist.githubusercontent.com/devswha/da985201e11483e9528eaf74e324799b/raw/b17fc96fae8baf717ddc1358b72c4cd4448a152d/pifix-after-reopen-labels-390.png"
width="180"> |

Not run locally: the full Integration and native Windows lanes (CI runs
them). The Windows alias case is covered deterministically.

## Reviews

This PR changes server code and the history API's behaviour, so both
reviewers ran, over three rounds.

**omo-native-code-reviewer: APPROVE (WATCH) in round 3.**
- Round 1 BLOCKed on an expiry before any header was checked returning
an empty 200 (HIGH), and on rows older than the expired file being
dropped (MEDIUM). Both were fixed by the header pass.
- Round 2 BLOCKed on non-deadline label-pass errors (an append, a read
failure, a deleted file) still turning the list into a 503. Fixed: those
rows keep null or cached labels.
- Round 3 confirmed every earlier finding fixed, and that the late
safety correction is right: a swapped symlink or a changed identity is
"no row", not an unchecked header. LOWs, kept:
- If every file in a store fails to read, each open answers 503 rather
than a false empty list.
- An append during the one-chunk header read can hide that row for one
open.
- A promise-ordering race in one test is deterministic but
order-sensitive.
- A file whose first line is a multi-MiB malformed record takes several
opens to recover.
- Round 4, the delta that fixes the cache churn: APPROVE (WATCH). LOWs,
kept:
- The 256-entry cache is shared across folders, so three or more
folders, each with 50+ headers over 64 KiB, opened in rotation could
evict each other's progress. Pi does not write headers that large.
- When the unfinished-header cap stops a pass, older complete sessions
are missing from that one response; they fill in on later opens.

**Codex (Sol 6.1 in round 1, Terra 6.1 from round 2, per the owner's
switch).**
- Round 1 reproduced the hidden-older-rows gap. Fixed.
- Round 2 raised three HIGHs and a MEDIUM; each HIGH was reproduced as a
failing test first, then fixed:
  - a long header causing a 503 loop;
  - foreign-header cache churn evicting progress;
  - the Windows identity being checked twice.
- MEDIUM: the header pass had no time bound. It now has a 10 s deadline.
- Round 3 confirmed those fixed and raised three more HIGHs:
- **Cache churn across 257 files that each have a header over 64 KiB (a
permanent 503).** Reproduced (0 passed, 1 failed on 98df12ca) and fixed
in 606cf7b2: each header traversal now stops after 50 unfinished
headers. That is independent of the 50-row limit and well below the
256-entry cache, so one traversal never evicts the newest checkpoints
before the next open advances them. After the fix the test passes (1/1),
the reader suite passes 61, and check fast passes (8,806 unit tests).
- **A header over 64 KiB is missing from the first response.** Kept, on
purpose. Real Pi headers are a few hundred bytes. Such a file is listed
on a later open, and older rows show meanwhile.
- **503 when no header at all could be checked** (for example `EIO` on
the only file). Kept, on purpose. Without one checked header there is no
trustworthy session identity to list. A 200 with no rows would claim "no
earlier sessions", which is the false answer round 1 removed. The 503
makes the client retry.

- Round 4, on the delta, found the same eviction class through
headerless files: empty `.jsonl` files cached as `null` but not counted
toward the cap. Fixed in 5405fbbc: one traversal touches at most 200
files that can take a cache entry, below the 256 slots. A 344-file repro
failed before and passes after.
- Its MEDIUM is kept as a known limit: 50 transcripts that are all being
appended to, each with a header over 64 KiB, ahead of an older session
keep that session out until they settle. Real Pi headers are a few
hundred bytes.
- Round 5, on 5405fbbc: both reviewers found that 200 empty `.jsonl`
files newer than a real session made every listing return an empty
array. Fixed in 90da040d: completed headerless results are not cached
and do not count. The cap is derived from the exported
`PI_CACHE_ENTRIES` (3/4 = 192). A cutoff with no rows gives the
retryable 503, never an empty 200. Repros: 200 and 201 empty files, 0/2
before, 2/2 after. Cache hits still count, because counting only
insertions would let a hit promote an old entry past new checkpoints;
omo agreed.
- Round 6, on 90da040d: omo APPROVE. Terra's last MEDIUM, the same case
as omo's L13: a headerless file over 64 KiB restarted from byte 0 on
every open, delaying older sessions. Fixed in 69415701: a completed
empty result is cached only for files larger than one chunk, keyed by
stat identity, and counts like any cached entry. Terra's 150-file repro
failed before (0/1) and passes after (1/1); later unchanged opens read
zero bytes.

**Follow-up, outside this PR:** Terra noted that origin/main's existing
400-check discovery bound can still produce an empty list, if enough
newer empty files fill the budget before a real session is discovered.
That limit predates this PR.
- Round 7, on 69415701: omo APPROVE (WATCH). Both reviewers named the
same boundary, Terra as a MEDIUM and omo as L14: **192 or more files
over 64 KiB with no session header, newer than every real session in one
folder, keep the list on a retryable 503.** This is shipped as a
documented limit, the same kind as the cache and discovery bounds.
- Any fixed per-open budget can be filled by enough junk files. Each
review round moved this threshold further out, and none removed it.
  - Pi writes no such files.
  - origin/main's existing 400-check discovery bound has the same shape.
- The list never shows a false "no sessions" from this PR's paths; a
cutoff with no rows answers the retryable 503.

## Known limits (documented in docs/development.md)
- Labels for files beyond the per-open budgets fill in over later opens.
- 192 or more headerless files over 64 KiB ahead of every real session
keep a retryable 503, as above.
- 50 transcripts that are all being appended to, each with a header over
64 KiB, delay older sessions until they settle.
- Several folders, each with many oversized headers, opened in rotation
can evict each other's progress (the cache is shared).
@devswha devswha mentioned this pull request Oct 30, 2026
devswha added a commit that referenced this pull request Oct 30, 2026
## Release 0.4.21

The release PR, prepared by step 1 of
[docs/development.md#releasing](https://github.com/devswha/ovis/blob/main/docs/development.md#releasing),
now re-folded on main `1ef6ea329108a0985b823e8235b03daddcd0a5f4` after
the owner held 0.4.21 for more work. The merge pass reported the 0.4.21
queue empty.

**Do not merge yet:** the owner judges the final build before release.
No tag and no Release run from this PR's author.

- **Version:** `version` is 0.4.21 in `package.json` and
`herdr-plugin.toml`.
- **Changelog:** `bun scripts/changelog-fold.ts 0.4.21 2026-10-30`
folded 63 fragments into the 2026-10-30 section of `CHANGELOG.md` (71
entries), linked their PRs and deleted the fragments; `changelog.d`
holds only `README.md`.
- `by @login` on every outside contributor's PR link: #2361 @eddieparc,
#2333 @IdrisGit, #2355 @imurfutur3, #2341 @sulthonzh, #2359 @YuuuXie,
#2377 @IdrisGit, #2269 @CharleoYang, #2405 @jpcarranza94, #2414
@homebodify, #2417 @cheol-95, #2418 @eddieparc, #2435 @cheol-95.
- Two outside PRs had no fragment and got an entry by hand: #2341
(OpenCode background commands, Added) and #2359 (installer test timing,
Maintenance).
- Issue reporters are credited in their entries: @blaker3115-Agri
(#1488), @Hyd3-14 (#2026), @osamahbeig (#2343), @Shunamxiao (#2329),
@matiemer (#2362), @kilhyeonjun (#2344), @eddieparc (#2360), @Ploppy3
(#2236), @sulthonzh (#2340), @WOULDU-pres (#2056), @odfalik (#2038),
@aNNdii (#511), @Noobear (#2281, fixed by #2424); #2435 fixes
@cheol-95's own #2434.
- Two fragments ran past the changelog's width (#2418, #2269); their
entries are re-wrapped, words unchanged. #2382's entry reads "OpenCode's
installer puts its folder first" (reviewed earlier on this PR).
- Maintainer PRs without a fragment and without a user-facing change
have no entry: #2353 (check tool), #2371 (guide docs), #2396 and #2397
(tests), #2403 and #2433 (server and client transport seams, no
behaviour change), #2437 (test-only fix for #2435's check). #2438's own
entry (the sidebar selection marked by its fill again) is dropped: the
stroke #2352 added never shipped, so users see no change; #2352's entry
keeps only the Windows high-contrast Highlight bar.
- **Release summaries:** en, ko, ja and zh each have 5 new, 5 improved
and 5 fixed lines. Since the first review: New lists the in-browser
Claude Code / Codex sign-in (#2428) in place of the tab/workspace
shortcut line; Improved lists Settings → Agents (#2427) in place of the
sidebar fold line; Fixed lists the Codex wrong-session fix (#2426,
#2430) in place of the phone screenshot paste line. The Artifacts and
Claude status-line lines keep their reviewed wording (turned on in
Settings). Not in 0.4.21: #2420 (Codex chat behind Kiro), #2065 (Portal
sign-in) and #2436 (relay foundations) stay open for a later release.
- **Remote bundle:** `REMOTE_BUNDLE_VERSION` rises from 39 to 40 because
the bundle inputs (`server/`, `shared/`, `patches/`) changed since
remote-v39. After merge: push `remote-v40` on the merged commit and wait
for the Remote PC bundles workflow before running Release.
- **iOS:** `CURRENT_PROJECT_VERSION` stays 3 (#2370 changed
`Info.plist`; build 3 is not known to be uploaded yet).

## Validation

- `bun scripts/release-guards.ts --base v0.4.20`: "Release 0.4.21:
remote bundle, telemetry Worker and release metadata are in order."
- `dori heavy … bun run check fast` on this branch: workflow syntax,
generated types and themes, typecheck, build, unit tests all ok. Unit:
9166 pass, 0 fail, 36 skip in 591 files.
- Every PR in `v0.4.20..main` was pre-run for the owner's hands-on guide
on isolated copies (own herdr session, fresh state, never the owner's
live session). Items that need a real device (iPhone tap dictation
#2370, dictation keyboards #2386, the installed desktop app's title-bar
overlay #2381) are left for the owner's final check.

This is a release-metadata PR: it changes no code path. Per the release
steps, merge it after CI and the owner's go, then push `remote-v40`,
wait for its bundles, and run Release with `0.4.21`.
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.

2 participants