Skip to content

feat(ios): export chat transcripts as Markdown via the share sheet - #100417

Merged
steipete merged 2 commits into
mainfrom
feat/ios-session-export
Jul 5, 2026
Merged

steipete merged 2 commits into
mainfrom
feat/ios-session-export

Conversation

@steipete

@steipete steipete commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Part of #100415

What Problem This Solves

Conversations are trapped in the app: there is no way to hand a chat transcript to Mail, Files, Notes, or a colleague.

Why This Change Was Made

Adds a pure, deterministic Markdown formatter to the shared chat package (ChatTranscriptExporter): H1 session title, per-message role + ISO8601 UTC timestamp headings, verbatim pass-through for fenced code and tables, _[attachment: name]_ placeholders, and the same hidden-row filtering the transcript view applies. Filenames are sanitized and UTF-8-length-bounded. The iOS chat screen gains an Export action in the trailing toolbar menu that writes <session-title>.md to a temp file and presents the system share sheet. Formatter stays platform-pure (macOS builds untouched); share-sheet wiring is iOS-only.

User Impact

iOS users can export the current conversation as a named Markdown file to any share-sheet destination. No behavior change otherwise.

Evidence

  • cd apps/shared/OpenClawKit && swift test --filter ChatTranscriptExporterTests — 3/3 (snapshot-exact fixture with user/assistant/attachment rows + unicode + code fence; filename sanitization; empty transcript).
  • pnpm ios:build — BUILD SUCCEEDED (includes SwiftFormat/SwiftLint phases); typography guard updated per apps/ios/AGENTS.md.
  • Implementation by Codex (gpt-5.5) from a frozen spec; reviewed line-by-line by the orchestrating session; changelog line removed per release-only policy.

@openclaw-barnacle openclaw-barnacle Bot added app: ios App: ios size: M maintainer Maintainer-authored PR labels Jul 5, 2026
@clawsweeper

clawsweeper Bot commented Jul 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 5, 2026, 5:11 PM ET / 21:11 UTC.

Summary
The branch adds a shared Swift Markdown transcript exporter, iOS Export Transcript share-sheet wiring, native i18n inventory updates, and Swift/typography tests.

PR surface: Other +387. Total +387 across 6 files.

Reproducibility: yes. for the PR defects by source inspection: the exporter serializes raw messages while ChatView renders merged/filtered rows and transient rows outside that array. The actual iOS share-sheet behavior has not been proven in a real setup.

Review metrics: none identified.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #100415
Summary: This PR is the transcript-export candidate for the open iOS chat-polish umbrella; the haptics sibling is adjacent and already merged.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🧂 unranked krab
Result: blocked until real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Export the same visible snapshot the chat UI renders, including hidden-tool-result and visible-system-row cases.
  • [P1] Block export during visible transient rows or include those rows in the exported transcript.
  • [P1] Add redacted simulator/device proof showing the share sheet with a named Markdown file.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body lists Swift tests and an iOS build, but no redacted simulator/device screenshot, recording, logs, terminal output, or linked artifact showing the share sheet with the named Markdown file; after adding proof, updating the PR body should trigger re-review, or a maintainer can comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Mantis proof suggestion
A short simulator or device recording would materially prove the visible iOS share-sheet flow and generated filename. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis visual task: verify iOS Chat Export Transcript opens the share sheet with a named .md transcript file and redacted sample content.

Risk before merge

  • [P1] Exporting raw committed rows can put hidden tool-result content into a user-shared Markdown file.
  • [P1] Export remains available while pending run, pending tool, or streaming assistant rows may be visible, so the shared file can omit content the user currently sees.
  • [P1] Visible system rows such as compaction markers can be dropped from exported transcripts.
  • [P1] The PR lacks redacted simulator/device proof showing the share sheet with the named Markdown file.
  • [P1] The protected maintainer/product signal means feature acceptance still needs human review after correctness blockers are fixed.

Maintainer options:

  1. Export visible snapshots before merge (recommended)
    Reuse or expose ChatView's merged/filtered visible-row model and either block or include transient rows before this export ships.
  2. Accept raw transcript semantics
    Maintainers could intentionally export raw session rows, but that needs explicit product/security signoff and user-facing wording because hidden tool output may be shared.
  3. Pause the export surface
    Pause or close this PR if the privacy and snapshot semantics are not worth resolving for the current iOS polish cycle.

Next step before merge

  • [P1] Protected feature PR needs maintainer/product review and contributor-supplied real iOS proof after the visible-snapshot blockers are fixed.

Maintainer decision needed

  • Question: After the visible-row export bugs and real-proof gap are resolved, should OpenClaw accept iOS Markdown transcript export as part of the broader iOS chat polish direction?
  • Rationale: This PR adds a new user-facing iOS feature tied to an open umbrella issue and carries a protected maintainer label, so implementation correctness alone does not settle product acceptance.
  • Likely owner: steipete — steipete is the strongest current-history owner for the iOS chat surface and the protected feature direction.
  • Options:
    • Accept after blockers (recommended): Land transcript export after visible-row parity, transient-state behavior, security review, and real iOS proof are all clean.
    • Narrow or defer export: Keep the broader iOS polish work open but pause this export surface for more design or privacy review.
    • Decline core export: Close or pause this PR if transcript export should not be part of the iOS app now.

