Skip to content

fix(gateway,ui): restore managed media transcript persistence in webchat - #70383

Closed
Ittiz wants to merge 7 commits into
openclaw:mainfrom
Ittiz:forge/pr2-managed-media-persistence-clean
Closed

Ittiz wants to merge 7 commits into
openclaw:mainfrom
Ittiz:forge/pr2-managed-media-persistence-clean

Conversation

@Ittiz

@Ittiz Ittiz commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Recreates the managed-media persistence fix from a clean branch after #69500 was auto-closed as dirty.

This restores the webchat/control UI path so assistant-managed media replies, especially image replies, are durably persisted and re-render correctly after reload/history fetch.

What changed

  • restore gateway-side managed attachment persistence and serving for assistant replies
  • preserve media-bearing reply metadata through transcript injection/history flows
  • add UI-side auth-aware managed media resolution/open behavior
  • harden grouped chat rendering and control-ui bootstrap handling for managed media
  • add targeted gateway, media, and UI regression coverage for the persistence path

Problem

Managed media could render live, then disappear or come back inconsistently after reload because the reply/transcript/UI path was not durably carrying the needed managed-media state.

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

  • pnpm check:changed --staged
  • targeted/full changed-lane Vitest coverage passed for gateway, media, and UI paths
  • browser image-open safety test passing in local Vitest browser run

Human Verification (required)

  • Verified scenarios:
    • targeted gateway chat tests for managed-image persistence paths
    • targeted UI chat tests
    • targeted managed-image attachment tests
    • browser image-open safety coverage
  • Edge cases checked:
    • image-only assistant replies
    • follow-up preview behavior
    • managed media auth/open path from the UI
  • What you did not verify:
    • broad end-to-end cross-channel coverage outside the targeted webchat/control UI path
    • live post-restart webchat smoke after merge

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? Yes
  • Config/env changes? No
  • Migration needed? No

Risks and Mitigations

  • Risk: managed-media rendering and transcript persistence touch both gateway and UI seams.
  • Mitigation: targeted gateway/UI/media regression coverage was added and hardened.
  • Risk: media auth/reload behavior can regress in subtle ways.
  • Mitigation: explicit UI auth-path coverage and browser validation for the image-open path.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime size: XL labels Apr 22, 2026
@greptile-apps

greptile-apps Bot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR restores the managed-media transcript persistence path for webchat/control-UI assistant replies, re-landing changes from the auto-closed #69500. It introduces a new managed-image-attachments.ts module with full lifecycle management (create → persist → serve → cleanup), registers the /api/chat/media/outgoing/…/full route in the gateway HTTP server, adds auth-aware blob-URL fetching in the UI renderer, and expands test coverage across the gateway, media, and UI layers.

The auth model (gateway auth → chat.history scope → session ownership or device-token → transcript presence check) is thorough. The retry logic in the UI fetch path correctly handles the transient→history window, and the LRU transcript-index cache with mtime/size invalidation is well-designed.

Confidence Score: 5/5

Safe to merge; both findings are minor style/defence-in-depth observations with no current exploitable path.

No P0 or P1 issues found. The security model is layered correctly (auth → scope → session ownership → transcript presence), the retry logic bridges the transient-to-history window, and the LRU cache invalidation is correct. Both inline comments are P2 (dead code with wrong semantics, and a minor defence-in-depth suggestion).

No files require special attention beyond the two P2 observations noted inline.

Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/gateway/managed-image-attachments.ts
Line: 223-229

Comment:
**Incorrect `contentType` in no-resize branch**

`resizeManagedImageBufferToLimits` returns `contentType: "image/jpeg"` in its early-return branch even when no resize is needed — meaning a PNG buffer would be tagged as JPEG. While this code path is unreachable today (the function is only invoked when dimensions exceed limits, which always produces a non-null target), it creates a silent correctness hazard if the function gains new callers.

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: src/gateway/managed-image-attachments.ts
Line: 991-996

Comment:
**`attachmentId` not validated to UUID format before file-path use**

`attachmentId` from the URL is extracted by `[^/]+` and passed directly to `resolveOutgoingRecordPath`, which constructs `path.join(recordsDir, \`${attachmentId}.json\`)`. A value like `..` would resolve to `outgoing/.json` (one level up from `records/`), still inside `stateDir` and always yielding a null record → 404, so there is no exploitable traversal today. However, adding an explicit UUID format guard is a clean defence-in-depth improvement that matches how attachment IDs are actually generated (`randomUUID()`).

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "fix(gateway,ui): restore managed media t..." | Re-trigger Greptile

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bd80568fa6

ℹ️ 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".

@Ittiz
Ittiz force-pushed the forge/pr2-managed-media-persistence-clean branch from bd80568 to 184996d Compare April 23, 2026 01:40

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 184996dd45

ℹ️ 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".

Comment thread src/gateway/server-http.ts Resolved
Comment thread ui/src/ui/app-render.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6f1501668f

ℹ️ 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".

Comment thread src/gateway/server-http.ts Resolved
Comment thread src/gateway/server-methods/chat.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ac5fdf2431

ℹ️ 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".

Comment thread src/gateway/server-methods/chat.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3c2adaa793

ℹ️ 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".

Comment thread ui/src/ui/chat/grouped-render.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 86d3249a42

ℹ️ 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".

Comment thread src/gateway/server-methods/chat.ts Resolved
Comment thread ui/src/ui/chat/grouped-render.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6425e8080a

ℹ️ 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".

Comment thread src/gateway/server-methods/chat.ts Resolved
Comment thread src/gateway/server-methods/chat.ts Resolved
@prtags

prtags Bot commented Apr 23, 2026

Copy link
Copy Markdown

Related work from PRtags group intent-mastiff-ytno

Title: Open PR duplicate: managed media transcript persistence

Number Title
#68821 fix(gateway,ui): restore managed media transcript persistence in webchat
#69500 fix(gateway,ui): restore managed media transcript persistence in webchat
#70383* fix(gateway,ui): restore managed media transcript persistence in webchat

* This PR

@steipete

Copy link
Copy Markdown
Contributor

Closing this as superseded by #70719.

Codex deep-review evidence:

  • fix(gateway): persist webchat images as managed media #70719 is already merged on main as 54731492a2 fix(gateway): persist webchat images as managed media (#70719) and explicitly lists fix(gateway,ui): restore managed media transcript persistence in webchat #70383 as related.
  • The merged fix covers the same core problem: generated/assistant image replies are copied into managed Gateway media storage, persisted as authenticated /api/chat/media/outgoing/.../full transcript URLs, and rendered by Control UI through authenticated blob fetches.
  • fix(gateway): persist webchat images as managed media #70719 also landed the user-facing docs/changelog updates and the focused proof this PR was missing on current main: managed-image attachment tests, gateway chat persistence tests, grouped-render tests, pnpm check:changed, pnpm build, and the mock Control UI image roundtrip QA scenario.
  • This PR is no longer cleanly mergeable. Current origin/main already added src/gateway/managed-image-attachments.ts, and git merge-tree reports an add/add conflict against fix(gateway,ui): restore managed media transcript persistence in webchat #70383. The branch is also stale enough that its diff against current main includes broad unrelated churn outside the managed-media surface.
  • Keeping this open would duplicate the already-landed path and risk regressing newer main changes (for example current gateway/chat/UI wiring that landed after this branch).

Thanks for recreating the clean branch and iterating through the review notes. The canonical fix is #70719, so I’m closing this duplicate rather than asking for another rebase.

@steipete steipete closed this Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui gateway Gateway runtime size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants