fix: Several new worklist issues (#6130)

* fix: Several new worklist issues

* refactor: Export a single OnStudyDoubleClick type from the StudyList barrel

Addresses PR review feedback: the double-click handler signature was
written out in both TableProps and the WorkList customization cast,
so the two could drift apart.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* feat: Run worklist study double-click as a command, registrable by modes

- Modes can now export getCommandsModule on their definition; appInit
  registers it (via the new ExtensionManager.registerCommandsModule)
  before the mode is instantiated, in a new 'WORKLIST' commands context,
  so the commands are available on the worklist before any mode route
  is entered.
- The workList.onStudyDoubleClick customization is now a command run
  input (name/options) instead of a bare function, defaulting to the
  new launchDefaultMode command, which launches the default workflow
  falling back to the first applicable one. commandOptions.workflowId
  overrides it to a specific mode.
- Duplicate mode ids are now skipped before running their modeFactory
  rather than after.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Bill WallaceandClaude Fable 5 authored and GitHub committed 2026-07-10 08:16:16 -04:00
1 parent dbb8b1526e
commit 6b6761088b
11 files changed
+230 -27

No files matched your search

+31
View File
@@ -842,6 +842,33 @@ const commandsModule = ({
}
};
},
/**
* Launches a workflow (mode) for a study from the worklist. This is the
* default `workList.onStudyDoubleClick` command.
*
* @param study - the StudyRow the action applies to
* @param workflows - the workflows applicable to the study, in menu order;
* each has `id`, `displayName`, `isDefault` and `launchWithStudy(study)`
* @param defaultWorkflow - the user's default workflow when it applies to
* the study
* @param workflowId - command option to force a specific workflow (mode id)
* instead of the default/first applicable one
*/
launchDefaultMode: ({ study, workflows = [], defaultWorkflow, workflowId }) => {
const workflow = workflowId
? workflows.find(w => w.id === workflowId)
: (defaultWorkflow ?? workflows[0]);
if (!workflow) {
console.warn(
workflowId
? `launchDefaultMode: workflow '${workflowId}' is not applicable to the study`
: 'launchDefaultMode: no workflow is applicable to the study'
);
return;
}
workflow.launchWithStudy(study);
},
};
const definitions = {
@@ -871,6 +898,10 @@ const commandsModule = ({
addDisplaySetAsLayer: actions.addDisplaySetAsLayer,
removeDisplaySetLayer: actions.removeDisplaySetLayer,
createStoreFunction: actions.createStoreFunction,
launchDefaultMode: {
commandFn: actions.launchDefaultMode,
context: 'WORKLIST',
},
};
return {
@@ -67,6 +67,29 @@ import { StudyList } from '@ohif/ui-next';
* `<StudyList.PreviewContainer>` layout is used.
* Currently only applies when `workList.variant` is `'default'`.
*
* - `workList.onStudyDoubleClick`: command run input (default:
* `{ commandName: 'launchDefaultMode' }`)
* The command(s) run when a study row is double-clicked (the row is selected
* first). Accepts anything `commandsManager.run` does: a command name string,
* `{ commandName, commandOptions, context }`, an array of those, or a plain
* function. At call time these are merged into the command options (a plain
* function receives them as its single argument):
* - `study`: the double-clicked `StudyRow`.
* - `workflows`: the workflows applicable to the study, in the same order as
* the row's Launch Workflow menu. Each has `id`, `displayName`,
* `isDefault`, and `launchWithStudy(study)`.
* - `defaultWorkflow`: the user's default workflow when it applies to the
* study, else `undefined`.
* The default `launchDefaultMode` command launches `defaultWorkflow`,
* falling back to the first applicable workflow. Override the options to
* always launch a specific mode:
* `{ commandName: 'launchDefaultMode', commandOptions: { workflowId: 'segmentation' } }`.
* Modes can contribute their own commands for this via a `getCommandsModule`
* export on the mode definition, registered at app init in the 'WORKLIST'
* context — before any mode route is entered. When set to a falsy value the
* built-in StudyList.Table double-click behavior applies.
* Currently only applies when `workList.variant` is `'default'`.
*
* - `workList.settingsMenuItems`: `(defaults) => SettingsMenuItem[]` (default: identity)
* Builds the items in the WorkList settings popover. Receives the default
* items (`about`, `userPreferences`, and `logout` when OIDC is configured)
@@ -82,6 +105,7 @@ export default function getWorkListCustomization() {
'workList.previewSeriesView': 'all',
'workList.columns': StudyList.defaultColumns,
'workList.renderPreviewContent': undefined,
'workList.onStudyDoubleClick': { commandName: 'launchDefaultMode' },
'workList.settingsMenuItems': (defaults: unknown) => defaults,
};
}