Skip to content

Board: moving a session that is not running no longer crashes, and the move shows - #17

Merged
daniel-pittman merged 1 commit into
developfrom
fix/move-session-without-record
Nov 19, 2026
Merged

daniel-pittman merged 1 commit into
developfrom
fix/move-session-without-record

Conversation

@daniel-pittman

@daniel-pittman daniel-pittman commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

What was wrong

  • The crash. Pressing m on a session known only from its status file (not running, so it has no live record; its row is on Needs you) and choosing a group crashed the board with KeyError in action_regroup. The move looked up the session's folder and session id in the live records with a plain index.
  • The move didn't show. Even past the crash, such a session stayed under Other. The board's group map held only sessions with a live row, so the overrides in groups.toml were never consulted for it.

The fix

  • The move: it reads the live record, else the Needs-you row's record, so it rewrites the same pins a live move wrote, by name and by session id. Without either, it pins by name, and the folder gives no group (Other).
  • The grouping: sessions with no live row fall back to the overrides, matched by name and by the row's session id.
  • The session id: the Needs-you row takes it from the status file when the record has none, because a pin written while the session ran is keyed by it. Without this, a later move left that pin behind, and the old group came back when the session ran again.

How it was checked

  • New test: tests/test_gone_rows.py EnterTests.test_m_moves_a_session_that_is_not_running drives the board. It presses m on a not-running session's Needs-you row that carries a pin from when it ran, and checks:
    • no crash;
    • both pins are rewritten;
    • the grouped board shows the session under the chosen group;
    • moving it back to Other removes both pins.
  • The test fails without each part of the fix: reverting the move fix gives KeyError; reverting the grouping fallback leaves it under Other; reverting the status-file id leaves the old id pin.
  • Live board run: the board was driven on a real set of sessions with a scratch config folder. A not-running session moved from Other to Professional and showed there after the refresh, with both pins written. The app stayed up.
  • Suites: tests.test_gone_rows, tests.test_v6 and tests.test_resume pass.
  • Reviews: Codex (GPT-6) and Claude (Opus 5.5) reviewed it. Codex's HIGH (the stale session-id pin) and LOW (the test didn't check the grouped display) are fixed here. Claude found nothing above LOW on the final version.

Not part of this change: p and u on such a row say "no session is highlighted", because parking needs a live record. That gets a follow-up ticket.

