Action rejection capability

This commit is contained in:
Dejvino 2026-06-30 22:27:13 +02:00
parent 6b277d725d
commit e97db7f5b7
2 changed files with 17 additions and 7 deletions

View File

@ -57,9 +57,9 @@ class GameEngine:
else:
state.append_llm_log(f"\n[VALIDATION REJECTED] {reason}")
return TurnResult(
book_log=f"",
book_log="",
log_entry=f"You can't do that — {reason}.",
user_prompt=auto_prompt(""),
user_prompt=f"*Your action \"{player_action}\" was rejected: {reason}*",
)
system = build_system_prompt()

View File

@ -204,6 +204,7 @@ class ChaosTUI(App):
self._settings_loaded = True
def _begin_game(self):
self._last_narrative: str = ""
if LAST_PROMPT_PATH.exists():
saved = LAST_PROMPT_PATH.read_text().strip()
if saved:
@ -446,11 +447,19 @@ class ChaosTUI(App):
if result.book_log:
state.archive_turn(result.book_log)
state.apply_state(result)
if result.book_log or not result.user_prompt:
self._display_scene(result)
else:
if self._last_narrative:
self._set_narrative(f"{self._last_narrative}\n\n---\n\n{result.user_prompt}")
self._enable_input()
else:
self._display_scene(result)
if result.book_log:
self._last_result = result
if result.user_prompt:
LAST_PROMPT_PATH.write_text(result.user_prompt.strip())
self._last_prompt = result.user_prompt
self._last_result = result
self._append_debug("✔ turn complete")
def _on_generation_error(self, error: Exception, traceback_str: str) -> None:
@ -481,6 +490,7 @@ class ChaosTUI(App):
inp.focus()
def _set_narrative(self, text: str) -> None:
self._last_narrative = text
self.query_one("#play-narrative", Static).update(RichMarkdown(text))
self.query_one("#play-scroll", VerticalScroll).scroll_home(animate=False)