Skip to content

Draft: add viewer session action model context - #201

Merged
100yenadmin merged 2 commits into
mainfrom
viewer/session-action-model
May 26, 2026
Merged

Draft: add viewer session action model context#201
100yenadmin merged 2 commits into
mainfrom
viewer/session-action-model

Conversation

@100yenadmin

@100yenadmin 100yenadmin commented May 26, 2026

Copy link
Copy Markdown
Member

Summary

Refs #115, #61.

This is the early visible Lane D draft for the viewer session action model. It keeps the engine as state authority and preserves the existing /move write lane, while making the /session-surface read model more explicit for the OpenWorlds Table.

Changes:

  • adds browser-safe writeLane metadata to the session/action read model (/move, POST, engine authority, player move intent, no campaign snapshot writes)
  • adds enabledActions and blockedActions buckets with concise disabled reasons, while keeping the existing availableActions shape for compatibility
  • adds public actionContext for scene, active quests, and consequence timing counts/signals without leaking notes, DM fields, private lore, or consequence notes
  • updates the OpenWorlds Table to consume enabled/blocked action buckets and post only enabled action IDs through the configured write lane endpoint
  • adds focused tests for blocked reasons, private-field non-leakage, read-only action disabling, and table source binding

Notes

This intentionally does not change engine state authority or add browser-side snapshot writes. Unsupported/non-live actions remain disabled with reasons.

PR #150 is intentionally out of scope.

Validation

Ran locally from /Volumes/LEXAR/repos/ClawDnD-session-action-model:

python3 -m unittest viewer.tests.test_session_surface -q
python3 -m unittest viewer.tests.test_openworlds_static -q
python3 -m py_compile viewer/server.py
python3 scripts/license_check.py
git diff --check

All commands exited 0.

Summary by CodeRabbit

  • New Features

    • Crimson "consequence due" badge in the Encounter section when consequences are due.
  • Improvements

    • Clearer enabled vs blocked action gating in the UI; disabled actions surface read-only reasons.
    • Action submission now verifies availability before sending and shows endpoint-aware error text.
    • Session context extended with richer action and consequence metadata.
  • Tests

    • Added tests validating action gating, submission routing, and surface metadata.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1b1ea8d5-4180-4021-a9bd-45d0c891656e

📥 Commits

Reviewing files that changed from the base of the PR and between 37d8537 and eb4c026.

📒 Files selected for processing (4)
  • viewer/openworlds/screen-table.jsx
  • viewer/server.py
  • viewer/tests/test_openworlds_static.py
  • viewer/tests/test_session_surface.py

Cache: Disabled due to Reviews > Disable Cache setting


📝 Walkthrough

Walkthrough

Server now projects writeLane, enabledActions/blockedActions, and actionContext into session surfaces/action models. Client ScreenTable reads these fields, validates action availability by id before POSTing to writeLane.endpoint (fallback /move), and renders consequence-due badges. Tests cover surface shape and client JSX usage.

Changes

Action Availability Gating and Write-Lane Routing

Layer / File(s) Summary
Client state derivation and read-only UI
viewer/openworlds/screen-table.jsx
Derives enabledActions, blockedActions, readOnlyReason, writeLane, actionContext/consequenceContext, and adds enabledActionById; uses these for UI state and consequence-due badge rendering.
postMove routing and caller updates
viewer/openworlds/screen-table.jsx
postMove(actionId) now validates action presence/enabled via enabledActionById and POSTs to `writeLane.endpoint
Server helpers and session surface wiring
viewer/server.py
Adds helpers that bucket projected actions into enabledActions/blockedActions, build writeLane metadata (endpoint, allowed kinds), and construct actionContext (scene, quests, consequence signals). build_session_surface and build_action_model include enabledActions, blockedActions, actionContext, and writeLane in returned JSON.
Tests: surface and client JSX validation
viewer/tests/test_session_surface.py, viewer/tests/test_openworlds_static.py
Unit test verifies build_session_surface includes writeLane, gated action buckets with disable reasons, actionContext rollups, and excludes private strings/fields. HTTP test asserts screen-table.jsx references enabledActions/blockedActions, uses enabledActionById, posts to `writeLane.endpoint

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related issues

  • 100yenadmin/ClawDnD#115: Related — both concern session-surface action metadata and client gating/write-lane routing.

Possibly related PRs

  • 100yenadmin/ClawDnD#128: Modifies screen-table.jsx and server session-surface to drive action availability and move routing; closely related to this change.
  • 100yenadmin/ClawDnD#201: Implements similar viewer/session-action-context refactor adding enabledActions/blockedActions, writeLane, and action-id gated postMove.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Draft: add viewer session action model context' accurately reflects the main changes—introducing action model context (enabledActions, blockedActions, writeLane, actionContext) to the viewer session surface.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • LINEAR integration encountered authorization issues. Please disconnect and reconnect the integration in the CodeRabbit UI.

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
viewer/openworlds/screen-table.jsx (1)

136-136: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Error message references hardcoded /move but endpoint is configurable.

The endpoint is now writeLane.endpoint (line 124), but this error fallback still says /move. If the server configures a different endpoint, the message will be misleading.

Suggested fix
-      toast({ kind: "danger", title: "Move not sent", body: error?.message || "The viewer could not reach /move." });
+      toast({ kind: "danger", title: "Move not sent", body: error?.message || `The viewer could not reach ${writeLane.endpoint || "/move"}.` });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@viewer/openworlds/screen-table.jsx` at line 136, The error toast message
incorrectly hardcodes "/move"; update the toast call that currently uses toast({
kind: "danger", title: "Move not sent", body: error?.message || "The viewer
could not reach /move." }) to reference the configured endpoint variable
(writeLane.endpoint) in its fallback text so it reads something like "The viewer
could not reach {writeLane.endpoint}." and retain error?.message when available;
ensure you locate this change at the toast invocation in the same component
where writeLane.endpoint is defined/used.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@viewer/tests/test_session_surface.py`:
- Line 255: The test is fragile because it indexes blockedActions[0]; instead,
locate the blocked action by its action ID and assert its disabled_reason, e.g.
build or use the existing mapping pattern used earlier (like lines that access
action maps) to find blocked_action = blocked_actions_by_id[<ACTION_ID>] or use
a comprehension/next(...) to find the entry where ["id"] == "<ACTION_ID>", then
assert blocked_action["disabled_reason"] == "no live move sink"; update
references to use the `surface` variable and its `actionModel["blockedActions"]`
list and the exact action ID string used elsewhere in the test.

---

Outside diff comments:
In `@viewer/openworlds/screen-table.jsx`:
- Line 136: The error toast message incorrectly hardcodes "/move"; update the
toast call that currently uses toast({ kind: "danger", title: "Move not sent",
body: error?.message || "The viewer could not reach /move." }) to reference the
configured endpoint variable (writeLane.endpoint) in its fallback text so it
reads something like "The viewer could not reach {writeLane.endpoint}." and
retain error?.message when available; ensure you locate this change at the toast
invocation in the same component where writeLane.endpoint is defined/used.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 66a1d6ea-e7f4-433c-b81f-9fc01afb8def

📥 Commits

Reviewing files that changed from the base of the PR and between af2c2b5 and 37d8537.

📒 Files selected for processing (4)
  • viewer/openworlds/screen-table.jsx
  • viewer/server.py
  • viewer/tests/test_openworlds_static.py
  • viewer/tests/test_session_surface.py
📜 Review details
🧰 Additional context used
🧬 Code graph analysis (1)
viewer/server.py (1)
viewer/tests/test_session_surface.py (1)
  • build_session_surface (91-91)
🔇 Additional comments (12)
viewer/server.py (6)

854-865: LGTM!


868-876: LGTM!


879-910: LGTM!


913-932: LGTM!


1065-1072: LGTM!

Also applies to: 1089-1089, 1108-1119


3666-3671: LGTM!

viewer/tests/test_session_surface.py (1)

193-254: LGTM!

Also applies to: 256-261

viewer/tests/test_openworlds_static.py (1)

131-143: LGTM!

viewer/openworlds/screen-table.jsx (4)

26-31: LGTM!


38-41: LGTM!


148-148: LGTM!

Also applies to: 158-158, 171-171


340-342: LGTM!

Comment thread viewer/tests/test_session_surface.py Outdated
@100yenadmin

Copy link
Copy Markdown
Member Author

Addressed the current-head CodeRabbit review items in a2f5935.\n\nValidation from /Volumes/LEXAR/repos/ClawDnD-session-action-model:\n- python3 -m unittest viewer.tests.test_session_surface -q: OK (6 tests)\n- python3 -m unittest viewer.tests.test_openworlds_static -q: OK (16 tests)\n- python3 -m py_compile viewer/server.py: OK\n- python3 scripts/license_check.py: OK\n- git diff --check: OK\n\nKept the PR in draft; no merge requested.

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