Skip to content

Conversation

@hiroTamada
Copy link
Contributor

@hiroTamada hiroTamada commented Oct 15, 2025

Here's a PR description for your changes:


Add Dynamic Chromium Flags API & Refactor Restart Logic

This PR adds the ability to dynamically update Chromium launch flags at runtime and consolidates duplicate code across the codebase.

Changes

New Feature:

  • Added PATCH /chromium/flags endpoint to update Chromium flags dynamically without container restart
  • Updated run-docker.sh to make flags file writable (removed ro mount option)
  • Set default to --kiosk mode for better fullscreen experience

Code Refactoring:

  • Created mergeAndWriteChromiumFlags() helper to consolidate flag merging logic (eliminates 52 lines of duplication)
  • Created restartChromiumAndWait() helper to consolidate Chromium restart logic (eliminates 62 lines of duplication)
  • Removed duplicate restartChromium() function from display.go
  • Updated display resolution handlers to use shared restart helper

Benefits:

  • Single source of truth for Chromium restart and flag management
  • Better logging with operation-specific context
  • Consistent error handling across all Chromium operations
  • ~100 lines of code reduction through DRY principles

Testing

E2E Tests:

  • Ran TestExtensionUploadAndActivation in e2e_chromium_test.go to verify extension endpoint still works correctly

Manual Testing:

  • Started Docker container with the updated image
  • Called the new flags endpoint to enable kiosk mode:
    curl -X PATCH http://localhost:444/chromium/flags \
      -H "Content-Type: application/json" \
      -d '{"flags": ["--kiosk"]}'
  • Verified kiosk mode was successfully applied and Chromium restarted with new flags
image

Unit Tests:

  • Added TestApiService_PatchChromiumFlags to verify flag validation and merging logic
  • All existing tests pass

Note

Introduces a new PATCH /chromium/flags API and consolidates Chromium flag merging and restart logic into shared helpers, updating extension upload and display flows, with OpenAPI/client generation and a unit test.

  • API/OpenAPI:
    • Add PATCH /chromium/flags endpoint (request: { flags: string[] }; responses: 200/400/500).
    • Regenerate oapi client/server types, routing, and swagger spec for the new endpoint.
  • Backend:
    • Implement ApiService.PatchChromiumFlags to validate, merge, write flags, restart Chromium, and wait for DevTools.
    • Refactor into helpers: mergeAndWriteChromiumFlags() and restartChromiumAndWait().
    • Update UploadExtensionsAndRestart to use the new helpers and improved logging.
    • Remove old restartChromium() from display.go and replace calls with restartChromiumAndWait().
  • Tests:
    • Add TestApiService_PatchChromiumFlags covering flag validation/flow.

Written by Cursor Bugbot for commit ee0c0f3. This will update automatically on new commits. Configure here.

@hiroTamada hiroTamada marked this pull request as ready for review October 15, 2025 16:37
@hiroTamada hiroTamada requested review from Sayan- and rgarcia October 15, 2025 16:37
@hiroTamada
Copy link
Contributor Author

As @rgarcia mentioned, when a user is request extension and kiosk. We are restarting the chromium twice.
This pr does not include a fix for it. Instead, I consolidated the paths/functions around restarting chromium and updating chromium flags.

https://linear.app/onkernel/issue/KERNEL-426/avoid-redundant-chromium-restart-with-kiosk-and-extension-enabled

I created a ticket for this as a backlog

@hiroTamada hiroTamada merged commit ca0e857 into main Oct 15, 2025
9 of 12 checks passed
@hiroTamada hiroTamada deleted the hiro/patch_chromium_flag_endpoint branch October 15, 2025 16:52
@rgarcia rgarcia mentioned this pull request Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants