Skip to content

Commit c1e0666

Browse files
committed
fix(android): serialize workspace file requests
1 parent 870d984 commit c1e0666

3 files changed

Lines changed: 35 additions & 14 deletions

File tree

apps/.i18n/native-source.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5539,87 +5539,87 @@
55395539
},
55405540
{
55415541
"kind": "ui-named-argument",
5542-
"line": 192,
5542+
"line": 198,
55435543
"path": "apps/android/app/src/main/java/ai/openclaw/app/ui/WorkspaceFilesScreen.kt",
55445544
"source": "Refresh",
55455545
"surface": "android",
55465546
"id": "native.android.066337249b9d9d30"
55475547
},
55485548
{
55495549
"kind": "ui-named-argument",
5550-
"line": 201,
5550+
"line": 212,
55515551
"path": "apps/android/app/src/main/java/ai/openclaw/app/ui/WorkspaceFilesScreen.kt",
55525552
"source": "Files unavailable",
55535553
"surface": "android",
55545554
"id": "native.android.eb6ff96aba8f67b4"
55555555
},
55565556
{
55575557
"kind": "ui-named-argument",
5558-
"line": 207,
5558+
"line": 218,
55595559
"path": "apps/android/app/src/main/java/ai/openclaw/app/ui/WorkspaceFilesScreen.kt",
55605560
"source": "Empty folder",
55615561
"surface": "android",
55625562
"id": "native.android.fefb4a6c1717210d"
55635563
},
55645564
{
55655565
"kind": "ui-named-argument",
5566-
"line": 207,
5566+
"line": 218,
55675567
"path": "apps/android/app/src/main/java/ai/openclaw/app/ui/WorkspaceFilesScreen.kt",
55685568
"source": "This folder has no files yet.",
55695569
"surface": "android",
55705570
"id": "native.android.b74f90dc5f65b1da"
55715571
},
55725572
{
55735573
"kind": "ui-named-argument",
5574-
"line": 237,
5574+
"line": 249,
55755575
"path": "apps/android/app/src/main/java/ai/openclaw/app/ui/WorkspaceFilesScreen.kt",
55765576
"source": "Could not load this folder.",
55775577
"surface": "android",
55785578
"id": "native.android.8f0b5317c75e334d"
55795579
},
55805580
{
55815581
"kind": "ui-named-argument",
5582-
"line": 246,
5582+
"line": 258,
55835583
"path": "apps/android/app/src/main/java/ai/openclaw/app/ui/WorkspaceFilesScreen.kt",
55845584
"source": "Load more",
55855585
"surface": "android",
55865586
"id": "native.android.4e48916e1b0f86ab"
55875587
},
55885588
{
55895589
"kind": "ui-named-argument",
5590-
"line": 248,
5590+
"line": 260,
55915591
"path": "apps/android/app/src/main/java/ai/openclaw/app/ui/WorkspaceFilesScreen.kt",
55925592
"source": "${entries.size} of $totalEntries",
55935593
"surface": "android",
55945594
"id": "native.android.f26b7b179d4765b0"
55955595
},
55965596
{
55975597
"kind": "ui-named-argument",
5598-
"line": 341,
5598+
"line": 353,
55995599
"path": "apps/android/app/src/main/java/ai/openclaw/app/ui/WorkspaceFilesScreen.kt",
56005600
"source": "Back",
56015601
"surface": "android",
56025602
"id": "native.android.b2a525ca00a799df"
56035603
},
56045604
{
56055605
"kind": "ui-named-argument",
5606-
"line": 352,
5606+
"line": 364,
56075607
"path": "apps/android/app/src/main/java/ai/openclaw/app/ui/WorkspaceFilesScreen.kt",
56085608
"source": "Share file",
56095609
"surface": "android",
56105610
"id": "native.android.737edf881bc586d5"
56115611
},
56125612
{
56135613
"kind": "ui-named-argument",
5614-
"line": 383,
5614+
"line": 395,
56155615
"path": "apps/android/app/src/main/java/ai/openclaw/app/ui/WorkspaceFilesScreen.kt",
56165616
"source": "No preview",
56175617
"surface": "android",
56185618
"id": "native.android.095574301bf487a1"
56195619
},
56205620
{
56215621
"kind": "ui-named-argument",
5622-
"line": 383,
5622+
"line": 395,
56235623
"path": "apps/android/app/src/main/java/ai/openclaw/app/ui/WorkspaceFilesScreen.kt",
56245624
"source": "This image could not be decoded.",
56255625
"surface": "android",

apps/android/app/src/main/java/ai/openclaw/app/ui/WorkspaceFilesScreen.kt

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ internal fun WorkspaceFilesScreen(
115115
}
116116
}
117117

