Skip to content

Session support#33

Merged
npiv merged 8 commits intonpiv:mainfrom
csabahenk:session
Apr 2, 2023
Merged

Session support#33
npiv merged 8 commits intonpiv:mainfrom
csabahenk:session

Conversation

@csabahenk
Copy link
Contributor

@csabahenk csabahenk commented Mar 29, 2023

This PR introduces sessions, named conversations that can be switched between, continued, reviewed, edited.

A basic session management facility is added, too (listing/renaming/deleting/dumping sessions).

@npiv
Copy link
Owner

npiv commented Mar 30, 2023

Hi @csabahenk looks great. I'm just on the road so will only be this weekend that I can fully go through and merge it.

The only thing I'd like to add or dig into is if if we can't autoconvert the old format for users that are upgrading. i.e. to avoid having the option --migrate-to-session migrate old saved messages to given session, is thatcould perhaps be automatically detected and executed on first run. Not sure if there is a good hook to detect it though.

@csabahenk
Copy link
Contributor Author

So, then we can do it like this:

  • the sessiion dir can be then just ~/.config/chatblade (what was so far the last conversation fiile), ie. we don't need to add the .d extension for the session dir, as the last conversation file will be eliminated (converted, optionally)
  • if ~/.config/chatblade is a file, user will be informed that chatblade will be session enabled now, and they have a choice to
    1. exit, leaving stuff intact
    2. save the last conversation to a session, whereby they need to pick a session name
    3. drop the last conversation
  • if choice is ii. or iii., create the session dir and if it's iii,, perform the migration process that's currently implemented for --migrate-to-session

I'll update the PR along these lines, probably also during the weekend.

instead of managing a single session with '-l', use '-S <sess>'

The existing cache path will be set up as a direcory
and sessions will reside in it as individual files.

We also provide the migration path from pre-session chatblade.
This enables users to view and edit
session data directly, or process it out
of the context of chatblade (grep it!).
- exit 1 on internal error
- print error message to stderr
- exit 1 if a non-extant session is
  specified but no query is given
  that would initialize it
@npiv
Copy link
Owner

npiv commented Apr 2, 2023

Was playing with it, and it's a very nice feature. I will be using it myself in future. Will merge it today.

I've made some small tweaks

  1. The migration of last is transparent, we just do it. If ~/.config/chatblade is a file we make it ~/.config/chatblade/last.json . I tried various ways to break it, but it always migrates correctly, so I think its most transparent for users, they don't even need to realize.
  2. Grouped options a little bit by section, with appropriate header and readme tweaks

To be honest I would kind of like to make this use -s instead of a capital, but not sure what to rename stream to :) will see if inspiration strikes, otherwise leave it as is

@npiv npiv merged commit beeeab7 into npiv:main Apr 2, 2023
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.

2 participants