Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"url": "git+https://github.com/opencor/webapp.git"
},
"type": "module",
"version": "0.20260324.0",
"version": "0.20260325.0",
"engines": {
"bun": ">=1.2.0"
},
Expand All @@ -41,8 +41,8 @@
"release": "bun src/renderer/scripts/libopencor.js && electron-builder",
"release:local": "bun src/renderer/scripts/libopencor.js && CSC_IDENTITY_AUTO_DISCOVERY=false electron-builder --config.mac.notarize=false --publish=never",
"start": "bun src/renderer/scripts/libopencor.js && electron-vite preview",
"typecheck": "bunx --bun vue-tsc --noEmit -p tsconfig.app.json",
"start:web": "bun --cwd src/renderer start",
"typecheck": "bunx --bun vue-tsc --noEmit -p tsconfig.app.json",
"version:new": "bun src/renderer/scripts/version.new.js"
},
"bun": {
Expand Down Expand Up @@ -72,7 +72,7 @@
"@types/node": "^25.5.0",
"@types/plotly.js": "^3.0.10",
"@vitejs/plugin-vue": "^6.0.5",
"@vue/tsconfig": "^0.9.0",
"@vue/tsconfig": "^0.9.1",
"@wasm-fmt/clang-format": "^22.1.1",
"autoprefixer": "^10.4.27",
"cmake-js": "^8.0.0",
Expand All @@ -89,8 +89,8 @@
"stylelint-config-standard": "^40.0.0",
"tailwindcss": "^4.2.2",
"tailwindcss-primeui": "^0.6.1",
"tar": "^7.5.12",
"typescript": "^5.9.3",
"tar": "^7.5.13",
"typescript": "^6.0.2",
"unplugin-vue-components": "^32.0.0",
"vite": "^7.3.1",
"vue-tsc": "^3.2.6"
Expand Down
16 changes: 8 additions & 8 deletions src/renderer/bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/renderer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
},
"./style.css": "./dist/opencor.css"
},
"version": "0.20260324.0",
"version": "0.20260325.0",
"scripts": {
"build": "vite build && bun scripts/generate.version.js",
"build:lib": "vite build --config vite.lib.config.ts && bun scripts/copy.indexdts.js",
Expand Down Expand Up @@ -81,7 +81,7 @@
"@types/node": "^25.5.0",
"@types/plotly.js": "^3.0.10",
"@vitejs/plugin-vue": "^6.0.5",
"@vue/tsconfig": "^0.9.0",
"@vue/tsconfig": "^0.9.1",
"autoprefixer": "^10.4.27",
"esbuild": "^0.27.4",
"postcss": "^8.5.8",
Expand All @@ -90,7 +90,7 @@
"stylelint-config-standard": "^40.0.0",
"tailwindcss": "^4.2.2",
"tailwindcss-primeui": "^0.6.1",
"typescript": "^5.9.3",
"typescript": "^6.0.2",
"unplugin-vue-components": "^32.0.0",
"vite": "^7.3.1",
"vue-tsc": "^3.2.6"
Expand Down
44 changes: 23 additions & 21 deletions src/renderer/src/components/widgets/GraphPanelWidget.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="flex flex-row h-full" :class="isVisible ? 'visible' : 'invisible'">
<div class="flex flex-row h-full">
<div v-if="showMarker" class="w-0.75 bg-primary" />
<div ref="mainDivRef" class="grow h-full" @contextmenu="onContextMenu" />
<ContextMenu ref="contextMenuRef" :model="contextMenuItems" />
Expand Down Expand Up @@ -123,7 +123,6 @@ defineExpose({

const instanceId = Symbol('GraphPanelWidget');
const mainDivRef = vue.ref<HTMLElement | null>(null);
const isVisible = vue.ref(false);
const margins = vue.ref<IGraphPanelMargins>({ left: -1, right: -1 });
const theme = vueCommon.useTheme();
const contextMenuRef = vue.ref<InstanceType<typeof ContextMenu> | null>(null);
Expand Down Expand Up @@ -596,6 +595,18 @@ const compMargins = (): IGraphPanelMargins => {
};
};

const canMeasureMargins = (): boolean => {
const mainDiv = mainDivRef.value;

if (!mainDiv) {
return false;
}

const { width, height } = mainDiv.getBoundingClientRect();

return width > 0 && height > 0;
};

const updateMarginsAsync = (): void => {
// Skip if we are already updating our margins.

Expand All @@ -608,6 +619,14 @@ const updateMarginsAsync = (): void => {
// Use requestAnimationFrame for optimal timing.

requestAnimationFrame(() => {
// Make sure that we can measure our margins before proceeding.

if (!canMeasureMargins()) {
updatingMargins = false;

return;
}

const newMargins = compMargins();

// Emit an update if our margins have changed.
Expand Down Expand Up @@ -722,26 +741,9 @@ const updatePlot = (): void => {
.then(() => {
plotIsReady = true;

if (!isVisible.value) {
// Force Plotly to recalculate the layout after the plot is rendered to ensure that it has correct dimensions.

return dependencies._plotlyJs.Plots.resize(mainDivRef.value);
}
})
.then(() => {
trackSize();

if (!isVisible.value) {
// Show the component now that the plot has been properly sized.

vue.nextTick(() => {
isVisible.value = true;
});
}

// Update our margins asynchronously after our initial render.
// Force Plotly to recalculate the layout after each react() call to keep the graph aligned with sibling panels.

Comment on lines +744 to 745
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

updatePlot() now unconditionally calls resize() after every Plotly.react(). When the widget is mounted but has 0x0 size (e.g., hidden panel/tab), this can trigger unnecessary Plotly resize work. Consider guarding the call (e.g., check mainDivRef dimensions before resizing) so resizes only happen once the container can actually be measured.

Suggested change
// Force Plotly to recalculate the layout after each react() call to keep the graph aligned with sibling panels.
// Force Plotly to recalculate the layout after each react() call to keep the graph aligned with sibling panels.
// Only resize when the main container has measurable (non-zero) dimensions to avoid unnecessary work when hidden.
const mainDivEl = mainDivRef.value as HTMLElement | null;
if (!mainDivEl) {
return;
}
const rect = mainDivEl.getBoundingClientRect();
if (rect.width === 0 || rect.height === 0) {
return;
}

Copilot uses AI. Check for mistakes.
updateMarginsAsync();
resize();
});
};

Expand Down
4 changes: 2 additions & 2 deletions src/renderer/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"compilerOptions": {
"allowImportingTsExtensions": true,
"baseUrl": ".",
"composite": true,
"module": "nodenext",
"moduleResolution": "nodenext",
"noEmit": true,
"strictNullChecks": true,
"resolveJsonModule": true
"resolveJsonModule": true,
"emitDeclarationOnly": false
},
"extends": "@vue/tsconfig/tsconfig.dom.json",
"include": ["**/*.js", "**/*.ts", "**/*.vue", "package.json"]
Expand Down
7 changes: 4 additions & 3 deletions tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"compilerOptions": {
"allowImportingTsExtensions": true,
"baseUrl": ".",
"composite": true,
"module": "nodenext",
"moduleResolution": "nodenext",
"noEmit": true,
"noEmit": false,
"strictNullChecks": true,
"resolveJsonModule": true
"resolveJsonModule": true,
"declaration": true,
"declarationMap": true
},
"extends": "@vue/tsconfig/tsconfig.dom.json",
"include": ["**/*.js", "**/*.ts", "**/*.vue", "package.json"]
Expand Down
6 changes: 5 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"compilerOptions": {
"module": "nodenext",
"strictNullChecks": true
"strictNullChecks": true,
"noEmit": false,
"composite": true,
"declaration": true,
"declarationMap": true
},
"include": ["*.ts"],
"references": [
Expand Down
5 changes: 4 additions & 1 deletion tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"compilerOptions": {
"composite": true,
"types": ["electron-vite/node"]
"types": ["electron-vite/node"],
"module": "nodenext",
"moduleResolution": "nodenext",
"noEmit": false
},
"extends": "@electron-toolkit/tsconfig/tsconfig.node.json",
"include": ["src/main/**/*", "src/preload/**/*"]
Expand Down
6 changes: 4 additions & 2 deletions tsconfig.web.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{
"compilerOptions": {
"baseUrl": ".",
"composite": true,
"lib": ["dom", "esnext"],
"paths": {
"@renderer/*": ["src/renderer/src/*"]
}
},
"module": "nodenext",
"moduleResolution": "nodenext",
"noEmit": false
},
"extends": "@electron-toolkit/tsconfig/tsconfig.web.json",
"include": ["src/**/*.ts"]
Expand Down
Loading