118+
internal fun isWorkspaceDirectoryRequestInFlight(
119+
loading: Boolean,
120+
loadingMore: Boolean,
121+
): Boolean = loading || loadingMore
122+
118123
@Composable
119124
private fun WorkspaceDirectoryScreen(
120125
viewModel: MainViewModel,
@@ -131,6 +136,7 @@ private fun WorkspaceDirectoryScreen(
131136
var loadingMore by remember(path) { mutableStateOf(false) }
132137
var errorText by remember(path) { mutableStateOf<String?>(null) }
133138
var refreshNonce by remember(path) { mutableIntStateOf(0) }
139+
val requestInFlight = isWorkspaceDirectoryRequestInFlight(loading, loadingMore)
134140

135141
LaunchedEffect(path, isConnected, refreshNonce) {
136142
if (!isConnected) {
@@ -182,15 +188,20 @@ private fun WorkspaceDirectoryScreen(
182188
)
183189
}
184190
}
185-
if (loading) {
191+
if (requestInFlight) {
186192
Box(modifier = Modifier.size(ClawTheme.spacing.touchTarget), contentAlignment = Alignment.Center) {
187193
CircularProgressIndicator(modifier = Modifier.size(18.dp), strokeWidth = 2.dp)
188194
}
189195
} else if (isConnected) {
190196
ClawPlainIconButton(
191197
icon = Icons.Outlined.Refresh,
192198
contentDescription = "Refresh",
193-
onClick = { refreshNonce += 1 },
199+
onClick = {
200+
if (!isWorkspaceDirectoryRequestInFlight(loading, loadingMore)) {
201+
loading = true
202+
refreshNonce += 1
203+
}
204+
},
194205
)
195206
}
196207
}
@@ -225,7 +236,8 @@ private fun WorkspaceDirectoryScreen(
225236
Modifier
226237
.fillMaxWidth()
227238
.clip(RoundedCornerShape(ClawTheme.radii.row))
228-
.clickable(enabled = !loadingMore) {
239+
.clickable(enabled = !requestInFlight) {
240+
if (isWorkspaceDirectoryRequestInFlight(loading, loadingMore)) return@clickable
229241
loadingMore = true
230242
scope.launch {
231243
try {

apps/android/app/src/test/java/ai/openclaw/app/WorkspaceFilesTest.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package ai.openclaw.app
22

3+
import ai.openclaw.app.ui.isWorkspaceDirectoryRequestInFlight
34
import kotlinx.serialization.json.Json
45
import org.junit.Assert.assertEquals
56
import org.junit.Assert.assertNull
@@ -9,6 +10,14 @@ import org.junit.Test
910
class WorkspaceFilesTest {
1011
private val json = Json { ignoreUnknownKeys = true }
1112

13+
@Test
14+
fun tracksDirectoryRequestInFlightAcrossRefreshAndPagination() {
15+
assertEquals(false, isWorkspaceDirectoryRequestInFlight(loading = false, loadingMore = false))
16+
assertEquals(true, isWorkspaceDirectoryRequestInFlight(loading = true, loadingMore = false))
17+
assertEquals(true, isWorkspaceDirectoryRequestInFlight(loading = false, loadingMore = true))
18+
assertEquals(true, isWorkspaceDirectoryRequestInFlight(loading = true, loadingMore = true))
19+
}
20+
1221
@Test
1322
fun parsesListingEntriesAndPagination() {
1423
val payload =

0 commit comments

Comments
 (0)