Asish Karthikeya Gogineni commited on
Commit
c00752d
Β·
1 Parent(s): 079d436

Refactor: Switch to horizontal tabs in Code Studio

Browse files
Files changed (1) hide show
  1. pages/1_⚑_Code_Studio.py +21 -53
pages/1_⚑_Code_Studio.py CHANGED
@@ -29,76 +29,44 @@ if "processed_files" not in st.session_state or not st.session_state.processed_f
29
  st.stop()
30
 
31
  # --- Layout ---
32
- # We use a custom 3-column layout to mimic IDE
33
- # Col 1: Activity Bar (Narrow, just icons)
34
- # Col 2: Side Panel (Resizable-ish via column ratio, contains the active tool)
35
- # Col 3: Main Editor (Wide, contains code)
36
 
37
- # Define column ratios
38
- # Activity bar needs to be very narrow. Streamlit cols are proportional.
39
- # Ratio: 0.5 : 3 : 7
40
- col_activity, col_panel, col_editor = st.columns([0.5, 3, 7])
41
-
42
- # --- 1. Activity Bar ---
43
- with col_activity:
44
- # We use a vertical layout of buttons.
45
- # To make them look like tabs, we can use a custom component or just buttons that update state.
46
- # Current limitation: Buttons rerun app. That's fine for Streamlit.
47
-
48
- st.markdown("<div style='margin-top: 10px;'></div>", unsafe_allow_html=True)
49
-
50
- # Explorer Tab
51
- if st.button("πŸ“", key="tab_explorer", help="Explorer", use_container_width=True):
52
- st.session_state.active_tab = "explorer"
53
-
54
- # Search Tab
55
- if st.button("πŸ”", key="tab_search", help="Search", use_container_width=True):
56
- st.session_state.active_tab = "search"
57
-
58
- # Chat Tab
59
- if st.button("πŸ’¬", key="tab_chat", help="Chat", use_container_width=True):
60
- st.session_state.active_tab = "chat"
61
-
62
- # Generate Tab
63
- if st.button("✨", key="tab_generate", help="Generate", use_container_width=True):
64
- st.session_state.active_tab = "generate"
65
-
66
- # Settings / Home (Exit)
67
- st.markdown("<div style='margin-top: 50vh;'></div>", unsafe_allow_html=True)
68
- if st.button("🏠", key="tab_home", help="Back to Home", use_container_width=True):
69
- st.switch_page("app.py")
70
-
71
-
72
- # --- 2. Side Panel ---
73
  with col_panel:
74
- active_tab = st.session_state.active_tab
 
75
 
76
- if active_tab == "explorer":
77
- st.markdown("### πŸ“ Explorer")
78
  render_file_tree(
79
  st.session_state.get("indexed_files", []),
80
  st.session_state.get("workspace_root", "")
81
  )
82
 
83
- elif active_tab == "search":
 
 
 
 
84
  render_search_panel(st.session_state.get("indexed_files", []))
85
-
86
- elif active_tab == "chat":
87
  chat_engine = st.session_state.get("chat_engine")
88
  if chat_engine:
89
  render_chat_panel(chat_engine)
90
  else:
91
- st.error("Chat engine unavailable.")
92
-
93
- elif active_tab == "generate":
94
  chat_engine = st.session_state.get("chat_engine")
95
  if chat_engine:
96
  render_generate_panel(chat_engine, st.session_state.get("indexed_files", []))
97
  else:
98
  st.error("Chat engine unavailable.")
99
 
100
-
101
- # --- 3. Main Editor ---
102
  with col_editor:
103
  # If a file is selected, show it. Otherwise show welcome/empty state.
104
  selected_file = st.session_state.get("selected_file")
@@ -108,7 +76,7 @@ with col_editor:
108
  with st.container():
109
  # Breadcrumbs / File Header
110
  filename = os.path.basename(selected_file)
111
- st.markdown(f"**{filename}**")
112
 
113
  # Code Viewer
114
  render_code_viewer_simple(selected_file)
@@ -120,7 +88,7 @@ with col_editor:
120
  <div style="display: flex; flex-direction: column; align-items: center; justify-content: center; height: 60vh; opacity: 0.5;">
121
  <h1>⚑ Code Studio</h1>
122
  <p>Select a file from the explorer to view context.</p>
123
- <p>Use the activity bar on the left to toggle tools.</p>
124
  </div>
125
  """,
126
  unsafe_allow_html=True
 
29
  st.stop()
30
 
31
  # --- Layout ---
32
+ # We use a 2-column layout: Side Panel (with Tabs) | Main Editor
33
+ # Ratio: 3.5 : 6.5
34
+ col_panel, col_editor = st.columns([3.5, 6.5])
 
35
 
36
+ # --- Side Panel (Tabs) ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  with col_panel:
38
+ # Use native Streamlit tabs for horizontal navigation
39
+ tab_explorer, tab_search, tab_chat, tab_generate = st.tabs(["πŸ“ Explorer", "πŸ” Search", "πŸ’¬ Chat", "✨ Generate"])
40
 
41
+ with tab_explorer:
42
+ st.markdown("### πŸ“ Project Files")
43
  render_file_tree(
44
  st.session_state.get("indexed_files", []),
45
  st.session_state.get("workspace_root", "")
46
  )
47
 
48
+ st.divider()
49
+ if st.button("🏠 Home", use_container_width=True):
50
+ st.switch_page("app.py")
51
+
52
+ with tab_search:
53
  render_search_panel(st.session_state.get("indexed_files", []))
54
+
55
+ with tab_chat:
56
  chat_engine = st.session_state.get("chat_engine")
57
  if chat_engine:
58
  render_chat_panel(chat_engine)
59
  else:
60
+ st.error("Chat engine unavailable. Please index a codebase first.")
61
+
62
+ with tab_generate:
63
  chat_engine = st.session_state.get("chat_engine")
64
  if chat_engine:
65
  render_generate_panel(chat_engine, st.session_state.get("indexed_files", []))
66
  else:
67
  st.error("Chat engine unavailable.")
68
 
69
+ # --- Main Editor ---
 
70
  with col_editor:
71
  # If a file is selected, show it. Otherwise show welcome/empty state.
72
  selected_file = st.session_state.get("selected_file")
 
76
  with st.container():
77
  # Breadcrumbs / File Header
78
  filename = os.path.basename(selected_file)
79
+ st.caption(f"Editing: {filename}")
80
 
81
  # Code Viewer
82
  render_code_viewer_simple(selected_file)
 
88
  <div style="display: flex; flex-direction: column; align-items: center; justify-content: center; height: 60vh; opacity: 0.5;">
89
  <h1>⚑ Code Studio</h1>
90
  <p>Select a file from the explorer to view context.</p>
91
+ <p>Use the tabs on the left to switch between tools.</p>
92
  </div>
93
  """,
94
  unsafe_allow_html=True