Skip to content

Fix the conversation restoration problem in version 0.2.0 New Computer #977

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions interpreter/terminal_interface/conversation_navigator.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@


def conversation_navigator(interpreter):
print(
"This feature is not working as of 0.2.0 (The New Computer Update). Please consider submitting a PR to repair it with the new streaming format."
)
import time

time.sleep(5)
Expand Down Expand Up @@ -67,6 +64,10 @@ def conversation_navigator(interpreter):
]
answers = inquirer.prompt(questions)

# User chose to exit
if not answers:
return

# If the user selected to open the folder, do so and return
if answers["name"] == "> Open folder":
open_folder(conversations_dir)
Expand Down
26 changes: 13 additions & 13 deletions interpreter/terminal_interface/render_past_conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ def render_past_conversation(messages):
if active_block:
active_block.end()
active_block = None
print(">", chunk["message"])
print(">", chunk["content"])
continue

# Message
if "message" in chunk:
if chunk["type"] == "message":
if active_block is None:
active_block = MessageBlock()
if active_block.type != "message":
active_block.end()
active_block = MessageBlock()
active_block.message += chunk["message"]
active_block.message += chunk["content"]

# Code
if "code" in chunk or "language" in chunk:
if chunk["type"] == "code":
if active_block is None:
active_block = CodeBlock()
if active_block.type != "code" or ran_code_block:
Expand All @@ -46,18 +46,18 @@ def render_past_conversation(messages):
ran_code_block = False
render_cursor = True

if "language" in chunk:
active_block.language = chunk["language"]
if "code" in chunk:
active_block.code += chunk["code"]
if "active_line" in chunk:
active_block.active_line = chunk["active_line"]
if "format" in chunk:
active_block.language = chunk["format"]
if "content" in chunk:
active_block.code += chunk["content"]
if "active_line" in chunk:
active_block.active_line = chunk["active_line"]

# Output
if "output" in chunk:
# Console
if chunk["type"] == "console":
ran_code_block = True
render_cursor = False
active_block.output += "\n" + chunk["output"]
active_block.output += "\n" + chunk["content"]
active_block.output = active_block.output.strip() # <- Aesthetic choice

if active_block:
Expand Down