From 8fef52bedb0f6f0f0e5a9ac9673d7c9372abe366 Mon Sep 17 00:00:00 2001 From: Irina Rueegg Date: Thu, 9 Apr 2026 17:18:40 +0200 Subject: [PATCH 1/3] Navigation chanche --- frontend/app.py | 18 ++++++++++++------ frontend/sidebar.py | 20 ++++++++++++-------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/frontend/app.py b/frontend/app.py index bc1456b..ead9ab9 100644 --- a/frontend/app.py +++ b/frontend/app.py @@ -23,14 +23,20 @@ def main(): init_state() render_sidebar() - - show_editor = st.session_state.get("show_Editor", False) - show_chat = st.session_state.get("show_Chat", False) - - if show_editor: + + if st.session_state.get("radio_interface_options") == "Code Editor": render_editor() - if show_chat: + elif st.session_state.get("radio_interface_options") == "Chat with AI Assistant": render_chat() + + #show_editor = st.session_state.get("show_Editor", False) + #show_chat = st.session_state.get("show_Chat", False) + # + #if show_editor: + # render_editor() + #if show_chat: + # render_chat() + if __name__ == "__main__": main() diff --git a/frontend/sidebar.py b/frontend/sidebar.py index b5482e9..73003ae 100644 --- a/frontend/sidebar.py +++ b/frontend/sidebar.py @@ -67,8 +67,19 @@ def render_filetree_arborist(tree): def render_sidebar(): st.sidebar.title("Navigation") - file_explorer_section = st.sidebar.container() navigation_section = st.sidebar.container() + file_explorer_section = st.sidebar.container() + + with navigation_section: + st.subheader("Options") + #st.checkbox("Code Editor", key="show_Editor") + #st.checkbox("Chat with AI Assistant", key="show_Chat") + st.radio( + "Action", + ["Code Editor", "Chat with AI Assistant"], + key=f"radio_interface_options") + + st.markdown("---") with file_explorer_section: st.subheader("File Explorer") @@ -162,13 +173,6 @@ def render_sidebar(): st.success(f"{action} created!") st.rerun() - st.sidebar.markdown("---") - - with navigation_section: - st.sidebar.subheader("Options") - st.sidebar.checkbox("Code Editor", key="show_Editor") - st.sidebar.checkbox("Chat with AI Assistant", key="show_Chat") - return if __name__ == "__main__": -- 2.30.2 From 3aa4c6749b47245d86fd57b4aa0e94d508f82806 Mon Sep 17 00:00:00 2001 From: Irina Rueegg Date: Thu, 9 Apr 2026 17:24:29 +0200 Subject: [PATCH 2/3] Chat as first choice --- frontend/app.py | 9 --------- frontend/sidebar.py | 4 +--- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/frontend/app.py b/frontend/app.py index ead9ab9..181aa32 100644 --- a/frontend/app.py +++ b/frontend/app.py @@ -29,14 +29,5 @@ def main(): elif st.session_state.get("radio_interface_options") == "Chat with AI Assistant": render_chat() - - #show_editor = st.session_state.get("show_Editor", False) - #show_chat = st.session_state.get("show_Chat", False) - # - #if show_editor: - # render_editor() - #if show_chat: - # render_chat() - if __name__ == "__main__": main() diff --git a/frontend/sidebar.py b/frontend/sidebar.py index 73003ae..65cc6a1 100644 --- a/frontend/sidebar.py +++ b/frontend/sidebar.py @@ -72,11 +72,9 @@ def render_sidebar(): with navigation_section: st.subheader("Options") - #st.checkbox("Code Editor", key="show_Editor") - #st.checkbox("Chat with AI Assistant", key="show_Chat") st.radio( "Action", - ["Code Editor", "Chat with AI Assistant"], + ["Chat with AI Assistant", "Code Editor"], key=f"radio_interface_options") st.markdown("---") -- 2.30.2 From 7769a0e1851fcfee0e7f39c45ce3285a66c8098d Mon Sep 17 00:00:00 2001 From: Irina Rueegg Date: Thu, 9 Apr 2026 18:19:04 +0200 Subject: [PATCH 3/3] rename&delet --- backend/managers/file_manager.py | 4 ++-- frontend/editor.py | 18 ++++++++++++------ frontend/sidebar.py | 3 +-- frontend/state.py | 3 +++ 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/backend/managers/file_manager.py b/backend/managers/file_manager.py index a25e8d8..5e23e4c 100644 --- a/backend/managers/file_manager.py +++ b/backend/managers/file_manager.py @@ -119,7 +119,7 @@ class FileManager: if not Path(new_name).suffix == file_type: new_name = Path(new_name).with_suffix(file_type) # Ensure the file extension remains the same - old_file_path = (self.base_path / Path(old_relative_path)).resolve() + old_file_path = (Path(old_relative_path)).resolve() new_file_path = old_file_path.parent / new_name if not str(old_file_path).startswith(str(self.base_path.resolve())) or not str(new_file_path).startswith(str(self.base_path.resolve())): @@ -134,7 +134,7 @@ class FileManager: return False def delete_file(self, relative_path): - file_path = (self.base_path / relative_path).resolve() + file_path = (relative_path).resolve() if not str(file_path).startswith(str(self.base_path.resolve())): st.error(f"Access denied: {relative_path}") diff --git a/frontend/editor.py b/frontend/editor.py index f959a04..42a3b39 100644 --- a/frontend/editor.py +++ b/frontend/editor.py @@ -50,12 +50,16 @@ def render_editor(): active_index = st.session_state.open_files.index(st.session_state.active_file) except (ValueError, KeyError): active_index = 0 + + st.session_state.active_tab = active_index tab_names = [Path(f).name for f in st.session_state.open_files] tabs = st.tabs(tab_names) for idx, file_path in enumerate(st.session_state.open_files): with tabs[idx]: + if idx == st.session_state.active_tab: + st.session_state.active_file = file_path if file_path not in st.session_state.files_content: st.session_state.files_content[file_path] = fm.read_file(Path(file_path)) @@ -69,11 +73,6 @@ def render_editor(): key=f"code_editor_{file_path}", auto_update=True, height=400, - # tab_size=4, - # font_size=14, - # show_gutter=True, - # show_print_margin=False, - # wrap=True ) if code != st.session_state.files_content[file_path]: @@ -98,8 +97,8 @@ def render_editor(): if st.session_state.open_files else None ) - st.rerun() # Refresh the page to update the UI + with cols[2]: if st.button("Rename File", key=f"rename_{file_path}"): new_name = st.text_input("New File Name", key=f"new_name_{file_path}") @@ -118,6 +117,13 @@ def render_editor(): try: fm.delete_file(file_path) st.success(f"File '{Path(file_path).name}' deleted successfully!") + st.session_state.open_files.remove(file_path) + del st.session_state.files_content[file_path] + st.session_state.active_file = ( + st.session_state.open_files[0] + if st.session_state.open_files + else None + ) st.rerun() except Exception as e: st.error(f"Error deleting file: {e}") diff --git a/frontend/sidebar.py b/frontend/sidebar.py index 65cc6a1..bc71125 100644 --- a/frontend/sidebar.py +++ b/frontend/sidebar.py @@ -71,9 +71,8 @@ def render_sidebar(): file_explorer_section = st.sidebar.container() with navigation_section: - st.subheader("Options") st.radio( - "Action", + "Options", ["Chat with AI Assistant", "Code Editor"], key=f"radio_interface_options") diff --git a/frontend/state.py b/frontend/state.py index a45c7fa..eb41a4c 100644 --- a/frontend/state.py +++ b/frontend/state.py @@ -22,6 +22,9 @@ def init_state(): if "active_file" not in st.session_state: 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 -- 2.30.2