Skip to content

Conversation

@sudo-tee
Copy link
Owner

@sudo-tee sudo-tee commented Nov 5, 2025

This implement a simple timeline pcker similar to the one found in opencode tui
image

@sudo-tee sudo-tee force-pushed the feat/timeline-picker branch 2 times, most recently from 9a6e14c to b885ccc Compare November 5, 2025 14:06
@sudo-tee sudo-tee changed the title feat(timeline-picker): Implement basic timeline picker feat(timeline-picker): implement basic timeline picker Nov 5, 2025
@cameronr
Copy link
Collaborator

cameronr commented Nov 5, 2025

Oh nice! I'm happy to review when it's ready

This is the first commit, the fork action is not yet implemented
Format the time as and highlight it as well as align it to the right
@sudo-tee sudo-tee force-pushed the feat/timeline-picker branch from 320e7ef to b83ba30 Compare November 6, 2025 14:13
@sudo-tee sudo-tee requested a review from cameronr November 6, 2025 14:26
@sudo-tee
Copy link
Owner Author

sudo-tee commented Nov 6, 2025

@cameronr

If you want to have a look, it's almost ready

@sudo-tee sudo-tee marked this pull request as ready for review November 6, 2025 14:27
@sudo-tee sudo-tee force-pushed the feat/timeline-picker branch from 5385c8e to 095f47c Compare November 6, 2025 18:03
@cameronr
Copy link
Collaborator

cameronr commented Nov 6, 2025

Great, I'll take a look today

@cameronr
Copy link
Collaborator

cameronr commented Nov 6, 2025

Had a few mins and tried to play around with it but ran into some early errors:

  1. Getting an error when typing in the session picker (using snacks). I assume related to the picker_utils unification?
Unhandled async error:
...nvim/lazy/snacks.nvim/lua/snacks/picker/core/matcher.lua:524: attempt to index local 'str' (a nil value)
  1. Error when I try to open the timeline:
E5108: Error executing lua: ...im-dev/opencode.nvim/lua/opencode/ui/timeline_picker.lua:4: module 'lua.opencode.config' not found:

Removing the "lua." does let me open the picker. I'll take a closer look but wanted to share those issues in case they were already on your radar.

@cameronr
Copy link
Collaborator

cameronr commented Nov 6, 2025

Do you think picker_util can get the size of the picker window and right align the dates across all of the picker plugins?

Screenshot 2025-11-06 at 15 29 20 Screenshot 2025-11-06 at 15 30 14 Screenshot 2025-11-06 at 15 31 24

Copy link
Collaborator

@cameronr cameronr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's coming along really nicely!

My only suggestion is that we should do some more work on how the pickers format their text:

  1. Dates should be right aligned consistently across the picker providers
  2. I wonder if there's an opportunity for a more condensed date format, maybe it's "Oct 05 14:23" if it's this year, and "2024-10-05 14:23" if not?

@sudo-tee
Copy link
Owner Author

sudo-tee commented Nov 7, 2025

Had a few mins and tried to play around with it but ran into some early errors:

  1. Getting an error when typing in the session picker (using snacks). I assume related to the picker_utils unification?
Unhandled async error:
...nvim/lazy/snacks.nvim/lua/snacks/picker/core/matcher.lua:524: attempt to index local 'str' (a nil value)
  1. Error when I try to open the timeline:
E5108: Error executing lua: ...im-dev/opencode.nvim/lua/opencode/ui/timeline_picker.lua:4: module 'lua.opencode.config' not found:

Removing the "lua." does let me open the picker. I'll take a closer look but wanted to share those issues in case they were already on your radar.

I will soon have a refactored picker that both sessions and timeline can use. It will be much easier to create new ones

@sudo-tee
Copy link
Owner Author

sudo-tee commented Nov 7, 2025

It's coming along really nicely!

My only suggestion is that we should do some more work on how the pickers format their text:

  1. Dates should be right aligned consistently across the picker providers
  2. I wonder if there's an opportunity for a more condensed date format, maybe it's "Oct 05 14:23" if it's this year, and "2024-10-05 14:23" if not?

Great idea.

For the alignment. I need to find a way to get the picker width.

This creates a base picker module to make it as easy as possible to
create new ones with the same pattern

It also aligns the date to the right properly for every picker
@sudo-tee
Copy link
Owner Author

sudo-tee commented Nov 7, 2025

It's coming along really nicely!

My only suggestion is that we should do some more work on how the pickers format their text:

  1. Dates should be right aligned consistently across the picker providers
  2. I wonder if there's an opportunity for a more condensed date format, maybe it's "Oct 05 14:23" if it's this year, and "2024-10-05 14:23" if not?

@cameronr

I did some work on having the dates align on all pickers.

Unfortunately some pickers construct their list before showing the window so getting the with was not possible.

I ended up fixing the with of the picker instead with a config, It works pretty well with some edges cases where telescope and fzf have somme padding in their default theme. I added a padding offset for theeses pickers. It should be good enough.

@sudo-tee
Copy link
Owner Author

sudo-tee commented Nov 7, 2025

Telescope
image

Snacks

image

FZF

image

mini.pick

image

@sudo-tee sudo-tee force-pushed the feat/timeline-picker branch from 5a76194 to b7fd9ef Compare November 7, 2025 18:34
@cameronr
Copy link
Collaborator

cameronr commented Nov 7, 2025

With my font settings, the times/dates are completely hidden with snacks (but the others are fine):

Screenshot 2025-11-07 at 11 21 30

For snacks, the width is available in the format function, so instead wrapping format_fn and hardcoding opts.width, we could leave format function as is and then for pickers that have a width available, they can use that:

    format = function(item, snacks_picker)
      return opts.format_fn(item, snacks_picker.layout.width):to_formatted_text()
    end,

For other pickers, they could just pass opts.width

I made that change and here's what it looks like (other pickers are unchanged):

Screenshot 2025-11-07 at 11 37 11

I made two other changes:

  • fixed snacks typing (it requires item.text to be set)
  • used the actual time to set time_width. I know that means that the ... transition will happen differently for short times vs long times but I think that's actually more desirable (and it shouldn't be jarring because it'll be one time transition from short dates to long dates).

Hopefully those changes are ok!

@cameronr
Copy link
Collaborator

cameronr commented Nov 7, 2025

Oh shoot, I just saw your update to set the snacks layout widths. I'll undo the the snacks width changes.

@cameronr cameronr force-pushed the feat/timeline-picker branch from 89e8a49 to 615d0d3 Compare November 7, 2025 20:26
@cameronr
Copy link
Collaborator

cameronr commented Nov 7, 2025

Ok, so now my changes are just fixing snacks matching and using the actual time for width calculation.

Everything else looks good. Really nicely done!

@sudo-tee
Copy link
Owner Author

sudo-tee commented Nov 7, 2025

Thanks for your fixes.

I will merge this pretty soon

@sudo-tee sudo-tee merged commit aea457a into main Nov 7, 2025
10 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.

3 participants