Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:1ay1 Agentty Provider Picker Rows

From Leeroopedia
Knowledge Sources
Domains UI, Provider_Selection
Last Updated 2026-10-28 12:00 GMT

Overview

One ordered, tagged row model for the provider picker, built once and consumed by both reducer and view, eliminating duplicated offset arithmetic across a heterogeneous list.

Description

The agentty::ui::build_provider_rows function builds the composite provider picker list as a value: built-in presets, ACP agents, saved custom hosts, and the "Custom host…" sentinel — each tagged with what it IS. The cursor is just an index into this vector; resolving a selection is `rows[index]`, with no offset math.

Two key rules: a host-shaped query promotes the sentinel to the top and pre-fills it (typing an endpoint is unambiguous intent — the answer should be first); saved custom hosts are searchable (they used to vanish the moment you typed, forcing you to scroll past every preset to reach a host you already saved).

`query_looks_like_host()` detects endpoint-shaped queries, leaning permissive — a false negative costs the feature (user concludes agentty can't reach their server), while a false positive costs one row.

Usage

Import this when you need to: build the provider picker's row list, resolve a selection, or detect if a query is endpoint-shaped.

Code Reference

Source Location

Signature

namespace agentty::ui {

struct ProviderRow {
    struct Preset { const provider::ProviderPreset* preset; };
    struct Acp { provider::AcpAgentSpec agent; };
    struct CustomHost { std::string spec; };
    struct NewCustomHost { std::string prefill; };
    std::variant<Preset, Acp, CustomHost, NewCustomHost> kind;

    [[nodiscard]] const provider::ProviderPreset* preset() const;
    [[nodiscard]] const provider::AcpAgentSpec* acp() const;
    [[nodiscard]] const std::string* custom_host() const;
    [[nodiscard]] bool is_new_custom_host() const;
    [[nodiscard]] const std::string* new_host_prefill() const;
};

[[nodiscard]] inline bool query_looks_like_host(std::string_view q);

[[nodiscard]] inline std::vector<ProviderRow> build_provider_rows(
    const std::vector<std::string>& saved_custom_hosts,
    std::string_view query);
}

Import

#include "agentty/runtime/provider_rows.hpp"

I/O Contract

Inputs

Name Type Required Description
saved_custom_hosts std::vector<string> Yes Saved custom host specs from Settings
query std::string_view Yes Live filter query (empty = show all)

Outputs

Name Type Description
return std::vector<ProviderRow> Ordered, tagged rows in display order
query_looks_like_host() bool True for endpoint-shaped queries

Usage Examples

Build and Resolve

#include "agentty/runtime/provider_rows.hpp"

auto rows = agentty::ui::build_provider_rows(
    saved_custom_hosts, picker.query());

// Cursor is just an index:
int cursor = picker.cursor();
if (cursor >= 0 && cursor < (int)rows.size()) {
    auto& row = rows[cursor];
    if (auto* preset = row.preset()) {
        // Select this built-in provider
    } else if (auto* host = row.custom_host()) {
        // Switch to saved custom host
    } else if (row.is_new_custom_host()) {
        // Open custom host input modal
        if (auto* prefill = row.new_host_prefill()) {
            // Pre-fill the modal with *prefill
        }
    }
}

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment