Repository navigation
Conversation
(cherry picked from commit 5360330805bd26bb0415f094650e9b329f5e0a6d)
- await async webchat audio block construction before transcript append - allow transcript-local audio files as embedding roots for agent replies - await the audio transcript append from the reply dispatcher - keeps the managed-image test slice green
Greptile SummaryThis PR fixes two related persistence bugs: (1) agent-run webchat completions could skip the transcript-append fallback used by the non-agent path, so media replies were delivered live but not durably recorded; (2) managed-image records lacked a Confidence Score: 5/5Safe to merge; remaining findings are style/minor-robustness P2 items that do not block correctness. All P0/P1 paths are covered: transcript append idempotency is enforced, auth gate remains strict, and the new audio path has test coverage. The two inline comments are P2 style observations (forward variable reference, incomplete regex) that do not affect runtime behavior for current call sites. src/gateway/server-methods/chat.ts — the
|
| if (/\/api\/chat\/media\/outgoing\/.+\/(download|open)$/.test(pathname)) { | ||
| return true; | ||
| } |
There was a problem hiding this comment.
isImageOnlyUrlToken regex misses /full variant
The pattern /\/api\/chat\/media\/outgoing\/.+\/(download|open)$/ matches the /download and /open route variants but not /full, which is the only variant actually generated by buildOutgoingVariantUrl. In practice this is benign because managed image URLs appear in the imageUrls Set (populated from extractImages content blocks) and are matched by imageUrls.has(normalized) before the regex path is reached. But if a URL ever appears in markdown text outside a content block, the regex wouldn't suppress it.
| if (/\/api\/chat\/media\/outgoing\/.+\/(download|open)$/.test(pathname)) { | |
| return true; | |
| } | |
| if (/\/api\/chat\/media\/outgoing\/.+\/(download|open|full)$/.test(pathname)) { |
Prompt To Fix With AI
This is a comment left during a code review.
Path: ui/src/ui/chat/grouped-render.ts
Line: 97-99
Comment:
**`isImageOnlyUrlToken` regex misses `/full` variant**
The pattern `/\/api\/chat\/media\/outgoing\/.+\/(download|open)$/` matches the `/download` and `/open` route variants but not `/full`, which is the only variant actually generated by `buildOutgoingVariantUrl`. In practice this is benign because managed image URLs appear in the `imageUrls` Set (populated from `extractImages` content blocks) and are matched by `imageUrls.has(normalized)` before the regex path is reached. But if a URL ever appears in markdown text outside a content block, the regex wouldn't suppress it.
```suggestion
if (/\/api\/chat\/media\/outgoing\/.+\/(download|open|full)$/.test(pathname)) {
```
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 76e5fe0e8b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if (sessionKeyFilter && record.sessionKey !== sessionKeyFilter) { | ||
| retainedCount += 1; | ||
| continue; |
There was a problem hiding this comment.
Preserve non-target files in session-scoped cleanup
When sessionKey is provided, records from other sessions are skipped here, but their original.path/thumbnail.path are never added to referencedPaths. The later orphan-file sweep still runs globally and can delete those skipped sessions’ media files, so a chat.history call for one session can silently break managed images in other active sessions while leaving their JSON records behind.
Useful? React with 👍 / 👎.
| if (normalized.length === 0) { | ||
| return rawTextPayloadCount > 0 ? [{ type: "text", text: "" }] : undefined; | ||
| } |
There was a problem hiding this comment.
Avoid emitting empty assistant blocks for suppressed replies
This branch fabricates [{ type: "text", text: "" }] whenever raw text existed but normalization removed every payload (for example NO_REPLY or directive-only replies). That causes chat.send to append blank assistant entries to transcript/history instead of suppressing the turn, creating invisible-but-persistent messages that can affect ordering and downstream history consumers.
Useful? React with 👍 / 👎.
| const blobUrl = URL.createObjectURL(blob); | ||
| managedImageBlobUrlResolvedCache.set(cacheKey, blobUrl); | ||
| return blobUrl; |
There was a problem hiding this comment.
Revoke cached managed-image blob URLs after rendering
Each successful managed-image fetch creates a blob URL and stores it in managedImageBlobUrlResolvedCache, but this commit does not add any call site for cleanupUnusedManagedImagePreviewBlobUrls (repo-wide search only finds its export). As users view more unique images, blob URLs and backing blobs accumulate for the page lifetime, causing unbounded memory growth in long-lived Control UI sessions.
Useful? React with 👍 / 👎.
|
Related work from PRtags group Title: Open PR duplicate: managed media transcript persistence
|
Summary
chat.historyor get inconsistent follow-up rendering/auth behavior on reload.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause (if applicable)
Regression Test Plan (if applicable)
src/gateway/server.chat.gateway-server-chat.test.tssrc/gateway/managed-image-attachments.test.tsui/src/ui/views/chat.test.tsui/src/ui/chat/gateway-http-auth.test.tsUser-visible / Behavior Changes
Diagram (if applicable)
Security Impact (required)
Repro + Verification
Environment
Steps
Expected
Assistant media replies render live and persist into transcript/history.
Actual
Some replies rendered live but were not durably persisted, causing missing or inconsistent history on reload.
Evidence
Human Verification (required)
Review Conversations
Compatibility / Migration
Risks and Mitigations