Also changes: pressing Enter on such a row to reopen the session now matches its Resume entry by the session id from the status file first, then by name (the cloud review's LOW note). That id is usually the better match; a status file left with an old id could pick an older transcript.

🤖 Generated with Claude Code

…e move shows

Pressing m on a session known only from its status file (not running,
so it has no live record, and its row sits on Needs you) and choosing a
group crashed the app: the move looked up the session's working folder
and session id in the live records with a plain index, which raised
KeyError. The move now reads the live record, else the Needs-you row's
record, so it rewrites the same pins a live move wrote, by name and by
session id. Without either, it pins the session by name and its folder
gives no group (Other).

Such a session also stayed under Other after the move: the board's group
map held only sessions with a live row, so the overrides were never
consulted for it. Sessions with no live row now fall back to the
overrides, matched by name and by the session id the Needs-you row
carries. That row now takes the session id from the status file when
the record has none, since a pin written while the session ran is keyed
by it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Semgrep (OSS): no findings

Clean scan. Posted before the Claude review.

@github-actions

Copy link
Copy Markdown

CI Tests

Tests passed: ruff lint and the unittest matrix (Python 3.11 to 3.14, Linux and macOS) are green on 8ebfdb0.

Posted before the Claude review so the test outcome is folded into the review.

@claude

claude Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Claude finished @daniel-pittman's task in 58s —— View job


Review of PR #17

  • Read PR context (diff, CI and Semgrep comments)
  • Read surrounding code (Snapshot.derive, Groups.of/by_path, set_override/_edit_table, offer_reopen, Grouping.of callers)
  • Check the move, the grouping fallback and the session-id change
  • Assess test coverage
  • Post review

Summary

I found no correctness bugs, security problems or CLAUDE.md violations (the repo has no CLAUDE.md). There is one LOW note.

  • The move: action_regroup (fleetwatch/app.py:1490) now reads snap.records.get(name) or snap.gone.get(name) or {}. That removes the KeyError.
    • With rec == {}, by_path(None) returns Other and sessionId is None. The move then pins by name only, which is the intended fallback.
  • The grouping: Grouping.of (fleetwatch/views.py:67-73) falls back to groups.of(name, gone.cwd, gone.sessionId) for names with no live row.
    • Its callers are the grouped Sessions tree, the Needs-you grouping, the to-dos grouping (views.py:412) and the finder/regroup lookups. All of them now honour overrides for not-running sessions.
    • For a name that is neither live nor gone, it returns the name override or Other. Before, that was always Other, so this is strictly more consistent.
    • The fallback runs lazily and costs a few dict lookups per call, so speed is not a concern.
  • The session id: gone_row (fleetwatch/data.py:576) takes it from the status file only when it is a str.
    • It reaches the TOML through clean() → _toml_string(), and set_override parses the result again before writing. A bad id can't inject anything into groups.toml.
    • item_key uses the original stale record, not gone_row, so hold keys don't change.

Findings

Severity Where Finding
LOW fleetwatch/data.py:576 This change also affects Enter → reopen. offer_reopen (app.py:1648-1651) tries rec["sessionId"] before the name, so a not-running session's reopen now goes by the status file's id first. That is usually the better match. A stale status file (the id changed and the file was never rewritten) could pick an older transcript than the name match would. I'm not sure this happens in practice. Either keep this id out of r["sessionId"] and give the pin lookup its own field, or mention the change in the PR body. Fix this →

Scan and CI results

  • Semgrep (OSS): no findings.
  • CI Tests: passed on 8ebfdb0 (ruff lint and the unittest matrix, Python 3.11–3.14, Linux and macOS).

Test coverage

The new test tests/test_gone_rows.py::EnterTests::test_m_moves_a_session_that_is_not_running covers all three parts of the change:

  • The move: it runs m on a session that is not running, with no live record, and checks there is no KeyError.
  • The session id: it checks that both the name pin and the session-id pin are rewritten. That second pin only works because of the status-file id fallback.
  • The grouping: it checks that the grouped board shows the row under the chosen group's header.
  • Moving back: it checks that moving the session back to Other removes both pins.

What it doesn't test:

  • The rec == {} path: no live record, and a gone row with no cwd and no session id.
  • The new effect on offer_reopen from the LOW finding.

Neither gap blocks the merge.

Public-repo check

The diff adds no home-directory paths, real names or emails, cloud-drive paths or credentials.

Comment thread fleetwatch/data.py
upd = to_epoch(sf.get("updated"))
# A file-only record carries no session id; the status file names it, and a
# group pin written while the session ran is keyed by it.
sid = r.get("sessionId") or (sf.get("sessionId") if isinstance(sf.get("sessionId"), str) else None)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOW: this also changes how Enter reopens a session that is not running. offer_reopen (fleetwatch/app.py:1648-1651) matches a Resume entry by rec["sessionId"] first and only falls back to the name when that finds nothing. Before this change, a file-only record had sessionId=None here, so reopen always matched by name. Now it matches by the status file's id first.

That is usually the better match. If the status file is stale, though, its id can point at an older transcript than the one the name match would find. One way this happens: the session got a new id (after /clear, say) and never rewrote its status file. I'm not sure this happens in practice. If the id should only feed the group pins, the narrowest fix is to keep it out of r["sessionId"] and give gone_row a separate field for the pin lookup. Otherwise, a line in the PR body saying reopen now prefers this id would cover it.

@daniel-pittman
daniel-pittman merged commit 7d0c058 into develop Nov 19, 2026
23 of 25 checks passed
@daniel-pittman
daniel-pittman deleted the fix/move-session-without-record branch November 19, 2026 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant