Skip to content

feat(morph): morph multi-state objects into smooth trajectories - #918

Merged
javierbq merged 73 commits into
masterfrom
worktree-morph-poc
Oct 29, 2026
Merged

javierbq merged 73 commits into
masterfrom
worktree-morph-poc

Conversation

@javierbq

@javierbq javierbq commented Oct 27, 2026 •

Copy link
Copy Markdown
Owner

Summary

Morph turns a multi-state object (an NMR ensemble, prediction seeds, a design trajectory) into a smooth trajectory object beside it. The source is never touched. Each pair of consecutive models becomes one leg of frames_per_model frames. By default the last model morphs back into the first, so the loop is seamless. The result is an ordinary multi-state object (<source>_morph). The State row, per-object Play, Play-models clips, mplay, movie export and .pse save all treat it like any other multi-state object.

  • Objects panel: a Morph… capsule beside Fit / Split / Sync opens a settings sheet. It shows frames per model, loop, refinement, a frame and duration summary, a memory estimate and a build-time hint. The morph builds in the background, with a progress card and Cancel in the tray. Once built, it auto-plays and its row gets a ⟳ badge with the frame count.

  • Movie tab: a Play-models clip gets a Smooth transitions toggle. It builds the morph and lays the clip over it, with stride-aware model→state mapping. The clip round-trips through the .pse (Timeline movies are not saved in sessions (.pse) #901). A clip whose morph is missing shows "⚠ not built", with a one-click rebuild.

  • Command line / MCP: morph_object (async in the app, synchronous in scripts or with async=0), morph_cancel and morph_dismiss. Two-object morphs stay command-line only (morph). MCP: named in GUIDE and INSTRUCTIONS, and morph jobs are reported under raymol.morph_jobs in get_session_state.

  • Engine (clean-room Krebs & Gerstein, modules/pymol/morphing.py):

    • sieve-fit core, then hinge cutting;
    • each rigid segment is fitted with Horn's quaternion method (Jacobi);
    • screw (ScLERP) interpolation between fits;
    • sculpt clean-up.

    Key frames land exactly on the original models.

  • Job layer (modules/pymol/morph_jobs.py):

    • The worker thread never touches cmd. pump() lands the results on the main thread within a time budget.
    • The memory model is measured: about 45 B per atom per frame, plus the cartoon cost per residue.
    • Warn and refuse thresholds scale with RAM; on iOS they use os_proc_available_memory. iOS also cancels a build on a memory warning.
    • Refusals appear as tray cards.

Also in this PR: a C++ fix for a latent use-after-free (separate commits 5f08c12, 08cf51c)

MovieSceneStore queued the scene thumbnail render with a raw pointer into the scene dict (&scene.thumbnail). These commands free that node, and the queued job wrote into it later:

  • reinitialize;
  • scene X, delete, scene *, clear, scene X, rename;
  • a session load.

The bug came from upstream and master has it too. Master's headless test runner never runs deferred jobs, so it never fired there. One new morph test calls _cmd._idle, which switches deferred execution on for the rest of the process. After that, the single-process CI list aborted in 5 of 6 runs.

The app's Metal path drains the deferred queue every frame. So scene store followed by reinitialize, delete, a load or a rename before the next frame can probably hit the bug in the shipping app too. That is inferred from the code; I didn't reproduce it in the app.

The fix: the thumbnail job now looks its scene up by stack and name when it runs. The raw out-pointer is gone from SceneDeferImage and OrthoDeferImage, so a caller that passes one no longer compiles.

testing/tests/raymol/scene_thumbnail_defer.py is a new regression test. Under Guard Malloc it crashes the old core on every free path, and the patched core survives all of them.

Crash rates, each a full single-process CI list:

Variant Crashed / runs
master 0/9
branch with the old core 5/6
master plus a test that only calls _cmd._idle 5/6
patched core 0/12, then 4 more clean gate runs

The yml sets RAYMOL_REQUIRE_GMALLOC=1, so these Guard Malloc subtests fail instead of skipping if Guard Malloc can't load. Master's #917 set the same line, and its GitHub run (40559042306) ran its Guard Malloc subtest and passed, so Guard Malloc does load on the runner.

Design docs

  • Spec: docs/superpowers/specs/2026-10-21-morph-design.md (decisions from the brainstorm in §3)
  • Plan: docs/superpowers/plans/2026-10-21-morph.md
  • User guide: docs/src/content/docs/guides/morph.md

How it was built and checked

  • Increments: 12 planned tasks plus 8b (the main-thread hitch and player lifecycle) and 12a (integrating Timeline movies are not saved in sessions (.pse) #901/MCP: tell clients RayMol is not stock PyMOL, and add RayMol-native tools #904). Each task had its own review and fix rounds.

  • Merges from master: test(shortcuts): pin ⌃L in the ⌃-shortcut audit set #912/ci: build and run the macOS XCTest bundle (UnitTests_macOS) on PRs #913, macOS: auto-hide the side panel in narrow windows (#914) #915, and fix(design): keep the visual-state snapshot in memory, not a shared temp file #916/core: keep jobs queued while the deferred queue drains #917. core: keep jobs queued while the deferred queue drains #917 changes how OrthoExecDeferred drains the queue, and that touches the same deferred-job machinery as the C++ fix above. The two compose: a thumbnail job queued during a drain waits for the next drain, then lands through its by-name receiver. The CI list keeps both sides' tests, and one RAYMOL_REQUIRE_GMALLOC line covers both Guard Malloc suites.

  • Final multi-agent review:

    • 8 dimension finders produced 124 raw findings, 61 after dedup.
    • 3-lens verification left 13 confirmed and refuted none.
    • A fix wave fixed all 13: the cartoon memory estimate (about 20× too low); the iOS runtime guard; refusals in the tray; sculpt clean-up stalls on ≥50k atoms; the finished morph's state pin freezing Lockstep and export; rigid-fit failures on extended or strand ensembles; and others.
    • A close-out round fixed the remaining items: a playing morph's pin saved into the .pse, the build hint for discrete objects, the "not built" caption, and the crash above.
    • A final re-review marks every item fixed and found no new breakage.
  • Copilot review (5 comments). An investigator and a skeptic confirmed all five as real, and each is fixed with a test:

    • expired frame-cost figures refresh oldest first (4a79c87);
    • a partial save leaves out a nested group player's CGO pin (ad7d890), reading the members from a binary dump (a813996);
    • a queued scene thumbnail lands only in the scene it was for, via a per-scene ticket in the core (e42a4cf);
    • only a molecule named <source>_morph counts as a restored morph (42629bd). The trigger was an alignment, whose name selects atoms and so reports states; CGOs and maps report none in the panel poll;
    • Add in the Play-models sheet waits while the morph it would name is still building (6f1274d).

    An adversarial review of those fixes led to 83afd99: Smooth transitions only for a molecule, plus guide and spec corrections.

  • Python: the full CI list from raymol-embedded-tests.yml, in one process:

    An independent two-lens review of the merged deferred-job C++ found that it composes correctly. It also found two older Metal-app limitations that neither side introduced: a plain png w,h writes a blank file in the app, and the image-size path reads uninitialized dims. Those are tracked separately.

  • Swift: the UnitTests_macOS scheme at 08cf51c: 1845 tests, 4 skipped (inference weights and an opt-in memory sweep), 0 failures.

    • With the first four Copilot fixes plus Add-waits, before 6f1274d was committed: 1847 tests, 1 failure. It was an AirDust "frames in flight did not retire within 5 s" timeout, in an hour-long run competing with the Python list. It passes when re-run alone (8/8).
    • After 83afd99, the morph classes (MorphSettings, MorphEngine, TimelineLaneLayout): 74 tests, 0 failures.
  • VM checks (disposable macOS VM, 8 GB, build RayMol-morph-closeout.app @08cf51c6d), all passing:

    • Build a morph from the sheet; it auto-plays.
    • Save while it plays, quit, relaunch, reopen: the object carries no pin, and a Lockstep clip's 10-frame PNG export has 10 different frames.
    • Pause on frame 15, save, reopen: the pin is kept, and Sync releases it.
    • A typed save while playing strips the pin.
    • The "not built" caption stays inside the lane at every zoom; its narrow form is "⚠ not built", and the remedy is in the tooltip and context menu.
    • A discrete object's build hint matches its source (≈ 16 s, not ≈ 5 min).
    • A CLI refusal card ("needs about 6934 MB").

    Earlier VM rounds covered estimate parity between the two sheets, Clear Session during a build, the ⟳ badge after relaunch, pumps of at most 0.34 s on a 50k-atom build, and .pse frame→state maps.

Known limits / follow-ups

  • iOS is not compiled here (no deps_ios on the build machine). MorphSheet, PlayModelsSheet, the iOS detent and the memory-warning observer follow the existing #if os(iOS) patterns and the iOS 17 floor, checked by reading. Before release, run xcodebuild -scheme PyMOLViewer_iOS -sdk iphonesimulator build and open both sheets in the simulator.
  • The docs site needs Node ≥ 22 to build (the host has Node 20). It was built with Node 24; re-run pnpm build in docs/ on Node 22+.
  • Memory: the core keeps every state's representations (defer_builds_mode 0). A 20-model NMR ensemble at the default 15 frames per model needs about 0.6 GB. That warns on macOS and may be refused on small iPhones. The real fix is in C++: build only the drawn states. The cartoon estimate reads up to about 2.2× high for sources with no secondary structure assigned.
  • Look changes: any look change on a finished morph rebuilds all its states at the next redraw. That takes about 0.35 s at 300 frames and about 1.5 s at 1,200, the same as any multi-state object of that size.
  • Re-morph start stall: re-morphing a large morph stalls 1.1–2.3 s at the start, while the core frees the old per-state caches (C++).
  • defer_builds_mode ≠ 0 (for example after loading a trajectory of 500 or more states) disables the hidden pre-build, so completing a large morph costs one frame of 1.5–2 s.
  • Spec deviations:
    • §5.6: the thresholds were re-tuned to measured costs; the spec's constants are kept as floors.
    • §5.2: the play parameter is not implemented. Auto-play is UI-only, and CLI/MCP morphs sit at frame 1.
    • A finished morph no longer pins its per-object state, so it plays like any other multi-state object.
    • A session saved while a morph auto-plays leaves out the player's pin, so it reopens following the movie frame. A deliberate stop on a frame is still saved.
  • Reopened play rate: a reopened morph's Objects-card play rate falls back to 15 fps; it auto-played at 30. The per-object fps is not saved in sessions (existing behaviour).
  • A reloaded loop=0 morph clip counts N−1 models; this needs a persisted loop flag in TimelineRecord.States.
  • Opening the Theme studio while a morph builds cancels the build.
  • A morph grouped while it builds lists at top level until the next tree edit.
  • With two morphs building at once, the second crawls while the first computes (GIL contention).
  • Algorithm limits:
    • Per-frame sculpting can add side-chain flicker.
    • A terminus that swings through its neighbour inside one rigid segment is not repaired.
    • Internal-coordinate interpolation remains a non-goal.
  • Editing a finished morph's atoms drops it from the registry (badge, prefilled settings, reuse) until it is morphed again.
  • Per-object auto-play at 30 fps costs about 30% of the main thread in SwiftUI updates (existing playback-panel behaviour).
  • MCP: raymol.morph_jobs entries have their own shape ({name, source, status, progress, error}), not prediction_jobs's.

🤖 Generated with Claude Code

javierbq and others added 30 commits October 21, 2026 14:47
Replaces the IncentiveOnlyException stub with a clean-room morph in pure
Python (no numpy, so it runs inside the shipped app):

- pairing via align/super alignment objects, identifiers (in/like) or an
  existing alignment object; multi-state legs (state1=0 / state2=0) with
  N*steps states exactly as the incentive docstring specifies
- method=rigimol: per-chain sieve-fit core (frame-invariant residual),
  ChimeraX-style run-length hinge rule, per-segment least-squares fit,
  screw (corkscrew) interpolation with exact endpoints, hinge blending,
  Cartesian lerp inside the segment frame; method=linear kept
- refinement=N: sculpting cycles on intermediates with the backbone fixed
- rate=linear|sinusoidal|"ramp up"|"ramp down", color_segments diagnostic

1AKE->4AKE (1656 atoms, 30 states): 0.07 s rigid, 0.43 s with refinement;
mid-morph bonds >10% off: linear 307, rigid 189, refined 26.
Proof of concept only: no internal-coordinate interpolation, no tests in
the suite yet, no UI entry point.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Brainstormed with the user: separate <source>_morph object (sibling row with
badge), "Morph…" capsule on the State row opening a small sheet, a "Smooth
transitions" toggle inside the Play-models sheet, cross-object morph left to
the command line, and the background worker landing before any UI ships.

Includes the verified mechanics the design rests on (main-thread-only core,
poll_panel/pending_jobs tray contract, coordset order, look copy limits),
the engine job layer (start_job/step/pump, cancel, fingerprint, size and
memory policy), per-state titles, Movie-tab model<->state mapping with
morphStride, verification gates and increments. Builder-checked by three
independent reviewers; their questions are answered in the text.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… Object panel, Movie tab, docs)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…the suite

Add key_frames(), residue_order(), and sculpt_states() helpers to morphing.py.

key_frames(nstates, steps, nlegs) returns the 1-based state numbers that hold
exact copies of the input models (1 + k*steps for k=0..N-1, plus nstates).

sculpt_states() replaces the old inline refinement loop; it skips every state
in key_frames() so intermediate model copies are never perturbed by sculpting.
This fixes the bug where a 3-leg morph with steps=5 would sculpt states 6 and
11 (the second and third key frames), leaving them different from the input
models.

residue_order() wraps sorted() on (resv, resi) pairs, making the sort intent
explicit and giving later tasks a stable named interface; _segment_chains now
calls it instead of sorted() directly.

Testing: 14-test morph_engine.py covers all three new helpers, the screw math
(60 random trials, tiny and near-180 deg cases), the ChimeraX hinge rule, the
_index_ranges compressor, multi-state state-count semantics, and the four error
paths. The file is added to the raymol-embedded-tests.yml --run list (after
metal_shader_sources.py, before scene_materials.py).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ook copy, titles)

Add modules/pymol/morph_jobs.py with the pure building blocks the MorphJob
class (Task 3) and Swift side (Task 4) will consume:

- morph_name(source)           — collision-safe name with _JOBS awareness
- validate_source(source)      — (atoms, models) or CmdException
- morph_estimate(source, ...)  — bytes/seconds/warn/refuse dict
- copy_look(src, dst)          — per-object settings copy, hides surface+mesh
- set_state_titles(name, ...)  — "model N" / "N → M" labels via key_frames
- fingerprint(source)          — {state_count, atom_count, crc32} identity

Also adds WARN_BYTES / REFUSE_BYTES platform constants (100 MB / 400 MB on
iOS, 200 MB / 1 GB elsewhere) and the _JOBS registry dict.

Tests: testing/tests/raymol/morph_jobs.py — 6 tests, all green.
CI: morph_jobs.py added to raymol-embedded-tests.yml (alphabetical order).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…pending surface

start_job snapshots a multi-state source on the main thread and creates the
morph object (disabled) holding model 1; MorphJob.step() computes one leg
without touching cmd; pump() lands frames within a time budget, sculpting
landed intermediates only, titling each leg as its key frame lands, and on
completion verifies the state count and last-frame round trip, shows the
morph and hides the source. Each leg ends on its key frame (j/f, last leg
j/(f-1)): the same coordinates as cmd.morph, regrouped so one landed leg
gives 1 + f states. Key frames are copied from the snapshot.

