4
4
from time import sleep
5
5
from typing import Generator , Literal
6
6
7
+ from .constants import CMDFIX
7
8
from .logmanager import LogManager
8
9
from .message import (
9
10
Message ,
15
16
from .tools .context import _gen_context_msg
16
17
from .tools .summarize import summarize
17
18
from .tools .useredit import edit_text_with_editor
18
- from .constants import CMDFIX
19
19
20
20
logger = logging .getLogger (__name__ )
21
21
@@ -91,9 +91,11 @@ def handle_cmd(
91
91
log .undo (1 , quiet = True )
92
92
log .print (show_hidden = "--hidden" in args )
93
93
case "rename" :
94
+ log .undo (1 , quiet = True )
94
95
# rename the conversation
95
96
new_name = args [0 ] if args else input ("New name: " )
96
97
log .rename (new_name )
98
+ print (f"Renamed conversation to { new_name } " )
97
99
case "fork" :
98
100
# fork the conversation
99
101
new_name = args [0 ] if args else input ("New name: " )
@@ -105,9 +107,7 @@ def handle_cmd(
105
107
print (f"Summary: { summary } " )
106
108
case "edit" :
107
109
# edit previous messages
108
-
109
110
# first undo the '/edit' command itself
110
- assert log .log [- 1 ].content == f"{ CMDFIX } edit"
111
111
log .undo (1 , quiet = True )
112
112
113
113
# generate editable toml of all messages
@@ -128,10 +128,10 @@ def handle_cmd(
128
128
log .write ()
129
129
# now we need to redraw the log so the user isn't seeing stale messages in their buffer
130
130
# log.print()
131
- logger . info ("Applied edited messages" )
131
+ print ("Applied edited messages, write /log to see the result " )
132
132
case "context" :
133
133
# print context msg
134
- print ( _gen_context_msg () )
134
+ yield _gen_context_msg ()
135
135
case "undo" :
136
136
# undo the '/undo' command itself
137
137
log .undo (1 , quiet = True )
@@ -179,6 +179,7 @@ def handle_cmd(
179
179
print ("Unknown command" )
180
180
# undo the '/help' command itself
181
181
log .undo (1 , quiet = True )
182
+ log .write ()
182
183
183
184
print ("Available commands:" )
184
185
for cmd , desc in action_descriptions .items ():
0 commit comments