Skip to content

feat(ui): return to the top of the list on a new copy or paste - #11

Merged
Walkercito merged 2 commits into
Walkercito:mainfrom
hadoukim:feat/reset-to-top
Aug 11, 2026
Merged

Walkercito merged 2 commits into
Walkercito:mainfrom
hadoukim:feat/reset-to-top

Conversation

@hadoukim

@hadoukim hadoukim commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Copying something new, or pasting a clip back from the list, snaps the history
list to the top with the newest clip highlighted; summoning the window lands
there too.

Type of change

  • Bug fix
  • New feature
  • Refactor / cleanup
  • Docs
  • Build / CI

Checklist

  • The build is clean — warnings are errors (-Werror).
  • ctest --preset debug passes. (150/150)
  • The sanitizer build passes: cmake --build --preset asan && ctest --preset asan (zero leaks, zero UB).
  • clang-format is clean (v18.1.8, the pinned version); clang-tidy is left to CI, per the project's .pre-commit-config.yaml.
  • Commits follow Conventional Commits, with no AI/assistant trailers.
  • A change to core/ ships with tests. — N/A, UI-only change, no core/ touched.
  • Docs (README / CONTRIBUTING) updated if behavior changed. — no doc surface: this is implicit list behavior, not a shortcut or setting.

Notes for reviewers

  • The cue is the newest created_at rising across a rebuild — which only add()
    (a copy or paste) does, never pin or remove — so pinning/deleting keep the
    cursor put. reset_to_top() also runs on present().

hakimilg and others added 2 commits August 11, 2026 15:24
Copying something new, or pasting a clip back from the list, snaps the
history list back to the top with the newest clip highlighted; summoning
the window lands there too. The cue is the newest created_at rising
across a rebuild, which only add() does — pin and remove leave the
cursor put.
Pinned clips sort above the newest, so snapping the list to the top left
the cursor on a pin instead of on the clip that just arrived. Follow the
clip itself: remember its content, select its card and scroll it into
view, and defer that scroll to the frame that lays the row out, since a
card appended moments ago — or every card in a window only just mapped —
has no position yet.

A copy usually happens with the window down, where nothing can be shown
and stray tick callbacks would pile up. Hold the arrival and honour it on
the next summon instead; a summon with nothing waiting still goes home to
the top. Seed the newest-seen stamp at startup so the history already on
disk does not count as one big arrival.

Closes Walkercito#10
@Walkercito

Copy link
Copy Markdown
Owner

Thanks for this — the behaviour you describe in #10 is exactly right, and the shape of the change (watch the max created_at, act on the lift) is the correct signal. I pushed a follow-up commit to the branch with three corrections found while testing it here:

1. Pinned clips sort above the newest, so the top is not the new clip. reset_to_top() puts the cursor on the first row; with pins in the list that is a pinned clip, and the clip just copied sits below them, off screen. The arrival is now followed by content: its card is selected and scrolled into view, wherever it sorts.

2. The scroll had to be deferred past the frame that lays the row out. A card appended moments ago — and every card in a window only just mapped — has no allocation yet, so reveal() finds no position and silently does nothing. It now runs from a Gtk::Widget::add_tick_callback that retries per frame until the row is laid out, which is what makes the hidden-copy → summon case land correctly with a long list of pins.

3. A copy almost always happens with the window down. Acting on it right then shows the user nothing and piles up tick callbacks on a hidden window. The arrival is held in pending_arrival_ and honoured on the next summon; a summon with nothing waiting still goes home to the top, and last_seen_newest_ is seeded at startup so the history already on disk doesn't count as one big arrival.

Verified live against a 12-pin history: copy while visible, copy while hidden then summon, summon with nothing new, cold start with and without something on the clipboard. ctest 150/150 on both the debug and ASan builds, clang-format and clang-tidy clean.

Merging — closes #10.

@Walkercito
Walkercito merged commit d4aeaaa into Walkercito:main Aug 11, 2026
3 checks passed
@hadoukim
hadoukim deleted the feat/reset-to-top branch August 13, 2026 10:08
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.

3 participants