morph_object(async_=0) runs the pipeline inline; async_=1 lets pump() step
the job (Task 5 moves that to a worker). reuse=1 keeps a done morph whose
spec and source fingerprint match. Explicit names may replace only a known
morph of the source or a <source>_morph<N> object. Cancel/error delete the
partial object, re-enable the source and keep a tray record until
morph_dismiss; a successful job leaves none. Records carry exactly the
designing.pending_info keys; specs are ints, never bools.

morphing.py: factor _snapshot/_coords_by_pos and the sculpt constants out
of cmd.morph so both paths share them (cmd.morph output unchanged).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
copy_look=0 skipped the only surface/mesh hide, so a surface shown on the
source was carried into every frame. start_job now hides surface and mesh
on the morph whatever copy_look says.

morph_name checked molecular objects only, so a group, map or CGO named
<source>_morph was treated as free and then deleted (a group with its
members) when the morph was built. A stale registry record also claimed
whatever was later created under its name. Names now count as taken when
any object has them, unless _is_known_morph holds: the record is for this
source and the object is still a molecule with the job's atom count. The
explicit-name <source>_morph<N> convention likewise applies to molecular
objects only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… register commands

- appkit_inspector.poll_panel(): add morph_jobs pump (guarded try after design
  pump) so legs landed by the worker thread reach the session on the main thread
  before the object list is gathered.
- Compute _pending_maps('morph_jobs') in its own guarded try (morph_records={} on
  failure) and add 'morph_jobs' (progress-tray records, NOT merged into 'pending')
  to the payload; add 'morph' (morph_sources()) in its own guarded try.
  A morph object's enable-toggle must stay active while the job runs.
- keywords.py: register morph_object, morph_cancel, morph_dismiss with
  parsing.STRICT after 'morph'.
- api.py: import morph_object, morph_cancel, morph_dismiss from .morph_jobs.
- testing/tests/raymol/morph_panel.py: 4 TDD tests (RED→GREEN confirmed):
    testPayloadCarriesMorphJobsAndSources,
    testMorphJobsPendingMapFailureWritesPanelWithEmptyMorphJobs,
    testCommandsRegistered,
    testCancelAndDismissViaCommandLine (exercises cmd.do() parser path).
- .github/workflows/raymol-embedded-tests.yml: add morph_panel.py to --run list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
start_job(run=True) (morph_object async_=1) starts a daemon thread that
loops step() until the legs run out or job._cancel is set; finished legs
reach the main thread through a queue.Queue and pump() is the only code
that touches cmd.  pump() no longer calls step() for any job, and
MorphJob.join(timeout) waits for the worker.

The job's state, error, done_legs and snapshot now change under a lock:
step() never overwrites a terminal state (neither the 'running' change
nor its except path), every terminal transition goes through
_terminate(), and step() takes its own references to the snapshot so a
cancel that frees it mid-leg ends 'cancelled', not 'error'.  pump()
fails a job whose source was deleted with "morph: source <src> was
deleted" (partial deleted, record retained); a worker exception is
recorded on the job and finalised by pump() on the main thread.  Error
text drops CmdException's " Error: " label.

Tests synchronise through a _leg_hook seam (no sleeps) and cover async
completion, cancel between legs, cancel mid-leg, an exception after
cancel, source deletion and a worker exception.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The worker computed every leg back to back, so with pump() landing far
slower (and not at all headless) the whole morph's frames sat in the
queue as Python lists, about 160 B per atom-frame, three times the
memory estimate.  The worker now waits on job._room, a Condition on the
job lock, while _LEGS_AHEAD (1) legs are queued.  _unit notifies after
taking a leg; _terminate and _end notify, so a cancel or failure wakes a
waiting worker, and the wait releases the lock so pump and cancel never
block on it.

testWorkerStaysOneLegAhead pins both: leg 1 starts only after a pump
takes leg 0, and cancel() wakes a worker waiting for room.  The async
tests pump while they wait instead of joining first, and the worker
exception test fails leg 0, which needs no pump.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The limit counted only queued legs and pump notified on taking one, so
the leg being landed plus one queued leg were held: for a two-model
morph (two legs with loop=1) that is the whole morph.  The worker now
waits on job._held, the legs computed and not yet landed, guarded by
job._room: step() counts a queued leg, _land_frame releases it with a
notify once the leg's key frame has landed, and _end zeroes it.  One
leg of frames exists as Python lists at a time.

testWorkerHoldsOneUnlandedLeg checks leg 1 starts only once
landed_legs == 1 (not after the first frame lands) and that cancel
wakes a waiting worker; testTwoModelMorphHoldsOneLeg checks a two-model
morph computes at most one leg until leg 0 has fully landed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With the worker released only when a leg has landed, a pump call ended
at every leg boundary, so a small morph needed one pump call per leg
(8 calls for 8 legs, about 4 s at the app's poll).  pump() now waits on
the job's Condition for the leg a run=True worker is computing, but only
within what is left of its budget, which all jobs share, and never at
budget 0.  step() notifies when it queues a leg; terminal transitions
and _end already notify.  The wait releases the job lock and the GIL
and is outside every cmd call; run=False jobs are never waited for.
The one-unlanded-leg memory bound is unchanged.

Tests: a 6-leg morph lands in <= 3 pump(1000) calls; pump(0) never
waits and pump(200) waits exactly its budget while the worker is held
mid-leg; one budget is shared by two waiting jobs; a worker error wakes
a waiting pump.  testAsyncCancelMidway drops a pump(10**6) that would
now wait for the gated worker.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure-Swift value type covering all parameters consumed by morph_jobs.morph_object.
Includes UserDefaults persistence, a summary estimator, a pythonCall builder that
routes every string through InferenceJob.pythonLiteral, and MorphClipMapping /
MorphCompletion helpers. 10 unit tests in MorphSettingsTests cover all brief
cases (TDD RED→GREEN confirmed).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- PanelPayload: add morph_jobs ([String: PredictionJobState]?) and
  morph ([String: MorphInfoWire]?); add MorphSpecWire/MorphInfoWire wire types
- ObjectEntry: add morphSource: String? (set from payload.morph[name]?.source)
- PyMOLEngine: publish morphJobs, morphSources, morphSpecs; add private
  morphAutoPlay and runningMorphs tracking; add morph(source:settings:autoPlay:
  reuse:name:), cancelMorph(_:), morphDidComplete(_:), and
  completedMorphs(previouslyRunning:nowRunning:known:) static func
- ProgressItem: add morph(_:) factory (icon repeat, leg k of N · P%, Cancel/Dismiss)
- ProgressItem.tray: add morphs parameter (default []) appended to item list
- ContentView: pass engine.morphJobs to tray
- MorphEngineTests: TDD coverage for all of the above (6 tests, RED→GREEN)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The State row of a multi-state object gets a "Morph…" capsule after
Fit/Split/Sync (hidden while the object is a pending placeholder or a
morph of it is being built). It opens MorphSheet: frames per model, loop,
method, clean-up cycles and rate, with a live summary of frames, seconds
at the movie fps and the memory estimate (orange above the warn
threshold, Morph disabled above the hard limit). On a morph object the
sheet is pre-filled with its spec, rebuilds it under the same name and
offers "Delete morph". The state-count badge of a morph shows a repeat
glyph.

The estimate's atom count comes from a new `natoms` field in the
inspector's objmeta, decoded into ObjStateMeta.atomCount.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…morph

Found in the VM run. A 1200-frame morph's badge ("⟳ 1,200") and the
State row's counter ("656/1,200") wrapped onto two lines; both now take
their ideal width and the name / slider give up the room. "Delete morph"
on a playing morph left its per-object timer sending `set state` to the
deleted name 30 times a second (an "Invalid selection name" error per
tick); the sheet now stops the object's playback before deleting it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Completing a 1200-frame morph of 2kpo stalled the main thread for 3.3-3.9 s.
A spindump of the stall in the VM shows two causes; this is the core-side
half (1.8 s): the first frame after completion ran SceneUpdate ->
ObjectMolecule::update -> CoordSet::update for every state. The core builds
representations only for objects in the scene, and for an object with its
own `state` setting (per-object playback) it builds all states at once
(ObjectAdjustStateRebuildRange), so a morph that grew disabled left all
1200 states for one frame.

pump() now ends by putting the morph into the scene for one update phase
(_cmd.surface_pick_prepare with update=1, reps mask 0: the frame's update
phase and nothing else) and disabling it again; no frame is drawn while pump
runs. Each pump builds only the frames it landed, and the landing loop
reserves the measured build cost inside its budget. Skipped when the user
switched the morph on, or when defer_builds_mode is not 0 (the update would
build only the current state, and at >= 3 disabling purges reps).

Headless: the first update after completion drops from 1.47 s to 0.10 s;
pumps stay under 0.2 s. Test: testFramesAreBuiltWhileHidden reads which
states already have a cartoon (no build) and fails without this change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The other half of the 3.3-3.9 s completion stall (1.8 s in the VM spindump):
when the finished morph's card expanded, the State row's
Slider(in: 1...total, step: 1) became an NSSlider with 1200 tick marks, and
-[NSSlider layout] ran -[NSSliderTickMarks _rebuildTickMarkRectCache] several
times per layout pass, about 0.5 s each time, again on later relayouts.

The State row now uses StateSlider: stepped (a tick per state) up to 100
states, so NMR ensembles look as before; continuous beyond, with the binding
rounding to whole states and applying only integer changes, as before. iOS
draws no tick marks either way.

Test: StateSlider.step(forStates:). The AppKit cost itself shows only in the
running app (macOS 27 draws Slider in SwiftUI, with no NSSlider to inspect);
the VM re-check found no NSSlider work after completion.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…target

A per-object playback timer (`set state, k, obj` ~30 times a second) kept
firing after its object was deleted by any path other than "Delete morph" --
the A menu, a `delete` command, cancelling or failing a re-morph in the tray,
reinitialize -- and each tick logged "Invalid selection".

- The object-panel poll stops the timer of every playing object missing from
  the published object list: one place for every deletion path
  (PyMOLEngine.timersToStop, pure and tested).
- engine.morph(...) stops playback of its target before sending the rebuild,
  so a re-morph no longer steps through the partial object; completion
  restarts playback when auto-play is on. Tested on the live test-host engine
  (fails without the change).

In the VM: cancelling a re-morph of a playing morph logs no error; deleting
a playing morph with `delete` stops the timer at the next poll (10 lines in
the 0.5 s before it, then none; it used to continue indefinitely).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After a .pse reload Python has no job record, so Morph… on the SOURCE row
called morph_object(source) unnamed and Python built <source>_morph2 next to
the restored <source>_morph, while the sheet said "creates 2kpo_morph" and
auto-play and the capsule's running-job watch looked for 2kpo_morph
(reproduced in the VM with the unfixed build).

MorphSettings.morphTarget(card:source:objects:groups:morphSources:) now
resolves the one target that the sheet line, the capsule watch, auto-play
and the job use, and the card always passes it as `name`: the card itself
on a morph; <source>_morph on a source, including a loaded one, which
Python's explicit-name rule (convention, molecular object) rebuilds in place
(spec 5.2). A group of that name or a known morph of another source is not
this source's morph; then Python's fallback is mirrored (first
<source>_morphN that is free or a known morph of this source). When the
target is already loaded the sheet reads "rebuilds 2kpo_morph, hides 2kpo".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- (d) A morph made at the command line can carry frames_per_model=200 or
  refinement=20. The sheet laid that spec over the saved settings as is, so
  the Steppers showed values they cannot reach and pressing Morph saved them
  as the new default. MorphSheet.prefill(saved:existing:) clamps to the
  Steppers' ranges (2...120, 0...10, now shared constants); tested.
- (e) role: .destructive on a bordered button in a macOS sheet draws grey.
  On macOS 15 (VM probe of six variants) neither .tint(.red) nor
  .foregroundStyle(.red) on the button changes that; a red label does. The
  label is red under #if os(macOS); iOS keeps the system destructive style.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review finding on 2e176af: the landing loop reserved time for _prebuild,
but the wait for the worker's next leg still ran to the full deadline and
_prebuild then ran after it, and the first pump had no cost estimate at all.
A cartoon-shown 1200-frame morph of 2kpo (budget 100 ms) had pumps up to
0.251 s at Clean-up 0 and 0.193 s at Clean-up 3.

- A frame is landed only while landing it and building every frame the pump
  landed still fit in the budget (measured land and build costs); the wait
  for the next leg ends at that same reserved deadline.
- A job's first frame is built at once, so the first pump has a measured
  build cost. The estimate rises at once and falls by halves.
- Each leg's frames are built at its key frame, before the worker is
  released: the core takes the GIL once per morph state during the update
  (OrthoBusyFast at the end of CoordSet::update), so a build overlapping the
  worker's pure-Python leg ran 5-10x slower (thread CPU 9 ms in 100 ms wall).
  No build now overlaps a computing worker, and the completing pump leaves
  nothing for the first frame after completion.
- pump()'s docstring states the real bound: one unit of work plus the
  estimates' error.

Headless, 2kpo cartoon, 20 models x 60, async, budget 100 ms: worst pump
0.251 -> 0.115 s (Clean-up 0), 0.193 -> 0.113 s (Clean-up 3).
New test testPumpStaysInBudgetWithCartoon (1500-atom helix, cartoon) asserts
every pump < 1.5x budget; it fails on the previous code (0.290 s).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Controller ruling on the review (spec 5.1: `_morph2` only when the name is
taken by a non-morph). 81e569d always passed `<source>_morph` as the name,
which also rebuilt a same-session user molecule or CGO of that name.

MorphSettings.morphTarget now returns (name, explicit):
- a morph card: the card, named (re-morph in place);
- a source card: `<source>_morph`, named, only when that object exists, is
  not a known morph of this session (morphSources), is not a group and has
  more than one state: a morph a session reload brought back, which Python,
  without a job record, would otherwise skip for `_morph2`;
- otherwise no name: Python's registry decides, and the target mirrors its
  rule (first of `_morph`, `_morph2`, ... that is free or a known morph of
  this source), so a known morph is reused and a non-morph of that name
  gives `_morph2`.

The sheet line, the capsule's running-job watch and auto-play use the
resolved target; engine.morph(..., target:) keys auto-play and the playback
stop on it when no name is passed.

Tests: reloaded morph (named), known morph (unnamed, reused), one-state user
molecule and group of that name (unnamed, `_morph2`), foreign known morph.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add `StatesSpec.morphStride: Int? = nil` so a states clip authored for a
morph object stores the logical model range (firstModel/lastModel) rather
than absolute PyMOL state indices. At each `rebuildMovie()` call the model
indices are converted to absolute states via `MorphClipMapping.absoluteRange`
using the morph's CURRENT `framesPerModel` stride, so a re-morph with a
different stride keeps the clip covering the intended models.

- `StatesSpec.morphStride: Int? = nil` — nil = plain clip, unchanged behaviour
- `static func statesClipRange(spec:models:currentStride:) -> (first:last:)` —
  nil morphStride → passthrough; else absoluteRange with currentStride ?? morphStride
- `rebuildMovie` `.states` case: when morphStride != nil and single object,
  resolves models from morphSources → source stateCount, falling back to
  clip's own stateCount / stride; emits statesClipRange result as first/last
- `appendStatesClip` gains `morphStride: Int? = nil` (existing call sites unchanged)
- Three TDD tests: plain passthrough, morph remap (stride 15 → stride 10), full range sentinel

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Movie tab's Play-models sheet gains "Smooth transitions (morph)" (spec
5.7). On Add it resolves the morph name as the Object panel does, submits
morph_object with reuse (Python keeps a morph whose spec and source
fingerprint match), and appends a clip for the morph with morphStride, so
Start/End keep counting models. Loop is implied on; the disclosure holds
frames per model, method, clean-up and rate, shared with the Morph… sheet
through MorphSettingsControls. Duration follows the natural length until
the user steps it, and its range widens to fit it. The toggle is off for
"all models" and for a morph (this session's, a building one, or one a
session reload brought back), and remembers its state.

