Skip to content

fix: preserve Draft when copying conversations - #186828

Merged
shakkernerd merged 1 commit into
mainfrom
draft-conversation-copy
Oct 28, 2026
Merged

shakkernerd merged 1 commit into
mainfrom
draft-conversation-copy

Conversation

@shakkernerd

@shakkernerd shakkernerd commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #186771

What Problem This Solves

Using Advanced → Fork conversation on a Draft creates a Shared copy without asking the creator to change its audience. The copy includes saved conversation history, so another signed-in guest can read text that remains unavailable in the original Draft. This happens during creation, before anyone sends a message in the copy.

User Impact

Whole-conversation copies of Drafts now remain Draft unless an existing authorized action explicitly selects another audience. The creator can continue the copied work using its saved history. If new Draft creation is disabled, the copy fails with guidance to continue the existing conversation or ask an administrator to enable Draft creation; it never silently falls back to Shared.

Existing Draft conversations remain usable after that setting is disabled. Explicit Shared choices, Shared-source defaults, per-row readers, source history and authority, workspace selection, active-source last-completed history, keyed adoption, and generic reset behavior retain their existing contracts.

Why This Change Was Made

The creation owner previously considered only an explicit visibility or a caller-supplied default. The ordinary fork action supplies neither, leaving the destination unstamped and therefore Shared. The owner now inherits Draft for an operator’s whole-conversation copy while preserving explicit choices and existing-key adoption.

The existing validator checks current configuration before workspace preparation and at the final creation boundary. A setting change during preparation uses the existing structured refusal and rollback path. The restriction ends once the row is committed, so it cannot block continued work in an existing Draft. Transcript import passes its existing live configuration getter to the same guard, preserving its initial default and keyed re-import behavior. Fork preparation moves into a bounded module with the same source, transcript, size, publication and workspace custody.

Evidence

On 39bb42e61507acd4d086551f1ab1314b5eb43e0f, 26 affected test files pass 431 cases, all 38 selected compiler graphs are qualified, and formatting, lint, structural checks and hosted CI pass. A retained pre-fix replay reproduced the settled-copy and active last-completed Draft failures. On the current candidate, removing only the import getter adaptation reproduces its policy-change failure while the other 15 import controls pass.

The exact-candidate live run created a Draft through the ordinary UI, copied it without an audience choice, and completed useful model work in the copy. Independent metadata confirmed Draft at first commit and after continuation, with the creator still owner. A separate ordinary guest was denied the source and copy before and after continuation. Copied history and source identities were preserved; original file-write content matched the copy’s first read before a later requested edit in their intentionally shared Agent workspace.

After disabling Draft creation through the native configuration owner, the same copy action returned INVALID_REQUEST with SESSION_VISIBILITY_DISABLED and visible guidance. An existing Draft still completed another useful turn. Final native inventory retained exactly the two original sessions and one existing sandbox workspace, with no partial child or workspace; the original configuration was restored afterward.

The queued source-access regression also passes: revoking parent participation while the writer is held rejects the fork without a child or transcript write. Current-policy preparation/rollback tests, existing Draft adoption and re-import, the initially-disabled Shared import default, and unchanged reset controls pass. No stored representation or reader-policy change is introduced.

Visual evidence

Open preview

Before After
Before: another signed-in guest can read copied Draft history After: another signed-in guest sees Session not found for the copied Draft

Draft copy, disabled-creation refusal, existing conversation continuation and foreign denial

draft-copy-proof-final.mp4

Visual verification

  • Baseline: 9a5581b
  • Exact head: 39bb42e61507acd4d086551f1ab1314b5eb43e0f
  • Scenario: An owner copies an existing Draft through Advanced → Fork conversation without selecting a new audience, then completes a useful first turn. An ordinary foreign guest cannot open the copied history.
  • Runtime/build: OpenClaw build 2026.10.8-39bb42e61507-2026-10-28T14-56-18.250Z; exact clean UI commit 39bb42e; Chrome 156.0.8078.49
  • Audience at first committed copy: Draft; creator remains owner
  • Audience after useful first continuation: Draft; foreign UI and metadata reads denied
  • Copy request: fork=true; no explicit audience supplied
  • Preserved history: Source task and completed response appear in the copy
  • Draft creation disabled: New copy refused with SESSION_VISIBILITY_DISABLED; existing Draft completes another useful turn
  • No partial copy: Exactly two original session identities remain; no new worktree or sandbox root
  • Existing source file: Original write and copy first-read contents match before later requested shared-workspace edit
  • Real creator and foreign guest use separate ordinary UI contexts on the exact candidate; native descriptions confirm the committed audience and preserved identities.
  • Before and after use distinct disposable synthetic library fixtures and guest identities with the same role and 1280×720 light viewport. Access outcome is the compared behavior.
  • Original file-write and copied first-read contents match before the later requested edit in their intentionally shared Agent workspace.
  • Recording: 00:00–00:52 enabled copy/first continuation; 00:52–00:57 disabled-copy refusal; 00:57–01:08 existing-Draft continuation; 01:08–01:14 foreign guest visits original and copy.
  • Fork action runs at one-third speed and refusal at two-thirds speed; idle inspection pauses are omitted. Model continuations run at normal speed. Native setting changes occur between recorded phases.
  • Only model-selector labels are redacted. The tested content, actions and access outcomes remain visible.

