74 lines
2.4 KiB
Python
74 lines
2.4 KiB
Python
import streamlit as st
|
|
from backend.managers.chat_manager import ChatManager
|
|
|
|
|
|
def init_state():
|
|
# Sidebar state initialization
|
|
if "last_selected" not in st.session_state:
|
|
st.session_state.last_selected = None
|
|
|
|
if "selected_folder" not in st.session_state:
|
|
st.session_state.selected_folder = None
|
|
|
|
if "selected_folder_rel" not in st.session_state:
|
|
st.session_state.selected_folder_rel = None
|
|
|
|
# Chat manager (persists across reruns)
|
|
if "chat_manager" not in st.session_state:
|
|
st.session_state.chat_manager = ChatManager()
|
|
|
|
# Editor state initialization
|
|
if "open_files" not in st.session_state:
|
|
"""A list of currently open file paths - absolute paths only. The order determines the tab order in the UI.
|
|
Format: [ "path/to/file1.py", "path/to/file2.js", ... ]
|
|
"""
|
|
st.session_state.open_files = []
|
|
|
|
if "files_content" not in st.session_state:
|
|
"""A dictionary mapping file paths to their current content in the editor.
|
|
Format: { "path/to/file.py": "file content as string", ... }
|
|
"""
|
|
st.session_state.files_content = {}
|
|
|
|
if "active_file" not in st.session_state:
|
|
"""The currently active file in the editor (absolute path in string e.g. "/workspace/path/to/file.py").
|
|
Should be one of the paths in open_files or None if no file is open."""
|
|
st.session_state.active_file = None
|
|
|
|
if "active_tab" not in st.session_state:
|
|
st.session_state.active_tab = 0
|
|
|
|
if "is_editing" not in st.session_state:
|
|
st.session_state.is_editing = False
|
|
|
|
if "code_suggestions" not in st.session_state:
|
|
st.session_state.code_suggestions = []
|
|
|
|
if "code_execution_output" not in st.session_state:
|
|
st.session_state.code_execution_output = ""
|
|
|
|
# Chat state initialization
|
|
if "chat_history" not in st.session_state:
|
|
st.session_state.chat_history = []
|
|
|
|
# Agent Mode state
|
|
if "agent_mode" not in st.session_state:
|
|
st.session_state.agent_mode = False
|
|
|
|
if "coding_agent" not in st.session_state:
|
|
st.session_state.coding_agent = None
|
|
|
|
if "agent_status" not in st.session_state:
|
|
st.session_state.agent_status = "idle"
|
|
|
|
if "agent_log" not in st.session_state:
|
|
st.session_state.agent_log = []
|
|
|
|
if "agent_pending_action" not in st.session_state:
|
|
st.session_state.agent_pending_action = None
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
init_state()
|