The decisions live in MorphMovie (pure, unit-tested). A morph clip's lane
label counts its source's models and carries the repeat glyph; the clip
menu's Motion/Duration edits no longer drop morphStride.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…' ids

Two defects the VM run found in the Smooth transitions sheet:

- A remembered toggle opened off at 8 s on a freshly built Movie panel.
  The sheet was a closure over TimelinePanel's own @State, and it saw only
  their initial values for state the panel's body never reads (logged in
  the VM: the Append action wrote smooth=1, f=10, 6.7 s; the sheet body
  read smooth=0, f=15, 8 s). The original sheet had the same flaw, hidden
  because the values it wrote equalled the defaults. The sheet is now
  PlayModelsSheet, which owns its state and initialises it when it is
  presented, as MorphSheet does.
- The identifier on the "Morph settings…" DisclosureGroup replaced the ids
  of every control inside it; it now sits on the group's label, which
  macOS merges into the disclosure triangle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add a "Movies & Playback" section to the command reference with
morph_object, morph_cancel, morph_dismiss and morph, a Morphing guide
(Object panel sheet, progress card, Movie tab smooth toggle, what is not
carried over, memory limits, command line), its sidebar entry after
Movies & Scenes, and a cross-link from the movies guide's multi-state
section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Rerunning morph_object rebuilds in place only for a morph built in this
  session; a restored morph needs name=<source>_morph, or _morph2 is built.
