Skip to content

feat: add guards to session management#101

Merged
lamchau merged 17 commits intoblock:mainfrom
lamchau:lam/fix-color
Oct 10, 2024
Merged

feat: add guards to session management#101
lamchau merged 17 commits intoblock:mainfrom
lamchau:lam/fix-color

Conversation

@lamchau
Copy link
Contributor

@lamchau lamchau commented Sep 27, 2024

  • added a fix/workaround for rich color handling
    image
    image

  • switched [dim] to [bold] for dark terminals
    image

  • added a cleanup for empty sessions: edge case when a user aborts early - without it empty sessions are generated so we're unable to find the "right" last valid session to resume

  • added a prompt menu for overwrites: added a check for existing session files and give a user an opportunity to recover before they take a destructive action
    image

note: the image shows both the empty session file (goose session list doesn't contain abcd.jsonl) and what the menu ux looks like for a session conflict

rich's parser gets confused when there's a color string so we need to
add a space otherwise the coloring ends up getting mashed.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

could use a second opinion on this menu, is there a way we can improve the ux?

Copy link
Contributor Author

@lamchau lamchau Oct 2, 2024

Choose a reason for hiding this comment

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

renamed this function to _prompt_overwrite_session in a1c8c82 (still could use the feedback)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lifeizhou-ap i added some screenshots in the body of the PR to to make this bold since it was hard to see with dark themes on my terminal. happy to change this back!

Copy link
Collaborator

Choose a reason for hiding this comment

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

keep it dim imo! this info shows every time in case you need it but you mostly don't, so i like it being de-emphasized

@lifeizhou-ap
Copy link
Collaborator

Hi @lamchau,

Nice one!

I noticed that the session.py file is getting bigger. Just wondering whether it is better to separate some of these logics to another component or file?

@lifeizhou-ap
Copy link
Collaborator

also I feel that with your change, we may not require session resume as user can resume the session via session start. WDYT?

@lamchau
Copy link
Contributor Author

lamchau commented Oct 1, 2024

@lifeizhou-ap maybe after we get to 500 lines or so unless you have another suggestion?

30% or so of the Session class is text strings (split lines) and docstrings - with code folding it feels digestible. i'm worried if we start to make it to abstract it requires more context switching/modification across files

@lamchau
Copy link
Contributor Author

lamchau commented Oct 1, 2024

[formatted for clarity]

@lifeizhou-ap possibly! but the challenge lies in how it's invoked in this project and internally as a subcommand and how it's used via pipx

  • xx goose session start <tab> doesn't autocomplete session names
    • xx doesn't have shell completions so click can't autocomplete on <tab> we would need to add shell completions to xx (in golang)
    • a user would need 4 steps
    1. xx goose session list (get top)
    2. xx goose session start <session_name>
    3. prompt with conflict
    4. r to resume

with pipx it would still require a conflict for a resume to happen (e.g. goose session start) creates a generated session each time, so that requires the user to use <tab> to autocomplete the latest one

  1. goose session start <tab>
  2. choose session with conflict
  3. r to resume

if we keep the command xx goose session resume and goose session resume it is only 1 step - this convenience is essentially "free" and saves a few steps for the user.

anyhoo, those are my thoughts/biases - we should go with whatever flow makes the most sense. since it's a product decision, maybe anna can make the call?

@lifeizhou-ap
Copy link
Collaborator

@lifeizhou-ap maybe after we get to 500 lines or so unless you have another suggestion?

30% or so of the Session class is text strings (split lines) and docstrings - with code folding it feels digestible. i'm worried if we start to make it to abstract it requires more context switching/modification across files

I see. Personally I prefer small files for readability and maintenance. However, I understand your concern and we can refactor in the future when it reaches the point for refactoring.

One suggestion: Maybe extract the code into a function?

# prevents cluttering the `sessions` with empty files, which
        # can be confusing when resuming a session
        if is_empty_session(self.session_file_path):
            try:
                self.session_file_path.unlink()
            except FileNotFoundError:
                pass
            except Exception as e:
                raise Exception(f"error deleting empty session file: {e}")

@lifeizhou-ap
Copy link
Collaborator

Hey @baxen I am happy with this PR (only with a small suggestion). Would you like to review it?

@lamchau
Copy link
Contributor Author

lamchau commented Oct 2, 2024

@lifeizhou-ap sure thing, extracted and reordered them here a1c8c82

Copy link
Collaborator

@baxen baxen left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

Choose a reason for hiding this comment

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

keep it dim imo! this info shows every time in case you need it but you mostly don't, so i like it being de-emphasized

@lamchau
Copy link
Contributor Author

lamchau commented Oct 4, 2024

keep it dim imo! this info shows every time in case you need it but you mostly don't, so i like it being de-emphasized

@baxen it's pretty hard to see dim magenta, it'd be friendlier imo if we either keep it the same gray color and not emphasize it with color at all. or alternatively we don't display the file location at all?

image

@baxen
Copy link
Collaborator

baxen commented Oct 8, 2024

keep it dim imo! this info shows every time in case you need it but you mostly don't, so i like it being de-emphasized

@baxen it's pretty hard to see dim magenta, it'd be friendlier imo if we either keep it the same gray color and not emphasize it with color at all. or alternatively we don't display the file location at all?

image

+1 to not needing tho show the file location at all here

@lamchau
Copy link
Contributor Author

lamchau commented Oct 10, 2024

@baxen for posterity

@lamchau lamchau merged commit 4375e2f into block:main Oct 10, 2024
@lamchau lamchau deleted the lam/fix-color branch October 10, 2024 12:01
ahau-square pushed a commit that referenced this pull request Oct 10, 2024
* main:
  feat: add groq provider (#134)
  feat: add a deep thinking reasoner model (o1-preview/mini) (#68)
  fix: use concrete SessionNotifier (#135)
  feat: add guards to session management (#101)
  fix: Set default model configuration for the Google provider. (#131)
  test: convert Google Gemini tests to VCR (#118)
  chore: Add goose providers list command (#116)
  docs: working ollama for desktop (#125)
  docs: format and clean up warnings/errors (#120)
  docs: update deploy workflow (#124)
  feat: Implement a goose run command (#121)
ahau-square pushed a commit that referenced this pull request May 2, 2025
cbruyndoncx pushed a commit to cbruyndoncx/goose that referenced this pull request Jul 20, 2025
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

Comments