Skip to content

Added drone FW version to main window title#868

Merged
ProgramPhantom merged 6 commits intomainfrom
801-display-ardupilot-fw-version-to-user
Nov 28, 2025
Merged

Added drone FW version to main window title#868
ProgramPhantom merged 6 commits intomainfrom
801-display-ardupilot-fw-version-to-user

Conversation

@ProgramPhantom
Copy link
Copy Markdown
Contributor

  • Removed <title> from index.html so it doesn't overwrite Electron
  • Added a new ipc handler for changing window title
  • Triggered ipc handler when drone SW version is set

* Added a new ipc handler for changing window title
* Triggered ipc handler when drone SW version is set
@ProgramPhantom ProgramPhantom requested a review from a team November 23, 2025 17:03
@ProgramPhantom ProgramPhantom self-assigned this Nov 23, 2025
@ProgramPhantom ProgramPhantom linked an issue Nov 23, 2025 that may be closed by this pull request
@ProgramPhantom
Copy link
Copy Markdown
Contributor Author

Want to just make sure I've done this right. Not sure how the electron stuff works so I've done this from just observing other pieces of code.
One thing I need to add is that the title needs to be reset when the drone disconnects. Is the "connected" state in redux what I need to use for this?
image
Can I put some if (!action.payload) and then dispatch something like "clear" to the ipc handler I've made, which then handles that specific value and set it back to the app version? (I assume this is better than accessing the app version in the redux code - I'm not sure how I'd do that)

@ProgramPhantom
Copy link
Copy Markdown
Contributor Author

Oh looks like Playwright has failed too. I'm not sure what it's saying can you decode this output? Everything seems completely fine when using the app...

Comment thread gcs/electron/main.ts Outdated
Comment thread gcs/electron/main.ts Outdated
Comment thread gcs/electron/main.ts Outdated
@1Blademaster
Copy link
Copy Markdown
Member

Want to just make sure I've done this right. Not sure how the electron stuff works so I've done this from just observing other pieces of code. One thing I need to add is that the title needs to be reset when the drone disconnects. Is the "connected" state in redux what I need to use for this? image Can I put some if (!action.payload) and then dispatch something like "clear" to the ipc handler I've made, which then handles that specific value and set it back to the app version? (I assume this is better than accessing the app version in the redux code - I'm not sure how I'd do that)

Yeah so when you disconnect from the drone is when you want to reset the title, you should be able to find that function in the socket middleware

@1Blademaster
Copy link
Copy Markdown
Member

Oh looks like Playwright has failed too. I'm not sure what it's saying can you decode this output? Everything seems completely fine when using the app...

It's failing because it's trying to find the window called "FGCS" but if it's changed name it can't find it, so update the if statement in electron-fixtures.ts to maybe include FGCS in the title instead of equalling it

@ProgramPhantom
Copy link
Copy Markdown
Contributor Author

Struggling to get rid of the test errors. Does anything look wrong to you in this Regex?
image

image

@1Blademaster
Copy link
Copy Markdown
Member

Struggling to get rid of the test errors. Does anything look wrong to you in this Regex? image

image

So in the electron-fixtures.ts there's a function getSharedElectronApp which has a function where it waits until the fgcs window is there. Can you just get the title from await window.title() and as that returns a string, check if the string includes the text "FGCS"? Don't need to use regex or anything.

@1Blademaster
Copy link
Copy Markdown
Member

Same for the test in the dashboard, surely there's a way to get the window title as a variable and compare that?

@ProgramPhantom
Copy link
Copy Markdown
Contributor Author

I've been having a lot of trouble fixing this. For some reason the title of the main window is coming back as an empty string, and remains that way even after reverting all relevant changes I made in this PR. This causes the getSharedElectronApp method to be unable to find the main window. I've put <title>FGCS</title> back into the index.html file, made sure the BrowswerWindow instantiation sets the title to "FGCS" as default, added a few win.setTitle("FGCS") in the createWindow method just for good measure - nothing, I still can't use the phrase "FGCS" to identify the window.

I have found a fix thanks to ChatGPT, but I don't know what the problem was. The fix involves accessing the main window via matching it to the index.html file:

  // Wait for the main window to appear
sharedMainWindow = await sharedElectronApp.waitForEvent("window", {
    predicate: async (window) => {
     const url = window.url();
     return url.endsWith("index.html"); 
  },
  timeout: 30000,
})

and also adding this to the rollup options in the vite config.

build: {
    rollupOptions: {
      input: {
        main: resolve(__dirname, "index.html"),
        linkStats: resolve(__dirname, "linkStats.html"),
        aboutWindow: resolve(__dirname, "aboutWindow.html"),
        videoWindow: resolve(__dirname, "videoWindow.html"),
        ekfStatus: resolve(__dirname, "ekfStatus.html"),
        vibeStatus: resolve(__dirname, "vibeStatus.html"),
      },
	  output: {
		intro: `document.title = "FGCS";`  // Here
	  }
    },
  },

Which really shouldn't be necessary.
No clue what's happened here. Like I said I returned it back to how it was before I made any changes and it still wasn't working... very strange. Maybe you know something I don't, any ideas?

@ProgramPhantom
Copy link
Copy Markdown
Contributor Author

Okay I found the fix. Turns out I did need to replace the <title> tag in the index.html file, but then it also needed a rebuild which made it look like it wasn't fixed... hate this kind of problem lol. The only reason I removed it was because ChatGPT said it would be able to be overridden if it was in the html - naturally it was wrong and it can still be changed by the code.

Comment thread gcs/src/redux/slices/droneInfoSlice.js Outdated
@ProgramPhantom ProgramPhantom merged commit 2732a3e into main Nov 28, 2025
6 checks passed
@ProgramPhantom ProgramPhantom deleted the 801-display-ardupilot-fw-version-to-user branch November 28, 2025 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Display ardupilot fw version to user

2 participants