@clawsweeper

clawsweeper Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: M labels Oct 28, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 28, 2026
@clawsweeper

clawsweeper Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Preserve Draft visibility when copying whole conversations and recheck current creation policy before persistence.

Example: A guest copies a Draft containing saved working notes through Advanced → Fork conversation.

  • Before: The copy defaults to Shared, allowing another eligible guest to read its history.
  • After: The copy remains Draft; disabling Draft creation refuses the copy while existing conversations remain usable.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused repair has no actionable findings and passing exact-head gates, with meaningful behavior evidence but incomplete upgrade validation.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Copying a Draft makes saved conversation text readable to another guest without an audience-changing action.
Reason: The maintainer-authored direction restores the documented Draft behavior through the existing owner without a new setting or public API.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current Draft audience defect and remains worthwhile; no actionable code defects were found.

Priority: P1
Reviewed head: 39bb42e61507acd4d086551f1ab1314b5eb43e0f

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Supply a latest-stable upgrade run preserving existing Draft and Shared conversations and the Draft-creation setting, then exercise copying and existing-Draft continuation.
Agent review details

How this fits together

The Gateway creation owner receives authenticated session requests, prepares workspace and transcript state, and commits destination metadata consumed by sharing readers.

flowchart LR
  A[Control UI fork request] --> B[Gateway authorization]
  B --> C[Session creation owner]
  C --> D[Visibility and current policy]
  D --> E[Transcript and workspace preparation]
  E --> F[Guarded session commit]
  F --> G[Per guest history access]
Loading

Technical review

Best possible solution:

Keep Draft inheritance and live creation-policy checks in the existing creation owner while preserving explicit audience choices and existing-session behavior.

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

Current-main visibility resolution omits parent Draft inheritance, and the report supplies a concrete original-denied/copy-readable guest scenario supported by a baseline screenshot.

Is this the best way to solve the issue?

The producer-side repair fits the existing ownership boundary; the extracted fork preparation replaces its former inline implementation without adding competing policy or state.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 745e8f2121c2.

Provenance checked

  • Visibility defaults and keyed adoption keeps the original intent (27bdedb: Transcript imports needed a creation-only Draft default while retaining existing keyed visibility and the initially-disabled Shared exception.)
  • Implicit whole-conversation audience changes intended behavior with a stated reason (27bdedb: The extracted resolver accepted explicit or caller-provided visibility without parent inheritance; this PR explains the demonstrated audience expansion and its narrow correction.)
  • Fork transcript and workspace custody keeps the original intent (fix(sessions): prevent duplicate labels during concurrent creation #158839: Fork history and destination creation share publication and commit custody so rejected creation cannot leave copied child history.)
  • Guest whole-conversation controls keeps the original intent (2b9dd45: Eligible guest owners can fork their own conversations, retaining completed-history boundaries and existing workspace restrictions.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Pinned change and current-main comparison: The introduced diff adds operator Draft inheritance and creation-policy revalidation; fetched main retains the original resolver without parent inheritance. (src/gateway/session-create-visibility.ts:16, 39bb42e61507)
  • Creation policy ends at commit: The composed guard preserves existing caller authority, rejects disabled visibility before commit, and stops applying creation restrictions after successful persistence. (src/gateway/session-create-service.ts:165, 39bb42e61507)
  • Revocation reaches the persistence boundary: The existing regression captures real sharing authorization, holds the SQLite writer, removes parent participation, and verifies rejection with no child or additional transcript events; the PR reports this regression passing on the reviewed head. (src/gateway/server.sessions.create.authority.test.ts:207, 39bb42e61507)
  • Supplied behavior evidence: Inspected before/after screenshots show readable copied history becoming Session not found for a foreign guest. The body supplies exact-head creator continuation, committed Draft metadata, disabled-policy refusal and cleanup results. Video inspection was limited by the manifest's ffprobe ENOENT failure and web fallback Cache miss; these are reviewer infrastructure limits. (39bb42e61507)
  • Exact-head gates: GitHub reports clean mergeability and successful openclaw/ci-gate, dependency-review and security-sensitive-review statuses for the reviewed head; paginated checks exposed no failed check. (39bb42e61507)
  • Original import contract: feat(sessions): import Claude Code and Codex transcripts into OpenClaw #161955 deliberately defaults new imports to Draft when enabled, permits Shared imports when initially disabled, and preserves published copies on re-import; this PR retains those choices. (src/gateway/server-methods/session-catalog-import.ts:129, 27bdedb8af42)

Likely related people:

  • Peter Steinberger: Raw commit 27bdedb adds src/gateway/session-create-visibility.ts:1 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 27bdedb8af42; files: src/gateway/session-create-visibility.ts)
  • Shakker: Raw commit 2b9dd45 adds docs/gateway/operator-scopes.md:123 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 2b9dd45ec2b8; files: docs/gateway/operator-scopes.md)

PR surface