- A rebuild deletes the old morph at once, so cancelling or a failed build
  leaves no morph (guide and morph_cancel).
- Lockstep clips do not move a finished morph (its state is pinned); use
  Sweep or Loop, or Sync the row first.
- Refusal list gains the non-unique atom identifiers case; the memory limit
  is 1 GB everywhere except iPhone/iPad (400 MB).
- Document the name-collision rule, the explicit-name rule, natural Duration
  covering the whole morph, Add rebuilding a restored morph, Morph... hidden
  while building, the last key frame with Loop off, and the repeat icon.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	swiftui/PyMOLViewer/Shared/PyMOLEngine.swift
master's Timeline-in-session record (TimelineRecord.States) had no
morphStride, so a reloaded morph clip's Start/End (model indices) were
read as absolute states: the next rebuild played the wrong frames and
the lane lost its morph glyph.

- TimelineRecord.States gains an optional morphStride. timelineRecords
  writes it and timelineItems(from:) reads it back; a stride below 1 is
  treated as none on both sides. nil is omitted by the synthesized
  encoder (no key, not null), so plain clips encode exactly as before and
  older sessions decode unchanged.
- Python passes item dicts through untouched (stage_timeline,
  session_save, session_restore, _emit_timeline); a new test pins that a
  states item's morphStride survives save -> restore -> TIMELINE:ready.
- testing/tests/raymol/timeline_session.py was not in the CI run list
  (master's #901 added the file but not the entry), so none of its tests
  ran in CI: listed now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
javierbq and others added 9 commits October 26, 2026 20:57
A group player's ticks (`set state, k, <group>`) pin the objects inside
the group, not the group, so the save left their pins in the file. The
strip now treats a playing group as its members: the session's own group
links reach every member it holds (a CGO too), and the live group adds
its molecules for a partial save that holds a member without its groups.

Renaming a playing object left the timer's last pin on it: the renamed
object kept that pin live and in every later save, not only in a short
window. cmd.set_name now drops it on every rename path
(appkit_movie.object_renamed, which follows set_name's legalised name).
The Objects panel's rename also stops the player at once: PyMOL matches
an unambiguous name prefix, so when the new name extends the old one the
ticks at the old name would pin the renamed object again until the
panel poll. Pins on objects that are not playing stay (C2).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The sheet passed the card's atom count to the build-time hint. For a
discrete multi-state object that is every state's atoms (2kpo made
discrete: 37,200 = 20 x 1,860), so it read "about 9 min to build" where
2kpo itself reads "about 28 s"; morph_estimate counts state 1.

The panel poll now publishes morph_atoms_per_frame beside
morph_bytes_per_frame, from the same cached pass: morph_jobs.frame_cost()
returns (state-1 atoms, bytes) in one go, bytes_per_frame and
morph_estimate use it, and the inspector cache keeps both. Swift decodes
the optional key into engine.morphAtomsPerFrame, and the sheet takes it
through MorphSheet.buildAtoms(perFrame:objectAtoms:), falling back to the
card's count when an older bundled Python does not publish it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A Play-models clip centred its caption in the whole block, so a clip
longer than the lane showed only "⚠ 2kpo_m" at the reopen zoom (the VM's
700-frame Smooth clip), and one scrolled past its start showed nothing.
The caption is now leading-aligned, with the lane's padding, in the part
of the block the lane shows unfaded (PyMOLEngine.statesClipVisibleSpan):
the block intersected with the viewport inside its edge fades. The lane
keeps its scroll offset for this (a GeometryReader read with onChange: in
this panel onPreferenceChange never fired for a scroll), in an object the
panel holds without observing, so a scroll re-lays out only the captions.
The text form follows the visible width, not the block's.

Narrower than 160 pt, a clip that plays nothing now reads just "⚠ not
built" (the note up to its " · "); "morph <source> to fill" was cut off
there. The remedy stays in the tooltip and the context menu (which also
offers "Build <clip> from <source>").

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A clip with little of it on screen now reads just "not built"; the Morph
guide said only the long form.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Morph sheet's atom count: MorphSheet.buildAtoms now takes the
engine's maps whole (source, card, atomsPerFrame, objectMeta), so the
card's call site only passes them, and the test covers a discrete card
(objectMeta 20 times one model) and a morph's own card keyed by its
source.

A states clip's caption picks its form by what fits, not a fixed 160 pt:
statesClipCaptions gives "label - note", "label - reason", the reason,
and the lane draws the first that fits in a ViewThatFits. At 210 pt of
a not-built clip the old cutoff drew the whole text, cut off; it now
reads "<name> - not built".

A sliver of a clip's tail (less than the padding, glyph and an ellipsis)
counts as off screen, and the caption is clipped to its span, so it no
longer draws past the block over the next item.

TimelineClipCaptionLayoutTests hosts the real TimelinePanel, scrolls the
lane and finds the caption in the drawn panel (in-process AX exposes
almost none of it): at the block's start, at the lane's clear left edge
once the start is scrolled off, the middle and short forms, and no ink
past a sliver's block. It fails against the previous view (middle form,
sliver) and when the caption ignores the scroll offset.

_shown_reps' docstring names frame_cost, which the panel poll calls.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cene

`scene store` queues the thumbnail render with SceneDeferImage(...,
&scene.thumbnail): a raw pointer into the std::map node in
G->scenes->dict. Without a valid GL context the render waits on Ortho's
deferred queue for the next draw (headless: the next refresh that runs
deferred jobs; in the app: the next frame). reinitialize, a session load
and scene delete/clear/rename free that node first and leave the job
queued, so the job later did `m_data = std::move(png)` on freed memory:
"pointer being freed was not allocated" in the SceneDeferImage lambda,
or silent heap corruption. The bug is upstream's and on master too;
master's headless test runner just never runs deferred jobs.

SceneDeferImageTo keeps the image inside the job and hands it to a
callback. MovieSceneStore's callback finds the scene by stack and name
when it runs and drops the image if the scene is gone (a renamed scene
keeps its blank thumbnail). MovieSceneStoreNoStore, which has no
callers, had the same bug against a local it returns by value; it now
renders only when the context is valid.