Security
Needs attention: Needs attention: the diff adds no supply-chain surface, but the current export path can include hidden tool-result content in a user-shared Markdown file.

Review findings

  • [P1] Export from the rendered-visible snapshot — apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatTranscriptExporter.swift:160
  • [P2] Disable export while transient rows are visible — apps/ios/Sources/Design/ChatProTab.swift:243
  • [P2] Keep visible system rows in exports — apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatTranscriptExporter.swift:85
Review details

Best possible solution:

Land transcript export only after it serializes the same visible chat snapshot as ChatView, handles or blocks transient rows, preserves visible system markers, and includes redacted iOS share-sheet proof.

Do we have a high-confidence way to reproduce the issue?

Yes for the PR defects by source inspection: the exporter serializes raw messages while ChatView renders merged/filtered rows and transient rows outside that array. The actual iOS share-sheet behavior has not been proven in a real setup.

Is this the best way to solve the issue?

No, not yet: the shared formatter and iOS share-sheet direction are plausible, but the best merge state must export the rendered-visible snapshot and include real iOS proof.

Full review comments:

  • [P1] Export from the rendered-visible snapshot — apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatTranscriptExporter.swift:160
    This still passes raw self.messages into the exporter, while ChatView first merges and filters rows before display. A matched tool_result row can be written into the shared Markdown even though it was hidden from the user; export the same visible snapshot the chat view renders.
    Confidence: 0.92
  • [P2] Disable export while transient rows are visible — apps/ios/Sources/Design/ChatProTab.swift:243
    Export stays enabled whenever a view model exists, but ChatView can show pending run, pending tool, and streaming assistant rows that are not in self.messages. Tapping Export mid-response can omit content currently visible on screen; block export until those rows settle or include them in the exported snapshot.
    Confidence: 0.88
  • [P2] Keep visible system rows in exports — apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatTranscriptExporter.swift:85
    This guard drops every system row, but current session history can synthesize visible system messages such as the compaction marker that ChatView renders as non-empty non-user text. Exports of compacted sessions would omit a row the user can see.
    Confidence: 0.86

Overall correctness: patch is incorrect
Overall confidence: 0.91

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against cff46028f4e5.

Label changes

Label justifications:

  • P2: This is a normal-priority iOS feature PR with concrete merge blockers and limited blast radius to chat transcript export.
  • merge-risk: 🚨 security-boundary: The current export path can put hidden tool-result content into a Markdown file the user shares.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body lists Swift tests and an iOS build, but no redacted simulator/device screenshot, recording, logs, terminal output, or linked artifact showing the share sheet with the named Markdown file; after adding proof, updating the PR body should trigger re-review, or a maintainer can comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Other +387. Total +387 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 6 400 13 +387
Total 6 400 13 +387

Security concerns:

  • [medium] Hidden tool output can be shared — apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatTranscriptExporter.swift:160
    The exporter serializes raw chat messages instead of the merged and filtered rows shown by ChatView, so hidden tool-result or trace content can be written to a file the user shares without seeing it first.
    Confidence: 0.9

What I checked:

Likely related people:

  • steipete: Current-main blame and log history point to Peter Steinberger for the central ChatView visible-row logic and ChatProTab surface, and the adjacent merged iOS haptics PR touched the same shared chat area. (role: recent iOS/shared chat area contributor and likely follow-up owner; confidence: high; commits: 8a187447f94a, bf156386aa5c; files: apps/ios/Sources/Design/ChatProTab.swift, apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatView.swift, apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatViewModel.swift)
  • Takhoffman: History for the compaction divider behavior points to the commit that introduced visible compaction context, which is relevant to the exporter dropping system rows. (role: adjacent compaction transcript contributor; confidence: medium; commits: 82419eaad60d; files: src/gateway/session-utils.fs.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (4 earlier review cycles)
  • reviewed 2026-07-05T18:48:42.341Z sha 1cbcd5307c3edddb720b7b333bead4ec8d02568d :: needs real behavior proof before merge. :: [P2] Sync native i18n inventory for export copy
  • reviewed 2026-07-05T19:40:35.547Z sha f9e210179a99227d97d2b3f7e1f8aa19f8887415 :: needs real behavior proof before merge. :: [P1] Export only visible chat rows | [P2] Disable export while transient rows are visible | [P2] Sync native i18n inventory for export copy
  • reviewed 2026-07-05T20:30:54.729Z sha 6a6f7b2 :: needs real behavior proof before merge. :: [P1] Export from the rendered-visible snapshot | [P2] Disable export while transient rows are visible | [P2] Keep visible system rows in exports
  • reviewed 2026-07-05T21:04:07.759Z sha a5ab771 :: needs real behavior proof before merge. :: [P1] Export from the rendered-visible snapshot | [P2] Disable export while transient rows are visible | [P2] Keep visible system rows in exports

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Jul 5, 2026

@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: 1cbcd5307c

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}
let text = self.visibleText(in: message)
guard !text.isEmpty else { return false }
return role == "user" || AssistantTextParser.hasVisibleContent(in: text)

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.

