Mode-driven workflows
Modes are product-facing viewer workflows. Each mode packages the route, layout, display rules, viewing protocol, user controls, and extension dependencies needed to move a supported study from a data source to a focused viewing experience. This model lets the application share its viewer shell while different modes serve general review, longitudinal comparison, segmentation, microscopy, quantitative analysis, or annotation tasks.
Mode model
Mode contract
A mode is a named workflow definition that tells the application how to enter, validate, and leave a viewing task. Its contract links a route to a layout, a hanging protocol to a study, and the display-set handlers and extensions that make the resulting view usable. The mode can also provide lifecycle hooks for workflow-specific setup and cleanup. platform/…/appInit.js creates configured mode instances before the router is built, while modes/…/index.tsx shows the shared shape used by a general viewer mode.
The main parts of the contract are:
- Identity: A stable mode ID and route name make the workflow addressable.
- Study validity: A rule decides whether a study belongs in the mode. Rules can require modalities, reject modalities, or exclude known study types.
- Route and layout: A route selects the entry path and returns the panels and viewports for the workflow.
- Viewing protocol: A hanging protocol selects the display sets and their initial arrangement.
- Display handling: SOP class handlers turn supported DICOM objects into display sets that the layout can show.
- Extension dependencies: Named extensions supply the panels, viewports, tools, protocols, data sources, and commands used by the mode.
- Lifecycle behavior: Entry and exit hooks prepare workflow state and return shared services to a clean boundary.
References: platform/…/appInit.js• L135-187 modes/…/index.tsx• L106-163 modes/…/index.tsx• L307-372
Mode inheritance
Modes can reuse a base workflow and replace only the parts that make the product task different. Longitudinal viewing builds on the basic layout and dependencies, while segmentation reuses the basic lifecycle and changes the panels, tools, validity rule, and protocol. A mode factory applies deployment configuration to the mode definition so a site can create a focused variant without copying the full workflow.
This relationship keeps common viewer behavior in one place. A change to a shared base mode can affect every extending mode, while a new layout or validity rule stays within the specialized workflow that owns it. The related basic and longitudinal viewing page describes those general review modes in detail.
References: modes/…/index.ts• L1-16 modes/…/index.ts• L28-74 modes/…/index.tsx• L1-15 modes/…/index.tsx• L131-141
Workflow assembly
Capability dependencies
Extension dependencies form the capability boundary of a mode. A mode declares the shared and task-specific packages it needs, then refers to their registered modules by qualified IDs instead of coupling its layout or controls to a concrete component import. The application can therefore load the workflow as a coherent product unit. The extension ecosystem provides the capabilities that these mode boundaries assemble.
The dependency set must cover the whole user path. A mode that accepts a data type needs a handler to create its display set and a viewport that can render it. A panel or toolbar reference also needs its providing extension to be registered before the mode enters. The basic mode provides the shared imaging foundation. Development and test variants reuse that foundation while adding only the capabilities needed for their environment. Other packages add measurement tracking, microscopy, dynamic volumes, tumor-volume analysis, or ultrasound annotation.
The package boundaries show how each workflow owns its capability set:
- Basic mode declares the common viewer and DICOM display capabilities, including segmentation and radiotherapy support.
- Basic development mode keeps the common viewer set for development use.
- Basic test mode reuses the basic mode and adds measurement-tracking and test capabilities.
- Longitudinal mode adds measurement tracking and reuses the basic mode.
- Segmentation mode reuses the basic mode for focused labelmap and contour work.
- Microscopy mode uses a dedicated microscopy extension rather than the general imaging set.
- Preclinical 4D mode combines dynamic-volume, segmentation, and tumor-volume capabilities.
- TMTV mode reuses the basic mode and adds measurement tracking and tumor-volume analysis.
- Ultrasound annotation mode packages its viewer core, Cornerstone runtime, ultrasound annotation, and DICOM structured-report capabilities directly with the mode.
Microscopy and preclinical 4D expose their task capabilities through their own extension sets rather than through the basic mode. Ultrasound annotation carries its core and annotation extensions directly for its own workflow. This distinction lets a mode either use capabilities supplied by the host or carry the capabilities that define its product task.
These boundaries are package contracts, not only install-time choices. A package that is present but is not available to the mode at route entry cannot provide the modules that the workflow names. Most modes declare host-provided viewer and extension packages as peer dependencies. Basic-test mode directly depends on the basic mode because it reuses that workflow. Longitudinal, segmentation, and TMTV declare the basic mode as a peer dependency because their host supplies the base workflow. The ultrasound annotation mode packages its viewer core, Cornerstone runtime, structured-report support, and annotation extension directly for its own workflow.
References: platform/…/appInit.js• L54-81 platform/…/appInit.js• L93-129 modes/…/index.tsx• L23-104 modes/…/package.json• L27-39 modes/…/package.json• L31-41 modes/…/package.json• L31-45 modes/…/package.json• L31-46 modes/…/package.json• L33-39 modes/…/package.json• L31-40 modes/…/package.json• L33-46 modes/…/package.json• L32-45 modes/…/package.json• L31-38
Layout composition
A mode layout is the visible shape of the workflow. It assigns panels to side regions and maps display-set types to viewport types, so the viewer can present the study in a form that fits the task. The layout template supplies the shared viewer frame; the mode supplies the workflow-specific panel and viewport choices.
The route keeps these choices separate from data retrieval. This means a mode can use the common viewer shell while changing the left and right panels, the number of viewports, the initial closed state, or the viewer used for a display-set type. The basic, longitudinal, and segmentation layouts show how related workflows vary these choices without creating a new application route system.
References: platform/…/Mode.tsx• L177-218 platform/…/Mode.tsx• L446-469 modes/…/index.tsx• L256-301 modes/…/index.ts• L28-46 modes/…/index.tsx• L36-60
Protocol mapping
A hanging protocol is the mode's viewing plan. It matches the study and its display sets, then chooses which data appears in each viewport and which stage starts first. The mode selects the default protocol, while an allowed URL value can select a valid protocol or stage for a particular viewing session.
The route starts protocol matching after it has enough display sets to make a useful plan. It can load the series needed for the first match before it starts the rest, then applies the plan again as more display sets arrive. This keeps initial viewing responsive while allowing the final layout to reflect the complete study.
References: platform/…/Mode.tsx• L292-320 platform/…/defaultRouteInit.ts• L29-55 platform/…/defaultRouteInit.ts• L118-155
Interaction composition
Toolbar groups, tools, panels, and workflow steps turn a mode's data view into a user task. The mode selects the capability packs that appear in the toolbar and initializes the tool groups that give those controls meaning in each viewport. Specialized modes can add workflow steps or event links when a task needs more than a static viewing plan.
Customization provides a controlled overlay on this composition. The route seeds the mode's layout and control choices, then applies app-level and URL-approved mode changes. The result lets a deployment extend a workflow without changing the mode's core definition, while the mode remains the owner of its required capabilities and lifecycle.
References: platform/…/Mode.tsx• L230-290 platform/…/Mode.tsx• L315-365 modes/…/modeCustomization.ts• L1-210 platform/…/WorkflowStepsService.ts• L1-180
Route lifecycle
Route entry
Mode route entry converts a URL and a selected data source into a ready viewer workflow. The router creates a route for each loaded mode and available source, then ModeRoute loads the mode's dependencies before it asks the source for study IDs and the mode for its layout.
When a study is ready, the route applies mode customizations, selects the active protocol and stage, runs mode-specific entry work, retrieves metadata, builds display sets, and starts protocol matching. It then renders the chosen layout inside the shared image-viewer and extension contexts.
This diagram shows how a mode turns a route into a product workflow.
flowchart TD
URL[Mode route and query] --> Route[Mode route]
Route --> Deps[Mode extension dependencies]
Deps --> Source[Selected data source]
Source --> Study[Study IDs and metadata]
Study --> Sets[Display sets]
Sets --> Protocol[Mode hanging protocol]
Protocol --> Layout[Mode layout]
Layout --> Viewer[Shared viewer workflow]
Route --> Hooks[Mode entry hooks and customizations]
Hooks --> Layout
References: platform/…/buildModeRoutes.tsx• L4-22 platform/…/buildModeRoutes.tsx• L42-86 platform/…/Mode.tsx• L90-218 platform/…/Mode.tsx• L225-378
Route exit
Mode exit is the boundary that stops one product workflow from affecting the next. The route calls the mode's exit hook first so the mode can save or release its own state, removes route subscriptions, clears hotkeys, and then asks the extension manager to reset mode-scoped extension state.
The cleanup contract matters because tools, panels, protocols, dialogs, and viewport state are shared services. A mode that leaves one of these active can expose controls from the old task or send later events to objects that no longer exist. The basic mode provides the common cleanup pattern for its imaging services.
References: platform/…/Mode.tsx• L392-418 modes/…/index.tsx• L235-254 platform/…/ExtensionManager.ts• L359-381
Workflow families
General diagnostic viewing
The basic and longitudinal modes provide the broad image-review workflows. Basic viewing presents a general study with common image, report, video, segmentation, radiotherapy, and microscopy-related display support. Longitudinal viewing keeps the general review model but replaces key panels and the primary image viewport with measurement-tracking support for comparison across time.
Read basic and longitudinal viewing for the study-review and comparison behavior built on this mode model.
References: modes/…/index.tsx• L256-372 modes/…/index.ts• L16-67 modes/…/package.json• L27-39 modes/…/package.json• L31-46
Specialized clinical viewing
Specialized modes narrow the entry rules and assemble controls around one clinical task. Segmentation mode joins source images with editable labelmap and contour views. Microscopy mode requires SM studies and joins whole-slide viewing with related measurements and derived objects.
Read segmentation and microscopy modes for these focused workflows. Their layouts and dependencies show how a mode can specialize the common viewer without changing the route lifecycle.
References: modes/…/index.tsx• L36-118 modes/…/index.tsx• L71-130 modes/…/package.json• L33-46 modes/…/package.json• L33-39
Quantitative and annotation workflows
Quantitative and annotation modes turn the viewer into a task-specific measurement or mark-up workflow. The preclinical 4D and TMTV packages add support for dynamic-volume and tumor-volume work, while the ultrasound annotation package adds image annotation support. Each package brings the extensions needed for its product task instead of making the general viewer own those capabilities.
Read quantitative and annotation modes for these focused workflows. They use the same mode assembly model as diagnostic viewing, but their dependency sets point to task-specific analysis and annotation capabilities.
References: modes/…/package.json• L31-40 modes/…/package.json• L32-45 modes/…/package.json• L31-38
Change checklist
When these files or sections are changed, remember to consider these:
- When a module ID changes, update the mode dependency set, layout references, protocol display-set references, and any toolbar or panel references that use the old ID.
- When a mode accepts or rejects a study differently, check that its handlers and viewports can support every newly valid data type.
- When a layout changes, check the matching hanging protocol stages because viewport count and viewport type are part of the same contract.
- When a mode adds an entry subscription or service change, add its exit cleanup before another mode can reuse the shared service.
- When customization keys or scope order changes, check both the mode defaults and app or URL overrides. A valid override can still produce an unusable workflow if it replaces a required panel or control.
- When a mode dependency version or package boundary changes, check the qualified module IDs and the module registration order that the mode uses during route entry.
- When a mode package moves a workspace package between peer and direct dependencies, check that every required shared or task-specific extension remains available to the mode at route entry.
- When a workflow moves a capability between peer dependencies and direct dependencies, check that the application still registers that capability as a mode extension rather than only installing its package.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A mode references a panel, viewport, handler, or protocol ID that its dependencies do not register | Route setup cannot assemble the intended workflow or a display set has no compatible viewer | Keep dependency declarations and qualified module references aligned. platform/…/Mode.tsx• L90-107 |
| A validity rule accepts a study without a compatible source display set | The mode opens with empty or unusable viewports | Make validity rules match the handlers and viewports declared by the mode. modes/…/index.tsx• L117-163 modes/…/index.tsx• L76-83 |
| A layout viewport and protocol stage use different display-set or viewport types | The protocol match cannot place the expected data in the intended pane | Treat layout mappings and protocol definitions as one workflow contract. modes/…/index.tsx• L36-59 platform/…/defaultRouteInit.ts• L33-55 |
| A required series is not retrieved before the first protocol run | The initial view misses the data needed to select or populate the opening layout | Let route initialization filter required series and wait for them before matching. platform/…/defaultRouteInit.ts• L136-154 |
| A mode leaves tools, subscriptions, or viewport state active on exit | The next workflow shows stale controls or receives events from the old mode | Pair every mode-entry side effect with mode-exit cleanup. platform/…/Mode.tsx• L392-418 modes/…/index.tsx• L235-254 |
Key files
| File | Why to read it |
|---|---|
| platform/…/appInit.js | Shows how configured modes become loaded instances and how their dependencies enter the application registry. |
| platform/…/buildModeRoutes.tsx | Shows how mode identities and data sources become protected viewer routes. |
| platform/…/Mode.tsx | Shows the shared mode entry, composition, protocol, render, and exit lifecycle. |
| platform/…/defaultRouteInit.ts | Shows how retrieved study metadata becomes display sets and the first protocol match. |
| modes/…/index.tsx | Defines the common mode shape and the broad diagnostic workflow used as a base by other modes. |
| modes/…/modeCustomization.ts | Shows how a base workflow exposes controlled layout and control changes. |
| modes/…/package.json | Shows the shared capability boundary for the general viewer workflow. |
| modes/…/package.json | Shows a development variant that reuses the basic viewer capabilities. |
| modes/…/package.json | Shows a test-oriented variant that adds test and measurement capabilities to the basic mode. |
| modes/…/index.ts | Shows how a mode extends the basic workflow for tracked comparison. |
| modes/…/index.tsx | Shows how a focused clinical mode changes validity, panels, tools, handlers, and protocol choice. |
| modes/…/index.tsx | Shows how a modality-specific mode pairs whole-slide data with a dedicated layout and measurement support. |
| modes/…/package.json | Shows the capability boundary for a dynamic-volume workflow. |
| modes/…/package.json | Shows how a quantitative tumor-volume workflow combines the basic mode with measurement and analysis support. |
| modes/…/package.json | Shows the direct dependency boundary for an ultrasound annotation workflow. |
| platform/…/ExtensionManager.ts | Shows the registry boundary that resolves mode extension dependencies and mode lifecycle hooks. |