Skip to content

Commit bcf57c9

Browse files
Add clusteringPixelSizeThreshold + memory monitoring (#363)
* Add clusteringPixelSizeThreshold * Update style * Add progress indicator to bulk ann retrieve and processing * Add toggle for clusters * Update progress dialog * Lock dicomweb-client verison * Revert "Add progress indicator to bulk ann retrieve and processing" This reverts commit 44c4dd8. * Auto select series (dicomtagbrowser) * Add memory monitoring * Add configuration * Enable memory profilling by default * CR Update: Copilot * Lint fix * CR Updates: Copilot * CR Updates * CR Updates * Use bun * Add biome and format code * Update scripts to use bun * Fix build issues * Address build errors * Fix dockerfile * Adjust reactivity of toggle * Address code quality * Add strict rules * Address quality issues * Update dmv * Deep source
1 parent fea13f6 commit bcf57c9

File tree

107 files changed

+11283
-19031
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+11283
-19031
lines changed

.eslintrc.strict.cjs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* ESLint config that approximates DeepSource + SonarQube rules.
3+
* Run with: bun run lint:strict (or: bunx eslint --config .eslintrc.strict.cjs src/)
4+
*
5+
* DeepSource's JavaScript analyzer uses ESLint under the hood and supports
6+
* style_guide (e.g. "standard"). SonarQube rules are available via eslint-plugin-sonarjs.
7+
* This config enables rules that catch the kinds of issues both report.
8+
*/
9+
module.exports = {
10+
root: true,
11+
extends: [
12+
'react-app',
13+
'react-app/jest',
14+
'plugin:sonarjs/recommended',
15+
],
16+
plugins: ['sonarjs'],
17+
overrides: [
18+
{
19+
files: ['src/**/*.{ts,tsx,js,jsx}'],
20+
rules: {
21+
// DeepSource JS-0050: use === and !==
22+
eqeqeq: ['error', 'always'],
23+
// Avoid console in browser code (DeepSource JS-0002)
24+
'no-console': ['warn', { allow: ['warn', 'error'] }],
25+
// Object shorthand (DeepSource JS-0240)
26+
'object-shorthand': ['warn', 'always'],
27+
// Empty callbacks (DeepSource JS-0321)
28+
'no-empty-function': ['warn', { allow: ['arrowFunctions'] }],
29+
// Prefer named exports when re-exporting (DeepSource JS-P1003)
30+
'sonarjs/prefer-single-boolean-return': 'warn',
31+
},
32+
},
33+
],
34+
ignorePatterns: [
35+
'build/',
36+
'node_modules/',
37+
'coverage/',
38+
'*.config.js',
39+
'*.config.cjs',
40+
],
41+
};

.github/workflows/deploy-to-firebase.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,16 @@ jobs:
1515
- name: Checkout to repository
1616
uses: actions/checkout@v4.2.2
1717

18-
- name: Setup Node
19-
uses: actions/setup-node@v4.4.0
18+
- name: Setup Bun
19+
uses: oven-sh/setup-bun@v2
2020
with:
21-
node-version: 20.8.1
22-
23-
- name: Install Yarn
24-
run: sudo npm i -g yarn
21+
bun-version: latest
2522

2623
- name: Install dependencies
27-
run: yarn
24+
run: bun install --frozen-lockfile
2825

2926
- name: Build
30-
run: REACT_APP_CONFIG=preview PUBLIC_URL=/ yarn build
27+
run: REACT_APP_CONFIG=preview PUBLIC_URL=/ bun run build
3128

3229
- name: Deploy
3330
uses: FirebaseExtended/action-hosting-deploy@v0

.github/workflows/deploy-to-github-pages.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,17 @@ jobs:
1414
- name: Checkout to repository
1515
uses: actions/checkout@v4.2.2
1616

17-
- name: Setup Node
18-
uses: actions/setup-node@v4.4.0
17+
- name: Setup Bun
18+
uses: oven-sh/setup-bun@v2
1919
with:
20-
node-version: 20.8.1
21-
22-
- name: Install Yarn
23-
run: sudo npm i -g yarn
20+
bun-version: latest
2421

2522
- name: Install dependencies
26-
run: yarn
23+
run: bun install --frozen-lockfile
2724

2825
- name: Build and deploy to GitHub Pages
2926
run: |
3027
git remote set-url origin https://git:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
31-
yarn deploy -- -u "github-actions-bot <support+actions@github.com>"
28+
bun run deploy -- -u "github-actions-bot <support+actions@github.com>"
3229
env:
3330
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ jobs:
1616
ref: master
1717
persist-credentials: false
1818

19-
- name: Setup Node
20-
uses: actions/setup-node@v4.4.0
19+
- name: Setup Bun
20+
uses: oven-sh/setup-bun@v2
2121
with:
22-
node-version: 20.8.1
22+
bun-version: latest
2323

2424
- name: Install dependencies
25-
run: yarn
25+
run: bun install --frozen-lockfile
2626

2727
- name: Build
28-
run: yarn build
28+
run: bun run build
2929

3030
- name: Zip build
3131
run: zip -r build.zip build
@@ -37,4 +37,4 @@ jobs:
3737
GIT_AUTHOR_EMAIL: ${{ vars.RELEASE_GIT_AUTHOR_EMAIL }}
3838
GIT_COMMITTER_NAME: ${{ vars.RELEASE_GIT_COMMITTER_NAME }}
3939
GIT_COMMITTER_EMAIL: ${{ vars.RELEASE_GIT_COMMITTER_EMAIL }}
40-
run: npx semantic-release --branches master
40+
run: bunx semantic-release --branches master

.github/workflows/unit-tests.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ jobs:
1414
- name: Checkout to repository
1515
uses: actions/checkout@v4.2.2
1616

17-
- name: Setup Node
18-
uses: actions/setup-node@v4.4.0
17+
- name: Setup Bun
18+
uses: oven-sh/setup-bun@v2
1919
with:
20-
node-version: 20.8.1
20+
bun-version: latest
2121

2222
- name: Install dependencies
23-
run: yarn
23+
run: bun install --frozen-lockfile
2424

2525
- name: Build
26-
run: yarn build
26+
run: bun run build
2727

2828
- name: Lint
29-
run: yarn lint
29+
run: bun run lint
3030

3131
- name: Test
32-
run: yarn test
32+
run: bun run test

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
/coverage
1010
.env
1111

12+
.cursorrules
13+
1214
# production
1315
/build
1416

.husky/pre-commit

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env sh
2+
# Block commit if typecheck or lint fails
3+
bun run typecheck && bun run lint

CONTRIBUTING.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,17 @@ The app is built using [craco](https://github.com/gsoft-inc/craco) (with the [cr
3131

3232
Tests are written and run using the [jest](https://jestjs.io/) framework.
3333

34-
The [yarn](https://yarnpkg.com/) package manager is used to manage dependencies and run scripts specified in `package.json` (`build`, `lint`, `test`, etc.).
34+
The [Bun](https://bun.sh/) runtime and package manager is used to manage dependencies and run scripts specified in `package.json` (`build`, `lint`, `test`, etc.).
3535

3636
## Coding style
3737

38-
Source code is linted using [ts-standard](https://github.com/standard/ts-standard) (based on [eslint](https://eslint.org/)) and TypeScript is used with [strict type checking compiler options](https://www.typescriptlang.org/tsconfig#Strict_Type_Checking_Options_6173) enabled.
38+
Source code is linted and formatted using [Biome](https://biomejs.dev/). TypeScript is used with [strict type checking compiler options](https://www.typescriptlang.org/tsconfig#Strict_Type_Checking_Options_6173) enabled. Semicolons are not used at the end of statements (Biome uses `asNeeded`).
3939

40-
Use the following command to identify potential coding style and type annotation violations:
40+
Use the following commands to check and fix style:
4141

42-
$ yarn lint
42+
$ bun run lint # check for issues
43+
$ bun run lint:fix # auto-fix issues
44+
$ bun run fmt # format code
4345

4446

4547
### Documentation

Dockerfile

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,27 @@ RUN apt-get update && \
1010
curl \
1111
dumb-init \
1212
gnupg \
13-
nginx && \
13+
nginx \
14+
unzip && \
1415
apt-get clean
1516

1617
RUN curl -fsSL https://deb.nodesource.com/setup_21.x | bash - && \
17-
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
18-
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
19-
curl -sS https://deb.nodesource.com/setup_21.x | bash - && \
2018
apt-get update && \
2119
apt-get install -y --no-install-suggests --no-install-recommends \
22-
nodejs \
23-
yarn && \
20+
nodejs && \
2421
apt-get clean
2522

23+
# Install Bun (matches packageManager in package.json)
24+
ENV BUN_INSTALL=/usr/local
25+
RUN curl -fsSL https://bun.sh/install | bash -
26+
2627
WORKDIR /usr/local/share/mghcomputationalpathology/slim
2728

2829
# Install dependencies first and then include code for efficient caching
2930
COPY package.json .
30-
COPY yarn.lock .
31+
COPY bun.lock .
3132

32-
# There are sometimes weird network errors. Increasing the network timeout
33-
# seems to help (see https://github.com/yarnpkg/yarn/issues/5259)
34-
RUN yarn install --frozen-lockfile --network-timeout 100000
33+
RUN bun install --frozen-lockfile
3534

3635
COPY craco.config.js .
3736
COPY tsconfig.json .
@@ -57,7 +56,7 @@ RUN addgroup --system --gid 101 nginx && \
5756
--shell /bin/false \
5857
nginx
5958

60-
RUN NODE_OPTIONS=--max_old_space_size=8192 yarn run build && \
59+
RUN NODE_OPTIONS=--max_old_space_size=8192 bun run build && \
6160
mkdir -p /var/www/html && \
6261
cp -R build/* /var/www/html/
6362

@@ -82,4 +81,4 @@ RUN useradd -m -s /bin/bash tester && \
8281

8382
USER tester
8483

85-
ENTRYPOINT ["/usr/bin/dumb-init", "--", "yarn", "test"]
84+
ENTRYPOINT ["/usr/bin/dumb-init", "--", "bun", "run", "test"]

README.md

Lines changed: 46 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ It relies on [DICOMweb](https://www.dicomstandard.org/dicomweb/) RESTful service
1616
- [Display of images](#display-of-images)
1717
- [Display of image annotations and analysis results](#display-of-image-annotations-and-analysis-results)
1818
- [Annotation of images](#annotation-of-images)
19+
- [Memory Monitoring](#memory-monitoring)
1920
- [Authentication and Authorization](#autentication-and-authorization)
2021
- [Configuration](#configuration)
2122
- [Server Configuration](#server-configuration)
@@ -105,6 +106,22 @@ ROIs are stored as 3D spatial coordinates (SCOORD3D) in millimeter unit accordin
105106
Specifically, [Image Region](http://dicom.nema.org/medical/dicom/current/output/chtml/part16/chapter_A.html#para_b68aa0a9-d0b1-475c-9630-fbbd48dc581d) is used to store the vector graphic data and [Finding](http://dicom.nema.org/medical/dicom/current/output/chtml/part16/chapter_A.html#para_c4ac1cac-ee86-4a86-865a-8137ebe1bd95) is used to describe what has been annotated using a standard medical terminology such as [SNOMED CT](https://www.snomed.org/).
106107
The terms that can be chosen by a user can be configured (see [AppConfig.d.ts](src/AppConfig.d.ts)).
107108

109+
### Memory Monitoring
110+
111+
_Slim_ includes automatic memory monitoring to help track browser memory usage when viewing large whole slide images. The memory monitor:
112+
113+
- Displays real-time memory usage in the footer (used memory, heap limit, usage percentage, remaining memory)
114+
- Automatically monitors memory every 5 seconds using modern browser APIs when available
115+
- Shows color-coded status indicators (green/orange/red) based on usage levels
116+
- Issues warnings when memory usage exceeds 80% (high) or 90% (critical)
117+
- Falls back to Chrome-specific APIs when modern APIs aren't available
118+
119+
The memory footer appears at the bottom of all pages and updates automatically. When memory usage is high, users receive notifications with recommendations to refresh the page or close other tabs.
120+
121+
Memory monitoring is enabled by default and can be disabled via configuration by setting `enableMemoryMonitoring: false` in the application config.
122+
123+
For technical details, see [Memory Monitoring Documentation](docs/MEMORY_MONITORING.md).
124+
108125
## Autentication and authorization
109126

110127
Users can authenticate and authorize the application to access data via [OpenID Connect (OIDC)](https://openid.net/connect/) based on the [OAuth 2.0](https://oauth.net/2/) protocol using either the [authorization code grant type](https://oauth.net/2/grant-types/authorization-code/) (with [Proof Key for Code Exchange (PKCE)](https://oauth.net/2/pkce/) extension) or the legacy [implicit grant type](https://oauth.net/2/grant-types/implicit/).
@@ -198,13 +215,29 @@ Default values if not specified:
198215
- `duration`: 5 seconds
199216
- `top`: 100 pixels
200217

218+
### Memory Monitoring Configuration
219+
220+
Memory monitoring can be enabled or disabled through configuration:
221+
222+
```javascript
223+
window.config = {
224+
// ... other config options ...
225+
enableMemoryMonitoring: false, // Set to false to disable memory monitoring footer
226+
};
227+
```
228+
229+
- **Default**: Memory monitoring is enabled (`enableMemoryMonitoring: true` or undefined)
230+
- **Disable**: Set `enableMemoryMonitoring: false` to hide the memory footer and stop monitoring
231+
232+
When enabled, the memory footer appears at the bottom of all pages and monitors memory usage every 5 seconds.
233+
201234
## Deployment
202235

203236
Download the latest release from [github.com/imagingdatacommons/slim/releases](https://github.com/imagingdatacommons/slim/releases) and then run the following commands to install build dependencies and build the app:
204237

205238
```none
206-
yarn install
207-
PUBLIC_URL=/ yarn build
239+
bun install
240+
PUBLIC_URL=/ bun run build
208241
```
209242

210243
Once the app has been built, the content of the `build` folder can be directly served by a static web server at the location specified by `PUBLIC_URL` (in this case at `/`).
@@ -341,57 +374,57 @@ For the time being, the legacy implicit grand type has to be used.
341374
To install requirements and run the app for local development, run the following commands:
342375

343376
```none
344-
yarn install
345-
yarn start
377+
bun install
378+
bun run start
346379
```
347380

348381
This will serve the app via a development server at [http://localhost:3000](http://localhost:3000) using the default `local` configuration.
349382

350383
The configuration can be specified using the `REACT_APP_CONFIG` environment variable, which can be set either in the `.env` file or directly in the command line:
351384

352385
```none
353-
REACT_APP_CONFIG=local yarn start
386+
REACT_APP_CONFIG=local bun run start
354387
```
355388

356389
## Linking Slim to a Local dicom-microscopy-viewer Library
357390

358-
If you are developing features or fixing bugs that require changes in both Slim and the underlying [`dicom-microscopy-viewer`](https://github.com/ImagingDataCommons/dicom-microscopy-viewer) library, you can use `yarn link` to connect your local Slim project to a local clone of `dicom-microscopy-viewer`. This allows Slim to immediately use the latest local changes from the library without publishing to npm.
391+
If you are developing features or fixing bugs that require changes in both Slim and the underlying [`dicom-microscopy-viewer`](https://github.com/ImagingDataCommons/dicom-microscopy-viewer) library, you can use `bun link` to connect your local Slim project to a local clone of `dicom-microscopy-viewer`. This allows Slim to immediately use the latest local changes from the library without publishing to npm.
359392

360393
### Steps
361394

362395
1. **Clone dicom-microscopy-viewer**
363396
If you haven't already, clone the `dicom-microscopy-viewer` repository to your machine.
364397

365-
2. **Set up yarn link in dicom-microscopy-viewer**
398+
2. **Set up bun link in dicom-microscopy-viewer**
366399
In the root directory of your local `dicom-microscopy-viewer` repository, run:
367400
```sh
368-
yarn link
401+
bun link
369402
```
370403

371404
3. **Link dicom-microscopy-viewer in Slim**
372405
In the root directory of your Slim project, run:
373406
```sh
374-
yarn link dicom-microscopy-viewer
407+
bun link dicom-microscopy-viewer
375408
```
376409

377410
4. **Enable live rebuilding in dicom-microscopy-viewer**
378411
To automatically rebuild `dicom-microscopy-viewer` when you make changes, run the following command in the `dicom-microscopy-viewer` directory:
379412
```sh
380-
yarn webpack:dynamic-import:watch
413+
bun run webpack:dynamic-import:watch
381414
```
382415
This will watch for file changes and rebuild the library, so Slim can immediately use the updated code.
383416

384417
5. **Run Slim as usual**
385418
In the Slim directory, start the development server:
386419
```sh
387-
yarn start
420+
bun run start
388421
```
389422
Slim will now use your locally linked version of `dicom-microscopy-viewer`.
390423

391424
### Notes
392425

393-
- If you want to unlink and return to the npm-published version, run `yarn unlink dicom-microscopy-viewer` and `yarn install --force` in the Slim directory.
394-
- Make sure both projects use compatible Node and Yarn versions to avoid dependency issues.
426+
- If you want to unlink and return to the npm-published version, run `bun unlink dicom-microscopy-viewer` and `bun install` in the Slim directory.
427+
- Make sure both projects use compatible Bun versions to avoid dependency issues.
395428

396429
## Citation
397430

0 commit comments

Comments
 (0)