File size: 1,453 Bytes
5249394
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import os
import streamlit as st

from utils.utils import load_css




class NavigationPanel:
    """Renders the sidebar file navigation."""
    
    def __init__(self, files):
        self.files = files
    
    def render(self):
        load_css("./ui/styles.css")
        with st.sidebar:
            st.title("Code Analyis")

            selected = st.selectbox(
                "Select File",
                self.files,
                format_func=os.path.basename
            )

        return selected


class CodePreview:
    """Displays file contents with syntax highlighting."""
    
    def __init__(self, file_path, language):
        load_css("./ui/styles.css")
        self.file_path = file_path
        self.language = language.lower()
    
    def render(self):
        st.header("Code Preview")
        try:
            with open(self.file_path, 'r') as f:
                st.code(f.read(), language=self.language)
        except FileNotFoundError:
            st.error("File not found")


class ResultsDisplay:
    """Presents analysis results in expandable sections."""
    
    def __init__(self, results):
        load_css("./ui/styles.css")
        self.results = results
    
    def render(self):
        st.header("Analysis")
        for agent, findings in self.results.items():
            with st.expander(f"{agent}", expanded=False):
                st.write(findings)