Problem
kosli list flows calls GET /api/v2/flows/{org} with no page/per_page and renders the full array. On orgs with many flows this is slow and there is no way to page through results. Pagination was explicitly deferred in #943 ("Pagination / large-list latency ... needs a server-side change first; tracked separately") because the endpoint did not support it.
API capability now available
The server-side change has landed. GET /api/v2/flows/{org} now accepts optional pagination, following the same pattern as the trails endpoint:
page (int, default 1, >= 1)
per_page (int, 1..100)
- When
per_page is omitted the endpoint returns a plain array (unchanged, backwards compatible with the current CLI).
- When
per_page is sent it returns an envelope: { "data": [...], "pagination": { "total", "page", "per_page", "page_count" } }.
FlowList items now also include an id field.
Proposed change
Bring kosli list flows in line with kosli list trails / kosli list artifacts, which already support pagination:
- Embed the shared
listOptions in listFlowsOptions and call addListFlags(cmd, &o.listOptions) (adds --page, default 1, and --page-limit/-n, default 15). Add a validate() that calls o.listOptions.validate(cmd).
- Always send
page and per_page as query params in cmd/kosli/listFlows.go (sending per_page switches the server to the envelope response).
- Update
printFlowsListAsTable to unmarshal the {data, pagination} envelope (like listTrailsResponse/printTrailsListAsTable), render rows from response.Data, and append a Showing page X of Y, total Z items footer. Include the page number in the "No flows were found" message.
⚠️ Shorthand conflict to resolve
listFlows.go currently binds -n to --name (StringVarP(&o.name, "name", "n", ...)), but addListFlags binds -n to --page-limit. These might collide in the future. Options: drop the -n shorthand from --name (keep --name/-i long forms), or wire the pagination flags manually without -n. Decide and call it out in the PR — this is the one non-mechanical decision. We could use -N
Out of scope
Definition of Done
References
Problem
kosli list flowscallsGET /api/v2/flows/{org}with nopage/per_pageand renders the full array. On orgs with many flows this is slow and there is no way to page through results. Pagination was explicitly deferred in #943 ("Pagination / large-list latency ... needs a server-side change first; tracked separately") because the endpoint did not support it.API capability now available
The server-side change has landed.
GET /api/v2/flows/{org}now accepts optional pagination, following the same pattern as the trails endpoint:page(int, default 1,>= 1)per_page(int,1..100)per_pageis omitted the endpoint returns a plain array (unchanged, backwards compatible with the current CLI).per_pageis sent it returns an envelope:{ "data": [...], "pagination": { "total", "page", "per_page", "page_count" } }.FlowListitems now also include anidfield.Proposed change
Bring
kosli list flowsin line withkosli list trails/kosli list artifacts, which already support pagination:listOptionsinlistFlowsOptionsand calladdListFlags(cmd, &o.listOptions)(adds--page, default 1, and--page-limit/-n, default 15). Add avalidate()that callso.listOptions.validate(cmd).pageandper_pageas query params incmd/kosli/listFlows.go(sendingper_pageswitches the server to the envelope response).printFlowsListAsTableto unmarshal the{data, pagination}envelope (likelistTrailsResponse/printTrailsListAsTable), render rows fromresponse.Data, and append aShowing page X of Y, total Z itemsfooter. Include the page number in the "No flows were found" message.listFlows.gocurrently binds-nto--name(StringVarP(&o.name, "name", "n", ...)), butaddListFlagsbinds-nto--page-limit. These might collide in the future. Options: drop the-nshorthand from--name(keep--name/-ilong forms), or wire the pagination flags manually without-n. Decide and call it out in the PR — this is the one non-mechanical decision. We could use-NOut of scope
--name/--ignore-casefilter flags (already wired via flows: wiresearch_by_nameinto a--name/--searchflag on kosli list flows #943) are unchanged.Definition of Done
--pageand--page-limitflags added tokosli list flowsand wired into the request URL{data, pagination}envelope and prints a pagination footer-nshorthand conflict resolved (documented in PR)kosli list flows --helpdocuments the new flags--name/--ignore-casebehaviour still worksReferences
cmd/kosli/listFlows.gocmd/kosli/listTrails.go,cmd/kosli/listArtifacts.gosearch_by_nameinto a--name/--searchflag on kosli list flows #943