-
Notifications
You must be signed in to change notification settings - Fork 15
Removed Graph's tab, added movable windows instead #1004
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
95eb65a
I took computer science because I like computers, I dont like compute…
Matthew-Dobson 90bbdfb
Merge branch 'main' into 977-display-graphs-as-popout-windows
Matthew-Dobson 28b4f1a
github comments
Matthew-Dobson c2448ed
Merge branch '977-display-graphs-as-popout-windows' of https://github…
Matthew-Dobson a62404c
linters again
Matthew-Dobson 325977a
more linters, silly me
Matthew-Dobson 0cac3c6
Merge branch 'main' into 977-display-graphs-as-popout-windows
1Blademaster 3ab4fe5
replaced custom checkbox with mantime checkbox with label prop
Matthew-Dobson 7972fe2
fixed an invalid tailwind class name
Matthew-Dobson e406e75
made function name more descriptive
Matthew-Dobson 2689547
clarified comment
Matthew-Dobson 72e2a55
switched search bar to mantine component
Matthew-Dobson 0384de9
kush change
Matthew-Dobson d9f33bc
changed button to mantine component and tidied up mantine imports
Matthew-Dobson 5d96d6a
fix popout electron window resizing to match graph size
Matthew-Dobson bf9c725
fixed checbox so that it 'unticks' when graph popout is closed manually
Matthew-Dobson 5fd8827
added a ready handshake to ensure the graph window init is never miss…
Matthew-Dobson 75804af
linters
Matthew-Dobson ba7e2dd
updated streaming duration to 30s
Matthew-Dobson 52ecbb5
removed use effect
Matthew-Dobson 634cb2f
removed title from graph windows
Matthew-Dobson 8ae822f
linters
Matthew-Dobson 6021cee
linters again
Matthew-Dobson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,161 @@ | ||
| import { BrowserWindow, ipcMain } from "electron" | ||
| import path from "path" | ||
|
|
||
| const VITE_DEV_SERVER_URL = process.env["VITE_DEV_SERVER_URL"] | ||
|
|
||
| type GraphKey = "graph_a" | "graph_b" | "graph_c" | "graph_d" | ||
|
|
||
| type GraphWindowMeta = { | ||
| id: string | ||
| msg: string | ||
| field: string | ||
| title: string | ||
| description?: string | ||
| label?: string | ||
| } | ||
|
|
||
| type OpenArgs = { | ||
| graphKey: GraphKey | ||
| meta: GraphWindowMeta | ||
| } | ||
|
|
||
| type CloseArgs = { | ||
| graphKey: GraphKey | ||
| } | ||
|
|
||
| type GraphPoint = { | ||
| graphKey: GraphKey | ||
| data: { x: number; y: number } | ||
| } | ||
|
|
||
| const graphWins: Partial<Record<GraphKey, BrowserWindow>> = {} | ||
|
|
||
| /** Get a window if it's still usable; auto-clean if destroyed. */ | ||
| function getGraphWin(graphKey: GraphKey): BrowserWindow | null { | ||
| const win = graphWins[graphKey] | ||
| if (!win) return null | ||
|
|
||
| if (win.isDestroyed()) { | ||
| graphWins[graphKey] = undefined | ||
| return null | ||
| } | ||
|
|
||
| if (win.webContents.isDestroyed()) { | ||
| graphWins[graphKey] = undefined | ||
| return null | ||
| } | ||
|
|
||
| return win | ||
| } | ||
|
|
||
| export function openGraphWindow({ graphKey, meta }: OpenArgs) { | ||
| console.log("openGraphWindow called", graphKey) | ||
|
|
||
| // Reuse existing window if it's alive | ||
| let win = getGraphWin(graphKey) | ||
|
|
||
| if (!win) { | ||
| win = new BrowserWindow({ | ||
| width: 700, | ||
| height: 350, | ||
| frame: true, | ||
| icon: path.join(process.env.VITE_PUBLIC!, "app_icon.ico"), | ||
| show: false, | ||
| title: meta?.title ?? "Graph", | ||
| webPreferences: { | ||
| preload: path.join(__dirname, "preload.js"), | ||
| contextIsolation: true, | ||
| }, | ||
| fullscreen: false, | ||
| fullscreenable: false, | ||
| alwaysOnTop: true, | ||
| }) | ||
|
|
||
| graphWins[graphKey] = win | ||
| win.setMenuBarVisibility(false) | ||
|
|
||
| // IMPORTANT: clean up reference when user closes window | ||
| win.on("closed", () => { | ||
| graphWins[graphKey] = undefined | ||
| }) | ||
|
|
||
| // Load content only on first creation | ||
| if (VITE_DEV_SERVER_URL) { | ||
| win.loadURL(VITE_DEV_SERVER_URL + "graphWindow.html") | ||
| } else { | ||
| win.loadFile(path.join(process.env.DIST!, "graphWindow.html")) | ||
| } | ||
|
|
||
| // When page finishes loading, send init | ||
| win.webContents.once("did-finish-load", () => { | ||
| // Guard again just in case it got closed mid-load | ||
| const alive = getGraphWin(graphKey) | ||
| if (!alive) return | ||
| alive.webContents.send("app:graph-window:init", { graphKey, meta }) | ||
| }) | ||
| } else { | ||
| // Window already exists: just update title + init payload | ||
| try { | ||
| win.setTitle(meta?.title ?? "Graph") | ||
| win.webContents.send("app:graph-window:init", { graphKey, meta }) | ||
| } catch (e) { | ||
| // If it threw, treat it as dead and try again once | ||
| graphWins[graphKey] = undefined | ||
| return openGraphWindow({ graphKey, meta }) | ||
| } | ||
| } | ||
|
|
||
| // Show/focus safely | ||
| if (!win.isDestroyed()) { | ||
| win.show() | ||
| win.focus() | ||
| } | ||
| } | ||
|
|
||
| export function closeGraphWindow({ graphKey }: CloseArgs) { | ||
| const win = getGraphWin(graphKey) | ||
| if (!win) return | ||
|
|
||
| // Do NOT set undefined here — let the 'closed' event clean up. | ||
| win.close() | ||
| } | ||
|
|
||
| export function destroyAllGraphWindows() { | ||
| ;(Object.keys(graphWins) as GraphKey[]).forEach((k) => { | ||
| const win = getGraphWin(k) | ||
| win?.close() | ||
| }) | ||
| } | ||
|
|
||
| export default function registerGraphWindowIPC() { | ||
| ipcMain.removeHandler("app:open-graph-window") | ||
| ipcMain.removeHandler("app:close-graph-window") | ||
| ipcMain.removeHandler("app:update-graph-windows") | ||
|
|
||
| ipcMain.handle("app:open-graph-window", (_event, args: OpenArgs) => { | ||
| openGraphWindow(args) | ||
| }) | ||
|
|
||
| ipcMain.handle("app:close-graph-window", (_event, args: CloseArgs) => { | ||
| closeGraphWindow(args) | ||
| }) | ||
|
|
||
| ipcMain.handle( | ||
| "app:update-graph-windows", | ||
| (_event, graphResults: GraphPoint[] | false) => { | ||
| if (!graphResults) return | ||
|
|
||
| for (const result of graphResults) { | ||
| const win = getGraphWin(result.graphKey) | ||
| if (!win) continue | ||
|
|
||
| try { | ||
| win.webContents.send("app:send-graph-point", result) | ||
| } catch { | ||
| // If it errors during close, drop it | ||
| graphWins[result.graphKey] = undefined | ||
| } | ||
| } | ||
| }, | ||
| ) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <!doctype html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <link rel="icon" type="image/svg+xml" href="/logo_dark_icon.svg" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| </head> | ||
| <body> | ||
| <div id="root"></div> | ||
| <script type="module" src="/src/graphWindow.jsx"></script> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { useEffect, useState } from "react" | ||
|
|
||
| export default function GraphWindow() { | ||
| const [meta, setMeta] = useState(null) | ||
|
|
||
| useEffect(() => { | ||
| window.ipcRenderer.on("app:graph-window:init", (_event, data) => { | ||
| setMeta(data) | ||
| }) | ||
| }, []) | ||
|
|
||
| return ( | ||
| <div className="w-full h-full bg-falcongrey-800 p-4"> | ||
| <div className="text-lg">{meta?.title ?? "Graph"}</div> | ||
| <div className="text-sm text-falcongray-90 opacity-70"> | ||
| {meta?.id ?? ""} | ||
| </div> | ||
| <div className="text-sm text-falcongray-90 opacity-70 mt-1"> | ||
| {meta?.description ?? ""} | ||
| </div> | ||
| <div className="mt-6 opacity-70">Graph goes here later.</div> | ||
| </div> | ||
| ) | ||
| } |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.