Skip to content

fix(web): optimize pending send pruning for YEF-899#392

Open
Yevanchen wants to merge 1 commit into
mainfrom
fix/performance-complexity-hotspots
Open

fix(web): optimize pending send pruning for YEF-899#392
Yevanchen wants to merge 1 commit into
mainfrom
fix/performance-complexity-hotspots

Conversation

@Yevanchen

Copy link
Copy Markdown
Collaborator

Summary

  • Optimized pending-send pruning by indexing user message ids by trimmed content before reconciling optimistic sends.
  • Added coverage for the case where matching text includes both a baseline message and a new server echo.

Why

  • Long agent sessions can accumulate many messages; the old pruning path scanned every message for every pending send and did a linear baseline-id check inside that scan.
  • The new path changes reconciliation from roughly O(pending * messages * baseline ids) to O(messages + pending * (baseline ids + matching messages)) while preserving trimmed-content and non-baseline-id semantics.
  • Closes YEF-899

Verification

  • Commands:
    • just test-file apps/web/tests/agent-session-pending-sends.test.ts
    • just tc-package @mosoo/web
    • just fmt-check-path apps/web/src/routes/agent/components/agent-session-pending-sends.ts
    • just fmt-check-path apps/web/tests/agent-session-pending-sends.test.ts
    • just test-package @mosoo/web
    • just check
  • Manual steps: N/A
  • Not run: N/A

Impact

  • User/API/contract changes: No API or contract changes; optimistic send cleanup is faster for long sessions.
  • Generated files / GraphQL / DB / lockfile: None.
  • Env or config changes: None.
  • Risk and rollback: Low; rollback is reverting the model and test commit.

Review

  • Closest review areas: pending-send reconciliation in agent-session-pending-sends.ts.
  • Known trade-offs: Each prune sweep now builds a linear message index, replacing repeated full-message scans.

@Yevanchen Yevanchen changed the title fix(web): optimize pending send pruning fix(web): optimize pending send pruning for YEF-899 Jul 24, 2026
@Yevanchen
Yevanchen force-pushed the fix/performance-complexity-hotspots branch from 1e715d9 to 5c94320 Compare July 24, 2026 16:17
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