@@ -22,9 +22,15 @@ ColumnLayout {
2222 // Track the query we're waiting for results from
2323 property string allAppsQueryId: " "
2424 property string searchQueryId: " "
25+ property int retryCount: 0
26+ property int maxRetries: 5
2527
2628 // Load all apps on startup
2729 Component .onCompleted : {
30+ loadAllApps ()
31+ }
32+
33+ function loadAllApps () {
2834 allAppsQueryId = Services .Datacube .queryAll (" " , 500 )
2935 }
3036
@@ -230,6 +236,8 @@ ColumnLayout {
230236
231237 function onQueryCompleted (queryId , results ) {
232238 if (queryId === root .allAppsQueryId ) {
239+ // Reset retry count on success
240+ root .retryCount = 0
233241 // Sort alphabetically by name
234242 results .sort ((a , b ) => {
235243 const nameA = (a .name || " " ).toLowerCase ()
@@ -246,6 +254,22 @@ ColumnLayout {
246254
247255 function onQueryFailed (queryId , error ) {
248256 console .log (" Datacube query failed:" , queryId, error)
257+ // If the allApps query failed, retry after a delay (service may have restarted)
258+ if (queryId === root .allAppsQueryId && root .retryCount < root .maxRetries ) {
259+ root .retryCount ++
260+ console .log (" Datacube: retrying allApps query (attempt" , root .retryCount , " of" , root .maxRetries , " )" )
261+ retryTimer .start ()
262+ }
263+ }
264+ }
265+
266+ // Retry timer for failed queries (datacube service may have restarted)
267+ Timer {
268+ id: retryTimer
269+ interval: 1000 * root .retryCount // Exponential backoff: 1s, 2s, 3s, etc.
270+ repeat: false
271+ onTriggered: {
272+ root .loadAllApps ()
249273 }
250274 }
251275
@@ -275,12 +299,16 @@ ColumnLayout {
275299
276300 // Check if terminal app - handle boolean or string "true"/"false"
277301 const isTerminal = metadata .terminal === true || metadata .terminal === " true"
302+ const source = app? .source || " native"
278303
279304 if (isTerminal) {
280305 // Terminal apps: launch with ghostty
281306 appLaunchProcess .command = [" ghostty" , " -e" , desktopId]
307+ } else if (source === " flatpak" ) {
308+ // Flatpak apps: use flatpak run
309+ appLaunchProcess .command = [" flatpak" , " run" , desktopId]
282310 } else {
283- // GUI apps: use gtk4-launch with desktop_id
311+ // Native apps: use gtk4-launch with desktop_id
284312 appLaunchProcess .command = [" gtk4-launch" , desktopId]
285313 }
286314 // Launch detached so apps survive shell restart and run independently
@@ -296,11 +324,18 @@ ColumnLayout {
296324 command: [" true" ]
297325 }
298326
299- // Reset state when sidebar closes
327+ // Handle sidebar state changes
300328 Connections {
301329 target: Root .GlobalStates
302330 function onSidebarLeftOpenChanged () {
303- if (! Root .GlobalStates .sidebarLeftOpen ) {
331+ if (Root .GlobalStates .sidebarLeftOpen ) {
332+ // Refresh apps if list is empty (datacube may have restarted)
333+ if (root .allApps .length === 0 ) {
334+ root .retryCount = 0
335+ root .loadAllApps ()
336+ }
337+ } else {
338+ // Reset state when sidebar closes
304339 searchInput .text = " "
305340 searchResults = []
306341 }
0 commit comments