Answer principles round 1: 0 🔴, 3 🟡 (0 misread); state listed's lock, let each module drop its own ended files, test run_loop's listing end to end

This commit is contained in:
2026-10-29 20:33:52 +01:00
parent 9f71b9aa91
commit 326866e85b
9 changed files with 79 additions and 33 deletions
+2 -1
View File
@@ -40,12 +40,12 @@ import typing
from loop_inbox.inbox import Answering, answering_lines, BACKSPACE, ENTER, ESCAPE, fitted, Listing, listing_lines, Open, pressed, Quit, Screen, Send
from loop_claude.waiting import Ask, ask_file, Asking, claim_talk, ClaudeEnded, drop_ended, MAKE_WAY_SECONDS, read_ask, send, Typed, waiting
from loop_claude.running_loops import drop_ended_loops, running_loops
from loop_claude.effects import Effects, system_effects
from failure import Failure
from loop_claude.hand_over import hand_over
from loop_claude.paths import Paths, paths_from
from loop_claude.session_lock import running
from loop_claude.running_loops import running_loops
USAGE = "usage: loop-inbox"
# Milliseconds between refreshes of the list while no key is pressed.
@@ -78,6 +78,7 @@ def run(window: curses.window, screen_off: typing.Callable[[], typing.ContextMan
screen: Screen = Listing()
while True:
drop_ended(folder)
drop_ended_loops(folder)
screen = entered(screen, refreshed(screen, folder), effects)
draw(window, screen, effects)
try:
+5 -7
View File
@@ -344,16 +344,17 @@ class Waiting(unittest.TestCase):
waiting.drop_ended(folder)
self.assertEqual(asks_and_answers(folder), [])
def test_loop_inbox_removes_a_killed_loops_ask_and_answer_as_it_looks(self):
def test_loop_inbox_removes_a_killed_loops_ask_answer_and_running_file_as_it_looks(self):
with tempfile.TemporaryDirectory() as home:
paths = paths_from(pathlib.Path(home))
ask = asked("s1", "/a")
waiting.publish(paths.waiting, ask)
waiting.send(paths.waiting, ask, Typed("Use A."))
running_loops.running_file(paths.waiting, "s1").write_text(json.dumps({"root": "/a", "items": []}))
main.run(Window("q"), contextlib.nullcontext, paths, system_effects())
self.assertEqual(asks_and_answers(paths.waiting), [])
def test_removes_only_the_asks_answers_and_running_files_whose_loop_has_ended(self):
def test_removes_only_the_asks_answers_and_running_files_whose_loop_has_ended_each_by_its_own_module(self):
with tempfile.TemporaryDirectory() as temp:
folder = pathlib.Path(temp)
loops_hold(self, folder, "s1")
@@ -363,6 +364,8 @@ class Waiting(unittest.TestCase):
for session in ("s1", "s2", "s3"):
running_loops.running_file(folder, session).write_text(json.dumps({"root": "/a", "items": []}))
waiting.drop_ended(folder)
self.assertEqual(asks_and_answers(folder), ["s1.answer", "s1.json", "s1.running", "s2.running", "s3.running"])
running_loops.drop_ended_loops(folder)
self.assertEqual(asks_and_answers(folder), ["s1.answer", "s1.json", "s1.running"])
def test_a_talk_claim_from_pid_0_or_below_is_no_answer_since_it_would_name_a_process_group(self):
@@ -453,11 +456,6 @@ class RunningLoops(unittest.TestCase):
with running_loops.shown_running(self.folder, "s1", "/code/log", dataclasses.replace(self.effects, sleep=lambda seconds: looking.close())):
self.assertEqual(running_loops.running_loops(self.folder), [RunningLoop("s1", "/code/log", ())])
def test_a_chunk_takes_its_routed_item_first_then_those_taken_in_once_each(self):
self.assertEqual(running_loops.taken_items(Failure("no todo.md"), 12, (14, 12, 3)), (Taken(12, ""), Taken(14, ""), Taken(3, "")))
self.assertEqual(running_loops.taken_items(Failure("no todo.md"), 0, (14,)), (Taken(14, ""),))
self.assertEqual(running_loops.taken_items(Failure("no todo.md"), 0, ()), ())
class Shown(unittest.TestCase):
def drawn(self, screen, window):