Skip to content
Merged
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
32 changes: 29 additions & 3 deletions selfdrive/ui/layouts/settings/software.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from openpilot.system.ui.widgets import Widget, DialogResult
from openpilot.system.ui.widgets.confirm_dialog import ConfirmDialog
from openpilot.system.ui.widgets.list_view import button_item, text_item, ListItem
from openpilot.system.ui.widgets.option_dialog import MultiOptionDialog
from openpilot.system.ui.widgets.scroller import Scroller

# TODO: remove this. updater fails to respond on startup if time is not correct
Expand Down Expand Up @@ -52,6 +53,9 @@ def __init__(self):
self._install_btn = button_item(tr("Install Update"), tr("INSTALL"), callback=self._on_install_update)
self._install_btn.set_visible(False)

self._select_branch_dialog: MultiOptionDialog | None = None
self._target_branch_btn = button_item(tr("Target Branch"), tr("SELECT"), callback=self._on_select_branch)

# Track waiting-for-updater transition to avoid brief re-enable while still idle
self._waiting_for_updater = False
self._waiting_start_ts: float = 0.0
Expand All @@ -65,8 +69,7 @@ def _init_items(self):
self._version_item,
self._download_btn,
self._install_btn,
# TODO: implement branch switching
# button_item("Target Branch", "SELECT", callback=self._on_select_branch),
self._target_branch_btn,
button_item("Uninstall", tr("UNINSTALL"), callback=self._on_uninstall),
]
return items
Expand All @@ -87,6 +90,8 @@ def _update_state(self):
self._version_item.action_item.set_text(current_desc)
self._version_item.set_description(current_release_notes)

self._target_branch_btn.action_item.set_value(ui_state.params.get("UpdaterTargetBranch") or "")

# Update download button visibility and state
self._download_btn.set_visible(ui_state.is_offroad())

Expand Down Expand Up @@ -163,4 +168,25 @@ def _on_install_update(self):
self._install_btn.action_item.set_enabled(False)
ui_state.params.put_bool("DoReboot", True)

def _on_select_branch(self): pass
def _on_select_branch(self):
current_branch = ui_state.params.get("GitBranch") or ""
branches_str = ui_state.params.get("UpdaterAvailableBranches") or ""

available_branches = [b.strip() for b in branches_str.split(",") if b.strip()]
priority_branches = [current_branch, "devel-staging", "devel", "nightly", "nightly-dev", "master"]
for branch in priority_branches:
if branch in available_branches:
available_branches.remove(branch)
available_branches.insert(0, branch)

self._select_branch_dialog = MultiOptionDialog(tr("Select a branch"), available_branches, current=current_branch)
gui_app.set_modal_overlay(self._select_branch_dialog, callback=self._handle_branch_selection)

def _handle_branch_selection(self, result: int):
if result == 1 and self._select_branch_dialog:
selected = self._select_branch_dialog.selection
self._target_branch_btn.action_item.set_value(selected)
ui_state.params.put("UpdaterTargetBranch", selected)
os.system("pkill -SIGHUP -f system.updated.updated")
Copy link
Contributor

Choose a reason for hiding this comment

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

Qt uses SIGUSR1 for branch switching


self._select_branch_dialog = None