Skip to content

Add expand modifier to pipeline#6

Merged
Roy-Kid merged 1 commit into
masterfrom
evaluate-or-refactor-expand-modifier-design
Jun 11, 2025
Merged

Add expand modifier to pipeline#6
Roy-Kid merged 1 commit into
masterfrom
evaluate-or-refactor-expand-modifier-design

Conversation

@Roy-Kid
Copy link
Copy Markdown
Owner

@Roy-Kid Roy-Kid commented Jun 11, 2025

Summary

  • support expanding selection by neighboring atoms
  • fix return value of Pipeline.modify

Testing

  • npm test -w core (fails: Module @swc/jest in the transform option was not found)

https://chatgpt.com/codex/tasks/task_e_68499033cf5c8324be267d6a8505ef8b

@Roy-Kid Roy-Kid merged commit f0a4cb3 into master Jun 11, 2025
@Roy-Kid Roy-Kid deleted the evaluate-or-refactor-expand-modifier-design branch August 11, 2025 19:02
Roy-Kid added a commit that referenced this pull request Apr 16, 2026
Core engine:
- Thin-instance rendering with ImpostorState GPU buffer management
- Command system with full undo/redo (DrawFrame, UpdateFrame, Clear, etc.)
- 5 interaction modes: View, Select, Edit, Manipulate, Measure
- Modifier pipeline: expression select, color-by-property, hide/delete, transparency, wrap PBC
- Smart trajectory playback with FrameDiff (position-only vs full rebuild)
- Ribbon rendering for protein secondary structure (PDB HELIX/SHEET)
- Bond order display (single/double/triple as parallel cylinders)
- Picker system with ID-pass off-screen rendering

File format support:
- PDB, XYZ, LAMMPS data/dump via @molcrafts/molrs WASM
- Export to XYZ

Web app (React 19):
- Three-panel layout with resizable panels
- Analysis tools: RDF, MSD, cluster, topology, scatter plot, histogram
- Per-atom labels, data inspector, property coloring
- Fence (lasso) selection, expression-based selection

VSCode extension:
- Custom editor for .pdb/.xyz/.data files
- Standalone viewer panel with message-based communication

Infrastructure:
- Monorepo with npm workspaces (core, page, vsc-ext, python, electron)
- CI pipeline: parallel lint/test/build with GitHub Actions
- Pre-commit hooks via Python pre-commit framework
- Biome for linting and formatting
- rstest for testing (287 tests)
Roy-Kid added a commit that referenced this pull request Apr 16, 2026
master's PR #6 (v0.0.3) is a squash of earlier dev history; dev already
contains that content as individual commits plus later features. Using
-s ours to retain dev's newer tree while recording master as a parent,
making dev fast-forwardable to master.
Roy-Kid added a commit that referenced this pull request Apr 29, 2026
Phase 1, task #5 of multi-data-source-pipeline spec.

Two new public methods on MolvisApp:

- `addDataSource(ds)`: appends a DataSourceModifier to the pipeline.
  TrajectoryDataSource frame counts must match every existing
  TrajectoryDataSource (throws with concrete numbers otherwise);
  FrameDataSource is always safe to append (it broadcasts across the
  system's frame count). When the new DS is the first
  TrajectoryDataSource, System adopts its trajectory so navigation
  events keep flowing. applyAutoAttach runs against the DS's frame 0
  to install default Draw modifiers (DrawAtom / DrawBond / DrawBox)
  for new block kinds the source contributes.

- `removeDataSource(id)`: cascade-removes via the existing
  pipeline.removeModifier path, calls dispose() on each removed DS to
  free WASM resources. Removing a TrajectoryDataSource re-derives
  System: if another TrajectoryDataSource remains, System adopts it;
  otherwise System collapses to a single empty frame so navigation
  state stays consistent. Per the spec's 1a "delete = rebuild"
  semantics, applyPipeline runs after.

Both methods route through applyPipeline at the end so the rendered
scene stays in sync. The pipeline's phase A handles the actual block
merge; these methods just manage DS lifecycle around it.

Task #6 wires the io loaders to use addDataSource for
second-and-later file loads (the multi-DS user flow). For now,
existing legacy paths (setTrajectory + ensureDataSource) remain
untouched and keep producing single-DS pipelines.

All 445 core tests pass.
Roy-Kid added a commit that referenced this pull request Apr 29, 2026
Phase 1, task #6 of multi-data-source-pipeline spec.

`loadFileContent` and `loadFileStream` gain an optional `mode`
parameter (`"replace" | "append"`, default `"replace"` to preserve
existing UX). In append mode they apply the spec's load decision tree:

- Single-frame file (`N_file === 1`) → wrap as `FrameDataSource` and
  broadcast across whatever trajectory length the pipeline already has
  (or stay at 1 if there's no trajectory yet).
- Multi-frame file matching the existing trajectory length (or no
  existing trajectory) → wrap as `TrajectoryDataSource` so phase A
  index-aligns frame-by-frame.
- Frame-count mismatch → throw `Cannot append "<filename>": file has
  N frame(s); existing trajectory has M. File must be single-frame
  (topology) or match existing frame count.`

A new internal helper `appendTrajectoryAsDataSource` runs the decision
tree and adds an atom-count consistency check: if both the existing
system and the new file contribute an `atoms` block, their atom
counts must match (otherwise downstream bonds/selection indices would
dangle). Then forwards to `MolvisApp.addDataSource`, which performs
the redundant frame-count check and runs auto-attach.

Trajectory disposal on error stays correct: append mode disposes the
trajectory if validation throws, so failed loads don't leak WASM.

Replace mode is unchanged — keeps using `ensureDataSource` +
`setTrajectory`, which after task #3+#4 also routes through a
TrajectoryDataSource transparently. Page UI stays single-DS until the
phase-3 "Add Data Source" button passes `mode: "append"`.

All 445 core tests pass.
Roy-Kid added a commit that referenced this pull request Apr 29, 2026
…s, append on drop

Phase 3 of multi-data-source-pipeline spec.

Sidebar / pipeline list:
- New "Add Data Source" button next to the "Add modifier" dropdown.
  Opens the format picker (same as drag-drop / per-DS panel) and calls
  loadFileSmart in append mode if the pipeline already has a DS,
  replace otherwise. First-load case routes through replace transparently.
- Each pipeline tree row for a DataSourceModifier now shows
  `<filename> · Trajectory · N frames` or `<filename> · Topology · 1 frame`
  so the user can tell trajectory vs topology DSs at a glance.

Drag-drop:
- MolvisWrapper drag-drop handler checks whether any DataSourceModifier
  is already in the pipeline and switches between replace (empty
  system, first load) and append (additive) automatically.

Per-DS panel (DataSourceModifier.tsx):
- Removed the deprecated showAtoms/showBonds/showBox visibility
  toggles. Their job is now done by the auto-attached DrawAtom /
  DrawBond / DrawBox children's `enabled` checkboxes (phase 2 nests
  them under the DS in the pipeline tree).
- New compact summary card shows kind badge, sourceType label,
  filename, and the contributedBlocks list ("atoms, bonds (default)"
  fallback when not explicitly set).
- New per-DS Remove button calls `app.removeDataSource(modifier.id)`
  via the lifecycle method introduced in phase 1 task #5 (cascade-
  removes child Draws, disposes WASM, re-derives system trajectory).

Plumbing:
- `loadFileSmart` / `loadFileWithFormatPrompt` /
  `loadFileStreamWithFormatPrompt` gain a `mode: "replace" | "append"`
  parameter, default `"replace"`. Threads through to the core io
  loaders' append branch (introduced in phase 1 task #6).

No core test changes — page UI doesn't have a unit-test harness.
Page typecheck clean (the pre-existing `FileSystemSyncAccessHandle`
errors in OPFS streaming code are unrelated). Core 474 tests still pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant