[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6KGJGVM0TWW632Y6VQQV2WN":3,"skill-same:01M6KGJGVM0TWW632Y6VQQV2WN":62},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":36,"linkOnly":37,"markdownContent":38,"markdownBody":39,"frontMatter":40,"refName":41,"commitSha":42,"skillDirectory":43,"forksCount":44,"repositoryHtmlUrl":45,"repositoryHomepageUrl":6,"ownerHtmlUrl":46,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":47,"install":48,"resources":61},"01M6KGJGVM0TWW632Y6VQQV2WN","using-streamlit-session-state",null,"Using st.session_state to manage state across Streamlit reruns. Use when persisting data, handling widget state, implementing callbacks, or debugging state issues. Covers initialization patterns, widget-state association, and common gotchas.","legout\u002Fpi-config","legout","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F1469563?v=4","01M6KGERP7E8TF4XARRKPFJ6HQ","Volker L.","01M6KGERT1FYD049PP1WW923TZ",3,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Flegout\u002Fpi-config\u002Fblob\u002Fmain\u002Finstalled-skills\u002Fdeveloping-with-streamlit\u002Fskills\u002Fusing-streamlit-session-state\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35],"state","using streamlit session state","session state","streamlit","session","common","use","manage","patterns","across","widget","data","Callbacks","issues","implementing","initialization","debugging","2026-11-10 10:12:30",false,"---\nname: using-streamlit-session-state\ndescription: Using st.session_state to manage state across Streamlit reruns. Use when persisting data, handling widget state, implementing callbacks, or debugging state issues. Covers initialization patterns, widget-state association, and common gotchas.\nlicense: Apache-2.0\n---\n\n# Using Streamlit session state\n\nStreamlit reruns scripts top-to-bottom on every interaction. Without session state, variables reset each time. Use `st.session_state` to persist values across reruns.\n\n## Basic usage\n\nSession state is a dictionary-like object supporting attribute and bracket notation:\n\n```python\n# Initialize with setdefault (preferred)\nst.session_state.setdefault(\"count\", 0)\n\n# Alternative: check before setting\nif \"count\" not in st.session_state:\n    st.session_state.count = 0\n\n# Read\ncurrent = st.session_state.count\n\n# Update\nst.session_state.count += 1\nst.session_state[\"count\"] = 5  # Bracket notation also works\n\n# Delete\ndel st.session_state.count\n```\n\n**Accessing uninitialized keys raises `KeyError`.** Use `st.session_state.get(\"key\", default)` for safe access.\n\n## Widget-state association\n\nEvery widget with a `key` parameter automatically syncs to session state:\n\n```python\nname = st.text_input(\"Name\", key=\"user_name\")\n# st.session_state.user_name contains the same value as `name`\n```\n\n## Callbacks\n\nCallbacks execute **before** the script reruns, allowing immediate state changes. Use `on_change` or `on_click` with optional `args` and `kwargs`:\n\n```python\ndef increment(amount):\n    st.session_state.count += amount\n\nst.button(\"Add 5\", on_click=increment, args=(5,))\n```\n\nAccess a widget's value in its own callback via `st.session_state.key`, not the return variable.\n\n## Initialization patterns\n\nInitialize all state at the top of your app for clarity:\n\n```python\nst.session_state.setdefault(\"user\", None)\nst.session_state.setdefault(\"page\", \"home\")\nst.session_state.setdefault(\"filters\", {})\n```\n\n## Multipage state\n\nWidgets are NOT stateful across pages. Their values reset when navigating between pages.\n\n### Sharing state\n\nUse session state variables (not widget keys) to share data:\n\n```python\n# Page 1: Store value\nst.session_state.selected_user = st.selectbox(\"User\", users)\n\n# Page 2: Read stored value\nif \"selected_user\" in st.session_state:\n    st.write(f\"Selected: {st.session_state.selected_user}\")\n```\n\n### Shared widgets pattern\n\nPut common widgets in the entrypoint file (before `nav.run()`):\n\n```python\n# app.py (entrypoint)\nwith st.sidebar:\n    st.session_state.theme = st.selectbox(\"Theme\", [\"Light\", \"Dark\"])\n\nnav = st.navigation(pages)\nnav.run()\n```\n\n## Common mistakes\n\n### Module-level mutable state\n\n```python\n# BAD: In imported modules, this is shared across ALL users\n# utils.py\ncache = {}  # Persists across reruns AND users!\n\n# GOOD: Use session state for per-user data\nst.session_state.setdefault(\"cache\", {})\n```\n\n### Modifying state after widget creation\n\nCannot assign to a widget's state after the widget has rendered:\n\n```python\nst.slider(\"Value\", key=\"my_slider\")\nst.session_state.my_slider = 50  # Raises StreamlitAPIException!\n```\n\n### Mixing `value` parameter and session state\n\nDon't set both—it causes warnings:\n\n```python\n# BAD: Conflicting sources\nst.session_state.setdefault(\"name\", \"Alice\")\nst.text_input(\"Name\", value=\"Bob\", key=\"name\")  # Warning!\n\n# GOOD: Use one or the other\nst.session_state.setdefault(\"name\", \"Alice\")\nst.text_input(\"Name\", key=\"name\")\n```\n\n## Session characteristics\n\n- **Per-user, per-tab**: Each browser tab has its own session\n- **Temporary**: Lost when tab closes or server restarts\n- **Not suitable for persistence**: Use databases for permanent storage\n\n## References\n\n- [st.session_state API](https:\u002F\u002Fdocs.streamlit.io\u002Fdevelop\u002Fapi-reference\u002Fcaching-and-state\u002Fst.session_state)\n- [Session State concepts](https:\u002F\u002Fdocs.streamlit.io\u002Fdevelop\u002Fconcepts\u002Farchitecture\u002Fsession-state)\n- [Widget behavior](https:\u002F\u002Fdocs.streamlit.io\u002Fdevelop\u002Fconcepts\u002Farchitecture\u002Fwidget-behavior)\n","# Using Streamlit session state\n\nStreamlit reruns scripts top-to-bottom on every interaction. Without session state, variables reset each time. Use `st.session_state` to persist values across reruns.\n\n## Basic usage\n\nSession state is a dictionary-like object supporting attribute and bracket notation:\n\n```python\n# Initialize with setdefault (preferred)\nst.session_state.setdefault(\"count\", 0)\n\n# Alternative: check before setting\nif \"count\" not in st.session_state:\n    st.session_state.count = 0\n\n# Read\ncurrent = st.session_state.count\n\n# Update\nst.session_state.count += 1\nst.session_state[\"count\"] = 5  # Bracket notation also works\n\n# Delete\ndel st.session_state.count\n```\n\n**Accessing uninitialized keys raises `KeyError`.** Use `st.session_state.get(\"key\", default)` for safe access.\n\n## Widget-state association\n\nEvery widget with a `key` parameter automatically syncs to session state:\n\n```python\nname = st.text_input(\"Name\", key=\"user_name\")\n# st.session_state.user_name contains the same value as `name`\n```\n\n## Callbacks\n\nCallbacks execute **before** the script reruns, allowing immediate state changes. Use `on_change` or `on_click` with optional `args` and `kwargs`:\n\n```python\ndef increment(amount):\n    st.session_state.count += amount\n\nst.button(\"Add 5\", on_click=increment, args=(5,))\n```\n\nAccess a widget's value in its own callback via `st.session_state.key`, not the return variable.\n\n## Initialization patterns\n\nInitialize all state at the top of your app for clarity:\n\n```python\nst.session_state.setdefault(\"user\", None)\nst.session_state.setdefault(\"page\", \"home\")\nst.session_state.setdefault(\"filters\", {})\n```\n\n## Multipage state\n\nWidgets are NOT stateful across pages. Their values reset when navigating between pages.\n\n### Sharing state\n\nUse session state variables (not widget keys) to share data:\n\n```python\n# Page 1: Store value\nst.session_state.selected_user = st.selectbox(\"User\", users)\n\n# Page 2: Read stored value\nif \"selected_user\" in st.session_state:\n    st.write(f\"Selected: {st.session_state.selected_user}\")\n```\n\n### Shared widgets pattern\n\nPut common widgets in the entrypoint file (before `nav.run()`):\n\n```python\n# app.py (entrypoint)\nwith st.sidebar:\n    st.session_state.theme = st.selectbox(\"Theme\", [\"Light\", \"Dark\"])\n\nnav = st.navigation(pages)\nnav.run()\n```\n\n## Common mistakes\n\n### Module-level mutable state\n\n```python\n# BAD: In imported modules, this is shared across ALL users\n# utils.py\ncache = {}  # Persists across reruns AND users!\n\n# GOOD: Use session state for per-user data\nst.session_state.setdefault(\"cache\", {})\n```\n\n### Modifying state after widget creation\n\nCannot assign to a widget's state after the widget has rendered:\n\n```python\nst.slider(\"Value\", key=\"my_slider\")\nst.session_state.my_slider = 50  # Raises StreamlitAPIException!\n```\n\n### Mixing `value` parameter and session state\n\nDon't set both—it causes warnings:\n\n```python\n# BAD: Conflicting sources\nst.session_state.setdefault(\"name\", \"Alice\")\nst.text_input(\"Name\", value=\"Bob\", key=\"name\")  # Warning!\n\n# GOOD: Use one or the other\nst.session_state.setdefault(\"name\", \"Alice\")\nst.text_input(\"Name\", key=\"name\")\n```\n\n## Session characteristics\n\n- **Per-user, per-tab**: Each browser tab has its own session\n- **Temporary**: Lost when tab closes or server restarts\n- **Not suitable for persistence**: Use databases for permanent storage\n\n## References\n\n- [st.session_state API](https:\u002F\u002Fdocs.streamlit.io\u002Fdevelop\u002Fapi-reference\u002Fcaching-and-state\u002Fst.session_state)\n- [Session State concepts](https:\u002F\u002Fdocs.streamlit.io\u002Fdevelop\u002Fconcepts\u002Farchitecture\u002Fsession-state)\n- [Widget behavior](https:\u002F\u002Fdocs.streamlit.io\u002Fdevelop\u002Fconcepts\u002Farchitecture\u002Fwidget-behavior)\n",{"name":5,"license":15,"description":7},"main","3efae68c898153694a2f4aad309c7ff9847b5602","installed-skills\u002Fdeveloping-with-streamlit\u002Fskills\u002Fusing-streamlit-session-state",0,"https:\u002F\u002Fgithub.com\u002Flegout\u002Fpi-config","https:\u002F\u002Fgithub.com\u002Flegout","2026-04-28 16:32:33",{"source":8,"skillName":5,"commands":49,"prompt":59,"zipAvailable":60},[50,53,56],{"tool":51,"command":52},"npx","npx skills add legout\u002Fpi-config --skill using-streamlit-session-state",{"tool":54,"command":55},"bunx","bunx skills add legout\u002Fpi-config --skill using-streamlit-session-state",{"tool":57,"command":58},"pnpm","pnpm dlx skills add legout\u002Fpi-config --skill using-streamlit-session-state","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Flegout\u002Fpi-config\u002Fblob\u002Fmain\u002Finstalled-skills\u002Fdeveloping-with-streamlit\u002Fskills\u002Fusing-streamlit-session-state\u002FSKILL.md",true,[],[63,100,127,142,160,181],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":67,"licenseFileUrl":6,"sourceHtmlUrl":68,"categories":69,"keywords":80,"publishedAt":36},"01M6KGW7MYKZ8MWFKN1V8ZJ2EG","visual-explainer","Generate beautiful, self-contained HTML pages that visually explain systems, code changes, plans, and data. Use when the user asks for a diagram, architecture overview, diff review, plan review, project recap, comparison table, or any visual explanation of technical concepts. Also use proactively when you are about to render a complex ASCII table (4+ rows or 3+ columns) — present it as a styled HTML page instead.","MIT","https:\u002F\u002Fgithub.com\u002Flegout\u002Fpi-config\u002Fblob\u002Fmain\u002Fskills\u002Fvisual-explainer\u002FSKILL.md",[70,75],{"categoryNo":71,"categoryName":72,"taxonomyType":73,"taxonomyTypeDesc":74},"01JBSEEDCAT000000000000009","前端开发","SCENARIO","使用场景",{"categoryNo":76,"categoryName":77,"taxonomyType":78,"taxonomyTypeDesc":79},"01JBSEEDCAT000000000000033","数据分析师","PROFESSION","适用职业",[81,82,83,84,85,86,87,88,89,90,91,92,93,94,25,95,96,97,98,99],"explainer","visual explainer","visual","image","files","for","surf","concepts","you","ascii","ascii table","as","present","project","view","table","plan","generate","architecture",{"skillNo":101,"name":102,"nameZh":6,"description":103,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":67,"licenseFileUrl":6,"sourceHtmlUrl":104,"categories":105,"keywords":112,"publishedAt":36},"01M6KGTMTJR6RXXC8AF29MQQW5","table-extractor",">","https:\u002F\u002Fgithub.com\u002Flegout\u002Fpi-config\u002Fblob\u002Fmain\u002Finstalled-skills\u002Ftable-extractor\u002FSKILL.md",[106,109],{"categoryNo":107,"categoryName":108,"taxonomyType":73,"taxonomyTypeDesc":74},"01JBSEEDCAT000000000000002","文档处理",{"categoryNo":110,"categoryName":111,"taxonomyType":73,"taxonomyTypeDesc":74},"01JBSEEDCAT000000000000023","Skill与智能体开发",[96,113,114,115,116,117,118,119,30,120,121,122,123,124,125,126],"table extractor","zh","en","extract","camelot","office","parsing","extraction","gpt","MCP","PDF","sonnet","tables","opus",{"skillNo":128,"name":129,"nameZh":6,"description":103,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":67,"licenseFileUrl":6,"sourceHtmlUrl":130,"categories":131,"keywords":134,"publishedAt":36},"01M6KGSWF2R22Z63PAY5NT6GRY","smart-ocr","https:\u002F\u002Fgithub.com\u002Flegout\u002Fpi-config\u002Fblob\u002Fmain\u002Finstalled-skills\u002Fsmart-ocr\u002FSKILL.md",[132,133],{"categoryNo":107,"categoryName":108,"taxonomyType":73,"taxonomyTypeDesc":74},{"categoryNo":110,"categoryName":111,"taxonomyType":73,"taxonomyTypeDesc":74},[135,136,137,126,124,138,119,123,114,115,116,139,118,120,121,140,122,141],"ocr","smart ocr","paddleocr","processing","text","support","multilingual",{"skillNo":143,"name":144,"nameZh":6,"description":103,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":67,"licenseFileUrl":6,"sourceHtmlUrl":145,"categories":146,"keywords":152,"publishedAt":36},"01M6KGMKKFNC1PRNX2W3E243DR","html-slides","https:\u002F\u002Fgithub.com\u002Flegout\u002Fpi-config\u002Fblob\u002Fmain\u002Finstalled-skills\u002Fhtml-slides\u002FSKILL.md",[147,150,151],{"categoryNo":148,"categoryName":149,"taxonomyType":73,"taxonomyTypeDesc":74},"01JBSEEDCAT000000000000003","演示文稿",{"categoryNo":71,"categoryName":72,"taxonomyType":73,"taxonomyTypeDesc":74},{"categoryNo":110,"categoryName":111,"taxonomyType":73,"taxonomyTypeDesc":74},[153,154,155,156,122,126,124,157,158,114,115,118,121,159],"slides","html slides","html","pptx","presentation","revealjs","web",{"skillNo":161,"name":162,"nameZh":6,"description":163,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":164,"categories":165,"keywords":167,"publishedAt":36},"01M6KGJD12GJB7W0ZG66JK00F6","using-streamlit-markdown","Covers all Markdown features in Streamlit including GitHub-flavored syntax plus Streamlit extensions like colored text, badges, Material icons, and LaTeX. Use when formatting text, labels, tooltips, or any text-rendering element.","https:\u002F\u002Fgithub.com\u002Flegout\u002Fpi-config\u002Fblob\u002Fmain\u002Finstalled-skills\u002Fdeveloping-with-streamlit\u002Fskills\u002Fusing-streamlit-markdown\u002FSKILL.md",[166],{"categoryNo":107,"categoryName":108,"taxonomyType":73,"taxonomyTypeDesc":74},[22,168,169,139,170,171,172,173,174,175,176,25,177,178,179,180],"markdown","using streamlit markdown","labels","features","extensions","rendering","material","element","formatting","syntax","LaTeX","icons","github",{"skillNo":182,"name":183,"nameZh":6,"description":184,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":185,"categories":186,"keywords":187,"publishedAt":36},"01M6KGJ7M5Q1RHBZ72MCWTM9GQ","using-streamlit-layouts","Structuring Streamlit app layouts. Use when placing content in sidebars, columns, containers, or dialogs. Covers sidebar usage, column limits, horizontal containers, dialogs, and bordered cards.","https:\u002F\u002Fgithub.com\u002Flegout\u002Fpi-config\u002Fblob\u002Fmain\u002Finstalled-skills\u002Fdeveloping-with-streamlit\u002Fskills\u002Fusing-streamlit-layouts\u002FSKILL.md",[],[188,22,189,190,191,192,25,193,194],"using streamlit layouts","usage","columns","column","app","content","containers"]