Source +76, Tests +185, Docs +4. Total +265 across 9 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 4 147 71 +76
Tests 4 192 7 +185
Docs 1 5 1 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 344 79 +265

Root-cause cluster

Relationship: same_root_cause
Canonical: #186771
Summary: This PR repairs whole-conversation creation; message-cut forks and spawned helpers have separate creation owners.

Members:

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

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: The current whole-conversation workflow silently broadens the audience of saved Draft history.
  • merge-risk: 🚨 security-boundary: The patch changes persisted audience selection and policy checks governing which authenticated guests can read copied history; the dedicated review found no concrete regression.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Record the latest-stable upgrade scenario with existing Draft and Shared history and the Draft-creation setting intact.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-28T15:03:32.900Z sha 39bb42e :: needs real behavior proof before merge. :: none

Reviewed October 28, 2026, 12:36 PM ET / 16:36 UTC (Revision 2).

@shakkernerd

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 28, 2026
@shakkernerd
shakkernerd merged commit 5ff57b8 into main Oct 28, 2026
158 checks passed
@shakkernerd
shakkernerd deleted the draft-conversation-copy branch October 28, 2026 16:58
@shakkernerd

Copy link
Copy Markdown
Contributor Author

Fixed: whole-conversation Draft copies now respect the current Draft-creation policy without silently becoming Shared.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 29, 2026
Preserve Draft visibility when copying a whole conversation, revalidate current creation policy before commit, and keep existing Draft conversations usable.

Fixes openclaw#186771.
RomneyDa added a commit that referenced this pull request Nov 11, 2026
Preserve Draft visibility when copying a whole conversation, revalidate current creation policy before commit, and keep existing Draft conversations usable.

Fixes #186771.

Release adaptation: preserve the stable creation, model-authority, incognito actor, lifecycle, and target-custody owners. Adapt only conflicting tests/docs to existing fixture APIs; retain all stronger base tests. Apply the three-line authorization-release fixture companion from ede7af8 to the touched handoff tests.

Bounded companion audit through 4b8fbc7:
82210a2|not-applicable|Only inactive-operator recovery documentation. Base live authority checks retained; no Draft policy dependency.
caa978c|not-applicable|Future template initialization feature; base initializeSession/atomic creation contracts unchanged.
abb2690|present-equivalent|Stable worktree fixtures already set config before allocation. Adaptation preserves that order and adds live policy change only after allocation.
987a9ef|not-applicable|Independent Android active-response child creation behavior; no change to preserved active-parent fork guards.
5088eac|not-applicable|Guest typing-preview authority/documentation; no Draft creation producer change.
95363ce|not-applicable|Separate parent-approved restricted-repository lane. Overlap with this delta is docs/gateway/operator-scopes.md only. This lane preserves current project/access owners.
b9a3df0|not-applicable|Trusted-admin Access eligibility docs, not creation visibility.
65c8e20|present-equivalent|Stable service already calls prepareSessionPatchRuntimeSelection with current authority validation before creation. Preserve stronger runtime selection/release contracts; unrelated typing half excluded.
d0e78b0|not-applicable|Actions widget approved-query policy documentation, no creation visibility producer.
7552558|not-applicable|Future Beam conversation handoff/initialization feature. Existing incognito actor storage and publication ownership retained.
3552814|not-applicable|Users-sidebar guest presence disclosure documentation, no copy creation dependency.
1139abe|not-applicable|Future native child repository workspace inheritance. Base session-create-project owner and destination preservation tests retained, no unrelated migration.
dc843b6|not-applicable|Agent avatar scope documentation, no Draft copy contract.
5d3e157|not-applicable|Private person activity timeline docs, no Draft copy contract.
ede7af8|selected|Necessary touched-fixture lifecycle companion. Base creation-handoff test acquires retained authorization without releasing it. Apply exact onTestFinished authorization.release cleanup (3 lines plus import) to preserve process-wide sharing-read ownership.
65a125a|not-applicable|Future attended permission defaults; existing stable permission-default behavior unchanged.
d40aa7c|not-applicable|Independent creation-request replay feature across restarts; stable creation operation and custody contracts retained.
f33f9c1|not-applicable|Workspace repository discovery documentation/UI, no creation policy dependency.
1347e90|not-applicable|Clarifies none-cap membership docs, no Draft copy semantics.
e0ed68c|not-applicable|Token-counter format changed to version2 on later main. Stable token-version1 producer retained; fork cap/version fixtures pass on current stable contract.
975e68c|not-applicable|Future human-owner cron management/transfer feature documentation.
0731967|not-applicable|Restricted-role UI forbidden-request documentation; no copied-conversation producer.
1851659|not-applicable|Future scoped cron management documentation, no copied-conversation producer.
284c109|not-applicable|Guest tool preview documentation, no copied-conversation producer.
6d8ba30|not-applicable|Separate parent-approved spawned-Draft lane. Exact overlap src/gateway/session-create-visibility.ts. Preserve operator-only copy condition in this lane; parent must reconcile later spawned audience policy.

(cherry picked from commit 5ff57b8)

Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Whole-conversation forks turn Draft copies into Shared conversations

1 participant