testing/tests/raymol/scene_thumbnail_defer.py frees a scene each way
before its pending render runs, in process and in a Guard Malloc child
process where the old core faults every time (exit -11 for all five).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SceneDeferImage and OrthoDeferImage no longer take a pymol::Image*
out-pointer. Without a valid context they queue the render and write
through that pointer later, the shape of the freed-scene thumbnail bug.
Every remaining caller passed nullptr. A caller that wants the image
back must now use SceneDeferImageTo, whose receiver looks up the
destination when it runs. A caller that passes a pointer no longer
compiles. MovieSceneStoreNoStore (no callers) uses SceneDeferImageTo
and stays immediate-only.

scene_thumbnail_defer.py: only its Guard Malloc subtests catch the
use-after-free. The in-process subtests pass on the unfixed core too,
and the docstrings now say so. The Guard Malloc subtests still skip
where Guard Malloc cannot load. With RAYMOL_REQUIRE_GMALLOC=1 they fail
instead, so a hardened-runtime CI Python cannot switch the guard off
without anyone noticing. raymol-embedded-tests.yml sets it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	.github/workflows/raymol-embedded-tests.yml
With legacy scroll bars (a mouse attached, or GitHub's macOS runner),
SwiftUI's horizontal ScrollView puts a 17 pt scroller under its 84 pt
content, so the lane's NSScrollView is 101 pt tall and the caption
layout test's height check failed in CI. The geometry the test reads is
the clip view's, which is the same with either scroller style; checked
here under both (overlay forced with -AppleShowScrollBars WhenScrolling).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	swiftui/PyMOLViewer.xcodeproj/project.pbxproj

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Outstanding correctness bugs can starve estimate refreshes, freeze nested CGOs after reopening, overwrite preserved thumbnails, and target unrelated objects or silently ignore requested morph settings.

5 open issues
What changed in this PR

This PR adds smooth morph trajectories to RayMol’s existing multi-state object workflow, integrating creation, playback, session handling and MCP discovery. It also fixes a deferred scene-thumbnail use-after-free.

Changes:

  • Adds Morph settings, progress cards, object badges and smooth Timeline clips with model-to-state mapping.
  • Registers morph commands and exposes job status through MCP, with session and regression coverage.
  • Replaces deferred thumbnail output pointers with callback-based delivery and documents the feature.
File Description
testing/​tests/​test_mcp_tools.py Checks that session-state descriptions mention morph jobs.
testing/​tests/​test_mcp_native.py Tests morph status, command help and guide content.
testing/​tests/​raymol/​timeline_session.py Tests clip-stride persistence and playback-pin handling.
testing/​tests/​raymol/​scene_thumbnail_defer.py Adds deferred-thumbnail lifetime regression tests.
testing/​tests/​raymol/​morph_panel.py Tests panel payloads, estimates and refusal cards.
swiftui/​PyMOLViewerTests/​LightsModeTests.swift Tests Timeline morph-stride serialization.
swiftui/​PyMOLViewer/​Shared/​ProgressTray.swift Adds morph progress cards and actions.
swiftui/​PyMOLViewer/​Shared/​MorphSettings.swift Defines preferences, estimates, target resolution and clip mapping.
swiftui/​PyMOLViewer/​Shared/​ContentView.swift Displays morph jobs and releases active playback pins for authoring.
swiftui/​PyMOLViewer/​Panels/​TimelinePanel.swift Adds smoothing controls, missing-object captions and rebuild actions.
swiftui/​PyMOLViewer/​Panels/​ObjectPanel.swift Adds morph controls, badges, payload handling and scalable sliders.
swiftui/​PyMOLViewer/​Panels/​MorphSheet.swift Adds shared morph controls and memory-aware summaries.
modules/​raymol_mcp/​tools.py Updates the session-state tool description.
modules/​raymol_mcp/​native.py Reports morph jobs in RayMol session state.
modules/​raymol_mcp/​guide.py Documents morph commands and polling behavior.
modules/​pymol/​keywords.py Registers the three morph commands.
modules/​pymol/​editing.py Releases player pins after object renames.
modules/​pymol/​commanding.py Resets morph jobs during full reinitialization.
modules/​pymol/​cmd.py Registers morph session-save and restore hooks.
modules/​pymol/​appkit_theme_preview.py Preserves player pins during Theme studio snapshots.
modules/​pymol/​appkit_movie.py Tracks active players and omits transient pins from saved sessions.
modules/​pymol/​appkit_inspector.py Pumps morph jobs and publishes cached estimates and status.
modules/​pymol/​api.py Exposes morph job commands through the Python API.
layer4/​Cmd.cpp Updates PNG dispatch for the revised image API.
layer3/​MovieScene.cpp Delivers deferred thumbnails through scene-name lookup.
layer3/​Executive.cpp Updates drawing calls for the revised image API.
layer1/​Scene.h Declares callback-based image delivery.
layer1/​Scene.cpp Keeps deferred image storage inside the render job.
layer1/​Ortho.h Removes the deferred image output-pointer parameter.
layer1/​Ortho.cpp Adapts deferred rendering to the revised interface.
docs/​superpowers/​specs/​2026-10-21-morph-design.md Records feature design and verification requirements.
docs/​src/​content/​docs/​reference/​commands.md Documents morph command syntax and behavior.
docs/​src/​content/​docs/​guides/​movies.md Links movie authoring to the morph workflow.
docs/​src/​content/​docs/​guides/​morph.md Explains morph creation, playback, limits and scripting.
docs/​src/​content/​docs/​guides/​mcp-setup.md Adds morphs to the documented session-state response.
docs/​astro.config.mjs Adds the Morphing guide to navigation.
.github/​workflows/​raymol-embedded-tests.yml Adds regression suites and clarifies Guard Malloc requirements.

Review effort: Balanced

Comment thread layer3/MovieScene.cpp Resolved
Comment thread modules/pymol/appkit_inspector.py Resolved
Comment thread modules/pymol/appkit_movie.py Resolved
javierbq and others added 9 commits October 27, 2026 15:29
In object-list order, the first few expired figures re-expired in time to
take every poll's refresh, so with five or more sources that each cost
more than the per-poll budget, a later object's figure never refreshed:
the Morph sheets kept a stale memory estimate and tier after a rep or
atom edit the signature does not see. (Copilot review on #918.)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A partial save of a CGO two group levels under a playing group held
neither group, and the live-group fallback was an atom selection, which
never reaches a CGO: the player's pin was saved and the CGO reopened
frozen. A playing group the session lacks now adds its members of every
type from a raw core read (no session-save tasks re-run). (Copilot review
on #918.)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The deferred thumbnail render found its scene by name alone, so after
`scene A, delete` and `scene B, rename, new_key=A`, or a session load,
the render queued for the old A overwrote B's thumbnail (or filled the
loaded A's). Each store now gives its render a ticket; the render lands
only if the scene under its name still holds it. The counter is never
reset, so a render queued before a reinitialize matches no later scene.
(Copilot review on #918.)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The resolver named `<source>_morph` explicitly for any non-group object
with more than one state. An alignment's name selects atoms, so it
reports states too: the sheets then sent a name Python's molecule-only
rule refuses, and the Movie path added a clip playing the alignment. The
resolver now also requires a multi-state molecule (the keys Python
publishes in morph_bytes_per_frame), and a card shows Morph… only for
one. CGOs and maps report no states, so they already went to _morph2.
(Copilot review on #918.)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With Smooth on, Add in the Play-models sheet appended a clip of a morph that
was still being built (from the Object panel or an earlier Add) and sent no
job, so the clip played whatever that build made: possibly Loop off or
another rate than the sheet asked for. Python refuses a second job on the
same target, so Add cannot rebuild it either. Add is now disabled while that
morph builds, with "<obj>_morph is still being built · Add once it is done"
under the toggle, and re-enables when it finishes; then the reuse rule keeps
the morph if it matches and rebuilds it otherwise. (Copilot review on #918.)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
_group_members asks the core for a partial session of the playing groups
only to read their member names, but under the default pse_binary_dump
setting that serialised every member's data as Python lists. It now asks
for a binary dump at the current version, whatever the user's pse
settings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Play-models object menu lists every object that reports states, which
includes a group or an alignment (their names select atoms). With Smooth
on, Add then appended a clip of a morph Python refuses to build. The toggle
is now unavailable for any target that is not a multi-state molecule ("Only
a molecule can be smoothed"), as the Object panel's Morph… already is.

Docs follow the last two fixes: the guide no longer says CGOs and maps
offer Morph… (non-molecules never do; morph_object refuses them), a
source is a molecular object, and the waiting-Add sentence names the morph
Add would build rather than a reusable one; the spec's capsule and toggle
rules match the code. The frame-cost comments no longer claim the keys are
exactly the multi-state molecules: one whose figure fails drops out until
its next one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…the code

A docs-readiness audit of every morph documentation surface, each finding
checked by a skeptic, found these inaccuracies:

- Guide: auto-play is off only while the timeline is expanded (on iPhone,
  while the Movie tab is open); on Mac and iPad a morph that finishes
  while the Movie tab shows does start playing. The iPhone/iPad memory
  levels change as RayMol's own session grows, not with other apps. Tray
  cards read "Morph cancelled: <name>" / "Morph failed: <name>". Counting
  cartoon residues as helix relies on auto_dss being on.
- help morph_object / morph: rate values are ramp_up / ramp_down (the
  quoted "ramp up" form fails from the command line); async=1 never
  completes outside the app; the <source>_morph2 fallback and which
  existing objects a name may replace; morph's hide argument; steps is
  states per leg; morph refuses any existing non-molecule name.
- commands.md: the same name rule for morph, the full cancelled-card
  title, and refusal records listed as "<name> (refused)".
- MCP GUIDE: the morph may be named <source>_morph2; find the job by its
  source; a refused morph is listed with status error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Five screenshots of the macOS app, captured from the PR build in a
disposable VM: the Morph… button on the State row, the Morph sheet, a
build in progress (the tray card with Cancel, the switched-off morph row
filling in), the finished morph playing with its Name line, and the
Play-models sheet with Smooth transitions on. Full window, dark theme,
transparent rounded corners, 1440 px wide, as the other guides' shots.

Every label and figure in them matches the text the guide quotes; the
leg example now reads leg 3 of 20 · 15% like the screenshot, the
settings table says the method switch has no label, and the summary is
noted as orange in the shots (867 MB is over that Mac's warning level).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A Play-models clip placed after other items (a Roll, say) played its object
outside the clip: only the clip's two ends were keyed, and `mview
interpolate` wraps across the loop seam when movie_loop is on, so the frames
before the clip ran the models backwards. Plain clips did the same; the code
has been on master since July.

Every per-object model track (Sweep/Loop clips, camera-capture holds, the
no-clip auto-sweep) now goes through one writer, _store_state_track. It
keys frames 1 and the movie's end, holding a clip's first model before it,
its end model after it and between clips. It re-stores the object's scene
keyframes with the scheduled model and the scene's Move-mode position, since
a per-object store also writes the live TTT and the object's own state. It
stores with movie_auto_store off (set_object_ttt otherwise auto-stores a
model-less key at the current frame) and reinterpolates the whole track.
Groups named by a clip become their member molecules. One-state objects the
scenes move hold the first and last scene's positions too, so a ligand stays
with its ensemble. As a side effect, scenes-only lanes keep an ensemble's
Move-mode motion, and models no longer move during scene transitions after
playback.

A stopgap: the camera still wraps (it drifts back to the first scene during a
clip that follows scenes), a key between two Move-mode scenes holds the earlier
scene's position, and a model ramp can kink at a scene frame. Parallel
timeline events with hold semantics are proposed in #920.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Active issues can leave renamed objects pinned to a state, disrupt interpolated transforms when model keys are added, and exclude non-molecular group members from Sweep/Loop animation.

3 open issues
5 resolved since last review

Review effort: Balanced

Comment thread modules/pymol/appkit_movie.py Resolved
Comment thread modules/pymol/appkit_movie.py Resolved
Comment thread modules/pymol/appkit_movie.py Resolved
Copilot review on #918:

- A player renamed by set_name kept ticking `set state, k, <old>`, which
  PyMOL resolves as a prefix of the new name, re-pinning it until the poll
  stopped the timer. The rename is now remembered: stopping that player
  releases the renamed object's pin, and saves meanwhile leave it out.
- A clip naming a group now plays every member, CGOs and maps too
  (_group_members), not only its molecules.
- A model key inside a scene transition holds the earlier scene's position
  (stopgap, #920). Every object the scenes move is now keyed at the same
  frames with the same step, so an ensemble and its ligand moved together
  keep together. Keeping the interpolated move exactly needs the core change
  proposed in #920. Scene-moved objects with no model track hold the same way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@javierbq
javierbq merged commit 25d419e into master Oct 29, 2026
7 checks passed
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.

2 participants