Skip to content

Conversation

vertti
Copy link
Owner

@vertti vertti commented Sep 30, 2025

Problem

Users with large ECS deployments (100+ services, tasks, or clusters) experienced crashes with the error:
Error: A list with shortcuts supports a maximum of 36 choices as this the maximum number of keyboard shortcuts that are available. You provided 104 choices.

This was caused by questionary's 36-item keyboard shortcut limit, which was hit when:

  1. Selecting from clusters with 100+ items
  2. Selecting from services with 100+ items
  3. Selecting actions for a service with 100+ tasks
  4. Selecting task features with 10+ containers (6 actions per container)

Additionally, only the first 100 clusters/services/tasks were shown due to AWS API pagination not being implemented.

Solution

Implemented comprehensive pagination at both the AWS API and UI layers:

  1. AWS API Pagination (paginate_aws_list())
  • Created reusable helper function in core/utils.py
  • Handles all AWS ECS list operations with type-safe operation names
  • Applied to:
    • ClusterService.get_cluster_names() - now returns all clusters
    • ServiceService.get_services() - now returns all services
    • TaskService.get_tasks() - now returns all tasks
    • TaskService.get_task_history() - paginates both running and stopped tasks
  1. UI Pagination (select_with_pagination())
  • Created paginated selection component in core/navigation.py
  • Features:
    • 25 items per page (configurable)
    • Next/Previous page navigation
    • Back and Exit buttons on every page
    • No keyboard shortcuts (avoids 36-item limit entirely)
  • Applied to:
    • ClusterUI.select_cluster()
    • ServiceUI.select_service()
    • ServiceUI.select_service_action()
    • TaskUI.select_task()
    • TaskUI.select_task_feature()
  1. Smart Threshold (30 items)
  • Lists ≤30 items: use keyboard shortcuts for better UX
  • Lists >30 items: use pagination to avoid crashes

Closes #16 and #17

  Add paginate_aws_list() utility function to handle AWS API pagination
  across multiple pages. This generic helper will be used to fix issues
  with listing large numbers of clusters and services.

  - Supports all ECS list operations via boto3 paginators
  - Handles empty results and missing keys gracefully
  - Includes comprehensive test coverage for single/multiple pages
  Update ClusterService to use paginate_aws_list() helper for fetching
  all clusters across multiple pages. Fixes issue where only first 100
  clusters were shown.

  - ClusterService.get_cluster_names() now handles 100+ clusters
  - Added test with 150 clusters to verify pagination works
  Update ServiceService to use paginate_aws_list() helper for fetching
  all services across multiple pages. Fixes issue where only first 100
  services were shown, which caused the questionary 36-item limit crash.

  - ServiceService.get_services() now handles 100+ services
  - Added test with 200 services to verify pagination works
  Add select_with_pagination() function to handle large lists without
  hitting questionary's 36-item keyboard shortcut limit. Displays items
  in pages with next/previous navigation.

  - Supports configurable page size (default: 25 items)
  - Navigation: next page, previous page, back, exit
  - No keyboard shortcuts (avoids 36-item limit)
  - Shows page indicator (Page X of Y)
  Update ClusterUI to use select_with_pagination() for lists with more
  than 30 clusters. Small lists continue using the existing shortcuts-
  enabled navigation.

  - Pagination threshold: 30 items
  - Automatically switches to pagination for large lists
  Extends pagination support to task operations:
  - Add pagination to TaskService.get_tasks() and get_task_history()
  - Add pagination to TaskUI.select_task() and select_task_feature()
@vertti vertti merged commit b6fbaed into main Sep 30, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support paging for instances of more than 36 options

1 participant