Skip to content

fix(desktop): batch pi streaming and reuse transcript derivation - #98932

Merged
trunk-io[bot] merged 6 commits into
masterfrom
codex/desktop-performance-streaming
Sep 12, 2026
Merged

trunk-io[bot] merged 6 commits into
masterfrom
codex/desktop-performance-streaming

Conversation

@charlesvien

@charlesvien charlesvien commented Sep 11, 2026

Copy link
Copy Markdown
Member

Problem

Long Pi chats repeatedly copy and process old messages as text arrives.

Changes

Batch streamed text and reuse completed message processing. Preserve event order and cancel buffered updates on disconnect. Layout unchanged.

Related: #76788 overlaps footer reuse; #92041 covers copy-text caching.

How did you test this code?

The full desktop suite and type checks pass on this PR alone.

Controller, builder, and hook tests cover batching, event order, and corrected messages. Production streaming latency remains unmeasured.

Automatic notifications

  • Publish to changelog?

Docs update

Desktop performance guidance

@charlesvien charlesvien self-assigned this Sep 11, 2026
@github-actions github-actions Bot added the feature/desktop Feature Tag: Desktop label Sep 11, 2026
@github-actions

github-actions Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

React Doctor found 1 issue in 1 file · 1 warning.

1 warning

packages/ui/src/features/sessions/components/chat-thread/ChatThread.tsx

Reviewed by React Doctor for commit 6769a69.

@charlesvien
charlesvien added this pull request to stack #98935 September 11, 2026 03:16
@github-actions

Copy link
Copy Markdown
Contributor

🤖 CI report

Trunk lane — non-backend lane (fe:product:desktop)

This PR is assigned to the non-backend lane (fe:product:desktop). It does not run backend Python tests and may merge in parallel with PRs in other lanes.

@charlesvien
charlesvien removed this pull request from stack #98935 September 11, 2026 03:27
@charlesvien
charlesvien force-pushed the codex/desktop-performance-streaming branch from e07e20c to 78a4127 Compare September 11, 2026 03:28
@charlesvien
charlesvien changed the base branch from codex/desktop-performance-pi-residency to codex/desktop-performance-subscriptions September 11, 2026 03:28
@charlesvien
charlesvien added this pull request to stack #98938 September 11, 2026 03:28
@charlesvien charlesvien added the reviewhog ($$$) Reviews pull requests before humans do label Sep 11, 2026
@posthog

posthog Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

🦔 PostHog Review reviewed this pull request

Found 0 must fix, 0 should fix, 4 consider.

Published 4 findings (view the review).

@charlesvien

Copy link
Copy Markdown
Member Author

@greptileai review this draft

@charlesvien
charlesvien marked this pull request as ready for review September 11, 2026 03:44
@pr-assigner-resolver-posthog
pr-assigner-resolver-posthog Bot requested a review from a team September 11, 2026 03:44
@greptile-apps

greptile-apps Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor
Prompt To Fix All With AI
### Issue 1
products/desktop/packages/ui/src/features/sessions/components/incrementalConversationItems.ts:63
**Missing explicit return type**

The new exported `createIncrementalAgentConversationBuilder` function relies on an inferred, nontrivial return type. This violates the repository directive that TypeScript functions use explicit return types. Please declare the builder contract before merging so this public API remains clear and stable.

```suggestion
export function createIncrementalAgentConversationBuilder(): ReturnType<
  typeof createIncrementalConversationBuilder
> {
```

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "fix(desktop): batch pi streaming and reu..." | Re-trigger Greptile

@posthog

posthog Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

PostHog Review alpha 🦔 If you find any issues helpful - please reply "valid", "invalid", etc., for evaluation purposes 🙏

@posthog posthog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PostHog Review

Found 4 consider.

Comment thread products/desktop/packages/core/src/pi-runtime/piSessionController.ts Outdated
@posthog posthog Bot removed the reviewhog ($$$) Reviews pull requests before humans do label Sep 11, 2026
@charlesvien charlesvien added the stamphog Request AI approval (no full review) label Sep 11, 2026

@stamphog stamphog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


@stamphog stamphog Bot removed the stamphog Request AI approval (no full review) label Sep 11, 2026
@charlesvien
charlesvien force-pushed the codex/desktop-performance-streaming branch from f79f388 to ea31a46 Compare September 11, 2026 06:06
@charlesvien
charlesvien force-pushed the codex/desktop-performance-subscriptions branch from 4256b22 to 4806be4 Compare September 11, 2026 06:06
@charlesvien charlesvien added the stamphog Request AI approval (no full review) label Sep 11, 2026
stamphog[bot]
stamphog Bot previously approved these changes Sep 11, 2026

@stamphog stamphog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved.

Internal performance refactor to the desktop app's Pi chat streaming/transcript-derivation logic — not risky territory (no auth, billing, data model, public API, or CI surface). Author is on the owning team with STRONG familiarity (76% of touched lines, 10/12 files previously modified, 28 merged PRs in these paths), the change ships with extensive new tests covering the batching, cancellation, and reconnect edge cases it introduces, and the only bot review turned up non-blocking "consider" items with a positive reaction, no unresolved substantive concerns.

  • Author wrote 76% of the modified lines and has 28 merged PRs in these paths (familiarity STRONG).
  • 👍 on the PR from greptile-apps[bot].
  • 12 of the 12 changed files are governed by products/desktop/AGENT_APPROVALS.md.
Gate mechanics and policy version
Gate Result
prerequisites all clear
deny-list no deny categories matched
size 352L, 8F substantive, 672L/12F incl. docs/generated/snapshots — within ceiling
tier T1-agent / T1d-complex (672L, 12F, single-area, fix)
stamphog 2.0.0b4 .stamphog/policy.yml @ ea31a46 · reviewed head ea31a46

@charlesvien
charlesvien force-pushed the codex/desktop-performance-subscriptions branch from 4806be4 to 946640b Compare September 11, 2026 15:54
@charlesvien
charlesvien force-pushed the codex/desktop-performance-streaming branch from ea31a46 to 476ed1c Compare September 11, 2026 15:54
@charlesvien
charlesvien removed this pull request from stack #98938 September 11, 2026 18:14
@charlesvien
charlesvien added this pull request to stack #99466 September 11, 2026 18:16
@charlesvien
charlesvien force-pushed the codex/desktop-performance-subscriptions branch from 946640b to 3d4ae4b Compare September 11, 2026 19:35
@charlesvien
charlesvien force-pushed the codex/desktop-performance-streaming branch from 476ed1c to 1344966 Compare September 11, 2026 19:35
@charlesvien
charlesvien removed this pull request from stack #99466 September 11, 2026 22:55
charlesvien and others added 5 commits September 11, 2026 16:00
Both factories returned an inferred shape. Naming the interface gives the
exported API an explicit return type.

Generated-By: PostHog Desktop
Task-Id: 3c052294-7a72-4a70-8963-8dd85db130bb
A source id only reaches session.events at flush, so batching text chunks
opened a window where a redelivered chunk passed the dedup guard and ran
applyTurnEvent again. If an abort landed between the two deliveries, that
second pass overwrote the cancelled stop reason and re-set isStreaming, so a
cancelled turn could notify as a normal completion.

Track the source ids already buffered in the pending batch and reject a
redelivery before it mutates turn state.

Generated-By: PostHog Desktop
Task-Id: 3c052294-7a72-4a70-8963-8dd85db130bb
@charlesvien
charlesvien force-pushed the codex/desktop-performance-subscriptions branch from 3d4ae4b to 78e26fd Compare September 11, 2026 23:18
@charlesvien
charlesvien force-pushed the codex/desktop-performance-streaming branch from 1344966 to 628c927 Compare September 11, 2026 23:19
@charlesvien
charlesvien changed the base branch from codex/desktop-performance-subscriptions to master September 11, 2026 23:19
@stamphog
stamphog Bot dismissed their stale review September 11, 2026 23:19

The PR was retargeted to a different base branch, so the approved diff is no longer what was reviewed. Stamphog re-reviews automatically.

@trunk-io

trunk-io Bot commented Sep 11, 2026

Copy link
Copy Markdown

😎 Merged successfully - details.

@stamphog stamphog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved.

Contained desktop streaming/UI change with no touch on auth, billing, migrations, public APIs, CI, or dependencies; author is on the owning team with STRONG familiarity (79% of touched lines, 29 merged PRs in these paths, last touch today), and the change ships substantial new tests covering batching, ordering, and cancellation. The only bot review comment is a minor style "consider" item, not a blocking concern.

  • Author wrote 79% of the modified lines and has 29 merged PRs in these paths (familiarity STRONG).
  • 👍 on the PR from greptile-apps[bot].
  • 12 of the 12 changed files are governed by products/desktop/AGENT_APPROVALS.md.
Gate mechanics and policy version
Gate Result
prerequisites all clear
deny-list no deny categories matched
size 339L, 8F substantive, 658L/12F incl. docs/generated/snapshots — within ceiling
tier T1-agent / T1d-complex (658L, 12F, single-area, fix)
stamphog 2.0.0b4 .stamphog/policy.yml @ 628c927 · reviewed head 628c927

@hosthog

hosthog Bot commented Sep 11, 2026

Copy link
Copy Markdown

HostHog preview — posthog-desktop-web

The previews for this PR have been torn down and no longer serve.

Generated-By: PostHog Desktop
Task-Id: 3c052294-7a72-4a70-8963-8dd85db130bb
@trunk-io
trunk-io Bot merged commit b58061a into master Sep 12, 2026
198 checks passed
@trunk-io
trunk-io Bot deleted the codex/desktop-performance-streaming branch September 12, 2026 03:49
@deployment-status-posthog

deployment-status-posthog Bot commented Sep 12, 2026

Copy link
Copy Markdown

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-09-12 04:13 UTC Run
prod-us ✅ Deployed 2026-09-12 04:23 UTC Run
prod-eu ✅ Deployed 2026-09-12 04:26 UTC Run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature/desktop Feature Tag: Desktop stamphog Request AI approval (no full review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant