Behavior
_ensure_session_state calls fetch_quota_info(SERPAPI_KEY) exactly once when the Streamlit session initializes. Every Submit that burns SerpAPI credits drops the real remaining count on SerpAPI's side, but the progress bar + caption stay frozen until the user restarts Streamlit.
Why this is the current shape
The account endpoint is not free (it's fast but still a network call); hitting it on every rerun would noisily ping SerpAPI. And for a self-use tool, "roughly correct at session start" is usually enough.
Proposed fix
- Add a small refresh button next to the quota caption (🔄 refresh quota). Click re-fetches
fetch_quota_info and updates session state.
- Optionally, auto-refresh after every Submit (add 1 network call per analysis; acceptable since each Submit already does at least one SerpAPI call).
References
app.py:_ensure_session_state, app.py:_render_mode_notice
seoserper/serpapi_account.py
Behavior
_ensure_session_statecallsfetch_quota_info(SERPAPI_KEY)exactly once when the Streamlit session initializes. Every Submit that burns SerpAPI credits drops the real remaining count on SerpAPI's side, but the progress bar + caption stay frozen until the user restarts Streamlit.Why this is the current shape
The account endpoint is not free (it's fast but still a network call); hitting it on every rerun would noisily ping SerpAPI. And for a self-use tool, "roughly correct at session start" is usually enough.
Proposed fix
fetch_quota_infoand updates session state.References
app.py:_ensure_session_state,app.py:_render_mode_noticeseoserper/serpapi_account.py