mpfaffenberger / mpfaffenberger/code_puppy

restore_autosave_interactively: magic 1-5/6 pagination keys, digit-named sessions unselectable, duplicates pagination.py and autosave_menu

Open
#429 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
814
Forks
278
Avg merge
2d 5h
Merged PRs (30d)
76

Description

Problem

The interactive autosave restore prompt in code_puppy/session_storage.py:218-292 (restore_autosave_interactively) hard-codes its pagination contract in a way that breaks for the user:

PAGE_SIZE = 5
...
# Numeric choice: 1-5 select within current page; 6 advances page
if selection.isdigit():
    num = int(selection)
    if num == 6 and total > PAGE_SIZE:
        page = (page + 1) % ((total + PAGE_SIZE - 1) // PAGE_SIZE)
        continue
    if 1 <= num <= 5:
        ...

Issues:

  1. Magic numbers 5 and 6 are sprinkled across rendering (render_page, line 246: emit_system_message(f" [6] {label}")), parsing (lines 275-285), and the prompt string ("Pick 1-5 ... 6 for next"). Changing PAGE_SIZE to anything else silently breaks the "6 = next page" convention — the option key should be derived (PAGE_SIZE + 1) or better, a letter (n for next).
  2. Sessions whose name is a digit 1-6 cannot be selected by name. The selection.isdigit() branch consumes the input before the exact-name match below it, and a session literally named 6 triggers page-flipping instead. ("In the face of ambiguity, refuse the temptation to guess.")
  3. This menu duplicates the nicer pagination already extracted into command_line/pagination.py (get_page_bounds, get_total_pages, etc.) and the full-blown TUI in command_line/autosave_menu.py — three implementations of "browse autosaves" now exist (this text prompt, autosave_menu.py, and the /autosave_load marker flow).

Suggested fix

  • Derive the next-page key: next_key = str(PAGE_SIZE + 1) and interpolate it in both rendering and parsing, or switch to n/p keys.
  • Use command_line/pagination.py helpers for page math.
  • Longer term: route the startup restore through autosave_menu.py's picker (with a plain-text fallback when not a TTY) so there is one obvious implementation.

Filed by Zen Reviewer C (code-puppy-60635a)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in code_puppy/session_storage.py at restore_autosave_interactively, then read command_line/pagination.py and command_line/autosave_menu.py to compare the existing pagination approaches. Done should include pagination keys derived from the page size, digit-named sessions remaining selectable, and consistent page navigation without introducing another autosave-browsing implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.