Skip to content

Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.

feat(apps): Extensions lists scroll and load more instead of paging

leepokai5e05d193cd20
diff --git a/apps/android/WhatsNew.md b/apps/android/WhatsNew.md
index 14716044..4925b4a2 100644
--- a/apps/android/WhatsNew.md
+++ b/apps/android/WhatsNew.md
@@ -12,7 +12,7 @@ else a generic "Bug fixes and improvements" line. Delete old sections.
### zh-Hant
- Bot 傳來的圖片會直接顯示在聊天裡,點一下可以放大看,不用先下載。
- 電腦上的 Codync 版本太舊時,更新提示多了「Update now」按鈕,直接從手機叫那台電腦更新。
-- 擴充套件一次顯示一個分類:智慧體、聯結器或技能,每個列表都分頁。點列表兩側的圓形按鈕或左右滑動翻頁,每頁可選 6、10、20 或 50 筆。
+- 擴充套件一次顯示一個分類:智慧體、聯結器或技能;聯結器往下捲到底會自動載入更多。
- 電腦使用自建中繼時,設定和連線狀態會顯示該中繼的地址,不再一律寫成 Cloudflare。
- 可以建立使用 WorkBuddy 的 Bot,在聊天裡登入即可。
- 用量也會顯示這台電腦上其他 agent 的額度。Cursor 會用本機登入向 cursor.com 查詢。
@@ -20,7 +20,7 @@ else a generic "Bug fixes and improvements" line. Delete old sections.
### en-US
- Images a bot sends now show right in the chat; tap one to see it full size, no download needed.
- When a computer's Codync is too old for this app, Update now on the notice updates that computer from your phone.
-- Extensions shows Agents, Connectors or Skills in pages: tap the round buttons or swipe, 6 to 50 per page.
+- Extensions shows Agents, Connectors or Skills one at a time; connectors load more as you scroll.
- A private relay shows its address in Settings and status.
- Bots can run WorkBuddy; sign in from the chat.
- Adds other agents' limits. Cursor asks cursor.com.
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/ConnectorCatalog.kt b/apps/android/app/src/main/kotlin/com/codync/android/ConnectorCatalog.kt
index de813f09..86bb710b 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/ConnectorCatalog.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/ConnectorCatalog.kt
@@ -1,17 +1,14 @@
package com.codync.android
import androidx.compose.runtime.getValue
-import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import com.codync.android.core.CatalogPage
-import com.codync.android.core.CatalogPaging
import kotlinx.coroutines.CancellationException
/**
- * The connector list Extensions pages through (iOS `ConnectorCatalog`): the rows loaded so far, the
- * registry cursor and the page on screen. A page that isn't full asks the registry until it is, or
- * until the cursor ends.
+ * The connector list Extensions scrolls through (iOS `ConnectorCatalog`): the rows loaded so far and
+ * the registry cursor. The end of the list coming into view asks for more (`loadMore`).
*/
internal class ConnectorCatalog<T>(
private val id: (T) -> String,
@@ -20,8 +17,6 @@ internal class ConnectorCatalog<T>(
var items by mutableStateOf(CatalogPage<T>()); private set
/** The registry page after the ones loaded; null at the end. */
var cursor by mutableStateOf<String?>(null); private set
- /** The page on screen. While the registry fills it, it can be the page past the loaded rows. */
- var page by mutableIntStateOf(0); private set
var loading by mutableStateOf(true); private set
var loadingMore by mutableStateOf(false); private set
var error by mutableStateOf<String?>(null); private set
@@ -35,19 +30,9 @@ internal class ConnectorCatalog<T>(
val mine = ++request
query = search; loading = true; loadingMore = false
try {
- var (rows, next) = fetch(search, null)
+ val (rows, next) = fetch(search, null)
if (request != mine) return
- // The host reads past registry pages with nothing to install only while the app waits for its
- // answer. An empty first page that still has a cursor gets a few more asks before it reads as
- // no results: a phone has no other way to reach the rows after it.
- var asks = 0
- while (rows.isEmpty() && !next.isNullOrBlank() && asks < EMPTY_PAGE_ASKS) {
- asks++
- val more = fetch(search, next)
- if (request != mine) return
- rows = more.first; next = more.second
- }
- items = CatalogPage<T>().append(rows, id); cursor = next?.takeIf(String::isNotBlank); page = 0; error = null
+ items = CatalogPage<T>().append(rows, id); cursor = next?.takeIf(String::isNotBlank); error = null
} catch (cancelled: CancellationException) { throw cancelled }
catch (failure: Exception) {
if (request != mine) return
@@ -55,36 +40,23 @@ internal class ConnectorCatalog<T>(
} finally { if (request == mine) loading = false }
}
- /** Turns to `next` at once, so a swipe stays where it landed; `fill` then loads its rows. */
- fun show(next: Int, size: Int) {
- if (!loading) page = CatalogPaging.clamp(next, items.items.size, size, hasMore)
- }
-
/**
- * Asks the registry until the page on screen is full or the cursor ends. A page turned meanwhile
- * is filled by the same loop. If a page fails, the list goes back to the last page with rows.
+ * The registry page at the cursor. It can bring nothing Codync can install; the cursor still moves on, so
+ * `LoadMoreRow` asks again. A failure keeps the cursor and shows under the list.
*/
- suspend fun fill(size: Int) {
- if (loading || loadingMore || !hasMore || !CatalogPaging.needsFetch(items.items.size, page, size)) return
+ suspend fun loadMore() {
+ val at = cursor
+ if (loading || loadingMore || at == null) return
val mine = request
- loadingMore = true
+ loadingMore = true; error = null
try {
- while (true) {
- val at = cursor ?: break
- if (!CatalogPaging.needsFetch(items.items.size, page, size)) break
- val (rows, next) = fetch(query, at)
- if (request != mine) return
- items = items.append(rows, id); cursor = next?.takeIf(String::isNotBlank)
- }
- page = CatalogPaging.clamp(page, items.items.size, size, hasMore); error = null
+ val (rows, next) = fetch(query, at)
+ if (request != mine) return
+ items = items.append(rows, id); cursor = next?.takeIf(String::isNotBlank)
} catch (cancelled: CancellationException) { throw cancelled }
catch (failure: Exception) {
if (request != mine) return
error = failure.message ?: "Couldn't load more connectors."
- page = CatalogPaging.clamp(page, items.items.size, size)
} finally { if (request == mine) loadingMore = false }
}
}
-
-/** Further registry pages a search reads when its first answer is empty but continues (iOS `emptyPageAsks`). */
-internal const val EMPTY_PAGE_ASKS = 3
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/MarketPager.kt b/apps/android/app/src/main/kotlin/com/codync/android/MarketPager.kt
deleted file mode 100644
index 0e24c83a..00000000
--- a/apps/android/app/src/main/kotlin/com/codync/android/MarketPager.kt
+++ /dev/null
@@ -1,169 +0,0 @@
-package com.codync.android
-
-import androidx.compose.foundation.background
-import androidx.compose.foundation.layout.Arrangement
-import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.BoxWithConstraints
-import androidx.compose.foundation.layout.Column
-import androidx.compose.foundation.layout.ExperimentalLayoutApi
-import androidx.compose.foundation.layout.FlowRow
-import androidx.compose.foundation.layout.Row
-import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.height
-import androidx.compose.foundation.layout.offset
-import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.size
-import androidx.compose.foundation.layout.width
-import androidx.compose.foundation.pager.HorizontalPager
-import androidx.compose.foundation.pager.rememberPagerState
-import androidx.compose.foundation.selection.selectable
-import androidx.compose.foundation.shape.CircleShape
-import androidx.compose.material3.Text
-import androidx.compose.runtime.Composable
-import androidx.compose.runtime.LaunchedEffect
-import androidx.compose.runtime.getValue
-import androidx.compose.runtime.key
-import androidx.compose.runtime.rememberCoroutineScope
-import androidx.compose.runtime.rememberUpdatedState
-import androidx.compose.runtime.snapshotFlow
-import androidx.compose.ui.Alignment
-import androidx.compose.ui.Modifier
-import androidx.compose.ui.draw.clip
-import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.graphics.graphicsLayer
-import androidx.compose.ui.semantics.Role
-import androidx.compose.ui.text.style.TextOverflow
-import androidx.compose.ui.unit.dp
-import com.codync.android.core.CatalogPaging
-import com.codync.android.design.*
-import com.kyant.shapes.Capsule
-import com.kyant.shapes.RoundedRectangle
-import kotlin.math.abs
-import kotlinx.coroutines.launch
-
-// Extensions' sections and paging (iOS `MarketplaceTabs` + `CatalogPager`): the section rail, the pager a
-// list turns in, and the bar under it.
-
-/** Narrower than this, a list is a pager with previous and next beside it, and the bar keeps only the size and the page. */
-private val PhonePagerWidth = 560.dp
-
-internal enum class ExtensionSection(val title: String, val icon: String, val source: String) {
- Agents("Agents", "terminal", "Agents come from the ACP registry and install on {name}."),
- Connectors("Connectors", "point.3.connected.trianglepath.dotted", "Connectors come from the official MCP Registry and install on {name}."),
- Skills("Skills", "book.pages", "Skills come from Anthropic and install on {name}."),
-}
-
-/** Agents, Connectors, Skills: the chosen row is filled, like a side tab. */
-@Composable internal fun ExtensionRail(selection: ExtensionSection, select: (ExtensionSection) -> Unit) {
- Column(Modifier.width(168.dp), verticalArrangement = Arrangement.spacedBy(4.dp)) {
- for (section in ExtensionSection.entries) {
- val on = section == selection
- Row(Modifier.fillMaxWidth().clip(RoundedRectangle(12.dp))
- .background(if (on) Palette.bubbleAgent else Color.Transparent)
- .selectable(selected = on, role = Role.Tab) { select(section) }
- .padding(horizontal = 12.dp, vertical = 8.dp),
- verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(10.dp)) {
- Symbol(section.icon, size = 16.dp, tint = if (on) Palette.text else Palette.secondary)
- Text(tr(section.title), style = if (on) Type.subheadline.semibold else Type.subheadline,
- color = if (on) Palette.text else Palette.secondary, maxLines = 1, overflow = TextOverflow.Ellipsis)
- }
- }
- }
-}
-
-/**
- * On a phone the list is a pager: swipe or the side buttons turn it, and `settle` hears where it came to rest.
- * When the page moves from outside (search, page size, a failed fetch), the pager follows `page` back.
- * A wide layout shows the one page.
- */
-@Composable internal fun FlankedPager(page: Int, count: Int, pageSize: Int, hasMore: Boolean = false, loading: Boolean = false,
- settle: (Int) -> Unit, content: @Composable (Int) -> Unit) {
- val scope = rememberCoroutineScope()
- val still = reduceMotion()
- val pages = CatalogPaging.pageCount(count, pageSize, hasMore)
- val current = CatalogPaging.clamp(page, count, pageSize, hasMore)
- BoxWithConstraints(Modifier.fillMaxWidth()) {
- if (maxWidth >= PhonePagerWidth) content(current)
- else key(pageSize) {
- val pager = rememberPagerState(current) { pages }
- val onSettle by rememberUpdatedState(settle)
- LaunchedEffect(pager) { snapshotFlow { pager.settledPage }.collect { onSettle(it) } }
- LaunchedEffect(current, loading) {
- val from = pager.settledPage
- if (loading || from == current) return@LaunchedEffect
- if (still || abs(from - current) > 1) pager.scrollToPage(current) else pager.animateScrollToPage(current)
- }
- fun turn(by: Int) {
- scope.launch { (pager.currentPage + by).let { if (still) pager.scrollToPage(it) else pager.animateScrollToPage(it) } }
- }
- Box(Modifier.fillMaxWidth()) {
- HorizontalPager(pager, Modifier.fillMaxWidth(), pageSpacing = 20.dp, userScrollEnabled = !loading,
- verticalAlignment = Alignment.Top) { content(it) }
- if (pages > 1) {
- PageEdgeButton("Previous page", "chevron.left", current > 0 && !loading, Modifier.align(Alignment.CenterStart).offset(x = (-40).dp)) { turn(-1) }
- PageEdgeButton(if (loading) "Loading…" else "Next page", "chevron.right", CatalogPaging.canForward(count, current, hasMore, pageSize) && !loading,
- Modifier.align(Alignment.CenterEnd).offset(x = 40.dp)) { turn(1) }
- }
- }
- }
- }
-}
-
-/** Previous or next, beside the list on a phone: filled in the text color so it reads as a control, faint when there is no page that way. */
-@Composable private fun PageEdgeButton(title: String, symbol: String, enabled: Boolean, modifier: Modifier = Modifier, action: () -> Unit) {
- Box(modifier.size(36.dp).graphicsLayer { alpha = if (enabled) 1f else 0.25f }.clip(CircleShape).background(Palette.text)
- .plainButton(enabled = enabled, action = action), contentAlignment = Alignment.Center) {
- Symbol(symbol, size = 15.dp, tint = Palette.background, contentDescription = tr(title))
- }
-}
-
-/** Count, page size, previous, current / total, and next. */
-@OptIn(ExperimentalLayoutApi::class)
-@Composable internal fun CatalogPager(page: Int, count: Int, pageSize: Int, hasMore: Boolean = false, loading: Boolean = false,
- go: (Int) -> Unit, onSize: (Int) -> Unit) {
- val pages = CatalogPaging.pageCount(count, pageSize, hasMore)
- val current = CatalogPaging.clamp(page, count, pageSize, hasMore)
- val total = tr("{count} total").replace("{count}", "$count")
- val canPrev = current > 0 && !loading
- val canNext = CatalogPaging.canForward(count, current, hasMore, pageSize) && !loading
- @Composable fun SizeLabel() {
- DropdownMenu(items = {
- CatalogPaging.pageSizes.map { size -> MenuItem("$size / page", selected = size == pageSize) { onSize(size) } }
- }) {
- Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(2.dp)) {
- Text(tr("$pageSize / page"), style = Type.footnote, color = Palette.secondary)
- Symbol("chevron.down", size = 10.dp, tint = Palette.secondary)
- }
- }
- }
- @Composable fun SizeMenu() {
- Text(tr("Per page"), style = Type.footnote, color = Palette.secondary)
- DropdownMenu(items = {
- CatalogPaging.pageSizes.map { size -> MenuItem("$size / page", selected = size == pageSize) { onSize(size) } }
- }) {
- Row(Modifier.clip(RoundedRectangle(8.dp)).background(Palette.bubbleAgent).padding(horizontal = 10.dp).height(28.dp),
- verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(4.dp)) {
- Text(tr("$pageSize / page"), style = Type.footnote, color = Palette.text)
- Symbol("chevron.down", size = 10.dp, tint = Palette.secondary)
- }
- }
- }
- BoxWithConstraints(Modifier.fillMaxWidth()) {
- if (maxWidth < PhonePagerWidth) {
- // Previous and next sit beside the list; the capsule keeps the page size and the page number.
- Row(Modifier.fillMaxWidth().clip(Capsule()).background(Palette.bubbleAgent).padding(horizontal = 16.dp, vertical = 8.dp),
- verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.SpaceBetween) {
- SizeLabel()
- Text("${current + 1} / $pages", style = Type.subheadline.semibold, color = Palette.text)
- }
- } else FlowRow(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(8.dp), verticalArrangement = Arrangement.spacedBy(8.dp),
- itemVerticalAlignment = Alignment.CenterVertically) {
- Text(total, style = Type.footnote, color = Palette.secondary)
- SizeMenu()
- IconButton("Previous page", "chevron.left", enabled = canPrev) { go(current - 1) }
- Text("${current + 1} / $pages", style = Type.footnote, color = Palette.text)
- IconButton(if (loading) "Loading…" else "Next page", "chevron.right", enabled = canNext) { go(current + 1) }
- }
- }
-}
-
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/MarketRows.kt b/apps/android/app/src/main/kotlin/com/codync/android/MarketRows.kt
index 99210e23..d24a951d 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/MarketRows.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/MarketRows.kt
@@ -24,7 +24,6 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
-import androidx.compose.ui.draw.alpha
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
@@ -72,13 +71,8 @@ import com.kyant.shapes.RoundedRectangle
}
}
-/** A catalog row's room, with nothing in it (an added row has nothing to tap). A short last page keeps a full page of rows. */
-@Composable internal fun MarketRowSpacer() {
- Box(Modifier.alpha(0f).clearAndSetSemantics {}) { MarketRow(" ", " ", added = true, icon = {}) {} }
-}
-
-/** An agent in the Agents row: its logo on a tile, its name and where it stands. */
-@Composable internal fun AgentCard(backend: AgentBackend, modifier: Modifier = Modifier.width(128.dp), action: () -> Unit) {
+/** An agent in the Agents grid: its logo on a tile, its name and where it stands. */
+@Composable internal fun AgentCard(backend: AgentBackend, modifier: Modifier, action: () -> Unit) {
val status = when {
!backend.installed && backend.curated -> "Not installed"
backend.needsNode -> "Needs Node.js"
@@ -86,25 +80,15 @@ import com.kyant.shapes.RoundedRectangle
backend.signedIn == false -> "Not signed in"
else -> "Installed"
}
- AgentCardBody(modifier.clip(RoundedRectangle(18.dp)).background(Palette.bubbleAgent.copy(alpha = 0.45f)).plainButton(action = action)
- .semantics(mergeDescendants = true) {}, backend.registry ?: backend.id, backend.name, tr(status))
-}
-
-/** An agent tile's room, with nothing in it. A short last page keeps a full page of rows, so the bar under it stays put. */
-@Composable internal fun AgentCardSpacer(modifier: Modifier = Modifier) {
- AgentCardBody(modifier.alpha(0f).clearAndSetSemantics {}, null, " ", " ")
-}
-
-/** An agent tile's logo, name and status line. */
-@Composable private fun AgentCardBody(modifier: Modifier, registry: String?, name: String, status: String) {
- Column(modifier.padding(horizontal = 10.dp, vertical = 14.dp),
+ Column(modifier.clip(RoundedRectangle(18.dp)).background(Palette.bubbleAgent.copy(alpha = 0.45f)).plainButton(action = action)
+ .semantics(mergeDescendants = true) {}.padding(horizontal = 10.dp, vertical = 18.dp),
horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy(12.dp)) {
- Box(Modifier.size(56.dp).clip(RoundedRectangle(16.dp)).background(Palette.bubbleAgent), contentAlignment = Alignment.Center) {
- AgentIcon(registry, 30.dp)
+ Box(Modifier.size(64.dp).clip(RoundedRectangle(18.dp)).background(Palette.bubbleAgent), contentAlignment = Alignment.Center) {
+ AgentIcon(backend.registry ?: backend.id, 34.dp)
}
Column(horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy(2.dp)) {
- Text(name, style = Type.subheadline.semibold, color = Palette.text, maxLines = 1, overflow = TextOverflow.Ellipsis)
- Text(status, style = Type.caption, color = Palette.secondary, maxLines = 1, overflow = TextOverflow.Ellipsis)
+ Text(backend.name, style = Type.subheadline.semibold, color = Palette.text, maxLines = 1, overflow = TextOverflow.Ellipsis)
+ Text(tr(status), style = Type.caption, color = Palette.secondary, maxLines = 1, overflow = TextOverflow.Ellipsis)
}
}
}
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/MarketplaceTabs.kt b/apps/android/app/src/main/kotlin/com/codync/android/MarketplaceTabs.kt
new file mode 100644
index 00000000..086ddf41
--- /dev/null
+++ b/apps/android/app/src/main/kotlin/com/codync/android/MarketplaceTabs.kt
@@ -0,0 +1,64 @@
+package com.codync.android
+
+import androidx.compose.foundation.background
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.selection.selectable
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.rememberCoroutineScope
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.clip
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.semantics.Role
+import androidx.compose.ui.text.style.TextOverflow
+import androidx.compose.ui.unit.dp
+import com.codync.android.design.*
+import com.kyant.shapes.RoundedRectangle
+import kotlinx.coroutines.launch
+
+// Extensions' sections (iOS `MarketplaceTabs`): the section rail, and the end of a list the registry continues.
+
+internal enum class ExtensionSection(val title: String, val icon: String, val source: String) {
+ Agents("Agents", "terminal", "Agents come from the ACP registry and install on {name}."),
+ Connectors("Connectors", "point.3.connected.trianglepath.dotted", "Connectors come from the official MCP Registry and install on {name}."),
+ Skills("Skills", "book.pages", "Skills come from Anthropic and install on {name}."),
+}
+
+/** Agents, Connectors, Skills: the chosen row is filled, like a side tab. */
+@Composable internal fun ExtensionRail(selection: ExtensionSection, select: (ExtensionSection) -> Unit) {
+ Column(Modifier.width(168.dp), verticalArrangement = Arrangement.spacedBy(4.dp)) {
+ for (section in ExtensionSection.entries) {
+ val on = section == selection
+ Row(Modifier.fillMaxWidth().clip(RoundedRectangle(12.dp))
+ .background(if (on) Palette.bubbleAgent else Color.Transparent)
+ .selectable(selected = on, role = Role.Tab) { select(section) }
+ .padding(horizontal = 12.dp, vertical = 8.dp),
+ verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(10.dp)) {
+ Symbol(section.icon, size = 16.dp, tint = if (on) Palette.text else Palette.secondary)
+ Text(tr(section.title), style = if (on) Type.subheadline.semibold else Type.subheadline,
+ color = if (on) Palette.text else Palette.secondary, maxLines = 1, overflow = TextOverflow.Ellipsis)
+ }
+ }
+ }
+}
+
+/**
+ * The end of a list the registry continues (iOS `LoadMoreRow`), as the last item of a lazy list, which composes it
+ * only near view. Composed, it asks for the page at `cursor`, and again each time the cursor moves on while it
+ * stays. After a failure it shows Try again, and asks again once it scrolls back into view.
+ */
+@Composable internal fun LoadMoreRow(cursor: String, failed: Boolean, load: suspend () -> Unit) {
+ val scope = rememberCoroutineScope()
+ LaunchedEffect(cursor) { load() }
+ if (failed) Box(Modifier.fillMaxWidth(), contentAlignment = Alignment.Center) {
+ IconButton("Try again", "arrow.clockwise") { scope.launch { load() } }
+ } else SkeletonRows()
+}
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/MarketplaceView.kt b/apps/android/app/src/main/kotlin/com/codync/android/MarketplaceView.kt
index 5e76a879..5a96c9a2 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/MarketplaceView.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/MarketplaceView.kt
@@ -11,20 +11,22 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.rememberScrollState
+import androidx.compose.foundation.lazy.LazyColumn
+import androidx.compose.foundation.lazy.LazyListScope
+import androidx.compose.foundation.lazy.LazyListState
+import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.text.KeyboardActions
-import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
-import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
@@ -38,7 +40,6 @@ import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.unit.dp
import androidx.compose.ui.text.style.TextOverflow
import com.codync.android.core.AgentBackend
-import com.codync.android.core.CatalogPaging
import com.codync.android.core.MarketConnector
import com.codync.android.core.MarketSkill
import com.codync.android.design.*
@@ -48,8 +49,9 @@ import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.launch
/**
- * Extensions (iOS `MarketplaceView`): Agents, Connectors and Skills, one at a time, each paged.
- * Installing happens on the computer; each bot turns connectors and skills on in its settings.
+ * Extensions (iOS `MarketplaceView`): Agents, Connectors and Skills, one at a time, each a lazy list; the connectors
+ * load more from the registry as their end comes into view. Installing happens on the computer; each bot turns
+ * connectors and skills on in its settings.
*/
@Composable internal fun MarketplaceView(state: AppState, store: AppStore) {
var showInstalled by remember { mutableStateOf(false) }
@@ -80,22 +82,7 @@ import kotlinx.coroutines.launch
var addingNode by remember { mutableStateOf(false) }
var showCredentials by remember { mutableStateOf(false) }
var section by remember { mutableStateOf(ExtensionSection.Agents) }
- var agentPage by remember { mutableIntStateOf(0) }
- var skillPage by remember { mutableIntStateOf(0) }
- var pageSize by remember { mutableIntStateOf(CatalogPaging.phonePageSize) }
- var pickedPageSize by remember { mutableStateOf(false) }
val query = search.trim()
- /**
- * A size picked from the menu, or one that follows the layout, starts every list over in the same change as
- * the size, so no pager is ever built for the new size at the old page.
- */
- fun resize(size: Int) { pageSize = size; agentPage = 0; skillPage = 0; connectors.show(0, size) }
- fun changePageSize(size: Int) { pickedPageSize = true; resize(size) }
- /** Turns the connector list to `page` at once; a page that isn't full then fills from the registry. */
- fun showConnectorPage(page: Int) {
- connectors.show(page, pageSize)
- scope.launch { connectors.fill(pageSize) }
- }
fun submit() { scope.launch { connectors.load(query) } }
LaunchedEffect(Unit) { store.refreshPlugins(); store.refreshBackends() }
LaunchedEffect(Unit) { connectors.load(query) }
@@ -110,84 +97,59 @@ import kotlinx.coroutines.launch
val installedSkills = state.plugins?.skills.orEmpty()
val shownSkills = if (query.isEmpty()) skills else skills.filter { it.name.contains(query, true) || it.description.contains(query, true) }
val inset = Modifier.padding(horizontal = 44.dp)
- fun changeSearch(next: String) { search = next; agentPage = 0; skillPage = 0 }
- fun pagePad(count: Int, shown: Int) = if (count > pageSize) maxOf(0, pageSize - shown) else 0
+ val needsNode = backends.any { it.needsNode }
+ val pinned = section != ExtensionSection.Agents || needsNode
+ // Each section opens at its top.
+ val listState = remember(section) { LazyListState() }
@Composable fun Pins() {
- if (section == ExtensionSection.Agents && backends.any { it.needsNode }) NodeNotice(state) { addingNode = true }
+ if (section == ExtensionSection.Agents && needsNode) NodeNotice(state) { addingNode = true }
if (section == ExtensionSection.Connectors) MarketRow("Custom connector", "Any MCP server: a command or a URL", added = false, addLabel = "New",
icon = { TileIcon("point.3.connected.trianglepath.dotted") }) { addingConnector = true }
if (section == ExtensionSection.Skills) MarketRow("Your own skill", "Write instructions a bot can follow", added = false, addLabel = "New",
icon = { TileIcon("square.and.pencil") }) { writingSkill = true }
}
- @Composable fun Lists() {
+ /** The open section's list as lazy items, two agent tiles to a row, so a long list composes only the rows near view. */
+ fun LazyListScope.lists() {
when (section) {
- ExtensionSection.Agents -> if (agents.isEmpty()) Text(if (query.isEmpty()) tr("No agents yet.") else tr("No agents match “{query}”.").replace("{query}", query), style = Type.body, color = Palette.secondary)
- else {
- FlankedPager(agentPage, agents.size, pageSize, settle = { agentPage = it }) { index ->
- val shown = CatalogPaging.slice(agents, index, pageSize)
- val slots = buildList<AgentBackend?> {
- addAll(shown)
- repeat(pagePad(agents.size, shown.size)) { add(null) }
- }
- Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
- for (row in slots.chunked(2)) Row(horizontalArrangement = Arrangement.spacedBy(10.dp)) {
- for (backend in row) if (backend != null) AgentCard(backend, Modifier.weight(1f)) { agent = backend }
- else AgentCardSpacer(Modifier.weight(1f))
- if (row.size == 1) Spacer(Modifier.weight(1f))
- }
- }
+ ExtensionSection.Agents -> if (agents.isEmpty()) item {
+ Text(if (query.isEmpty()) tr("No agents yet.") else tr("No agents match “{query}”.").replace("{query}", query), style = Type.body, color = Palette.secondary)
+ } else items(agents.chunked(2)) { row ->
+ Row(Modifier.padding(bottom = 6.dp), horizontalArrangement = Arrangement.spacedBy(10.dp)) {
+ for (backend in row) AgentCard(backend, Modifier.weight(1f)) { agent = backend }
+ if (row.size == 1) Spacer(Modifier.weight(1f))
}
}
ExtensionSection.Connectors -> when {
- connectors.loading -> SkeletonRows()
- connectors.items.items.isEmpty() -> Text(if (query.isEmpty()) tr("Couldn't load connectors.") else tr("No connectors match “{query}”.").replace("{query}", query), style = Type.body, color = Palette.secondary)
+ connectors.loading -> item { SkeletonRows() }
+ connectors.items.items.isEmpty() && !connectors.hasMore -> item {
+ Text(if (query.isEmpty()) tr("Couldn't load connectors.") else tr("No connectors match “{query}”.").replace("{query}", query), style = Type.body, color = Palette.secondary)
+ }
else -> {
val rows = connectors.items.items
- FlankedPager(connectors.page, rows.size, pageSize, connectors.hasMore, connectors.loadingMore, ::showConnectorPage) { index ->
- val shown = CatalogPaging.slice(rows, index, pageSize)
- // The page past the loaded rows, while the registry fills it.
- if (shown.isEmpty()) SkeletonRows()
- else Column(verticalArrangement = Arrangement.spacedBy(4.dp)) {
- for (c in shown) MarketRow(c.title, c.description ?: c.name, c.installed,
- icon = { ServiceLogo(c.website, c.title, c.name) }) { installing = c }
- repeat(pagePad(rows.size, shown.size)) { MarketRowSpacer() }
- }
+ items(rows, key = { it.name }) { c ->
+ MarketRow(c.title, c.description ?: c.name, c.installed, icon = { ServiceLogo(c.website, c.title, c.name) }) { installing = c }
}
+ connectors.cursor?.let { cursor -> item { LoadMoreRow(cursor, connectors.error != null) { connectors.loadMore() } } }
}
}
- ExtensionSection.Skills -> if (loadingSkills) SkeletonRows()
- else if (query.isNotEmpty() && shownSkills.isEmpty()) Text(tr("No skills match “{query}”.").replace("{query}", query), style = Type.body, color = Palette.secondary)
- else {
- FlankedPager(skillPage, shownSkills.size, pageSize, settle = { skillPage = it }) { index ->
- val shown = CatalogPaging.slice(shownSkills, index, pageSize)
- Column(verticalArrangement = Arrangement.spacedBy(4.dp)) {
- for (s in shown) {
- val added = s.installed || installedSkills.any { it.id == s.source.lowercase() }
- MarketRow(s.name, s.description, added, busy = busySkill == s.source,
- open = { viewingSkill = SkillRef("catalog/${s.source}", s.name, s.description, s.source, added) }, icon = { SkillGlyph() }) {
- busySkill = s.source
- scope.launch {
- try { store.installSkill(s.source) }
- catch (cancelled: CancellationException) { throw cancelled }
- catch (failure: Exception) { error = failure.message ?: "Couldn't add ${s.name}." }
- finally { busySkill = null }
- }
- }
- }
- repeat(pagePad(shownSkills.size, shown.size)) { MarketRowSpacer() }
+ ExtensionSection.Skills -> if (loadingSkills) item { SkeletonRows() }
+ else if (query.isNotEmpty() && shownSkills.isEmpty()) item {
+ Text(tr("No skills match “{query}”.").replace("{query}", query), style = Type.body, color = Palette.secondary)
+ } else items(shownSkills, key = { it.source }) { s ->
+ val added = s.installed || installedSkills.any { it.id == s.source.lowercase() }
+ MarketRow(s.name, s.description, added, busy = busySkill == s.source,
+ open = { viewingSkill = SkillRef("catalog/${s.source}", s.name, s.description, s.source, added) }, icon = { SkillGlyph() }) {
+ busySkill = s.source
+ scope.launch {
+ try { store.installSkill(s.source) }
+ catch (cancelled: CancellationException) { throw cancelled }
+ catch (failure: Exception) { error = failure.message ?: "Couldn't add ${s.name}." }
+ finally { busySkill = null }
}
}
}
}
}
- @Composable fun Pagers() {
- when (section) {
- ExtensionSection.Agents -> CatalogPager(agentPage, agents.size, pageSize, go = { agentPage = CatalogPaging.clamp(it, agents.size, pageSize) }, onSize = ::changePageSize)
- ExtensionSection.Connectors -> if (!connectors.loading) CatalogPager(connectors.page, connectors.items.items.size, pageSize, connectors.hasMore,
- connectors.loadingMore, ::showConnectorPage, ::changePageSize)
- ExtensionSection.Skills -> if (!loadingSkills) CatalogPager(skillPage, shownSkills.size, pageSize, go = { skillPage = CatalogPaging.clamp(it, shownSkills.size, pageSize) }, onSize = ::changePageSize)
- }
- }
@Composable fun SourceLine() {
Text(tr(section.source).replace("{name}", state.hostName), style = Type.footnote, color = Palette.tertiary)
}
@@ -197,33 +159,27 @@ import kotlinx.coroutines.launch
Box(Modifier.fillMaxSize().background(Palette.background)) {
BoxWithConstraints(Modifier.fillMaxSize()) {
val wide = maxWidth >= 760.dp
- LaunchedEffect(wide, pickedPageSize) {
- val size = if (wide) CatalogPaging.pageSize else CatalogPaging.phonePageSize
- if (!pickedPageSize && size != pageSize) resize(size)
- }
Column(Modifier.fillMaxSize().padding(vertical = 20.dp), verticalArrangement = Arrangement.spacedBy(20.dp)) {
Header(state, inset, showInstalled) { showCredentials = true }
- SearchBox(search, ::changeSearch, inset, ::submit) { changeSearch(""); submit() }
+ SearchBox(search, { search = it }, inset, ::submit) { search = ""; submit() }
if (wide) Row(Modifier.weight(1f).padding(horizontal = 44.dp), horizontalArrangement = Arrangement.spacedBy(20.dp)) {
ExtensionRail(section) { section = it }
Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(12.dp)) {
SourceLine()
Pins()
- Column(Modifier.weight(1f).verticalScroll(rememberScrollState()), verticalArrangement = Arrangement.spacedBy(8.dp)) {
- Lists()
- Pagers()
- }
+ LazyColumn(Modifier.weight(1f), listState, verticalArrangement = Arrangement.spacedBy(4.dp)) { lists() }
Foot()
}
- } else Column(Modifier.weight(1f).verticalScroll(rememberScrollState()).then(inset), verticalArrangement = Arrangement.spacedBy(16.dp)) {
- Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
- TabChoice(section, ExtensionSection.entries.map { it to it.title }, { section = it })
- SourceLine()
+ } else LazyColumn(Modifier.weight(1f), listState, contentPadding = PaddingValues(horizontal = 44.dp), verticalArrangement = Arrangement.spacedBy(4.dp)) {
+ item {
+ Column(Modifier.padding(bottom = 12.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {
+ TabChoice(section, ExtensionSection.entries.map { it to it.title }, { section = it })
+ SourceLine()
+ }
}
- Pins()
- Lists()
- Pagers()
- Foot()
+ if (pinned) item { Box(Modifier.padding(bottom = 12.dp)) { Pins() } }
+ lists()
+ item { Foot() }
}
}
}
diff --git a/apps/android/app/src/test/kotlin/com/codync/android/ConnectorCatalogTest.kt b/apps/android/app/src/test/kotlin/com/codync/android/ConnectorCatalogTest.kt
index 281e1f57..84bbbb2c 100644
--- a/apps/android/app/src/test/kotlin/com/codync/android/ConnectorCatalogTest.kt
+++ b/apps/android/app/src/test/kotlin/com/codync/android/ConnectorCatalogTest.kt
@@ -5,55 +5,40 @@ import org.junit.Assert.*
import org.junit.Test
class ConnectorCatalogTest {
- @Test fun aConnectorPageFillsUntilFullAndFallsBackWhenItCannot() = runBlocking {
+ @Test fun moreConnectorsReadOnPastEmptyPagesAndStopAtAFailure() = runBlocking {
val asked = mutableListOf<String?>()
- var offline = false
- val catalog = ConnectorCatalog<Int>({ it.toString() }) { _, cursor ->
- asked += cursor
- if (offline) error("offline")
+ var answer: (String?) -> Pair<List<Int>, String?> = { cursor ->
when (cursor) {
null -> (0 until 15).toList() to "a"
- "a" -> (15 until 18).toList() to "b"
- else -> (18 until 25).toList() to "c"
+ "a" -> emptyList<Int>() to "b"
+ else -> (15 until 25).toList() to "c"
}
}
+ val catalog = ConnectorCatalog<Int>({ it.toString() }) { _, cursor -> asked += cursor; answer(cursor) }
catalog.load("")
assertEquals(15, catalog.items.items.size)
- // Page 2 needs rows 10-19: two registry pages fill it.
- catalog.show(1, 10)
- catalog.fill(10)
+ // The next page has nothing to install but moves the cursor on: the one after it brings the rows.
+ catalog.loadMore()
+ assertEquals(15, catalog.items.items.size)
+ assertEquals("b", catalog.cursor)
+ catalog.loadMore()
assertEquals(listOf(null, "a", "b"), asked)
- assertEquals(1, catalog.page)
assertEquals(25, catalog.items.items.size)
assertEquals("c", catalog.cursor)
- // The page past the loaded rows fails: back to the last page with rows.
- offline = true
- catalog.show(3, 10)
- assertEquals(3, catalog.page)
- catalog.fill(10)
- assertEquals(2, catalog.page)
+ answer = { error("offline") }
+ catalog.loadMore()
+ assertEquals(25, catalog.items.items.size)
+ assertEquals("c", catalog.cursor)
assertEquals("offline", catalog.error)
assertFalse(catalog.loadingMore)
- }
-
- @Test fun anEmptyFirstPageThatContinuesReadsOnToRows() = runBlocking {
- val catalog = ConnectorCatalog<Int>({ it.toString() }) { _, cursor ->
- when (cursor) {
- null -> emptyList<Int>() to "a"
- "a" -> emptyList<Int>() to "b"
- else -> listOf(1, 2) to "c"
- }
- }
- catalog.load("search")
- assertEquals(2, catalog.items.items.size)
- assertEquals("c", catalog.cursor)
- // Past the asks it allows, an empty answer reads as no results, cursor and all.
- val endless = ConnectorCatalog<Int>({ it.toString() }) { _, cursor -> emptyList<Int>() to "${cursor.orEmpty()}x" }
- endless.load("none")
- assertEquals(0, endless.items.items.size)
- assertEquals("xxxx", endless.cursor)
+ // The cursor ends: nothing more to ask for.
+ answer = { listOf(25) to null }
+ catalog.loadMore()
+ assertEquals(26, catalog.items.items.size)
+ assertFalse(catalog.hasMore)
+ assertNull(catalog.error)
}
}
diff --git a/apps/android/core/src/main/kotlin/com/codync/android/core/Market.kt b/apps/android/core/src/main/kotlin/com/codync/android/core/Market.kt
index 9ed64f5b..71f7bfff 100644
--- a/apps/android/core/src/main/kotlin/com/codync/android/core/Market.kt
+++ b/apps/android/core/src/main/kotlin/com/codync/android/core/Market.kt
@@ -20,42 +20,10 @@ data class PluginListing(val connectors: List<InstalledConnector>, val skills: L
@Serializable data class MarketConnectors(val items: List<MarketConnector>, val nextCursor: String? = null)
@Serializable data class MarketSkill(val source: String, val name: String, val description: String = "", val installed: Boolean = false)
-/** Registry metadata stays in memory. The Extensions tabs page through it. */
+/** Registry metadata stays in memory. The Extensions tabs scroll through it. */
data class CatalogPage<T>(val items: List<T> = emptyList()) {
fun append(page: List<T>, id: (T) -> String): CatalogPage<T> {
val known = items.mapTo(mutableSetOf(), id)
return copy(items = items + page.filter { known.add(id(it)) })
}
}
-
-/** How many catalog rows one Extensions page shows, and which page a click lands on. */
-object CatalogPaging {
- const val pageSize = 10
- /** Two agent tiles across, three rows: a page has no leftover card. */
- const val phonePageSize = 6
- val pageSizes = listOf(6, 10, 20, 50)
-
- /** Loaded rows split into pages. While the registry still has a cursor, one more page is offered so the bar is never 1 / 1 for a list that continues. */
- fun pageCount(count: Int, size: Int = pageSize, hasMore: Boolean = false): Int {
- val loaded = if (count <= 0) 1 else (count + size - 1) / size
- return if (hasMore) loaded + 1 else loaded
- }
-
- fun clamp(page: Int, count: Int, size: Int = pageSize, hasMore: Boolean = false): Int =
- page.coerceIn(0, pageCount(count, size, hasMore) - 1)
-
- fun <T> slice(items: List<T>, page: Int, size: Int = pageSize): List<T> {
- val start = page.coerceAtLeast(0) * size
- return items.drop(start).take(size)
- }
-
- /** Next stays available through the last shown page, including the page that still has to be fetched. */
- fun canForward(count: Int, page: Int, hasMore: Boolean, size: Int = pageSize): Boolean =
- page < pageCount(count, size, hasMore) - 1
-
- /** A later page that isn't full yet, so the registry has to be asked. The first page is whatever the first answer held. */
- fun needsFetch(count: Int, page: Int, size: Int = pageSize): Boolean {
- val start = page.coerceAtLeast(0) * size
- return start > 0 && start + size > count
- }
-}
diff --git a/apps/android/core/src/test/kotlin/com/codync/android/core/MarketTest.kt b/apps/android/core/src/test/kotlin/com/codync/android/core/MarketTest.kt
index 3781f8e6..36c14df4 100644
--- a/apps/android/core/src/test/kotlin/com/codync/android/core/MarketTest.kt
+++ b/apps/android/core/src/test/kotlin/com/codync/android/core/MarketTest.kt
@@ -11,33 +11,6 @@ class MarketTest {
assertEquals(26, next.items.size)
}
- @Test fun catalogPagingClampsAndFetchesOnlyPastLoadedRows() {
- val items = (0..46).toList()
- assertEquals(5, CatalogPaging.pageCount(47))
- assertEquals(2, CatalogPaging.pageCount(19))
- assertEquals(1, CatalogPaging.pageCount(0))
- assertEquals(9, CatalogPaging.pageCount(72, hasMore = true))
- assertEquals((0..9).toList(), CatalogPaging.slice(items, 0))
- assertEquals((40..46).toList(), CatalogPaging.slice(items, 4))
- assertEquals(emptyList<Int>(), CatalogPaging.slice(items, 9))
- assertEquals(4, CatalogPaging.clamp(9, 47))
- assertEquals(8, CatalogPaging.clamp(9, 72, hasMore = true))
- assertEquals(0, CatalogPaging.clamp(-1, 20))
- assertEquals(0, CatalogPaging.clamp(4, 0))
- assertTrue(CatalogPaging.canForward(10, 0, true))
- assertTrue(CatalogPaging.needsFetch(10, 1))
- assertTrue(CatalogPaging.canForward(20, 0, false))
- assertFalse(CatalogPaging.needsFetch(20, 1))
- assertFalse(CatalogPaging.canForward(8, 0, false))
- assertFalse(CatalogPaging.needsFetch(60, 5))
- assertTrue(CatalogPaging.needsFetch(60, 6))
- assertTrue(CatalogPaging.needsFetch(72, 7))
- assertFalse(CatalogPaging.needsFetch(80, 7))
- assertFalse(CatalogPaging.needsFetch(0, 0))
- assertFalse(CatalogPaging.needsFetch(3, 0))
- assertTrue(CatalogPaging.needsFetch(0, 1))
- }
-
@Test fun connectorInputsRetainHostDefaultsAndUnknownAuthorizationDoesNotClaimSignIn() {
val input = WireJson.decodeFromString<MarketInput>("""{"name":"REGION","required":true,"default":"provided-by-host","future":true}""")
val option = InstallOption("local", "npm", "On computer", listOf(input))
diff --git a/apps/desktop/src/renderer/lib/l10n.test.ts b/apps/desktop/src/renderer/lib/l10n.test.ts
index 09ef8444..5555f628 100644
--- a/apps/desktop/src/renderer/lib/l10n.test.ts
+++ b/apps/desktop/src/renderer/lib/l10n.test.ts
@@ -65,7 +65,7 @@ test('known chrome becomes Chinese and everything else stays', () => {
assert.equal(translate('Check for updates', 'zh', false), '检查更新')
assert.equal(translate('Computer access is ready.', 'zh', false), '电脑访问已就绪。')
assert.equal(translate('Storage', 'zh', false), '存储')
- assert.equal(translate('Next page', 'zh', false), '下一页')
+ assert.equal(translate('Extensions sections', 'zh', false), '扩展分类')
assert.equal(
translate('listing skills on GitHub: https://api.github.com/repos/anthropics/skills answered 403 Forbidden', 'zh', false),
'无法列出 GitHub 上的技能:https://api.github.com/repos/anthropics/skills 返回了 403 Forbidden',
diff --git a/apps/desktop/src/renderer/views/marketplace/MarketplacePanel.tsx b/apps/desktop/src/renderer/views/marketplace/MarketplacePanel.tsx
index 93cbf8d0..5be66720 100644
--- a/apps/desktop/src/renderer/views/marketplace/MarketplacePanel.tsx
+++ b/apps/desktop/src/renderer/views/marketplace/MarketplacePanel.tsx
@@ -5,8 +5,8 @@ import { Text } from '../../components/Text'
import { useTr } from '../../lib/use-language'
import { AgentTile, NodeNotice } from './AgentSheet'
import type { ConnectorCatalog } from './connector-catalog'
-import { clampPage, EXTENSION_SECTIONS, pageItems, type ExtensionSection, type MarketConnector, type MarketSkill } from './market-models'
-import { ItemGrid, MarketRow, PageBar, ServiceLogo, SkeletonGrid, SkillGlyph, TileIcon } from './pieces'
+import { EXTENSION_SECTIONS, type ExtensionSection, type MarketConnector, type MarketSkill } from './market-models'
+import { ItemGrid, LoadMoreRow, MarketRow, ServiceLogo, SkeletonGrid, SkillGlyph, TileIcon } from './pieces'
/** One tab of Extensions: the line saying where its items come from, the tab, and an error under it. */
export function MarketPanel({ section, hostName, error, children }: { section: ExtensionSection; hostName: string; error: string | null; children: ReactNode }) {
@@ -21,14 +21,7 @@ export function MarketPanel({ section, hostName, error, children }: { section: E
)
}
-interface Paging {
- page: number
- pageSize: number
- onPage: (page: number) => void
- onPageSize: (size: number) => void
-}
-
-export function AgentsPanel({ agents, query, needsNode, page, pageSize, onPage, onPageSize, onAddNode, onAgent }: Paging & {
+export function AgentsPanel({ agents, query, needsNode, onAddNode, onAgent }: {
agents: Backend[]
query: string
needsNode: boolean
@@ -36,7 +29,6 @@ export function AgentsPanel({ agents, query, needsNode, page, pageSize, onPage,
onAgent: (backend: Backend) => void
}) {
const tr = useTr()
- const rows = pageItems(agents, page, pageSize)
return (
<>
{needsNode ? <NodeNotice onAdd={onAddNode} /> : null}
@@ -45,25 +37,22 @@ export function AgentsPanel({ agents, query, needsNode, page, pageSize, onPage,
<Text tone="secondary">{query ? tr('No agents match “{query}”.').replaceAll('{query}', query) : tr('No agents yet.')}</Text>
) : (
<div className="agent-grid">
- {rows.map((b) => <AgentCard key={b.id} backend={b} onClick={() => onAgent(b)} />)}
- <PageSpacers count={pagePad(agents.length, rows.length, pageSize)} kind="agent" />
+ {agents.map((b) => <AgentCard key={b.id} backend={b} onClick={() => onAgent(b)} />)}
</div>
)}
- <PageBar page={page} count={agents.length} pageSize={pageSize} onPage={(next) => onPage(clampPage(next, agents.length, pageSize))} onPageSize={onPageSize} />
</div>
</>
)
}
-export function ConnectorsPanel({ catalog, query, pageSize, onPage, onPageSize, onAddConnector, onInstall }: Omit<Paging, 'page'> & {
+export function ConnectorsPanel({ catalog, query, onAddConnector, onInstall }: {
catalog: ConnectorCatalog<MarketConnector>
query: string
onAddConnector: () => void
onInstall: (connector: MarketConnector) => void
}) {
const tr = useTr()
- const all = catalog.items.items
- const rows = pageItems(all, catalog.page, pageSize)
+ const rows = catalog.items.items
return (
<>
<MarketRow
@@ -77,35 +66,31 @@ export function ConnectorsPanel({ catalog, query, pageSize, onPage, onPageSize,
<div className="market-panel-scroll fade-in">
{catalog.loading ? (
<SkeletonGrid />
- ) : all.length === 0 ? (
+ ) : rows.length === 0 && !catalog.hasMore ? (
<Text tone="secondary">{query ? tr('No connectors match “{query}”.').replaceAll('{query}', query) : tr(`Couldn't load connectors.`)}</Text>
- ) : rows.length === 0 ? (
- // The page past the loaded rows, while the registry fills it.
- <SkeletonGrid />
) : (
- <ItemGrid>
- {rows.map((c) => (
- <MarketRow
- key={c.name}
- title={c.title}
- subtitle={c.description ?? c.name}
- added={c.installed}
- icon={<ServiceLogo website={c.website} name={c.title} registryName={c.name} />}
- onAdd={() => onInstall(c)}
- />
- ))}
- <PageSpacers count={pagePad(all.length, rows.length, pageSize)} kind="row" />
- </ItemGrid>
- )}
- {catalog.loading ? null : (
- <PageBar page={catalog.page} count={all.length} pageSize={pageSize} hasMore={catalog.hasMore} loading={catalog.loadingMore} onPage={onPage} onPageSize={onPageSize} />
+ <>
+ <ItemGrid>
+ {rows.map((c) => (
+ <MarketRow
+ key={c.name}
+ title={c.title}
+ subtitle={c.description ?? c.name}
+ added={c.installed}
+ icon={<ServiceLogo website={c.website} name={c.title} registryName={c.name} />}
+ onAdd={() => onInstall(c)}
+ />
+ ))}
+ </ItemGrid>
+ {catalog.cursor !== null ? <LoadMoreRow cursor={catalog.cursor} failed={catalog.error !== null} onLoad={() => void catalog.loadMore()} /> : null}
+ </>
)}
</div>
</>
)
}
-export function SkillsPanel({ skills, loading, query, installedSkillIds, busySkill, page, pageSize, onPage, onPageSize, onWriteSkill, onInstallSkill, onViewSkill }: Paging & {
+export function SkillsPanel({ skills, loading, query, installedSkillIds, busySkill, onWriteSkill, onInstallSkill, onViewSkill }: {
skills: MarketSkill[]
loading: boolean
query: string
@@ -116,7 +101,6 @@ export function SkillsPanel({ skills, loading, query, installedSkillIds, busySki
onViewSkill: (skill: MarketSkill) => void
}) {
const tr = useTr()
- const rows = pageItems(skills, page, pageSize)
return (
<>
<MarketRow
@@ -134,7 +118,7 @@ export function SkillsPanel({ skills, loading, query, installedSkillIds, busySki
query ? <Text tone="secondary">{tr('No skills match “{query}”.').replaceAll('{query}', query)}</Text> : null
) : (
<ItemGrid>
- {rows.map((s) => (
+ {skills.map((s) => (
<MarketRow
key={s.source}
title={s.name}
@@ -146,38 +130,13 @@ export function SkillsPanel({ skills, loading, query, installedSkillIds, busySki
onOpen={() => onViewSkill(s)}
/>
))}
- <PageSpacers count={pagePad(skills.length, rows.length, pageSize)} kind="row" />
</ItemGrid>
)}
- {loading ? null : (
- <PageBar page={page} count={skills.length} pageSize={pageSize} onPage={(next) => onPage(clampPage(next, skills.length, pageSize))} onPageSize={onPageSize} />
- )}
</div>
</>
)
}
-function pagePad(count: number, shown: number, size: number) {
- return count > size ? Math.max(0, size - shown) : 0
-}
-
-/** Rooms the size of a row, with nothing in them: a short last page keeps a full page's height, so the bar stays put. */
-function PageSpacers({ count, kind }: { count: number; kind: 'agent' | 'row' }) {
- const cells: ReactNode[] = []
- for (let i = 0; i < count; i++) {
- cells.push(kind === 'agent' ? (
- <div key={i} className="agent-card page-spacer" aria-hidden="true">
- <AgentCardBody registry={null} name={'\u00a0'} status={'\u00a0'} />
- </div>
- ) : (
- <div key={i} className="page-spacer" aria-hidden="true">
- <MarketRow title={'\u00a0'} subtitle={'\u00a0'} added icon={null} onAdd={() => {}} />
- </div>
- ))
- }
- return <>{cells}</>
-}
-
function AgentCard({ backend, onClick }: { backend: Backend; onClick: () => void }) {
const tr = useTr()
const status = backend.installed !== true && backend.curated === true ? 'Not installed'
@@ -187,20 +146,11 @@ function AgentCard({ backend, onClick }: { backend: Backend; onClick: () => void
: 'Installed'
return (
<button className="agent-card" title={backend.name} onClick={onClick}>
- <AgentCardBody registry={backend.registry ?? backend.id} name={backend.name} status={tr(status)} />
- </button>
- )
-}
-
-/** An agent tile's logo, name and status line. */
-function AgentCardBody({ registry, name, status }: { registry: string | null; name: string; status: string }) {
- return (
- <>
- <AgentTile registry={registry} icon={24} tile={40} radius={11} />
+ <AgentTile registry={backend.registry ?? backend.id} icon={24} tile={40} radius={11} />
<VStack as="span" align="flex-start" gap={3} shrink>
- <Text size="subheadline" weight="semibold" tone="text" truncate className="agent-card-line">{name}</Text>
- <Text size="caption" tone="secondary" truncate className="agent-card-line">{status}</Text>
+ <Text size="subheadline" weight="semibold" tone="text" truncate className="agent-card-line">{backend.name}</Text>
+ <Text size="caption" tone="secondary" truncate className="agent-card-line">{tr(status)}</Text>
</VStack>
- </>
+ </button>
)
}
diff --git a/apps/desktop/src/renderer/views/marketplace/MarketplaceView.tsx b/apps/desktop/src/renderer/views/marketplace/MarketplaceView.tsx
index 6f4c20c1..ed1511a0 100644
--- a/apps/desktop/src/renderer/views/marketplace/MarketplaceView.tsx
+++ b/apps/desktop/src/renderer/views/marketplace/MarketplaceView.tsx
@@ -15,16 +15,16 @@ import { SetupTerminalView } from './SetupTerminal'
import { SkillSheet, type SkillRef } from './SkillSheet'
import { useModel } from '../../lib/observable'
import { ConnectorCatalog } from './connector-catalog'
-import { errorText, market, MARKET_PAGE_SIZE, needsSignIn, type ExtensionSection, type MarketConnector, type MarketSkill } from './market-models'
+import { errorText, market, needsSignIn, type ExtensionSection, type MarketConnector, type MarketSkill } from './market-models'
import { AgentsPanel, ConnectorsPanel, MarketPanel, SkillsPanel } from './MarketplacePanel'
-import { AppLogo, ExtensionRail, FormSheet, ItemGrid, ItemRow, MarketSection, ScreenHeader, ServiceLogo, SkillGlyph, SlideStack } from './pieces'
+import { AppLogo, ExtensionTabs, FormSheet, ItemGrid, ItemRow, MarketSection, ScreenHeader, ServiceLogo, SkillGlyph, SlideStack } from './pieces'
import { usePlugins } from './plugins'
import { useTr } from '../../lib/use-language'
/**
* Extensions for the bots on one computer (the store in context): Agents, Connectors
- * and Skills, one at a time. Each list turns a page; a connector page that isn't full fetches
- * more from the registry (`ConnectorCatalog`). Installing happens on that computer; each bot
+ * and Skills, one at a time. Each list scrolls; the connectors load more from the registry as
+ * their end comes into view (`ConnectorCatalog`). Installing happens on that computer; each bot
* turns connectors and skills on in its settings. Each computer has its own, opened
* from its heading in the sidebar.
*/
@@ -51,9 +51,6 @@ export function MarketplaceView() {
const [agent, setAgent] = useState<Backend | null>(null)
const [addingNode, setAddingNode] = useState(false)
const [section, setSection] = useState<ExtensionSection>('agents')
- const [agentPage, setAgentPage] = useState(0)
- const [skillPage, setSkillPage] = useState(0)
- const [pageSize, setPageSize] = useState(MARKET_PAGE_SIZE)
const [showInstalled, setShowInstalled] = useState(false)
const [showCredentials, setShowCredentials] = useState(false)
@@ -64,19 +61,6 @@ export function MarketplaceView() {
const shownSkills = query ? skills.filter((s) => matches(s.name) || matches(s.description)) : skills
const installedCount = plugins.installedConnectors.length + plugins.installedSkills.length
- const changePageSize = (size: number) => {
- setPageSize(size)
- setAgentPage(0)
- setSkillPage(0)
- connectors.show(0, size)
- }
-
- /** Turns the connector list to `page` at once; a page that isn't full then fills from the registry. */
- const showConnectorPage = (page: number) => {
- connectors.show(page, pageSize)
- void connectors.fill(pageSize)
- }
-
useEffect(() => {
void plugins.refresh()
// Picks up CLIs installed or signed in outside Codync.
@@ -147,11 +131,7 @@ export function MarketplaceView() {
placeholder={tr('Search agents, connectors and skills')}
aria-label={tr('Search agents, connectors and skills')}
spellCheck={false}
- onChange={(e) => {
- setSearch(e.target.value)
- setAgentPage(0)
- setSkillPage(0)
- }}
+ onChange={(e) => setSearch(e.target.value)}
onKeyDown={(e) => {
if (e.key === 'Enter' && !e.nativeEvent.isComposing) submit(search.trim())
}}
@@ -163,8 +143,6 @@ export function MarketplaceView() {
className="market-search-clear"
onClick={() => {
setSearch('')
- setAgentPage(0)
- setSkillPage(0)
submit('')
}}
>
@@ -179,49 +157,36 @@ export function MarketplaceView() {
<div className="market-frame">
{header}
{searchField}
- <div className="market-split">
- <ExtensionRail selection={section} onChange={setSection} />
- <MarketPanel section={section} hostName={store.hostName} error={error ?? connectors.error}>
- {section === 'agents' ? (
- <AgentsPanel
- agents={agents}
- query={query}
- needsNode={allAgents.some((b) => b.node === 'missing')}
- page={agentPage}
- pageSize={pageSize}
- onPage={setAgentPage}
- onPageSize={changePageSize}
- onAddNode={() => setAddingNode(true)}
- onAgent={setAgent}
- />
- ) : section === 'connectors' ? (
- <ConnectorsPanel
- catalog={connectors}
- query={query}
- pageSize={pageSize}
- onPage={showConnectorPage}
- onPageSize={changePageSize}
- onAddConnector={() => setAddingConnector(true)}
- onInstall={setInstalling}
- />
- ) : (
- <SkillsPanel
- skills={shownSkills}
- loading={loadingSkills}
- query={query}
- installedSkillIds={plugins.installedSkills.map((s) => s.id)}
- busySkill={busySkill}
- page={skillPage}
- pageSize={pageSize}
- onPage={setSkillPage}
- onPageSize={changePageSize}
- onWriteSkill={() => setWritingSkill(true)}
- onInstallSkill={(s) => void installSkill(s)}
- onViewSkill={setViewingSkill}
- />
- )}
- </MarketPanel>
- </div>
+ <ExtensionTabs selection={section} onChange={setSection} />
+ <MarketPanel section={section} hostName={store.hostName} error={error ?? connectors.error}>
+ {section === 'agents' ? (
+ <AgentsPanel
+ agents={agents}
+ query={query}
+ needsNode={allAgents.some((b) => b.node === 'missing')}
+ onAddNode={() => setAddingNode(true)}
+ onAgent={setAgent}
+ />
+ ) : section === 'connectors' ? (
+ <ConnectorsPanel
+ catalog={connectors}
+ query={query}
+ onAddConnector={() => setAddingConnector(true)}
+ onInstall={setInstalling}
+ />
+ ) : (
+ <SkillsPanel
+ skills={shownSkills}
+ loading={loadingSkills}
+ query={query}
+ installedSkillIds={plugins.installedSkills.map((s) => s.id)}
+ busySkill={busySkill}
+ onWriteSkill={() => setWritingSkill(true)}
+ onInstallSkill={(s) => void installSkill(s)}
+ onViewSkill={setViewingSkill}
+ />
+ )}
+ </MarketPanel>
</div>
{/* Dismissing slides the sheet away; clearing the caller's state would cut it off. */}
<div className="market-close">
diff --git a/apps/desktop/src/renderer/views/marketplace/connector-catalog.test.ts b/apps/desktop/src/renderer/views/marketplace/connector-catalog.test.ts
index c430e368..335a847e 100644
--- a/apps/desktop/src/renderer/views/marketplace/connector-catalog.test.ts
+++ b/apps/desktop/src/renderer/views/marketplace/connector-catalog.test.ts
@@ -13,32 +13,38 @@ registerHooks({ resolve(specifier, context, nextResolve) {
const rows = (from: number, to: number) => Array.from({ length: to - from }, (_, i) => from + i)
-test('a connector page fills until it is full, and falls back when the registry fails', async () => {
+test('more connectors read on past empty pages and stop at a failure', async () => {
const { ConnectorCatalog } = await import('./connector-catalog.ts')
const asked: (string | null)[] = []
- let answer = async (cursor: string | null) => {
+ let answer = async (cursor: string | null): Promise<{ items: number[]; next: string | null }> => {
asked.push(cursor)
if (cursor === null) return { items: rows(0, 15), next: 'a' }
- return cursor === 'a' ? { items: rows(15, 18), next: 'b' } : { items: rows(18, 25), next: 'c' }
+ return cursor === 'a' ? { items: [], next: 'b' } : { items: rows(15, 25), next: 'c' }
}
const catalog = new ConnectorCatalog<number>(String, (_search, cursor) => answer(cursor))
await catalog.load('')
assert.equal(catalog.items.items.length, 15)
- // Page 2 needs rows 10-19: two registry pages fill it.
- catalog.show(1, 10)
- await catalog.fill(10)
+ // The next page has nothing to install but moves the cursor on: the one after it brings the rows.
+ await catalog.loadMore()
+ assert.equal(catalog.items.items.length, 15)
+ assert.equal(catalog.cursor, 'b')
+ await catalog.loadMore()
assert.deepEqual(asked, [null, 'a', 'b'])
- assert.equal(catalog.page, 1)
assert.equal(catalog.items.items.length, 25)
assert.equal(catalog.cursor, 'c')
- // The page past the loaded rows fails: back to the last page with rows.
answer = async () => { throw new Error('offline') }
- catalog.show(3, 10)
- assert.equal(catalog.page, 3)
- await catalog.fill(10)
- assert.equal(catalog.page, 2)
+ await catalog.loadMore()
+ assert.equal(catalog.items.items.length, 25)
+ assert.equal(catalog.cursor, 'c')
assert.equal(catalog.error, 'offline')
assert.equal(catalog.loadingMore, false)
+
+ // The cursor ends: nothing more to ask for.
+ answer = async () => ({ items: rows(25, 26), next: null })
+ await catalog.loadMore()
+ assert.equal(catalog.items.items.length, 26)
+ assert.equal(catalog.hasMore, false)
+ assert.equal(catalog.error, null)
})
diff --git a/apps/desktop/src/renderer/views/marketplace/connector-catalog.ts b/apps/desktop/src/renderer/views/marketplace/connector-catalog.ts
index 3e9dd298..cc5dd030 100644
--- a/apps/desktop/src/renderer/views/marketplace/connector-catalog.ts
+++ b/apps/desktop/src/renderer/views/marketplace/connector-catalog.ts
@@ -1,19 +1,16 @@
import { Observable } from '../../lib/observable'
-import { appendPage, clampPage, emptyPage, errorText, needsFetch, replacePage, type MarketplacePage } from './market-models'
+import { appendPage, emptyPage, errorText, replacePage, type MarketplacePage } from './market-models'
type Fetch<T> = (search: string, cursor: string | null) => Promise<{ items: T[]; next: string | null }>
/**
- * The connector list Extensions pages through (kit `ConnectorCatalog`): the rows loaded so far, the
- * registry cursor and the page on screen. A page that isn't full asks the registry until it is, or
- * until the cursor ends.
+ * The connector list Extensions scrolls through (kit `ConnectorCatalog`): the rows loaded so far
+ * and the registry cursor. The end of the list coming into view asks for more (`loadMore`).
*/
export class ConnectorCatalog<T> extends Observable {
items: MarketplacePage<T> = emptyPage()
/** The registry page after the ones loaded; null at the end. */
cursor: string | null = null
- /** The page on screen. While the registry fills it, it can be the page past the loaded rows. */
- page = 0
loading = true
loadingMore = false
error: string | null = null
@@ -44,7 +41,6 @@ export class ConnectorCatalog<T> extends Observable {
if (request !== this.#request) return
this.items = replacePage(first.items, this.#id)
this.cursor = first.next
- this.page = 0
this.error = null
} catch (e) {
if (request !== this.#request) return
@@ -64,36 +60,24 @@ export class ConnectorCatalog<T> extends Observable {
return this.load(this.#query)
}
- /** Turns to `next` at once; `fill` then loads its rows. */
- show(next: number, size: number) {
- if (this.loading) return
- this.page = clampPage(next, this.items.items.length, size, this.hasMore)
- this.changed()
- }
-
/**
- * Asks the registry until the page on screen is full or the cursor ends. A page turned meanwhile
- * is filled by the same loop. If a page fails, the list goes back to the last page with rows.
+ * The registry page at the cursor. It can bring nothing Codync can install; the cursor still moves
+ * on, so `LoadMoreRow` asks again. A failure keeps the cursor and shows under the list.
*/
- async fill(size: number) {
- if (this.loading || this.loadingMore || !this.hasMore || !needsFetch(this.items.items.length, this.page, size)) return
+ async loadMore() {
+ if (this.loading || this.loadingMore || !this.hasMore) return
const request = this.#request
this.loadingMore = true
+ this.error = null
this.changed()
try {
- while (this.cursor && needsFetch(this.items.items.length, this.page, size)) {
- const more = await this.#fetch(this.#query, this.cursor)
- if (request !== this.#request) return
- this.items = appendPage(this.items, more.items, this.#id)
- this.cursor = more.next
- this.changed()
- }
- this.page = clampPage(this.page, this.items.items.length, size, this.hasMore)
- this.error = null
+ const more = await this.#fetch(this.#query, this.cursor)
+ if (request !== this.#request) return
+ this.items = appendPage(this.items, more.items, this.#id)
+ this.cursor = more.next
} catch (e) {
if (request !== this.#request) return
this.error = errorText(e)
- this.page = clampPage(this.page, this.items.items.length, size)
} finally {
if (request === this.#request) {
this.loadingMore = false
diff --git a/apps/desktop/src/renderer/views/marketplace/extensions-layout.css b/apps/desktop/src/renderer/views/marketplace/extensions-layout.css
index 96a36acd..b8c39557 100644
--- a/apps/desktop/src/renderer/views/marketplace/extensions-layout.css
+++ b/apps/desktop/src/renderer/views/marketplace/extensions-layout.css
@@ -1,5 +1,5 @@
-/* The Extensions sheet's layout: the section rail, one paged section, and the pager under its list. */
-/* Header and search stay put, one section fills the rest. */
+/* The Extensions sheet's layout: the section chips and one section, whose list scrolls. */
+/* Header, search and chips stay put, one section fills the rest. */
.market-frame {
height: 100%;
min-height: 0;
@@ -10,40 +10,27 @@
max-width: 980px;
margin: 0 auto;
}
-.market-split {
- flex: 1;
- min-height: 0;
- display: flex;
- gap: 20px;
-}
-.market-rail {
- width: 176px;
- flex: none;
+.market-tabs {
display: flex;
- flex-direction: column;
- gap: 4px;
+ flex-wrap: wrap;
+ gap: 8px;
}
-.market-rail-item {
- display: flex;
- align-items: center;
- gap: 10px;
- width: 100%;
- text-align: left;
- padding: 8px 12px;
- border-radius: var(--radius-m);
- color: var(--secondary);
+.market-tab {
+ height: calc(32px * var(--scale));
+ padding: 0 calc(16px * var(--scale));
+ border-radius: var(--radius-pill);
+ background: var(--bubble-agent);
+ color: var(--text);
+ font-size: var(--text-body);
+ white-space: nowrap;
transition: background-color var(--hover), color var(--hover), transform var(--press);
}
-.market-rail-item:hover {
- color: var(--text);
+.market-tab:active {
+ transform: scale(0.96);
}
-.market-rail-item:active {
- transform: scale(0.98);
-}
-.market-rail-item.on {
- background: var(--bubble-agent);
- color: var(--text);
- font-weight: 600;
+.market-tab.on {
+ background: var(--text);
+ color: var(--background);
}
.market-panel {
flex: 1;
@@ -58,45 +45,10 @@
min-height: 0;
overflow-y: auto;
}
-.market-pager {
- display: flex;
- flex-wrap: wrap;
- align-items: center;
- gap: 8px 14px;
+/* The end of a list the registry continues: placeholder rows, or Try again after a failure. */
+.load-more {
margin-top: 8px;
- color: var(--secondary);
- font-size: var(--text-footnote);
-}
-.market-pager-size {
- display: inline-flex;
- align-items: center;
- gap: 6px;
-}
-.market-pager-size-button {
- display: inline-flex;
- align-items: center;
- gap: 4px;
- height: 28px;
- padding: 0 10px;
- border: 0;
- border-radius: 8px;
- background: var(--bubble-agent);
- color: var(--text);
- font: inherit;
-}
-.market-pager-fraction {
- min-width: 3.2em;
- color: var(--text);
- font-variant-numeric: tabular-nums;
- text-align: center;
-}
-/* Fills a short last page to a full page's height, so the pager stays put. */
-.page-spacer {
- visibility: hidden;
}
@media (max-width: 640px) {
.market-frame { padding: 28px 18px 16px; }
- .market-split { flex-direction: column; gap: 12px; }
- .market-rail { width: auto; flex-direction: row; flex-wrap: wrap; }
- .market-rail-item { width: auto; }
}
diff --git a/apps/desktop/src/renderer/views/marketplace/market-models.test.ts b/apps/desktop/src/renderer/views/marketplace/market-models.test.ts
index 9b5b11c7..638c66bf 100644
--- a/apps/desktop/src/renderer/views/marketplace/market-models.test.ts
+++ b/apps/desktop/src/renderer/views/marketplace/market-models.test.ts
@@ -1,6 +1,6 @@
import assert from 'node:assert/strict'
import { test } from 'node:test'
-import { appendPage, canPageForward, clampPage, emptyPage, needsFetch, pageCount, pageItems, replacePage } from './market-models.ts'
+import { appendPage, emptyPage, replacePage } from './market-models.ts'
test('catalog pages keep every fetched row and drop duplicates', () => {
const first = replacePage([0, 1, 2], (n) => String(n))
@@ -8,34 +8,3 @@ test('catalog pages keep every fetched row and drop duplicates', () => {
assert.deepEqual(next.items, [0, 1, 2, 3])
assert.deepEqual(replacePage([], (n: number) => String(n)).items, emptyPage().items)
})
-
-test('a catalog of 47 is five pages of 10, and the bar is never a single page while more rows exist', () => {
- const items = Array.from({ length: 47 }, (_, i) => i)
- assert.equal(pageCount(47), 5)
- assert.equal(pageCount(19), 2)
- assert.equal(pageCount(0), 1)
- assert.equal(pageCount(72, 10, true), 9)
- assert.deepEqual(pageItems(items, 0), items.slice(0, 10))
- assert.deepEqual(pageItems(items, 4), items.slice(40, 47))
- assert.deepEqual(pageItems(items, 9), [])
- assert.equal(clampPage(9, 47), 4)
- assert.equal(clampPage(9, 72, 10, true), 8)
- assert.equal(clampPage(-1, 20), 0)
- assert.equal(clampPage(4, 0), 0)
-})
-
-test('next stays available while the registry has another page', () => {
- assert.equal(canPageForward(10, 0, true), true)
- assert.equal(needsFetch(10, 1), true)
- assert.equal(canPageForward(20, 0, false), true)
- assert.equal(needsFetch(20, 1), false)
- assert.equal(canPageForward(8, 0, false), false)
- assert.equal(canPageForward(60, 5, true), true)
- assert.equal(needsFetch(60, 5), false)
- assert.equal(needsFetch(60, 6), true)
- assert.equal(needsFetch(72, 7), true)
- assert.equal(needsFetch(80, 7), false)
- assert.equal(needsFetch(0, 0), false)
- assert.equal(needsFetch(3, 0), false)
- assert.equal(needsFetch(0, 1), true)
-})
diff --git a/apps/desktop/src/renderer/views/marketplace/market-models.ts b/apps/desktop/src/renderer/views/marketplace/market-models.ts
index 03717ac0..0012665b 100644
--- a/apps/desktop/src/renderer/views/marketplace/market-models.ts
+++ b/apps/desktop/src/renderer/views/marketplace/market-models.ts
@@ -236,7 +236,7 @@ export const market = {
termClose: (c: HostClient, term: string) => c.call('termClose', { term }),
}
-/** Keep fetched catalog metadata in memory. The Extensions tabs page through it. */
+/** Keep fetched catalog metadata in memory. The Extensions tabs scroll through it. */
export interface MarketplacePage<T> {
items: T[]
}
@@ -250,45 +250,14 @@ export function appendPage<T>(page: MarketplacePage<T>, more: T[], id: (t: T) =>
export const replacePage = <T>(items: T[], id: (t: T) => string) => appendPage(emptyPage<T>(), items, id)
-/** How many catalog rows one Extensions page shows, and the sizes the pager offers. */
-export const MARKET_PAGE_SIZE = 10
-export const PAGE_SIZES = [6, 10, 20, 50] as const
-
export type ExtensionSection = 'agents' | 'connectors' | 'skills'
-/** Each section with its icon and the line saying where its items come from. */
-export const EXTENSION_SECTIONS: { id: ExtensionSection; label: string; icon: string; source: string }[] = [
- { id: 'agents', label: 'Agents', icon: 'terminal', source: 'Agents come from the ACP registry and install on {name}.' },
- { id: 'connectors', label: 'Connectors', icon: 'point.3.connected.trianglepath.dotted', source: 'Connectors come from the official MCP Registry and install on {name}.' },
- { id: 'skills', label: 'Skills', icon: 'book.pages', source: 'Skills come from Anthropic and install on {name}.' },
+/** Each section with the line saying where its items come from. */
+export const EXTENSION_SECTIONS: { id: ExtensionSection; label: string; source: string }[] = [
+ { id: 'agents', label: 'Agents', source: 'Agents come from the ACP registry and install on {name}.' },
+ { id: 'connectors', label: 'Connectors', source: 'Connectors come from the official MCP Registry and install on {name}.' },
+ { id: 'skills', label: 'Skills', source: 'Skills come from Anthropic and install on {name}.' },
]
-/** Loaded rows split into pages. While the registry still has a cursor, one more page is offered so the bar is never 1 / 1 for a list that continues. */
-export function pageCount(count: number, size = MARKET_PAGE_SIZE, hasMore = false): number {
- const loaded = count <= 0 ? 1 : Math.ceil(count / size)
- return hasMore ? loaded + 1 : loaded
-}
-
-/** The page index that still lands on a page, or 0 when the list is empty. */
-export function clampPage(page: number, count: number, size = MARKET_PAGE_SIZE, hasMore = false): number {
- return Math.min(Math.max(0, page), pageCount(count, size, hasMore) - 1)
-}
-
-export function pageItems<T>(items: readonly T[], page: number, size = MARKET_PAGE_SIZE): T[] {
- const start = Math.max(0, page) * size
- return items.slice(start, start + size)
-}
-
-/** Next stays available through the last shown page, including the page that still has to be fetched. */
-export function canPageForward(count: number, page: number, hasMore: boolean, size = MARKET_PAGE_SIZE): boolean {
- return page < pageCount(count, size, hasMore) - 1
-}
-
-/** A later page that isn't full yet, so the registry has to be asked. The first page is whatever the first answer held. */
-export function needsFetch(count: number, page: number, size = MARKET_PAGE_SIZE): boolean {
- const start = Math.max(0, page) * size
- return start > 0 && start + size > count
-}
-
export const errorText = (e: unknown) => (e instanceof Error ? e.message : String(e))
export const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms))
diff --git a/apps/desktop/src/renderer/views/marketplace/pieces.tsx b/apps/desktop/src/renderer/views/marketplace/pieces.tsx
index f77f28a5..c6c58b49 100644
--- a/apps/desktop/src/renderer/views/marketplace/pieces.tsx
+++ b/apps/desktop/src/renderer/views/marketplace/pieces.tsx
@@ -1,11 +1,11 @@
-import { useEffect, useRef, useState, type CSSProperties, type ReactNode } from 'react'
-import { DropdownMenu, IconButton } from '../../components/Controls'
+import { useEffect, useEffectEvent, useRef, useState, type CSSProperties, type ReactNode } from 'react'
+import { IconButton } from '../../components/Controls'
import { Sheet, usePresence } from '../../components/Overlay'
import { Icon } from '../../components/Icon'
import { HStack, Spacer, VStack } from '../../components/Stack'
import { Text } from '../../components/Text'
import { useTr } from '../../lib/use-language'
-import { EXTENSION_SECTIONS, PAGE_SIZES, canPageForward, clampPage, pageCount, type ExtensionSection } from './market-models'
+import { EXTENSION_SECTIONS, type ExtensionSection } from './market-models'
import { ThinkingOrb } from '../../components/ThinkingOrb'
import './marketplace.css'
import './extensions-layout.css'
@@ -121,6 +121,34 @@ export function SkeletonGrid() {
)
}
+/**
+ * The end of a list the registry continues (kit `LoadMoreRow`). In view, it asks for the page at
+ * `cursor`, and again each time the cursor moves on while it stays in view. After a failure it shows
+ * Try again, and asks again once it scrolls back into view.
+ */
+export function LoadMoreRow({ cursor, failed, onLoad }: { cursor: string; failed: boolean; onLoad: () => void }) {
+ const end = useRef<HTMLDivElement>(null)
+ const [inView, setInView] = useState(false)
+ const load = useEffectEvent(onLoad)
+ useEffect(() => {
+ const seen = new IntersectionObserver(([e]) => setInView(e!.isIntersecting))
+ seen.observe(end.current!)
+ return () => seen.disconnect()
+ }, [])
+ useEffect(() => {
+ if (inView) load()
+ }, [inView, cursor])
+ return (
+ <div ref={end} className="load-more">
+ {failed ? (
+ <HStack justify="center">
+ <IconButton title="Try again" icon="arrow.clockwise" onClick={onLoad} />
+ </HStack>
+ ) : <SkeletonGrid />}
+ </div>
+ )
+}
+
/** A loaded image, or nothing until (and unless) it loads. */
function RemoteImage({ src, className, style }: { src: string; className: string; style: CSSProperties }) {
const [loaded, setLoaded] = useState(false)
@@ -296,17 +324,16 @@ export function useWindowHeight() {
return height
}
-/** Agents, Connectors, Skills: the chosen row is filled, like a side tab. */
-export function ExtensionRail({ selection, onChange }: { selection: ExtensionSection; onChange: (id: ExtensionSection) => void }) {
+/** Agents, Connectors, Skills: a row of filled chips over the list, the chosen one in the text color. */
+export function ExtensionTabs({ selection, onChange }: { selection: ExtensionSection; onChange: (id: ExtensionSection) => void }) {
const tr = useTr()
return (
- <nav className="market-rail" role="tablist" aria-label={tr('Extensions sections')}>
+ <nav className="market-tabs" role="tablist" aria-label={tr('Extensions sections')}>
{EXTENSION_SECTIONS.map((section) => {
const on = section.id === selection
return (
- <button key={section.id} type="button" role="tab" aria-selected={on} className={`market-rail-item${on ? ' on' : ''}`} onClick={() => onChange(section.id)}>
- <Icon name={section.icon} size={15} />
- <span>{tr(section.label)}</span>
+ <button key={section.id} type="button" role="tab" aria-selected={on} className={`market-tab${on ? ' on' : ''}`} onClick={() => onChange(section.id)}>
+ {tr(section.label)}
</button>
)
})}
@@ -314,42 +341,6 @@ export function ExtensionRail({ selection, onChange }: { selection: ExtensionSec
)
}
-/** Count, page size, previous, current / total, and next. */
-export function PageBar({ page, count, pageSize, hasMore = false, loading = false, onPage, onPageSize }: {
- page: number
- count: number
- pageSize: number
- hasMore?: boolean
- loading?: boolean
- onPage: (page: number) => void
- onPageSize: (size: number) => void
-}) {
- const tr = useTr()
- const pages = pageCount(count, pageSize, hasMore)
- const current = clampPage(page, count, pageSize, hasMore)
- const canPrev = current > 0 && !loading
- const canNext = canPageForward(count, current, hasMore, pageSize) && !loading
- return (
- <div className="market-pager">
- <span>{tr('{count} total').replaceAll('{count}', String(count))}</span>
- <span className="market-pager-size">
- <span>{tr('Per page')}</span>
- <DropdownMenu
- className="market-pager-size-button"
- title={tr(`${pageSize} / page`)}
- items={() => PAGE_SIZES.map((size) => ({ title: `${size} / page`, selected: size === pageSize, action: () => onPageSize(size) }))}
- >
- <span>{tr(`${pageSize} / page`)}</span>
- <Icon name="chevron.down" size={10} weight="semibold" />
- </DropdownMenu>
- </span>
- <IconButton title="Previous page" icon="chevron.left" disabled={!canPrev} onClick={() => onPage(current - 1)} />
- <span className="market-pager-fraction" aria-current="page">{current + 1} / {pages}</span>
- <IconButton title={loading ? 'Loading…' : 'Next page'} icon="chevron.right" disabled={!canNext} onClick={() => onPage(current + 1)} />
- </div>
- )
-}
-
/**
* A Marketplace form in its own modal card (`.codyncSheet`), as tall as its content up to
* `height`; `fixed` keeps it at `height` for content that fills the card (a terminal).
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/de.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/de.json
index 834bb22a..4f39dee0 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/de.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/de.json
@@ -621,14 +621,6 @@
"No connectors match “{query}”.": "Keine Konnektoren passen zu „{query}“.",
"Couldn't load apps.": "Apps konnten nicht geladen werden.",
"No apps match “{query}”.": "Keine Apps passen zu „{query}“.",
- "Previous page": "Vorherige Seite",
- "Next page": "Nächste Seite",
- "{count} total": "{count} insgesamt",
- "Per page": "Pro Seite",
- "6 / page": "6 / Seite",
- "10 / page": "10 / Seite",
- "20 / page": "20 / Seite",
- "50 / page": "50 / Seite",
"Extensions sections": "Erweiterungsbereiche",
"No agents match “{query}”.": "Keine Agenten passen zu „{query}“.",
"No skills match “{query}”.": "Keine Skills passen zu „{query}“.",
@@ -658,9 +650,9 @@
"Some agents need it to run. Codync adds a copy just for them.": "Einige Agenten benötigen es. Codync installiert eine eigene Kopie für sie.",
"Paste any MCP server's config": "Konfiguration eines beliebigen MCP-Servers einfügen",
"Loading the registry…": "Registry wird geladen…",
- "pgup/pgdn · alt-s · tab · ↵ install / sign in · ^r · esc": "PgUp/PgDn Seite · Alt-S Größe · Tab wechseln · ↵ installieren / anmelden · ^R · Esc",
- "pgup/pgdn · alt-s · tab · ↵ add / sign in · ^x remove · esc": "PgUp/PgDn Seite · Alt-S Größe · Tab wechseln · ↵ hinzufügen / anmelden · ^X entfernen · Esc",
- "pgup/pgdn · alt-s · tab · ↵ details · ^x remove · esc": "PgUp/PgDn Seite · Alt-S Größe · Tab wechseln · ↵ Details · ^X entfernen · Esc",
+ "tab switch · ↵ install / sign in · ^r refresh · esc close": "tab wechseln · ↵ installieren / anmelden · ^r aktualisieren · esc schließen",
+ "tab switch · ↵ add / sign in · ^x remove · ^r refresh · esc": "tab wechseln · ↵ hinzufügen / anmelden · ^x entfernen · ^r aktualisieren · esc",
+ "tab switch · ↵ details · ^x remove · esc close": "tab wechseln · ↵ Details · ^x entfernen · esc schließen",
"Sign in": "Anmelden",
"No matching time zones": "Keine passenden Zeitzonen",
"e.g. Morning summary": "z. B. Morgenzusammenfassung",
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/es.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/es.json
index da4b23a1..ffd715c3 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/es.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/es.json
@@ -621,14 +621,6 @@
"No connectors match “{query}”.": "Ningún conector coincide con «{query}».",
"Couldn't load apps.": "No se pudieron cargar las apps.",
"No apps match “{query}”.": "Ninguna app coincide con «{query}».",
- "Previous page": "Página anterior",
- "Next page": "Página siguiente",
- "{count} total": "{count} en total",
- "Per page": "Por página",
- "6 / page": "6 / página",
- "10 / page": "10 / página",
- "20 / page": "20 / página",
- "50 / page": "50 / página",
"Extensions sections": "Secciones de extensiones",
"No agents match “{query}”.": "Ningún agente coincide con «{query}».",
"No skills match “{query}”.": "Ninguna habilidad coincide con «{query}».",
@@ -658,9 +650,9 @@
"Some agents need it to run. Codync adds a copy just for them.": "Algunos agentes lo necesitan para funcionar. Codync instala una copia dedicada para ellos.",
"Paste any MCP server's config": "Pega la configuración de cualquier servidor MCP",
"Loading the registry…": "Cargando el registro…",
- "pgup/pgdn · alt-s · tab · ↵ install / sign in · ^r · esc": "PgUp/PgDn página · Alt-S tamaño · Tab pestaña · ↵ instalar / iniciar sesión · ^R · Esc",
- "pgup/pgdn · alt-s · tab · ↵ add / sign in · ^x remove · esc": "PgUp/PgDn página · Alt-S tamaño · Tab pestaña · ↵ añadir / iniciar sesión · ^X quitar · Esc",
- "pgup/pgdn · alt-s · tab · ↵ details · ^x remove · esc": "PgUp/PgDn página · Alt-S tamaño · Tab pestaña · ↵ detalles · ^X quitar · Esc",
+ "tab switch · ↵ install / sign in · ^r refresh · esc close": "tab cambiar · ↵ instalar / iniciar sesión · ^r actualizar · esc cerrar",
+ "tab switch · ↵ add / sign in · ^x remove · ^r refresh · esc": "tab cambiar · ↵ añadir / iniciar sesión · ^x eliminar · ^r actualizar · esc",
+ "tab switch · ↵ details · ^x remove · esc close": "tab cambiar · ↵ detalles · ^x eliminar · esc cerrar",
"Sign in": "Iniciar sesión",
"No matching time zones": "No hay zonas horarias coincidentes",
"e.g. Morning summary": "Ej.: resumen de la mañana",
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/fr.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/fr.json
index 5a180043..f567cc95 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/fr.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/fr.json
@@ -621,14 +621,6 @@
"No connectors match “{query}”.": "Aucun connecteur ne correspond à « {query} ».",
"Couldn't load apps.": "Impossible de charger les apps.",
"No apps match “{query}”.": "Aucune app ne correspond à « {query} ».",
- "Previous page": "Page précédente",
- "Next page": "Page suivante",
- "{count} total": "{count} au total",
- "Per page": "Par page",
- "6 / page": "6 / page",
- "10 / page": "10 / page",
- "20 / page": "20 / page",
- "50 / page": "50 / page",
"Extensions sections": "Sections des extensions",
"No agents match “{query}”.": "Aucun agent ne correspond à « {query} ».",
"No skills match “{query}”.": "Aucune compétence ne correspond à « {query} ».",
@@ -658,9 +650,9 @@
"Some agents need it to run. Codync adds a copy just for them.": "Certains agents en ont besoin pour fonctionner. Codync en installe une copie dédiée.",
"Paste any MCP server's config": "Collez la configuration d’un serveur MCP",
"Loading the registry…": "Chargement du registre…",
- "pgup/pgdn · alt-s · tab · ↵ install / sign in · ^r · esc": "PgUp/PgDn page · Alt-S taille · Tab onglet · ↵ installer / connexion · ^R · Esc",
- "pgup/pgdn · alt-s · tab · ↵ add / sign in · ^x remove · esc": "PgUp/PgDn page · Alt-S taille · Tab onglet · ↵ ajouter / connexion · ^X retirer · Esc",
- "pgup/pgdn · alt-s · tab · ↵ details · ^x remove · esc": "PgUp/PgDn page · Alt-S taille · Tab onglet · ↵ détails · ^X retirer · Esc",
+ "tab switch · ↵ install / sign in · ^r refresh · esc close": "tab changer · ↵ installer / se connecter · ^r actualiser · esc fermer",
+ "tab switch · ↵ add / sign in · ^x remove · ^r refresh · esc": "tab changer · ↵ ajouter / se connecter · ^x supprimer · ^r actualiser · esc",
+ "tab switch · ↵ details · ^x remove · esc close": "tab changer · ↵ détails · ^x supprimer · esc fermer",
"Sign in": "Se connecter",
"No matching time zones": "Aucun fuseau horaire correspondant",
"e.g. Morning summary": "Ex. : résumé du matin",
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ja.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ja.json
index 5ded5d1b..50b17a31 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ja.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ja.json
@@ -621,14 +621,6 @@
"No connectors match “{query}”.": "「{query}」に一致するコネクタはありません。",
"Couldn't load apps.": "アプリを読み込めませんでした。",
"No apps match “{query}”.": "「{query}」に一致するアプリはありません。",
- "Previous page": "前のページ",
- "Next page": "次のページ",
- "{count} total": "全 {count} 件",
- "Per page": "ページあたり",
- "6 / page": "6 件/ページ",
- "10 / page": "10 件/ページ",
- "20 / page": "20 件/ページ",
- "50 / page": "50 件/ページ",
"Extensions sections": "拡張機能の区分",
"No agents match “{query}”.": "「{query}」に一致するエージェントはありません。",
"No skills match “{query}”.": "「{query}」に一致するスキルはありません。",
@@ -658,9 +650,9 @@
"Some agents need it to run. Codync adds a copy just for them.": "一部のエージェントは実行するためにこれを必要とします。 Codync は彼ら専用のコピーを追加します。",
"Paste any MCP server's config": "MCP サーバーの設定を貼り付けます",
"Loading the registry…": "レジストリをロード中…",
- "pgup/pgdn · alt-s · tab · ↵ install / sign in · ^r · esc": "PgUp/PgDn ページ · Alt-S 件数 · Tab 切替 · ↵ インストール / サインイン · ^R 更新 · Esc",
- "pgup/pgdn · alt-s · tab · ↵ add / sign in · ^x remove · esc": "PgUp/PgDn ページ · Alt-S 件数 · Tab 切替 · ↵ 追加 / サインイン · ^X 削除 · Esc",
- "pgup/pgdn · alt-s · tab · ↵ details · ^x remove · esc": "PgUp/PgDn ページ · Alt-S 件数 · Tab 切替 · ↵ 詳細 · ^X 削除 · Esc",
+ "tab switch · ↵ install / sign in · ^r refresh · esc close": "タブスイッチ · ↵ インストール/サインイン · ^r 更新 · Esc 閉じる",
+ "tab switch · ↵ add / sign in · ^x remove · ^r refresh · esc": "タブ切り替え · ↵ 追加/サインイン · ^x 削除 · ^r 更新 · Esc",
+ "tab switch · ↵ details · ^x remove · esc close": "タブスイッチ · ↵ 詳細 · ^x 削除 · Esc 閉じる",
"Sign in": "サインイン",
"No matching time zones": "一致するタイムゾーンがありません",
"e.g. Morning summary": "例えば朝のまとめ",
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ko.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ko.json
index 97f1cf0a..abf1bb9d 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ko.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ko.json
@@ -621,14 +621,6 @@
"No connectors match “{query}”.": "“{query}”와 일치하는 커넥터가 없습니다.",
"Couldn't load apps.": "앱을 불러오지 못했습니다.",
"No apps match “{query}”.": "“{query}”와 일치하는 앱이 없습니다.",
- "Previous page": "이전 페이지",
- "Next page": "다음 페이지",
- "{count} total": "총 {count}개",
- "Per page": "페이지당",
- "6 / page": "6개/페이지",
- "10 / page": "10개/페이지",
- "20 / page": "20개/페이지",
- "50 / page": "50개/페이지",
"Extensions sections": "확장 구분",
"No agents match “{query}”.": "“{query}”와 일치하는 에이전트가 없습니다.",
"No skills match “{query}”.": "“{query}”와 일치하는 기술이 없습니다.",
@@ -658,9 +650,9 @@
"Some agents need it to run. Codync adds a copy just for them.": "일부 에이전트를 실행하려면 필요합니다. Codync가 해당 에이전트 전용으로 설치합니다.",
"Paste any MCP server's config": "MCP 서버 구성 붙여넣기",
"Loading the registry…": "레지스트리를 불러오는 중…",
- "pgup/pgdn · alt-s · tab · ↵ install / sign in · ^r · esc": "PgUp/PgDn 페이지 · Alt-S 개수 · Tab 전환 · ↵ 설치 / 로그인 · ^R 새로고침 · Esc",
- "pgup/pgdn · alt-s · tab · ↵ add / sign in · ^x remove · esc": "PgUp/PgDn 페이지 · Alt-S 개수 · Tab 전환 · ↵ 추가 / 로그인 · ^X 제거 · Esc",
- "pgup/pgdn · alt-s · tab · ↵ details · ^x remove · esc": "PgUp/PgDn 페이지 · Alt-S 개수 · Tab 전환 · ↵ 자세히 · ^X 제거 · Esc",
+ "tab switch · ↵ install / sign in · ^r refresh · esc close": "tab 전환 · ↵ 설치 / 로그인 · ^r 새로고침 · esc 닫기",
+ "tab switch · ↵ add / sign in · ^x remove · ^r refresh · esc": "tab 전환 · ↵ 추가 / 로그인 · ^x 제거 · ^r 새로고침 · esc",
+ "tab switch · ↵ details · ^x remove · esc close": "tab 전환 · ↵ 상세 정보 · ^x 제거 · esc 닫기",
"Sign in": "로그인",
"No matching time zones": "일치하는 시간대가 없습니다",
"e.g. Morning summary": "예: 아침 요약",
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hans.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hans.json
index 0a1f46ad..7498dba6 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hans.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hans.json
@@ -621,14 +621,6 @@
"No connectors match “{query}”.": "没有匹配“{query}”的连接器。",
"Couldn't load apps.": "无法加载应用。",
"No apps match “{query}”.": "没有匹配“{query}”的应用。",
- "Previous page": "上一页",
- "Next page": "下一页",
- "{count} total": "共 {count} 条",
- "Per page": "每页",
- "6 / page": "6 条/页",
- "10 / page": "10 条/页",
- "20 / page": "20 条/页",
- "50 / page": "50 条/页",
"Extensions sections": "扩展分类",
"No agents match “{query}”.": "没有匹配“{query}”的智能体。",
"No skills match “{query}”.": "没有匹配“{query}”的技能。",
@@ -658,9 +650,9 @@
"Some agents need it to run. Codync adds a copy just for them.": "有些智能体需要它才能运行。Codync 会只为它们添加一份。",
"Paste any MCP server's config": "粘贴任意 MCP 服务器的配置",
"Loading the registry…": "正在加载注册表…",
- "pgup/pgdn · alt-s · tab · ↵ install / sign in · ^r · esc": "PgUp/PgDn 翻页 · Alt-S 条数 · Tab 切换 · ↵ 安装 / 登录 · ^R 刷新 · Esc",
- "pgup/pgdn · alt-s · tab · ↵ add / sign in · ^x remove · esc": "PgUp/PgDn 翻页 · Alt-S 条数 · Tab 切换 · ↵ 添加 / 登录 · ^X 移除 · Esc",
- "pgup/pgdn · alt-s · tab · ↵ details · ^x remove · esc": "PgUp/PgDn 翻页 · Alt-S 条数 · Tab 切换 · ↵ 详情 · ^X 移除 · Esc",
+ "tab switch · ↵ install / sign in · ^r refresh · esc close": "Tab 切换 · ↵ 安装 / 登录 · ^r 刷新 · Esc 关闭",
+ "tab switch · ↵ add / sign in · ^x remove · ^r refresh · esc": "Tab 切换 · ↵ 添加 / 登录 · ^x 移除 · ^r 刷新 · Esc",
+ "tab switch · ↵ details · ^x remove · esc close": "Tab 切换 · ↵ 详情 · ^x 移除 · Esc 关闭",
"Sign in": "登录",
"No matching time zones": "没有匹配的时区",
"e.g. Morning summary": "例如:早晨摘要",
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hant.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hant.json
index 6c3df1ea..5200041c 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hant.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hant.json
@@ -621,14 +621,6 @@
"No connectors match “{query}”.": "沒有匹配“{query}”的聯結器。",
"Couldn't load apps.": "無法載入應用。",
"No apps match “{query}”.": "沒有匹配“{query}”的應用。",
- "Previous page": "上一頁",
- "Next page": "下一頁",
- "{count} total": "共 {count} 條",
- "Per page": "每頁",
- "6 / page": "6 條/頁",
- "10 / page": "10 條/頁",
- "20 / page": "20 條/頁",
- "50 / page": "50 條/頁",
"Extensions sections": "擴充分類",
"No agents match “{query}”.": "沒有匹配“{query}”的智慧體。",
"No skills match “{query}”.": "沒有匹配“{query}”的技能。",
@@ -658,9 +650,9 @@
"Some agents need it to run. Codync adds a copy just for them.": "有些智慧體需要它才能執行。Codync 會只為它們新增一份。",
"Paste any MCP server's config": "貼上任意 MCP 伺服器的配置",
"Loading the registry…": "正在載入登錄檔…",
- "pgup/pgdn · alt-s · tab · ↵ install / sign in · ^r · esc": "PgUp/PgDn 翻頁 · Alt-S 條數 · Tab 切換 · ↵ 安裝 / 登入 · ^R 重新整理 · Esc",
- "pgup/pgdn · alt-s · tab · ↵ add / sign in · ^x remove · esc": "PgUp/PgDn 翻頁 · Alt-S 條數 · Tab 切換 · ↵ 新增 / 登入 · ^X 移除 · Esc",
- "pgup/pgdn · alt-s · tab · ↵ details · ^x remove · esc": "PgUp/PgDn 翻頁 · Alt-S 條數 · Tab 切換 · ↵ 詳情 · ^X 移除 · Esc",
+ "tab switch · ↵ install / sign in · ^r refresh · esc close": "Tab 切換 · ↵ 安裝 / 登入 · ^r 重新整理 · Esc 關閉",
+ "tab switch · ↵ add / sign in · ^x remove · ^r refresh · esc": "Tab 切換 · ↵ 新增 / 登入 · ^x 移除 · ^r 重新整理 · Esc",
+ "tab switch · ↵ details · ^x remove · esc close": "Tab 切換 · ↵ 詳情 · ^x 移除 · Esc 關閉",
"Sign in": "登入",
"No matching time zones": "沒有匹配的時區",
"e.g. Morning summary": "例如:早晨摘要",
diff --git a/apps/ios/Kit/Sources/CodyncUI/Marketplace/MarketRows.swift b/apps/ios/Kit/Sources/CodyncUI/Marketplace/MarketRows.swift
index 04d19a9c..3b057896 100644
--- a/apps/ios/Kit/Sources/CodyncUI/Marketplace/MarketRows.swift
+++ b/apps/ios/Kit/Sources/CodyncUI/Marketplace/MarketRows.swift
@@ -24,9 +24,23 @@ struct AgentCard: View {
var body: some View {
Button(action: action) {
- AgentCardLabel(registry: backend.registry ?? backend.id, name: backend.name, status: L10n.tr(status))
- .background(Palette.bubbleAgent.opacity(hovering ? 0.8 : 0.45), in: RoundedRectangle(cornerRadius: 18, style: .continuous))
- .contentShape(RoundedRectangle(cornerRadius: 18, style: .continuous))
+ VStack(spacing: 12) {
+ AgentIcon(registry: backend.registry ?? backend.id, size: 34)
+ .frame(width: 64, height: 64)
+ .background(Palette.bubbleAgent, in: RoundedRectangle(cornerRadius: 18, style: .continuous))
+ VStack(spacing: 2) {
+ Text(backend.name).font(.subheadline.weight(.semibold)).foregroundStyle(Palette.text).lineLimit(1)
+ Text(L10n.tr(status))
+ .font(.caption)
+ .foregroundStyle(Palette.secondary)
+ .lineLimit(1)
+ }
+ }
+ .frame(maxWidth: .infinity)
+ .padding(.vertical, 18)
+ .padding(.horizontal, 10)
+ .background(Palette.bubbleAgent.opacity(hovering ? 0.8 : 0.45), in: RoundedRectangle(cornerRadius: 18, style: .continuous))
+ .contentShape(RoundedRectangle(cornerRadius: 18, style: .continuous))
}
.buttonStyle(PressScale())
.onHover { h in withAnimation(Motion.hover) { hovering = h } }
@@ -34,38 +48,6 @@ struct AgentCard: View {
}
}
-/// An agent tile's logo, name and status line.
-private struct AgentCardLabel: View {
- let registry: String?
- let name: String
- let status: String
-
- var body: some View {
- VStack(spacing: 10) {
- AgentIcon(registry: registry, size: 30)
- .frame(width: 56, height: 56)
- .background(Palette.bubbleAgent, in: RoundedRectangle(cornerRadius: 16, style: .continuous))
- VStack(spacing: 2) {
- Text(name).font(.subheadline.weight(.semibold)).foregroundStyle(Palette.text).lineLimit(1)
- Text(status)
- .font(.caption)
- .foregroundStyle(Palette.secondary)
- .lineLimit(1)
- }
- }
- .frame(maxWidth: .infinity)
- .padding(.vertical, 14)
- .padding(.horizontal, 10)
- }
-}
-
-/// An agent tile's room, with nothing in it. A short last page keeps a full page of rows, so the bar under it stays put.
-struct AgentCardSpacer: View {
- var body: some View {
- AgentCardLabel(registry: nil, name: " ", status: " ").hidden().accessibilityHidden(true)
- }
-}
-
struct MarketRow<Icon: View>: View {
let title: String
let subtitle: String
@@ -117,38 +99,6 @@ struct MarketRow<Icon: View>: View {
}
}
-/// A catalog row's room, with nothing in it. A short last page keeps a full page of rows.
-struct MarketRowSpacer: View {
- var body: some View {
- MarketRow(title: " ", subtitle: " ", added: true) { Color.clear } add: {}
- .hidden()
- .accessibilityHidden(true)
- }
-}
-
-/// Previous or next, beside the list on a phone: a dark filled circle (the text color, so white in dark mode)
-/// with the chevron in the page's background, faint when there is no page that way.
-struct PageEdgeButton: View {
- let title: String
- let systemImage: String
- let enabled: Bool
- let action: () -> Void
-
- var body: some View {
- Button(action: action) {
- Image(systemName: systemImage)
- .font(.subheadline.weight(.bold))
- .frame(width: 36, height: 36)
- .foregroundStyle(Palette.background)
- .background(Palette.text, in: Circle())
- .opacity(enabled ? 1 : 0.25)
- }
- .buttonStyle(PressScale())
- .disabled(!enabled)
- .accessibilityLabel(L10n.tr(title))
- }
-}
-
/// Placeholder rows while a list loads, shaped like the real ones.
struct SkeletonGrid: View {
@State private var dim = false
@@ -270,107 +220,3 @@ struct WebLink: View {
.help(url.absoluteString)
}
}
-
-/// The bar under a list. A phone: the page size and the page number (previous and next sit beside the list).
-/// A wide layout: the count, the page size, previous, current / total, and next.
-struct CatalogPager: View {
- let page: Int
- let count: Int
- let pageSize: Int
- var hasMore = false
- var loading = false
- let go: (Int) -> Void
- let onSize: (Int) -> Void
- @Environment(\.horizontalSizeClass) private var sizeClass
-
- private var pages: Int { CatalogPaging.pageCount(count, size: pageSize, hasMore: hasMore) }
- private var current: Int { CatalogPaging.clamp(page: page, count: count, size: pageSize, hasMore: hasMore) }
-
- var body: some View {
- Group {
- if sizeClass == .compact {
- HStack(spacing: 12) {
- sizeLabel
- Spacer(minLength: 12)
- fraction
- }
- .padding(.horizontal, 16)
- .padding(.vertical, 8)
- .background(Palette.bubbleAgent, in: Capsule())
- } else {
- controls
- }
- }
- .font(.footnote)
- }
-
- private var controls: some View {
- HStack(spacing: 12) {
- total
- sizePicker
- navigation
- }
- }
-
- private var total: some View {
- Text(L10n.tr("{count} total").replacingOccurrences(of: "{count}", with: String(count)))
- .foregroundStyle(Palette.secondary)
- }
-
- private var fraction: some View {
- Text("\(current + 1) / \(pages)")
- .font(.subheadline.weight(.semibold))
- .foregroundStyle(Palette.text)
- .monospacedDigit()
- .accessibilityAddTraits(.isSelected)
- }
-
- /// The size menu, sitting on the capsule with no chip of its own.
- private var sizeLabel: some View {
- DropdownMenu {
- CatalogPaging.pageSizes.map { size in
- MenuItem("\(size) / page", selected: size == pageSize) { onSize(size) }
- }
- } label: {
- HStack(spacing: 2) {
- Text(L10n.tr("\(pageSize) / page"))
- Image(systemName: "chevron.down").font(.caption2.weight(.semibold))
- }
- .foregroundStyle(Palette.secondary)
- }
- }
-
- private var sizePicker: some View {
- HStack(spacing: 6) {
- Text(L10n.tr("Per page")).foregroundStyle(Palette.secondary)
- DropdownMenu {
- CatalogPaging.pageSizes.map { size in
- MenuItem("\(size) / page", selected: size == pageSize) { onSize(size) }
- }
- } label: {
- HStack(spacing: 4) {
- Text(L10n.tr("\(pageSize) / page"))
- Image(systemName: "chevron.down").font(.caption2.weight(.semibold))
- }
- .foregroundStyle(Palette.text)
- .padding(.horizontal, 10)
- .frame(height: 28)
- .background(Palette.bubbleAgent, in: RoundedRectangle(cornerRadius: 8, style: .continuous))
- }
- }
- }
-
- private var navigation: some View {
- HStack(spacing: 4) {
- IconButton("Previous page", systemImage: "chevron.left") { go(current - 1) }
- .disabled(current == 0 || loading)
- Text("\(current + 1) / \(pages)")
- .foregroundStyle(Palette.text)
- .monospacedDigit()
- .frame(minWidth: 44)
- .accessibilityAddTraits(.isSelected)
- IconButton(loading ? "Loading…" : "Next page", systemImage: "chevron.right") { go(current + 1) }
- .disabled(!CatalogPaging.canForward(count: count, page: current, hasMore: hasMore, size: pageSize) || loading)
- }
- }
-}
diff --git a/apps/ios/Kit/Sources/CodyncUI/Marketplace/MarketplacePage.swift b/apps/ios/Kit/Sources/CodyncUI/Marketplace/MarketplacePage.swift
index b8557399..2a23e7e0 100644
--- a/apps/ios/Kit/Sources/CodyncUI/Marketplace/MarketplacePage.swift
+++ b/apps/ios/Kit/Sources/CodyncUI/Marketplace/MarketplacePage.swift
@@ -1,6 +1,6 @@
import SwiftUI
-/// Keep fetched catalog metadata in memory. The Extensions tabs page through it.
+/// Keep fetched catalog metadata in memory. The Extensions tabs scroll through it.
struct MarketplacePage<Item: Identifiable> {
private(set) var items: [Item] = []
@@ -17,44 +17,8 @@ struct MarketplacePage<Item: Identifiable> {
}
}
-/// How many catalog rows one Extensions page shows, and which page a click lands on.
-enum CatalogPaging {
- static let pageSize = 10
- /// Two agent tiles across, three rows: a page has no leftover card.
- static let phonePageSize = 6
- static let pageSizes = [6, 10, 20, 50]
- /// Further registry pages a search reads when its first answer is empty but continues.
- static let emptyPageAsks = 3
-
- /// Loaded rows split into pages. While the registry still has a cursor, one more page is offered so the bar is never 1 / 1 for a list that continues.
- static func pageCount(_ count: Int, size: Int = pageSize, hasMore: Bool = false) -> Int {
- let loaded = count <= 0 ? 1 : (count + size - 1) / size
- return hasMore ? loaded + 1 : loaded
- }
-
- static func clamp(page: Int, count: Int, size: Int = pageSize, hasMore: Bool = false) -> Int {
- min(max(0, page), pageCount(count, size: size, hasMore: hasMore) - 1)
- }
-
- static func slice<T>(_ items: [T], page: Int, size: Int = pageSize) -> ArraySlice<T> {
- let start = max(0, page) * size
- return items.dropFirst(start).prefix(size)
- }
-
- /// Next stays available through the last shown page, including the page that still has to be fetched.
- static func canForward(count: Int, page: Int, hasMore: Bool, size: Int = pageSize) -> Bool {
- page < pageCount(count, size: size, hasMore: hasMore) - 1
- }
-
- /// A later page that isn't full yet, so the registry has to be asked. The first page is whatever the first answer held.
- static func needsFetch(count: Int, page: Int, size: Int = pageSize) -> Bool {
- let start = max(0, page) * size
- return start > 0 && start + size > count
- }
-}
-
-/// The connector list Extensions pages through: the rows loaded so far, the registry cursor and the
-/// page on screen. A page that isn't full asks the registry until it is, or until the cursor ends.
+/// The connector list Extensions scrolls through: the rows loaded so far and the registry cursor.
+/// The end of the list coming into view asks for more (`loadMore`).
@MainActor @Observable
final class ConnectorCatalog<Item: Identifiable> {
typealias Fetch = @MainActor (_ search: String, _ cursor: String?) async throws -> (items: [Item], next: String?)
@@ -62,8 +26,6 @@ final class ConnectorCatalog<Item: Identifiable> {
private(set) var items = MarketplacePage<Item>()
/// The registry page after the ones loaded; nil at the end.
private(set) var cursor: String?
- /// The page on screen. While the registry fills it, it can be the page past the loaded rows.
- private(set) var page = 0
private(set) var loading = true
private(set) var loadingMore = false
private(set) var error: String?
@@ -81,20 +43,10 @@ final class ConnectorCatalog<Item: Identifiable> {
loadingMore = false
defer { if self.request == request { loading = false } }
do {
- var first = try await fetch(search, nil)
+ let first = try await fetch(search, nil)
guard !Task.isCancelled, self.request == request else { return }
- // The host reads past registry pages with nothing to install only while the app waits for its
- // answer. An empty first page that still has a cursor gets a few more asks before it reads
- // as no results: a phone has no other way to reach the rows after it.
- var asks = 0
- while first.items.isEmpty, let next = first.next, asks < CatalogPaging.emptyPageAsks {
- asks += 1
- first = try await fetch(search, next)
- guard !Task.isCancelled, self.request == request else { return }
- }
items.replace(with: first.items)
cursor = first.next
- page = 0
error = nil
} catch {
guard self.request == request, !(error is CancellationError), !Task.isCancelled else { return }
@@ -104,32 +56,22 @@ final class ConnectorCatalog<Item: Identifiable> {
}
}
- /// Turns to `next` at once, so a swipe stays where it landed; `fill` then loads its rows.
- func show(_ next: Int, size: Int) {
- guard !loading else { return }
- page = CatalogPaging.clamp(page: next, count: items.items.count, size: size, hasMore: hasMore)
- }
-
- /// Asks the registry until the page on screen is full or the cursor ends. A page turned meanwhile is
- /// filled by the same loop. If a page fails, the list goes back to the last page with rows.
- func fill(size: Int, animation: Animation? = nil, fetch: Fetch) async {
- guard !loading, !loadingMore, hasMore, CatalogPaging.needsFetch(count: items.items.count, page: page, size: size) else { return }
+ /// The registry page at the cursor. It can bring nothing Codync can install; the cursor still moves
+ /// on, so `LoadMoreRow` asks again. A failure keeps the cursor and shows under the list.
+ func loadMore(fetch: Fetch) async {
+ guard !loading, !loadingMore, let cursor else { return }
let request = self.request
loadingMore = true
+ error = nil
defer { if self.request == request { loadingMore = false } }
do {
- while let cursor, CatalogPaging.needsFetch(count: items.items.count, page: page, size: size) {
- let more = try await fetch(query, cursor)
- guard !Task.isCancelled, self.request == request else { return }
- items.append(more.items)
- self.cursor = more.next
- }
- page = CatalogPaging.clamp(page: page, count: items.items.count, size: size, hasMore: hasMore)
- error = nil
+ let more = try await fetch(query, cursor)
+ guard self.request == request else { return }
+ items.append(more.items)
+ self.cursor = more.next
} catch {
guard self.request == request, !(error is CancellationError), !Task.isCancelled else { return }
self.error = error.localizedDescription
- withAnimation(animation) { page = CatalogPaging.clamp(page: page, count: items.items.count, size: size) }
}
}
}
diff --git a/apps/ios/Kit/Sources/CodyncUI/Marketplace/MarketplaceTabs.swift b/apps/ios/Kit/Sources/CodyncUI/Marketplace/MarketplaceTabs.swift
index 2a30eeec..828753a5 100644
--- a/apps/ios/Kit/Sources/CodyncUI/Marketplace/MarketplaceTabs.swift
+++ b/apps/ios/Kit/Sources/CodyncUI/Marketplace/MarketplaceTabs.swift
@@ -39,8 +39,6 @@ extension MarketplaceView {
}
}
.frame(maxWidth: .infinity, alignment: .leading)
- // On a phone the section gives up a little width so the page buttons beside the list have room.
- .padding(.horizontal, sizeClass == .compact ? 8 : 0)
.id(section)
.transition(.opacity)
}
@@ -53,15 +51,10 @@ extension MarketplaceView {
Text(query.isEmpty ? L10n.tr("No agents yet.") : L10n.tr("No agents match “{query}”.").replacingOccurrences(of: "{query}", with: query))
.foregroundStyle(Palette.secondary)
} else {
- flanked(count: agents.count, page: agentPage) { index in
- let shown = Array(CatalogPaging.slice(agents, page: index, size: pageSize))
- LazyVGrid(columns: agentColumns, spacing: 10) {
- ForEach(shown) { b in agentCard(b) }
- ForEach(0..<pagePad(count: agents.count, shown: shown.count), id: \.self) { _ in AgentCardSpacer() }
- }
+ LazyVGrid(columns: agentColumns, spacing: 10) {
+ ForEach(agents) { b in agentCard(b) }
}
}
- CatalogPager(page: agentPage, count: agents.count, pageSize: pageSize, go: { agentPage = CatalogPaging.clamp(page: $0, count: agents.count, size: pageSize) }, onSize: changePageSize)
}
@ViewBuilder private var connectorsTab: some View {
@@ -72,33 +65,22 @@ extension MarketplaceView {
}
if connectors.loading {
SkeletonGrid()
- } else if connectors.items.isEmpty {
+ } else if connectors.items.isEmpty, !connectors.hasMore {
Text(query.isEmpty ? L10n.tr("Couldn't load connectors.") : L10n.tr("No connectors match “{query}”.").replacingOccurrences(of: "{query}", with: query))
.foregroundStyle(Palette.secondary)
} else {
- let rows = connectors.items.items
- flanked(count: rows.count, page: connectors.page, hasMore: connectors.hasMore, loading: connectors.loadingMore) { index in
- let shown = Array(CatalogPaging.slice(rows, page: index, size: pageSize))
- // The page past the loaded rows, while the registry fills it.
- if shown.isEmpty {
- SkeletonGrid()
- } else {
- ItemGrid {
- ForEach(shown) { c in
- MarketRow(title: c.title, subtitle: c.description ?? c.name, added: c.installed) {
- ServiceLogo(website: c.website, name: c.title, registryName: c.name)
- } add: {
- installing = c
- }
- }
- ForEach(0..<pagePad(count: rows.count, shown: shown.count), id: \.self) { _ in MarketRowSpacer() }
+ ItemGrid {
+ ForEach(connectors.items.items) { c in
+ MarketRow(title: c.title, subtitle: c.description ?? c.name, added: c.installed) {
+ ServiceLogo(website: c.website, name: c.title, registryName: c.name)
+ } add: {
+ installing = c
}
}
}
- }
- if !connectors.loading {
- CatalogPager(page: connectors.page, count: connectors.items.items.count, pageSize: pageSize, hasMore: connectors.hasMore,
- loading: connectors.loadingMore, go: { showConnectorPage($0, animated: true) }, onSize: changePageSize)
+ if let cursor = connectors.cursor {
+ LoadMoreRow(cursor: cursor, failed: connectors.error != nil) { await loadMoreConnectors() }
+ }
}
}
@@ -116,67 +98,22 @@ extension MarketplaceView {
.foregroundStyle(Palette.secondary)
}
} else {
- flanked(count: shownSkills.count, page: skillPage) { index in
- let shown = Array(CatalogPaging.slice(shownSkills, page: index, size: pageSize))
- ItemGrid {
- ForEach(shown) { s in
- let added = s.installed || model.installedSkills.contains { $0.id == s.source.lowercased() }
- MarketRow(title: s.name, subtitle: s.description, added: added, busy: busySkill == s.source,
- open: { viewingSkill = SkillRef(s, installed: added) }) {
- SkillGlyph()
- } add: {
- busySkill = s.source
- Task {
- do { try await model.installSkill(source: s.source) } catch { report(error) }
- busySkill = nil
- }
+ ItemGrid {
+ ForEach(shownSkills) { s in
+ let added = s.installed || model.installedSkills.contains { $0.id == s.source.lowercased() }
+ MarketRow(title: s.name, subtitle: s.description, added: added, busy: busySkill == s.source,
+ open: { viewingSkill = SkillRef(s, installed: added) }) {
+ SkillGlyph()
+ } add: {
+ busySkill = s.source
+ Task {
+ do { try await model.installSkill(source: s.source) } catch { report(error) }
+ busySkill = nil
}
}
- ForEach(0..<pagePad(count: shownSkills.count, shown: shown.count), id: \.self) { _ in MarketRowSpacer() }
}
}
}
- if !loadingSkills {
- CatalogPager(page: skillPage, count: shownSkills.count, pageSize: pageSize, go: { skillPage = CatalogPaging.clamp(page: $0, count: shownSkills.count, size: pageSize) }, onSize: changePageSize)
- }
- }
-
- /// How many invisible rows a short last page needs so the bar under the list does not jump.
- private func pagePad(count: Int, shown: Int) -> Int {
- count > pageSize ? max(0, pageSize - shown) : 0
- }
-
- /// On a phone the pages sit side by side in a paging scroll view, so a swipe turns the page,
- /// with previous and next on either side. A wide layout shows the one page.
- @ViewBuilder private func flanked<Content: View>(count: Int, page: Int, hasMore: Bool = false, loading: Bool = false, @ViewBuilder content: @escaping (Int) -> Content) -> some View {
- let pages = CatalogPaging.pageCount(count, size: pageSize, hasMore: hasMore)
- let current = CatalogPaging.clamp(page: page, count: count, size: pageSize, hasMore: hasMore)
- if sizeClass == .compact {
- ScrollView(.horizontal) {
- LazyHStack(alignment: .top, spacing: 0) {
- ForEach(0..<pages, id: \.self) { index in
- content(index).containerRelativeFrame(.horizontal)
- }
- }
- .scrollTargetLayout()
- }
- .scrollTargetBehavior(.paging)
- .scrollIndicators(.hidden)
- .scrollPosition(id: Binding(get: { current }, set: { if let index = $0, index != current { swiped(to: index) } }))
- .overlay {
- if pages > 1 {
- HStack(spacing: 0) {
- PageEdgeButton(title: "Previous page", systemImage: "chevron.left", enabled: current > 0 && !loading) { slide(forward: false) }
- Color.clear.frame(maxWidth: .infinity).allowsHitTesting(false)
- PageEdgeButton(title: loading ? "Loading…" : "Next page", systemImage: "chevron.right",
- enabled: CatalogPaging.canForward(count: count, page: current, hasMore: hasMore, size: pageSize) && !loading) { slide(forward: true) }
- }
- .padding(.horizontal, -44)
- }
- }
- } else {
- content(current)
- }
}
/// Two tiles across on a phone. One flexible column stretches each icon into a full-width card.
@@ -185,5 +122,29 @@ extension MarketplaceView {
? [GridItem(.flexible(), spacing: 10), GridItem(.flexible(), spacing: 10)]
: [GridItem(.adaptive(minimum: 160), spacing: 10)]
}
+}
+/// The end of a list the registry continues. In view, it asks for the page at `cursor`, and again each
+/// time the cursor moves on while it stays in view. After a failure it shows Try again, and asks again
+/// once it scrolls back into view.
+private struct LoadMoreRow: View {
+ let cursor: String
+ let failed: Bool
+ let load: () async -> Void
+ @State private var inView = false
+
+ var body: some View {
+ Group {
+ if failed {
+ IconButton("Try again", systemImage: "arrow.clockwise") { Task { await load() } }
+ .frame(maxWidth: .infinity)
+ } else {
+ SkeletonGrid()
+ }
+ }
+ .onScrollVisibilityChange(threshold: 0.01) { inView = $0 }
+ .task(id: inView ? cursor : nil) {
+ if inView { await load() }
+ }
+ }
}
diff --git a/apps/ios/Kit/Sources/CodyncUI/Marketplace/MarketplaceView.swift b/apps/ios/Kit/Sources/CodyncUI/Marketplace/MarketplaceView.swift
index fe53872a..cc7a0363 100644
--- a/apps/ios/Kit/Sources/CodyncUI/Marketplace/MarketplaceView.swift
+++ b/apps/ios/Kit/Sources/CodyncUI/Marketplace/MarketplaceView.swift
@@ -2,12 +2,11 @@ import CodyncKit
import SwiftUI
/// Extensions for the bots on one computer (the store in the environment): Agents,
-/// Connectors and Skills, one at a time. Each list turns a page; a connector page that
-/// isn't full fetches more from the registry (`ConnectorCatalog`). Installing happens on that
+/// Connectors and Skills, one at a time. Each list scrolls; the connectors load more from the
+/// registry as their end comes into view (`ConnectorCatalog`). Installing happens on that
/// computer; each bot turns connectors and skills on in its settings.
public struct MarketplaceView: View {
@Environment(BotStore.self) var model
- @Environment(\.accessibilityReduceMotion) private var reduceMotion
@State var search = ""
@State var connectors = ConnectorCatalog<MarketConnector>()
@State var skills: [MarketSkill] = []
@@ -21,10 +20,6 @@ public struct MarketplaceView: View {
@State var agent: Backend?
@State var addingNode = false
@State var section = ExtensionSection.agents
- @State var agentPage = 0
- @State var skillPage = 0
- /// Nil until the menu is used, so a phone stays at 6 and a wide layout stays at 10.
- @State var chosenPageSize: Int?
@State var showInstalled = false
@State var showCredentials = false
@Environment(\.dismissModal) private var dismiss
@@ -68,8 +63,6 @@ public struct MarketplaceView: View {
do { skills = try await model.marketSkills() } catch { report(error) }
if !Task.isCancelled { loadingSkills = false }
}
- // A size picked from the menu, or one that follows the layout, starts every list over.
- .onChange(of: pageSize) { _, _ in resetPages() }
.codyncSheet(item: $installing) { item in
InstallConnectorSheet(item: item) { Task { await loadConnectors() } }
}
@@ -182,7 +175,6 @@ public struct MarketplaceView: View {
.textFieldStyle(.plain)
.plainTextInput()
.onSubmit { Task { await loadConnectors() } }
- .onChange(of: search) { _, _ in resetPages() }
if !search.isEmpty {
Button { search = ""; Task { await loadConnectors() } } label: {
Image(systemName: "xmark.circle.fill").foregroundStyle(Palette.tertiary)
@@ -204,6 +196,10 @@ public struct MarketplaceView: View {
await connectors.load(search: query, fetch: fetchConnectors)
}
+ func loadMoreConnectors() async {
+ await connectors.loadMore(fetch: fetchConnectors)
+ }
+
private func fetchConnectors(search: String, cursor: String?) async throws -> (items: [MarketConnector], next: String?) {
try await model.marketConnectors(search: search, cursor: cursor)
}
@@ -213,61 +209,6 @@ public struct MarketplaceView: View {
if error is CancellationError || Task.isCancelled { return }
self.error = error.localizedDescription
}
-
- var pageSize: Int {
- chosenPageSize ?? (sizeClass == .compact ? CatalogPaging.phonePageSize : CatalogPaging.pageSize)
- }
-
- private func canTurn(_ forward: Bool) -> Bool {
- let (page, count, hasMore) = switch section {
- case .agents: (agentPage, agents.count, false)
- case .skills: (skillPage, shownSkills.count, false)
- case .connectors: (connectors.page, connectors.items.items.count, connectors.hasMore)
- }
- if section == .connectors, connectors.loading || connectors.loadingMore { return false }
- let next = page + (forward ? 1 : -1)
- return CatalogPaging.clamp(page: next, count: count, size: pageSize, hasMore: hasMore) == next
- }
-
- /// How a page turn from an arrow scrolls the pager.
- var pageMotion: Animation? { reduceMotion ? nil : Motion.layout }
-
- /// The arrow buttons turn the page; on a phone the pager scrolls over to it.
- func slide(forward: Bool) {
- guard canTurn(forward) else { return }
- let step = forward ? 1 : -1
- switch section {
- case .agents: withAnimation(pageMotion) { agentPage += step }
- case .skills: withAnimation(pageMotion) { skillPage += step }
- case .connectors: showConnectorPage(connectors.page + step, animated: true)
- }
- }
-
- /// A swipe landed on `page`. The page shows at once; a connector page that isn't full then fills.
- func swiped(to page: Int) {
- switch section {
- case .agents: agentPage = page
- case .skills: skillPage = page
- case .connectors: showConnectorPage(page, animated: false)
- }
- }
-
- /// The new size starts every list over (`onChange(of: pageSize)`).
- func changePageSize(_ size: Int) {
- chosenPageSize = size
- }
-
- private func resetPages() {
- agentPage = 0
- skillPage = 0
- connectors.show(0, size: pageSize)
- }
-
- /// Turns the connector list to `page`; a page that isn't full then fills from the registry.
- func showConnectorPage(_ page: Int, animated: Bool) {
- withAnimation(animated ? pageMotion : nil) { connectors.show(page, size: pageSize) }
- Task { await connectors.fill(size: pageSize, animation: pageMotion, fetch: fetchConnectors) }
- }
}
enum ExtensionSection: String, CaseIterable, Identifiable {
diff --git a/apps/ios/Kit/Tests/CodyncUITests/MarketplacePageTests.swift b/apps/ios/Kit/Tests/CodyncUITests/MarketplacePageTests.swift
index c18a6e57..4e52a82a 100644
--- a/apps/ios/Kit/Tests/CodyncUITests/MarketplacePageTests.swift
+++ b/apps/ios/Kit/Tests/CodyncUITests/MarketplacePageTests.swift
@@ -12,71 +12,34 @@ private struct CatalogItem: Identifiable { let id: Int }
#expect(page.isEmpty)
}
-@Test func catalogPagingClampsAndFetchesOnlyPastLoadedRows() {
- let items = Array(0..<47)
- #expect(CatalogPaging.pageCount(47) == 5)
- #expect(CatalogPaging.pageCount(19) == 2)
- #expect(CatalogPaging.pageCount(0) == 1)
- #expect(CatalogPaging.pageCount(72, hasMore: true) == 9)
- #expect(Array(CatalogPaging.slice(items, page: 0)) == Array(0..<10))
- #expect(Array(CatalogPaging.slice(items, page: 4)) == Array(40..<47))
- #expect(Array(CatalogPaging.slice(items, page: 9)).isEmpty)
- #expect(CatalogPaging.clamp(page: 9, count: 47) == 4)
- #expect(CatalogPaging.clamp(page: 9, count: 72, hasMore: true) == 8)
- #expect(CatalogPaging.clamp(page: -1, count: 20) == 0)
- #expect(CatalogPaging.clamp(page: 4, count: 0) == 0)
- #expect(CatalogPaging.canForward(count: 10, page: 0, hasMore: true))
- #expect(CatalogPaging.needsFetch(count: 10, page: 1))
- #expect(CatalogPaging.canForward(count: 20, page: 0, hasMore: false))
- #expect(!CatalogPaging.needsFetch(count: 20, page: 1))
- #expect(!CatalogPaging.canForward(count: 8, page: 0, hasMore: false))
- #expect(!CatalogPaging.needsFetch(count: 60, page: 5))
- #expect(CatalogPaging.needsFetch(count: 60, page: 6))
- #expect(CatalogPaging.needsFetch(count: 72, page: 7))
- #expect(!CatalogPaging.needsFetch(count: 80, page: 7))
- #expect(!CatalogPaging.needsFetch(count: 0, page: 0))
- #expect(!CatalogPaging.needsFetch(count: 3, page: 0))
- #expect(CatalogPaging.needsFetch(count: 0, page: 1))
-}
-
private struct Offline: Error {}
-@Test @MainActor func aConnectorPageFillsUntilFullAndFallsBackWhenItCannot() async {
+@Test @MainActor func moreConnectorsReadOnPastEmptyPagesAndStopAtAFailure() async {
let catalog = ConnectorCatalog<CatalogItem>()
var asked: [String?] = []
let rows = { (range: Range<Int>) in range.map { CatalogItem(id: $0) } }
await catalog.load(search: "") { _, cursor in asked.append(cursor); return (rows(0..<15), "a") }
- #expect(catalog.items.items.count == 15 && catalog.page == 0 && !catalog.loading)
+ #expect(catalog.items.items.count == 15 && !catalog.loading)
- // Page 2 needs rows 10-19: two registry pages fill it.
- catalog.show(1, size: 10)
- await catalog.fill(size: 10) { _, cursor in
- asked.append(cursor)
- return cursor == "a" ? (rows(15..<18), "b") : (rows(18..<25), "c")
- }
+ // The next page has nothing to install but moves the cursor on: the one after it brings the rows.
+ await catalog.loadMore { _, cursor in asked.append(cursor); return ([], "b") }
+ #expect(catalog.items.items.count == 15 && catalog.cursor == "b")
+ await catalog.loadMore { _, cursor in asked.append(cursor); return (rows(15..<25), "c") }
#expect(asked == [nil, "a", "b"])
- #expect(catalog.page == 1 && catalog.items.items.count == 25 && catalog.cursor == "c" && !catalog.loadingMore)
+ #expect(catalog.items.items.count == 25 && catalog.cursor == "c" && !catalog.loadingMore)
- // The page past the loaded rows fails: back to the last page with rows.
- catalog.show(3, size: 10)
- #expect(catalog.page == 3)
- await catalog.fill(size: 10) { _, _ in throw Offline() }
- #expect(catalog.page == 2 && catalog.error != nil)
+ await catalog.loadMore { _, _ in throw Offline() }
+ #expect(catalog.items.items.count == 25 && catalog.cursor == "c" && catalog.error != nil && !catalog.loadingMore)
+
+ // The cursor ends: nothing more to ask for.
+ await catalog.loadMore { _, _ in (rows(25..<26), nil) }
+ #expect(catalog.items.items.count == 26 && !catalog.hasMore && catalog.error == nil)
}
-@Test @MainActor func anEmptyFirstPageThatContinuesReadsOnToRows() async {
+@Test @MainActor func anEmptyFirstPageThatContinuesKeepsItsCursor() async {
let catalog = ConnectorCatalog<CatalogItem>()
- await catalog.load(search: "search") { _, cursor in
- switch cursor {
- case nil: ([], "a")
- case "a": ([], "b")
- default: ([CatalogItem(id: 1), CatalogItem(id: 2)], "c")
- }
- }
- #expect(catalog.items.items.count == 2 && catalog.cursor == "c")
-
- // Past the asks it allows, an empty answer reads as no results, cursor and all.
- let endless = ConnectorCatalog<CatalogItem>()
- await endless.load(search: "none") { _, cursor in ([], (cursor ?? "") + "x") }
- #expect(endless.items.isEmpty && endless.cursor == "xxxx")
+ await catalog.load(search: "search") { _, cursor in cursor == nil ? ([], "a") : ([CatalogItem(id: 1)], nil) }
+ #expect(catalog.items.isEmpty && catalog.cursor == "a")
+ await catalog.loadMore { _, _ in ([CatalogItem(id: 1)], nil) }
+ #expect(catalog.items.items.count == 1 && !catalog.hasMore)
}
diff --git a/apps/ios/WhatsNew.md b/apps/ios/WhatsNew.md
index b3a3255a..e5c04047 100644
--- a/apps/ios/WhatsNew.md
+++ b/apps/ios/WhatsNew.md
@@ -12,8 +12,8 @@ a version without one gets a generic "Bug fixes and improvements" line. Delete o
- 修正 iOS 18 在送出文字、清空或替換聊天草稿時可能閃退的問題。
- Bot 傳來的圖片會直接顯示在聊天裡,點一下可以放大看,不用先下載。
- 電腦上的 Codync 版本太舊時,更新提示多了「Update now」按鈕,直接從手機叫那台電腦更新。
-- 擴充套件一次顯示一個分類:智慧體、聯結器或技能,每個列表都分頁。點列表兩側的圓形按鈕或左右滑動就能翻頁,下方可選每頁 6、10、20 或 50 筆,並顯示目前在第幾頁。
-- 聯結器翻到還沒載入的頁面時,會從 MCP Registry 接著載入。
+- 擴充套件一次顯示一個分類:智慧體、聯結器或技能。
+- 聯結器往下捲到底,會自動從 MCP Registry 載入更多,不用再按「載入更多」。
- 「憑證」移到上方電腦名稱旁;「自定義聯結器」和「自己的技能」放在各自分類的列表上方。
- 電腦使用自建中繼時,設定和連線狀態會顯示該中繼的地址,不再一律寫成 Cloudflare。
- 可以建立使用 WorkBuddy 的 Bot:Codync 會使用 WorkBuddy 桌面 App 內附的 CLI,並在聊天裡請你登入。
@@ -23,8 +23,8 @@ a version without one gets a generic "Bug fixes and improvements" line. Delete o
- Fixed a possible crash on iOS 18 when sending text or clearing or replacing a chat draft.
- Images a bot sends now show right in the chat; tap one to see it full size, no download needed.
- When a computer's Codync is too old for this app, Update now on the notice updates that computer from your phone.
-- Extensions shows one section at a time: Agents, Connectors or Skills, each in pages. Tap the round buttons beside the list or swipe left or right to turn the page; under it, pick 6, 10, 20 or 50 per page and see which page you're on.
-- Connectors keep loading from the MCP Registry as you page past what's loaded.
+- Extensions shows one section at a time: Agents, Connectors or Skills.
+- Connectors load more from the MCP Registry as you scroll to the end, with no Load more button to press.
- Credentials sits beside the computer's name at the top, and Custom connector and Your own skill sit above their lists.
- When a computer uses a private relay, Settings and connection status show that relay's address instead of always saying Cloudflare.
- Create bots that run WorkBuddy: Codync uses the CLI inside the WorkBuddy desktop app and asks you to sign in from the chat.
diff --git a/docs/features/marketplace.md b/docs/features/marketplace.md
index 264995cb..39e56a30 100644
--- a/docs/features/marketplace.md
+++ b/docs/features/marketplace.md
@@ -26,7 +26,7 @@ has only Agents, Connectors and Skills tabs.
Install runs the CLI's own native installer where it has one, on Windows too (Claude Code, Codex, Grok, Qwen, Droid, Qoder, Cursor…, `Install` in `backends.rs`); CLIs published only on npm (Gemini, Cline, Auggie, Kilo…) install with `codync-host npm install -g <package>`, npm on the computer's own Node or else on Codync's. A CLI with its own ACP mode then runs as installed, without Node.js. Refreshing the agents re-reads the PATH a fresh login would get (the login shell's; on Windows the user's and machine's PATH from the registry), so a CLI found by an installer that just ran shows up without restarting the host. Many agents' ACP adapters run through `npx` (Claude, Codex, Gemini, Qwen…). On a computer without Node.js, the agent list marks each of them `node: "missing"` (only then is the field there; `added` once Codync's copy is in place) and they aren't available; Extensions shows one *Add Node.js* notice above the agents, each such agent reads *Needs Node.js*, and its setup sheet gets a Node.js step between Install and Sign in. Adding it (`agentSetup {step: "node"}`, a setup terminal running `codync-host node`) downloads the official Node.js of a pinned version (`VERSION` and SHA-256s in `node.rs`) once into `~/.codync/node/<version>`; npm installs with it go to `~/.codync/node/global`. Both folders come last on the agent search path, so the computer's own Node and CLIs always win, and nothing outside `~/.codync` changes. Linux builds of Node need glibc: on musl distros (Alpine) install Node.js yourself.
-Extensions shows one section at a time — Agents, Connectors, or Skills — and each list is paged. A phone starts at 6 rows, three rows of the two agent tiles, so a page has no leftover card; the desktop and the terminal start at 10. The size menu is 6, 10, 20 or 50. The bar shows the count, the page size, previous and next, and the current page over the page count (`1 / 5`). On a phone, previous and next are dark filled circles on either side of the list, and swiping the list left or right also turns the page, in Agents, Connectors and Skills alike. The agent tiles are a bit smaller there, to leave room for the buttons. The bar under the list keeps the page size and the page number. A short last page still takes the height of a full page, so the bar does not move. The Connectors section opens with the first registry page, then, when a later page isn't full, fetches registry pages until it is or the cursor ends (`marketConnectors {search, cursor}` → `{items, nextCursor}`, 60 metadata records per API page). That page shows at once, with placeholder rows while it has none; if a fetch fails, the list goes back to the last page with rows. While a cursor remains, the page count includes one more page, so a list that continues never reads `1 / 1`. A registry that answers with the cursor it was asked for ends the list there: the host drops that cursor rather than serve the same page forever. Searching starts again at the first page; late responses from an older search are ignored. The terminal pages the same lists: Page Up and Page Down move, and Alt+S changes the page size. Its rows that aren't catalog entries (Add Node.js, installed connectors and skills, Custom connector) start every page and aren't counted. Listed: stdio npm/PyPI/OCI/NuGet packages (the registry's runtime and package arguments become inputs) and streamable-HTTP or SSE remotes (URL `{variables}` become inputs). Not listed: MCPB bundles and packages that serve HTTP locally; add those as a custom connector.
+Extensions shows one section at a time — Agents, Connectors, or Skills — and each is one list that scrolls; there are no pages. The lists are lazy (iPhone `LazyVGrid`, Android `LazyColumn`), so only the rows near view are built. Agents and Skills arrive whole. The Connectors section opens with the first registry page (`marketConnectors {search, cursor}` → `{items, nextCursor}`, 60 metadata records per API page); while a cursor remains, placeholder rows end the list (`LoadMoreRow`), and when they come into view the client asks for the page at the cursor, one page per ask, then again each time the cursor moves on while the end stays in view (`ConnectorCatalog.loadMore`). A page with nothing Codync can install still moves the cursor, so the list reads on and never stalls on an empty answer. If a fetch fails, the rows stay, the error shows under the list, the end of the list becomes a Try again button, and it also asks again once it scrolls back into view. A registry that answers with the cursor it was asked for ends the list there: the host drops that cursor rather than serve the same page forever. Searching starts the list over; late responses from an older search are ignored. In the terminal, moving the cursor within about a screen of the end of Connectors asks for the next page the same way. Listed: stdio npm/PyPI/OCI/NuGet packages (the registry's runtime and package arguments become inputs) and streamable-HTTP or SSE remotes (URL `{variables}` become inputs). Not listed: MCPB bundles and packages that serve HTTP locally; add those as a custom connector.
Registry package installs use pinned package references: npm, PyPI and NuGet require the package’s own version; OCI uses the tag or SHA-256 digest already in its image identifier, even when the separate package version is omitted. Untagged images, `latest` tags without a digest, and invalid references are rejected; a server-level version does not pin the executable package.
diff --git a/host/src/market/registry.rs b/host/src/market/registry.rs
index 856b30b0..b96f41b7 100644
--- a/host/src/market/registry.rs
+++ b/host/src/market/registry.rs
@@ -120,8 +120,8 @@ fn listings(servers: &[Value], installed: &[Connector]) -> Vec<Value> {
.collect()
}
-/// Registry pages read past one with nothing Codync can install. An empty answer reads as the end
-/// of the list in every app, so a few more pages are tried while the cursor goes on.
+/// Registry pages read past one with nothing Codync can install, within `BROWSE_BUDGET`, so an app
+/// gets rows in fewer round trips. An app that still gets an empty page with a cursor reads on by itself.
const EMPTY_PAGE_SKIPS: usize = 3;
/// The apps wait 60 s for `marketConnectors`, and one registry page can take 45 s: skipping stops
/// in time to answer, handing back the cursor it didn't get to.
diff --git a/host/src/tui/manage/market.rs b/host/src/tui/manage/market.rs
index 72d55a2e..6c2f7030 100644
--- a/host/src/tui/manage/market.rs
+++ b/host/src/tui/manage/market.rs
@@ -1,11 +1,21 @@
//! The marketplace: agents, connectors and skills.
-use crossterm::event::{KeyCode, KeyEvent, KeyModifiers};
+use crossterm::event::{KeyCode, KeyEvent};
use serde_json::{Value, json};
use super::super::app::{After, App, Confirm, ConfirmAct, Editor, Overlay, fuzzy};
use super::super::l10n::tr;
-use super::{Fields, Input, Market, MarketPage, Reply, Row, Submit, TABS, Tab, ctrl, s};
+use super::{Fields, Input, Market, Reply, Row, Submit, TABS, Tab, ctrl, s};
+
+/// Registry rows kept loaded under the cursor on Connectors, about the list's height.
+const AHEAD: usize = 20;
+
+impl Market {
+ /// The registry page this list waits for: an answer for another search or cursor is a late one.
+ pub(super) fn awaits(&self, search: &str, cursor: Option<&str>) -> bool {
+ self.searched.as_deref().unwrap_or_default() == search && self.next.as_deref() == cursor
+ }
+}
impl App {
pub fn open_market(&mut self) {
@@ -13,7 +23,7 @@ impl App {
self.call("connectors", json!({}), After::Connectors);
self.call("skills", json!({}), After::Skills);
self.sheet("marketSkills", json!({}), Reply::Skills);
- self.sheet("marketConnectors", json!({"search": ""}), Reply::Registry { more: false });
+ self.sheet("marketConnectors", json!({"search": ""}), Reply::Registry { search: String::new(), cursor: None });
self.overlays.push(Overlay::Market(Box::new(Market {
tab: Tab::Agents,
query: Editor::default(),
@@ -24,107 +34,70 @@ impl App {
loading: true,
cursor: 0,
error: None,
- pages: [0; 3],
- page_size: PAGE_SIZE,
})));
}
- /// The open tab's page: the rows every page starts with, then this page's catalog rows.
- pub fn market_page<'a>(&'a self, m: &'a Market) -> MarketPage<'a> {
- let (mut rows, catalog) = self.market_catalog(m, m.tab);
- let more = m.tab == Tab::Connectors && m.next.is_some();
- let count = catalog.len();
- let page = clamp_page(m.pages[m.tab.index()], count, m.page_size, more);
- rows.extend(catalog.into_iter().skip(page * m.page_size).take(m.page_size));
- MarketPage { rows, count, page, pages: page_count(count, m.page_size, more) }
- }
-
- fn connector_count(&self, m: &Market) -> usize {
- self.market_catalog(m, Tab::Connectors).1.len()
- }
-
fn load_more_connectors(&self, m: &mut Market) {
if m.loading || m.next.is_none() {
return;
}
m.loading = true;
let search = m.searched.clone().unwrap_or_default();
- self.sheet("marketConnectors", json!({"search": search, "cursor": m.next}), Reply::Registry { more: true });
+ let reply = Reply::Registry { search: search.clone(), cursor: m.next.clone() };
+ self.sheet("marketConnectors", json!({"search": search, "cursor": m.next}), reply);
}
- /// After a connector page turns or a registry page arrives, keep fetching until that page is full or the cursor ends.
- /// The Connectors page fills even while another tab is open.
- pub(super) fn continue_market_page(&self, m: &mut Market) {
- let count = self.connector_count(m);
- let i = Tab::Connectors.index();
- if m.next.is_some() && needs_fetch(count, m.pages[i], m.page_size) {
+ /// The cursor near the end of the Connectors list asks for the next registry page, and again as pages
+ /// arrive while it stays near it (a page can have nothing to install). A page that failed is asked for
+ /// again on the next move.
+ pub(super) fn load_near_end(&self, m: &mut Market) {
+ if m.tab == Tab::Connectors && m.cursor + AHEAD >= self.market_rows(m).len() {
self.load_more_connectors(m);
- } else {
- m.pages[i] = clamp_page(m.pages[i], count, m.page_size, m.next.is_some());
}
}
- /// A registry page that didn't come: back to the last Connectors page with rows.
- pub(super) fn settle_connector_page(&self, m: &mut Market) {
- let i = Tab::Connectors.index();
- m.pages[i] = clamp_page(m.pages[i], self.connector_count(m), m.page_size, false);
- }
-
- fn turn_market_page(&self, m: &mut Market, forward: bool) {
- let MarketPage { page, pages, .. } = self.market_page(m);
- let next = if forward { page + 1 } else { page.saturating_sub(1) };
- if next == page || next >= pages {
- return;
- }
- m.pages[m.tab.index()] = next;
- m.cursor = 0;
- if m.tab == Tab::Connectors {
- self.continue_market_page(m);
- }
- }
-
- /// A tab's rows, split into the ones every page starts with and the catalog rows that are paged.
- fn market_catalog<'a>(&'a self, m: &'a Market, tab: Tab) -> (Vec<Row<'a>>, Vec<Row<'a>>) {
+ /// The marketplace's rows on its current tab, filtered by the query.
+ pub fn market_rows<'a>(&'a self, m: &'a Market) -> Vec<Row<'a>> {
let q = m.query.text.trim();
let hit = |v: &Value, keys: &[&str]| {
let fields: Vec<&str> = keys.iter().map(|k| v[*k].as_str().unwrap_or_default()).collect();
fuzzy(q, &fields)
};
- match tab {
+ match m.tab {
Tab::Agents => {
let agents = self
.backends
.iter()
.filter(|b| b["available"] == true || b["installed"] == true || b["curated"] == true);
let node = agents.clone().any(|b| b["node"] == "missing").then_some(Row::Node);
- (node.into_iter().collect(), agents.filter(|b| hit(b, &["name", "id"])).map(Row::Agent).collect())
+ node.into_iter().chain(agents.filter(|b| hit(b, &["name", "id"])).map(Row::Agent)).collect()
}
Tab::Connectors => {
let installed: Vec<&str> = self.plugins.0.iter().filter_map(|c| c["registryName"].as_str()).collect();
- let mut pinned: Vec<Row> =
+ let mut rows: Vec<Row> =
self.plugins.0.iter().filter(|c| hit(c, &["name", "description"])).map(Row::Installed).collect();
- pinned.push(Row::Custom);
- let registry = m
- .registry
- .iter()
- .filter(|c| !installed.contains(&c["name"].as_str().unwrap_or_default()))
- .map(Row::Registry)
- .collect();
- (pinned, registry)
+ rows.push(Row::Custom);
+ rows.extend(
+ m.registry
+ .iter()
+ .filter(|c| !installed.contains(&c["name"].as_str().unwrap_or_default()))
+ .map(Row::Registry),
+ );
+ rows
}
Tab::Skills => {
let installed: Vec<String> = self.plugins.1.iter().map(|v| s(v, "id").to_lowercase()).collect();
- let own =
+ let mut rows: Vec<Row> =
self.plugins.1.iter().filter(|v| hit(v, &["name", "description"])).map(Row::OwnSkill).collect();
- let catalog = m
- .skills
- .iter()
- .flatten()
- .filter(|v| !installed.contains(&s(v, "source").to_lowercase()))
- .filter(|v| hit(v, &["name", "description"]))
- .map(Row::Skill)
- .collect();
- (own, catalog)
+ rows.extend(
+ m.skills
+ .iter()
+ .flatten()
+ .filter(|v| !installed.contains(&s(v, "source").to_lowercase()))
+ .filter(|v| hit(v, &["name", "description"]))
+ .map(Row::Skill),
+ );
+ rows
}
}
}
@@ -135,8 +108,7 @@ impl App {
}
pub(in crate::tui) fn market_key(&mut self, mut m: Box<Market>, k: KeyEvent) -> Option<Overlay> {
- let n = self.market_page(&m).rows.len();
- let alt = k.modifiers.contains(KeyModifiers::ALT);
+ let n = self.market_rows(&m).len();
match k.code {
KeyCode::Esc => return None,
KeyCode::Tab | KeyCode::BackTab => {
@@ -147,14 +119,6 @@ impl App {
}
KeyCode::Down => m.cursor = (m.cursor + 1).min(n.saturating_sub(1)),
KeyCode::Up => m.cursor = m.cursor.saturating_sub(1),
- KeyCode::PageDown => self.turn_market_page(&mut m, true),
- KeyCode::PageUp => self.turn_market_page(&mut m, false),
- KeyCode::Char('s') if alt => {
- let i = PAGE_SIZES.iter().position(|s| *s == m.page_size).unwrap_or(0);
- m.page_size = PAGE_SIZES[(i + 1) % PAGE_SIZES.len()];
- m.pages = [0; 3];
- m.cursor = 0;
- }
KeyCode::Char('n' | 'j') if ctrl(k) => m.cursor = (m.cursor + 1).min(n.saturating_sub(1)),
KeyCode::Char('p') if ctrl(k) => m.cursor = m.cursor.saturating_sub(1),
KeyCode::Char('r') if ctrl(k) => {
@@ -168,13 +132,16 @@ impl App {
m.cursor = 0;
m.registry.clear();
m.next = None;
- m.pages[Tab::Connectors.index()] = 0;
- self.sheet("marketConnectors", json!({"search": search}), Reply::Registry { more: false });
+ self.sheet(
+ "marketConnectors",
+ json!({"search": search}),
+ Reply::Registry { search: search.clone(), cursor: None },
+ );
m.searched = Some(search);
}
KeyCode::Enter => return self.market_enter(m),
KeyCode::Char('x') if ctrl(k) => {
- let (id, name, skill) = match self.market_page(&m).rows.get(m.cursor) {
+ let (id, name, skill) = match self.market_rows(&m).get(m.cursor) {
Some(Row::Installed(c)) => (s(c, "id"), s(c, "name"), false),
Some(Row::OwnSkill(v)) => (s(v, "id"), s(v, "name"), true),
_ => return Some(Overlay::Market(m)),
@@ -198,10 +165,10 @@ impl App {
_ => {
if m.query.key(k) {
m.cursor = 0;
- m.pages[m.tab.index()] = 0;
}
}
}
+ self.load_near_end(&mut m);
Some(Overlay::Market(m))
}
@@ -215,7 +182,7 @@ impl App {
Skill(Value, bool),
None,
}
- let act = match self.market_page(&m).rows.get(m.cursor) {
+ let act = match self.market_rows(&m).get(m.cursor) {
Some(Row::Node) => Act::Node,
Some(Row::Agent(b)) => Act::Agent(s(b, "id")),
Some(Row::Installed(c)) if c["auth"] == "signedOut" => Act::SignIn(s(c, "id")),
@@ -312,41 +279,6 @@ impl App {
}
}
-const PAGE_SIZE: usize = 10;
-const PAGE_SIZES: [usize; 4] = [6, 10, 20, 50];
-
-impl MarketPage<'_> {
- /// The pager, in the same order as the other clients: count, size, previous, current / total, next.
- pub fn pager_line(&self, page_size: usize) -> String {
- format!(
- "{} {} {} {} {} / {} {}",
- tr("{count} total").replace("{count}", &self.count.to_string()),
- tr("Per page"),
- tr(&format!("{page_size} / page")),
- tr("Previous page"),
- self.page + 1,
- self.pages,
- tr("Next page"),
- )
- }
-}
-
-/// Catalog rows split into pages. While the registry still has a cursor, one more page is offered.
-fn page_count(count: usize, size: usize, has_more: bool) -> usize {
- let loaded = if count == 0 { 1 } else { count.div_ceil(size) };
- if has_more { loaded + 1 } else { loaded }
-}
-
-fn clamp_page(page: usize, count: usize, size: usize, has_more: bool) -> usize {
- page.min(page_count(count, size, has_more).saturating_sub(1))
-}
-
-/// A later page that isn't full yet: the registry has to be asked. The first page is whatever the first answer held.
-fn needs_fetch(count: usize, page: usize, size: usize) -> bool {
- let start = page * size;
- start > 0 && start + size > count
-}
-
/// The inputs of a connector's chosen way to run, defaults filled in.
pub(super) fn connector_inputs(f: &mut Fields) {
let Submit::Connector(item) = &f.submit else { return };
@@ -373,34 +305,24 @@ pub(super) fn connector_inputs(f: &mut Fields) {
#[cfg(test)]
mod tests {
- use super::super::super::app::{App, Overlay};
+ use super::super::super::app::{App, Editor, Overlay};
use super::super::super::net::Client;
use super::super::{Market, Reply, Tab};
- use super::{clamp_page, needs_fetch, page_count};
+ use crossterm::event::{KeyCode, KeyEvent};
use serde_json::{Value, json};
- #[test]
- fn forty_seven_agents_are_five_pages() {
- assert_eq!(page_count(47, 10, false), 5);
- assert_eq!(page_count(19, 10, false), 2);
- assert_eq!(page_count(0, 10, false), 1);
- assert_eq!(page_count(72, 10, true), 9);
- assert_eq!(clamp_page(9, 47, 10, false), 4);
- assert_eq!(clamp_page(9, 72, 10, true), 8);
- assert!(!needs_fetch(60, 5, 10));
- assert!(needs_fetch(60, 6, 10));
- assert!(needs_fetch(72, 7, 10));
- assert!(!needs_fetch(80, 7, 10));
- assert!(!needs_fetch(0, 0, 10));
- assert!(!needs_fetch(3, 0, 10));
- assert!(needs_fetch(0, 1, 10));
- }
-
fn registry(range: std::ops::Range<usize>, next: Option<&str>) -> Value {
let items: Vec<Value> = range.map(|i| json!({"name": format!("c{i}"), "title": format!("C{i}")})).collect();
json!({"items": items, "nextCursor": next})
}
+ fn open() -> App {
+ let (tx, _rx) = tokio::sync::mpsc::unbounded_channel();
+ let mut app = App::new(Client::new("http://127.0.0.1:1", None), tx, String::new());
+ app.open_market();
+ app
+ }
+
fn market(app: &App) -> &Market {
match app.overlays.last() {
Some(Overlay::Market(m)) => m,
@@ -408,44 +330,64 @@ mod tests {
}
}
- fn turn_to(app: &mut App, page: usize) {
+ /// The registry's answer for `search` at `cursor`.
+ fn answer(app: &mut App, search: &str, cursor: Option<&str>, res: Result<Value, String>) {
+ app.on_sheet_reply(Reply::Registry { search: search.into(), cursor: cursor.map(str::to_owned) }, res);
+ }
+
+ /// The cursor on Connectors row `row`, as arrow keys leave it.
+ fn move_to(app: &mut App, row: usize) {
let Some(Overlay::Market(mut m)) = app.overlays.pop() else { panic!("the marketplace is open") };
m.tab = Tab::Connectors;
- m.pages[Tab::Connectors.index()] = page;
- app.continue_market_page(&mut m);
+ m.cursor = row;
+ app.load_near_end(&mut m);
app.overlays.push(Overlay::Market(m));
}
#[tokio::test]
- async fn a_connector_page_fills_from_the_registry_and_falls_back_when_it_cannot() {
- let (tx, _rx) = tokio::sync::mpsc::unbounded_channel();
- let mut app = App::new(Client::new("http://127.0.0.1:1", None), tx, String::new());
- app.open_market();
- app.on_sheet_reply(Reply::Registry { more: false }, Ok(registry(0..15, Some("a"))));
- turn_to(&mut app, 0);
- let page = app.market_page(market(&app));
- assert_eq!((page.count, page.pages), (15, 3));
+ async fn connectors_load_more_as_the_cursor_nears_the_end() {
+ let mut app = open();
+ answer(&mut app, "", None, Ok(registry(0..30, Some("a"))));
+ // Custom connector, then 30 registry rows: a screenful still lies under row 0.
+ move_to(&mut app, 0);
+ assert!(!market(&app).loading);
- // Page 2 starts at row 10 but only 15 are loaded: the next registry page is asked for.
- turn_to(&mut app, 1);
- assert!(market(&app).loading);
- app.on_sheet_reply(Reply::Registry { more: true }, Ok(registry(15..18, Some("b"))));
- assert!(market(&app).loading, "18 rows still leave page 2 short");
- app.on_sheet_reply(Reply::Registry { more: true }, Ok(registry(18..25, Some("c"))));
+ move_to(&mut app, 12);
+ assert!(market(&app).loading, "near the end, the next page is asked for");
+ answer(&mut app, "", Some("a"), Ok(registry(30..30, Some("b"))));
+ assert!(market(&app).loading, "a page with nothing to install reads on");
+ answer(&mut app, "", Some("b"), Ok(registry(30..40, Some("c"))));
assert!(!market(&app).loading);
- assert_eq!(market(&app).pages[Tab::Connectors.index()], 1);
+ assert_eq!(app.market_rows(market(&app)).len(), 41);
- // The page past the loaded rows fails: back to the last page with rows.
- turn_to(&mut app, 3);
+ // A failed page keeps the rows; the next move asks again, until the cursor ends.
+ move_to(&mut app, 25);
+ answer(&mut app, "", Some("c"), Err("offline".into()));
+ assert_eq!((market(&app).loading, market(&app).error.as_deref()), (false, Some("offline")));
+ move_to(&mut app, 26);
assert!(market(&app).loading);
- app.on_sheet_reply(Reply::Registry { more: true }, Err("offline".into()));
+ answer(&mut app, "", Some("c"), Ok(registry(40..41, None)));
+ move_to(&mut app, 41);
+ assert!(!market(&app).loading && market(&app).next.is_none());
+ }
+
+ #[tokio::test]
+ async fn answers_for_an_older_search_are_dropped() {
+ let mut app = open();
+ move_to(&mut app, 0);
+ answer(&mut app, "", None, Ok(registry(0..5, Some("a"))));
+ assert!(market(&app).loading, "page a is on its way");
+
+ let Some(Overlay::Market(mut m)) = app.overlays.pop() else { panic!("the marketplace is open") };
+ m.query = Editor::with("linear");
+ let m = app.market_key(m, KeyEvent::from(KeyCode::Enter)).expect("the marketplace stays open");
+ app.overlays.push(m);
+ answer(&mut app, "", Some("a"), Ok(registry(5..10, Some("b"))));
+ answer(&mut app, "", Some("a"), Err("offline".into()));
let m = market(&app);
- assert!(!m.loading);
- assert_eq!(m.error.as_deref(), Some("offline"));
- assert_eq!(m.pages[Tab::Connectors.index()], 2);
+ assert!(m.registry.is_empty() && m.next.is_none() && m.loading && m.error.is_none());
- // The cursor ends: no page past the rows.
- app.on_sheet_reply(Reply::Registry { more: true }, Ok(registry(25..26, None)));
- assert_eq!(app.market_page(market(&app)).pages, 3);
+ answer(&mut app, "linear", None, Ok(registry(0..2, None)));
+ assert_eq!(market(&app).registry.len(), 2);
}
}
diff --git a/host/src/tui/manage/mod.rs b/host/src/tui/manage/mod.rs
index 7a4caa76..360cf83d 100644
--- a/host/src/tui/manage/mod.rs
+++ b/host/src/tui/manage/mod.rs
@@ -56,8 +56,10 @@ pub enum Reply {
},
/// A voice call's own messages, by call id.
CallEntries(String),
+ /// A registry page: the search it lists and the cursor it was asked at (`None`: the first page).
Registry {
- more: bool,
+ search: String,
+ cursor: Option<String>,
},
Skills,
/// A skill's instructions, for the details sheet with that id.
@@ -130,16 +132,6 @@ pub enum Tab {
pub const TABS: [(Tab, &str); 3] = [(Tab::Agents, "Agents"), (Tab::Connectors, "Connectors"), (Tab::Skills, "Skills")];
-impl Tab {
- pub(in crate::tui) fn index(self) -> usize {
- match self {
- Self::Agents => 0,
- Self::Connectors => 1,
- Self::Skills => 2,
- }
- }
-}
-
pub struct Market {
pub tab: Tab,
pub query: Editor,
@@ -151,9 +143,6 @@ pub struct Market {
pub loading: bool,
pub cursor: usize,
pub error: Option<String>,
- /// Page index on Agents, Connectors, then Skills.
- pub pages: [usize; 3],
- pub page_size: usize,
}
pub enum Row<'a> {
@@ -167,16 +156,6 @@ pub enum Row<'a> {
Skill(&'a Value),
}
-/// One page of the open marketplace tab.
-pub struct MarketPage<'a> {
- /// The rows every page starts with (Add Node.js, what's installed, Custom connector), then this page's catalog rows.
- pub rows: Vec<Row<'a>>,
- /// Catalog rows on the tab, without the ones every page starts with.
- pub count: usize,
- pub page: usize,
- pub pages: usize,
-}
-
pub struct AgentSetup {
pub backend: String,
pub auth: Option<Value>,
diff --git a/host/src/tui/manage/replies.rs b/host/src/tui/manage/replies.rs
index e0ff332f..f7bfa141 100644
--- a/host/src/tui/manage/replies.rs
+++ b/host/src/tui/manage/replies.rs
@@ -107,9 +107,12 @@ impl App {
"Copied a curl command (the cloud is off: this computer only)"
});
}
- Reply::Registry { more } => self.with_market(|app, m| {
+ Reply::Registry { search, cursor } => self.with_market(|app, m| {
+ if !m.awaits(&search, cursor.as_deref()) {
+ return;
+ }
let items = v["items"].as_array().cloned().unwrap_or_default();
- if more {
+ if cursor.is_some() {
m.registry.extend(items);
} else {
m.registry = items;
@@ -118,7 +121,7 @@ impl App {
m.searched.get_or_insert_with(String::new);
m.loading = false;
m.error = None;
- app.continue_market_page(m);
+ app.load_near_end(m);
}),
Reply::Skills => {
if let Some(Overlay::Market(m)) =
@@ -220,16 +223,12 @@ impl App {
}
}
}
- Reply::Registry { more } => {
- let more = *more;
- self.with_market(|app, m| {
+ Reply::Registry { search, cursor } => self.with_market(|_, m| {
+ if m.awaits(search, cursor.as_deref()) {
m.loading = false;
m.error = Some(e);
- if more {
- app.settle_connector_page(m);
- }
- });
- }
+ }
+ }),
Reply::Skills => self.with_market(|_, m| {
m.skills.get_or_insert_with(Vec::new);
m.error = Some(e);
diff --git a/host/src/tui/sheets/market_view.rs b/host/src/tui/sheets/market_view.rs
index ee62d96f..4cb6a32d 100644
--- a/host/src/tui/sheets/market_view.rs
+++ b/host/src/tui/sheets/market_view.rs
@@ -1,4 +1,4 @@
-//! The Extensions sheet: three tabs, a search field, and a pinned pager.
+//! The Extensions sheet: three tabs, a search field, and the open tab's list.
use super::{App, Buffer, Rect, centered, footer, frame_box, put, row, rput, s, theme, truncate, u, window};
use crate::tui::l10n::tr;
@@ -29,10 +29,9 @@ pub fn draw(buf: &mut Buffer, area: Rect, app: &App, m: &Market) {
};
let source = source.replace("{name}", &app.host);
put(buf, inner.x, inner.y + 1, inner.width, &truncate(&source, usize::from(inner.width)), t.dim.patch(t.panel));
- let page = app.market_page(m);
- let rows = &page.rows;
- // Tabs, source line, then the list; under it the pager, the error and the keys.
- let list_h = usize::from(inner.height.saturating_sub(6));
+ let rows = app.market_rows(m);
+ // Tabs, source line, then the list; under it the error and the keys.
+ let list_h = usize::from(inner.height.saturating_sub(5));
let mut y = inner.y + 2;
if App::market_stale(m) {
put(buf, inner.x, y, inner.width, &tr("↵ searches the registry"), t.secondary.patch(t.panel));
@@ -92,21 +91,11 @@ pub fn draw(buf: &mut Buffer, area: Rect, app: &App, m: &Market) {
put(buf, inner.x, y, inner.width, &msg, t.dim.patch(t.panel));
}
let keys = match m.tab {
- Tab::Agents => tr("pgup/pgdn · alt-s · tab · ↵ install / sign in · ^r · esc"),
- Tab::Connectors => tr("pgup/pgdn · alt-s · tab · ↵ add / sign in · ^x remove · esc"),
- Tab::Skills => tr("pgup/pgdn · alt-s · tab · ↵ details · ^x remove · esc"),
+ Tab::Agents => tr("tab switch · ↵ install / sign in · ^r refresh · esc close"),
+ Tab::Connectors => tr("tab switch · ↵ add / sign in · ^x remove · ^r refresh · esc"),
+ Tab::Skills => tr("tab switch · ↵ details · ^x remove · esc close"),
};
let loading = m.loading && m.tab == Tab::Connectors && !rows.is_empty();
let registry = tr("Loading the registry…");
- // Like the apps, a list still loading for the first time has no pager yet.
- let settled = match m.tab {
- Tab::Agents => true,
- Tab::Connectors => !(m.loading && m.registry.is_empty()),
- Tab::Skills => m.skills.is_some(),
- };
- if settled {
- let line = page.pager_line(m.page_size);
- put(buf, inner.x, inner.bottom().saturating_sub(3), inner.width, &line, t.secondary.patch(t.panel));
- }
footer(buf, inner, m.error.as_deref().or(loading.then_some(registry.as_ref())), &keys);
}
diff --git a/web/content/docs/agents.mdx b/web/content/docs/agents.mdx
index 8894a507..796c6a6f 100644
--- a/web/content/docs/agents.mdx
+++ b/web/content/docs/agents.mdx
@@ -68,7 +68,7 @@ Agents are set up from **Extensions**, which belongs to one computer:
- **iPhone:** tap the account button at the top left of the Bots tab, open **Computers & settings**, and tap the **Extensions** button on the computer.
- **Terminal UI:** press `A`.
-The **Agents** section shows each agent's status: **Installed**, **Not installed**, **Not signed in**, **Needs Node.js**, or **Sets up on first use** (registry agents). The list is paged: **Previous page** and **Next page** move through it (on a phone, you can also swipe the list left or right), and the bar shows the current page over the page count, such as **1 / 5**. Select an agent to open its setup sheet. It walks through up to three steps.
+The **Agents** section shows each agent's status: **Installed**, **Not installed**, **Not signed in**, **Needs Node.js**, or **Sets up on first use** (registry agents). Select an agent to open its setup sheet. It walks through up to three steps.
### Install
diff --git a/web/content/docs/connectors-and-skills.mdx b/web/content/docs/connectors-and-skills.mdx
index 14731f1c..8440d3b5 100644
--- a/web/content/docs/connectors-and-skills.mdx
+++ b/web/content/docs/connectors-and-skills.mdx
@@ -12,7 +12,7 @@ The header names the computer everything installs on. **Credentials** sits on th
## Add a connector from the registry
-Extensions opens on one section at a time: **Agents**, **Connectors**, or **Skills**. On the desktop, and on a wide phone, those are a side list; on a narrow phone they are tabs along the top. Each list is paged. A phone starts at 6 at a time, three rows of the two agent tiles; elsewhere it starts at 10. The bar under the list shows how many there are, how many fit on a page (6, 10, 20 or 50), **Previous page**, the current page over the page count (such as **1 / 8**), and **Next page**. On a phone, previous and next are the dark round buttons on either side of the list, and you can also swipe the list left or right to turn the page. The bar underneath is the page size and the page number (`1 / 8` is the page, not how many fit). A short last page keeps the height of a full page, so the bar stays put. The **Connectors** list starts with the first page from the official MCP Registry; opening a page that isn't full yet fetches more. Search by service name. In the terminal, Tab still switches sections, Page Up and Page Down turn the page, and Alt+S changes the page size.
+Extensions opens on one section at a time: **Agents**, **Connectors**, or **Skills**. On the desktop they are a row of chips under the search field; on a wide phone they are a side list, and on a narrow phone tabs along the top. Each section is one list you scroll. The **Connectors** list starts with the first connectors from the official MCP Registry, and more load as you scroll down to the end; if that fails, **Try again** at the end of the list asks again. Search by service name. In the terminal, Tab switches sections, and moving down the Connectors list loads more as you near its end.
1. Pick a connector. The **Add connector** sheet opens.
2. If it can run more than one way, choose under **Runs**: hosted by the service, or on your computer as a package.