Skip to content

Commit 8d40b81

Browse files
author
Raffaele Crafa
committed
refactor: solved scroll up issue of app.py
1 parent 12ff213 commit 8d40b81

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

app.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,8 @@ def initialize_financial_advisor(
292292
raise
293293

294294

295-
# AGGIUNTA: nuova funzione per smooth scroll della pagina
295+
# TODO: vedere se eliminare
296+
# Funzione per smooth scroll della pagina
296297
def _scroll_to_bottom():
297298
"""
298299
Force scroll to bottom by targeting the specific Streamlit main container.
@@ -1855,6 +1856,14 @@ def main():
18551856
with st.chat_message(message["role"]):
18561857
st.markdown(message["content"])
18571858

1859+
# --- INPUT SEMPRE PRESENTE ---
1860+
# Manteniamo la chat input renderizzata ma disabilitata se la conversazione è finita.
1861+
# Questo impedisce al browser di perdere il focus e "saltare" in alto.
1862+
prompt = st.chat_input(
1863+
"Assessment completato. Vedi i risultati qui sopra.",
1864+
disabled=st.session_state.conversation_completed,
1865+
)
1866+
18581867
# Show message if conversation is completed
18591868
if st.session_state.conversation_completed:
18601869
if not st.session_state.generated_portfolio:
@@ -1864,8 +1873,8 @@ def main():
18641873
duration="long",
18651874
)
18661875

1867-
# --- Aggiunta: Scrolla giù all'inizio della generazione ---
1868-
_scroll_to_bottom() # <--- Chiama qui per evitare il salto iniziale
1876+
# TODO: vedere se elimanrla
1877+
_scroll_to_bottom()
18691878

18701879
logger.debug("Conversation is completed")
18711880

@@ -1934,6 +1943,7 @@ def main():
19341943
"Your financial profile and PAC metrics have been extracted and analyzed."
19351944
)
19361945

1946+
# TODO: vedere se eliminare
19371947
_scroll_to_bottom()
19381948

19391949
# Financial Profile in an expanded section
@@ -1948,14 +1958,14 @@ def main():
19481958
"- Click 'Clear Conversation' to start a new assessment or 'Change Provider' to start over"
19491959
)
19501960

1951-
# --- Aggiunta: Scrolla giù alla fine per mostrare tutto ---
1952-
_scroll_to_bottom() # <--- Chiama qui per assicurarti di vedere la fine
1961+
# TODO: vedere se eliminare
1962+
_scroll_to_bottom()
19531963

19541964
else:
19551965
logger.debug("No financial profile available to display")
19561966
else:
1957-
# User input - only show if conversation is not completed
1958-
if prompt := st.chat_input("Ask me about your finances..."):
1967+
# Gestiamo l'input dell'utente SOLO se c'è un prompt (quindi non è disabilitato)
1968+
if prompt:
19591969
logger.debug("User input received: %s", prompt[:100])
19601970

19611971
# Display user message

0 commit comments

Comments
 (0)