diff --git a/README.md b/README.md index 7db5e594..252c2d25 100644 --- a/README.md +++ b/README.md @@ -147,6 +147,12 @@ Continue from the last response or a given title or SHA1. Lists all saved conversations. +#### Show last + +`-S`, `--show-last` + +Show the previous conversation. + #### Show `-s`, `--show` diff --git a/config.go b/config.go index e0d1f982..64275d99 100644 --- a/config.go +++ b/config.go @@ -45,7 +45,8 @@ var help = map[string]string{ "title": "Saves the current conversation with the given title.", "list": "Lists saved conversations.", "delete": "Deletes a saved conversation with the given title or ID.", - "show": "Show a saved conversation with the given title or ID", + "show": "Show a saved conversation with the given title or ID.", + "show-last": "Show a the last saved conversation.", } // Model represents the LLM model used in the API call. @@ -113,6 +114,7 @@ type Config struct { ContinueLast bool Continue string Title string + ShowLast bool Show string List bool Delete string diff --git a/main.go b/main.go index cd3436bf..f133565d 100644 --- a/main.go +++ b/main.go @@ -117,6 +117,7 @@ var ( if config.ShowHelp || (mods.Input == "" && config.Prefix == "" && config.Show == "" && + !config.ShowLast && config.Delete == "" && !config.List) { //nolint: wrapcheck @@ -140,7 +141,7 @@ var ( } } - if config.Show != "" { + if config.Show != "" || config.ShowLast { return nil } @@ -168,6 +169,7 @@ func initFlags() { flags.StringVarP(&config.Title, "title", "t", config.Title, stdoutStyles().FlagDesc.Render(help["title"])) flags.StringVarP(&config.Delete, "delete", "d", config.Delete, stdoutStyles().FlagDesc.Render(help["delete"])) flags.StringVarP(&config.Show, "show", "s", config.Show, stdoutStyles().FlagDesc.Render(help["show"])) + flags.BoolVarP(&config.ShowLast, "show-last", "S", false, stdoutStyles().FlagDesc.Render(help["show-last"])) flags.BoolVarP(&config.Quiet, "quiet", "q", config.Quiet, stdoutStyles().FlagDesc.Render(help["quiet"])) flags.BoolVarP(&config.ShowHelp, "help", "h", false, stdoutStyles().FlagDesc.Render(help["help"])) flags.BoolVarP(&config.Version, "version", "v", false, stdoutStyles().FlagDesc.Render(help["version"])) @@ -198,6 +200,7 @@ func initFlags() { rootCmd.MarkFlagsMutuallyExclusive( "settings", "show", + "show-last", "delete", "list", "continue", diff --git a/mods.go b/mods.go index fb24d3bc..0bd729fe 100644 --- a/mods.go +++ b/mods.go @@ -128,7 +128,7 @@ func (m *Mods) Update(msg tea.Msg) (tea.Model, tea.Cmd) { if msg.content != "" { m.Input = msg.content } - if msg.content == "" && m.Config.Prefix == "" && m.Config.Show == "" { + if msg.content == "" && m.Config.Prefix == "" && m.Config.Show == "" && !m.Config.ShowLast { return m, m.quit } m.state = requestState @@ -254,7 +254,7 @@ func (m *Mods) retry(content string, err modsError) tea.Msg { } func (m *Mods) startCompletionCmd(content string) tea.Cmd { - if m.Config.Show != "" { + if m.Config.Show != "" || m.Config.ShowLast { return m.readFromCache() } @@ -512,7 +512,7 @@ func (m *Mods) findCacheOpsDetails() tea.Cmd { } } - if readID != "" || continueLast { + if readID != "" || continueLast || m.Config.ShowLast { found, err := m.findReadID(readID) if err != nil { return modsError{