P1 Badge Hide matched tool results before exporting

When a session contains an assistant tool call followed by a matching toolResult/tool_result row, the chat UI first merges that result into the prior message (ChatView.mergeToolResults) and, with showsAssistantTrace == false in ChatProTab, hides inline tool results. The exporter walks raw viewModel.messages, and this predicate treats the tool-result text as visible, so exporting a transcript after tool use can include hidden tool output/trace content that was not shown in the chat before the user shares the Markdown file.

Useful? React with 👍 / 👎.

Comment thread CHANGELOG.md
Comment on lines +16 to +20
- **Cron duration validation:** reject positive durations that truncate below one millisecond instead of silently scheduling a zero-duration interval. (#100311) Thanks @qingminglong.
- **Skill workshop proposals:** preserve the terminal newline in generated proposal Markdown while still rejecting blank raw content. (#100293) Thanks @anyech.
- **Agent tool inputs and LSP startup:** treat blank optional integer arguments as absent, and fail embedded LSP startup immediately when its child process cannot spawn. (#100273, #99922) Thanks @snotty and @cxbAsDev.
- **Gateway and memory diagnostics:** report failed start-session persistence and close-time memory work instead of silently discarding those failures. (#100313, #100308) Thanks @masatohoshino and @lin-hongkuan.
- **Unicode and plugin package verification:** match native slice semantics for reversed UTF-16 bounds, and reject published plugin packages that omit `openclaw.plugin.json`. (#100014, #99904) Thanks @Simon-XYDT and @849261680.

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.

P2 Badge Drop unrelated changelog entries

When this iOS transcript-export commit is merged, these manually added Unreleased fix entries publish unrelated release-note content for other issues. The root AGENTS.md Docs/Changelog section says CHANGELOG.md is release-only and normal feature/fix commits should not edit it, so this block should be removed from this commit and left to release generation.

Useful? React with 👍 / 👎.

@steipete
steipete force-pushed the feat/ios-session-export branch from 1cbcd53 to f9e2101 Compare July 5, 2026 19:24

@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: f9e210179a

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Image(systemName: "square.and.arrow.up")
}
}
.disabled(self.viewModel == nil)

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.

P2 Badge Prevent exporting while streaming rows are visible

When a run is in progress, this keeps Export enabled as soon as a view model exists. The chat view can still be showing transient content from pendingRunCount, pendingToolCalls, and especially streamingAssistantText (apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatView.swift:349-379), but exportTranscriptMarkdown() serializes only self.messages, so tapping Export mid-response produces a Markdown file that omits assistant text the user can currently see. Disable export until transient rows settle or include those transient rows in the exported snapshot.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. label Jul 5, 2026
@steipete
steipete force-pushed the feat/ios-session-export branch from f9e2101 to 6a6f7b2 Compare July 5, 2026 20:18

@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: 6a6f7b209e

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


private static func shouldExport(_ message: OpenClawChatMessage) -> Bool {
let role = message.role.trimmingCharacters(in: .whitespacesAndNewlines).lowercased()
guard role != "system" else { return false }

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.

P2 Badge Keep visible system rows in exports

When a session contains a visible system row such as the compaction marker synthesized by src/gateway/session-utils.fs.ts (role: "system", text Compaction), ChatView.shouldDisplayMessage renders it because it has visible non-user text, but this guard always drops it from the exported Markdown. That makes exports of compacted sessions omit rows the user can see in the chat, so the exporter should mirror the chat visibility rules or distinguish truly hidden system prompts from displayable system markers.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 5, 2026
@steipete
steipete force-pushed the feat/ios-session-export branch from 6a6f7b2 to a5ab771 Compare July 5, 2026 20:59
@steipete
steipete merged commit 8c19dbf into main Jul 5, 2026
75 checks passed
@steipete
steipete deleted the feat/ios-session-export branch July 5, 2026 21:14

@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: a5ab771c1b

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

var parts: [String] = []
let text = self.visibleText(in: message)
if !text.isEmpty {
parts.append(text)

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.

P2 Badge Apply the chat markdown cleanup before exporting

When a message contains markdown that the chat renderer cleans before display, such as [message_id: ...] hints, untrusted context blocks, prefixed timestamps, or inline data:image/... markdown, the UI runs it through ChatMarkdownPreprocessor.preprocess in ChatMarkdownRenderer before rendering. Appending the raw visibleText here means the exported Markdown can include hidden metadata or large base64 image blobs that were not visible in the chat the user is sharing, so the exporter should use the same cleaned text path or otherwise represent inline images consistently.

Useful? React with 👍 / 👎.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 6, 2026
…penclaw#100417)

* feat(ios): export chat transcripts as Markdown via the share sheet

* chore(ios): sync native i18n inventory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: ios App: ios maintainer Maintainer-authored PR merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant