Spaces:
Sleeping

byte-vortex commited on
Commit
f3d4702
·
verified ·
1 Parent(s): 6a0826f

Deploy Myco from CI

Browse files
Files changed (1) hide show
  1. ui/interface.py +23 -5
ui/interface.py CHANGED
@@ -190,15 +190,35 @@ def cute_mushroom_garden_html() -> str:
190
  </div>
191
  '''
192
 
193
-
194
  def render_shroom_tab():
195
- # Build the tab UI for Myco
 
 
 
196
  scene_html = gr.HTML()
197
  thought_html = gr.HTML() # use HTML so markup is not escaped
198
  dex_md = gr.Markdown()
199
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
200
  # Bind polling: update scene and thought periodically (inline lambdas avoid NameError)
201
- # These lambdas call helpers that should be defined/imported earlier in the module.
202
  gr.load(fn=lambda: _get_scene_html(), outputs=scene_html, every=1.5)
203
  gr.load(fn=lambda: myco_talking_markdown(STATE.get("thought", "")), outputs=thought_html, every=1.5)
204
 
@@ -211,8 +231,6 @@ def render_shroom_tab():
211
  show_dex_btn = gr.Button("Show MycoDex")
212
  show_dex_btn.click(fn=show_dex, inputs=None, outputs=dex_md)
213
 
214
- # Return components if needed
215
  return scene_html, thought_html, dex_md
216
 
217
-
218
 
 
190
  </div>
191
  '''
192
 
 
193
  def render_shroom_tab():
194
+ """
195
+ Build the Myco tab UI. This version is self-contained and uses inline lambdas
196
+ for gr.load so it won't require external poll_scene/poll_myco_bubble_html names.
197
+ """
198
  scene_html = gr.HTML()
199
  thought_html = gr.HTML() # use HTML so markup is not escaped
200
  dex_md = gr.Markdown()
201
 
202
+ # Local helper to build the scene HTML from STATE safely
203
+ def _get_scene_html():
204
+ try:
205
+ with _STATE_LOCK:
206
+ state_copy = copy.deepcopy(STATE)
207
+ except Exception:
208
+ state_copy = {}
209
+ state_for_renderer = {
210
+ "active_mushrooms": state_copy.get("active_mushrooms", []),
211
+ "score_total": state_copy.get("score_total", 0),
212
+ "health": state_copy.get("health", 3),
213
+ "event_emoji": "✨",
214
+ "event_title": state_copy.get("thought", ""),
215
+ "mystery_title": "The Wrong Memory",
216
+ "picked": "No",
217
+ "game_over": "No",
218
+ }
219
+ return forest_scene(state_for_renderer, state_copy.get("collection", []), state_copy.get("position"))
220
+
221
  # Bind polling: update scene and thought periodically (inline lambdas avoid NameError)
 
222
  gr.load(fn=lambda: _get_scene_html(), outputs=scene_html, every=1.5)
223
  gr.load(fn=lambda: myco_talking_markdown(STATE.get("thought", "")), outputs=thought_html, every=1.5)
224
 
 
231
  show_dex_btn = gr.Button("Show MycoDex")
232
  show_dex_btn.click(fn=show_dex, inputs=None, outputs=dex_md)
233
 
 
234
  return scene_html, thought_html, dex_md
235
 
 
236