Skip to content

feat(cli): list a node's sessions in the chunk dev JVM tab and filter logs by session - #344

Draft
oglassdev wants to merge 4 commits into
mainfrom
feat/dev-tui-sessions
Draft

oglassdev wants to merge 4 commits into
mainfrom
feat/dev-tui-sessions

Conversation

@oglassdev

Copy link
Copy Markdown
Contributor

Closes #140. Once a JVM hosts a lobby and a couple of arenas, chunk dev can't pick out one session: the JVM tab lists nodes only, and a node's sessions all share one log stream. Now each node's open sessions are listed under it. Selecting one filters the log to that session, the way selecting a node already does.

  • Operator topic: Node.sessions gives each open session's ID, session type, destination key, player count and phase.
    • Player counts update incrementally from the claims that changed, like the players topic, so an update doesn't scan every claim.
    • The topic still wakes only on commits, health passes and drain deadlines, not on every JVM report. A phase change no commit follows can show up to one health pass (5 s) late.
  • Session log tags: JVM output that runs in a session's context starts with [session:<id>] . This covers session handler callbacks, ticks, the scheduler and Kotlin coroutines (through a ThreadContextElement), plus the session's event listeners.
    • System.out and System.err are wrapped to add the tag. Each written line is complete and carries one writer's tag, even when stdout and stderr share a file. That covers slf4j-simple and JUL's console handler.
  • Untagged lines (startup, GC, Minestom's own output) appear under their node and in "All nodes", not under each session.
  • TUI: sessions are nested and selectable under their node. The header shows the selected session's details and a session count for a node and for "All nodes". Nodes and sessions are coloured in interleaved log lines. Stopped nodes still hide stale health (fix(cli): stop showing a stopped node's stale heap and players in chunk dev #324).

Behaviour changes and limits

  • Exceptions: a session's own events are dispatched a second time with the session bound. As a result, a failing session listener no longer stops the global listeners that come after it. On main it did.
  • Event priority: priority and ownership filtering work as on main.
  • Partial lines: a line that is flushed before its newline, or that reaches 8 KiB, is written as a complete tagged line. Its continuation starts a new line.
  • Lost output: text printed without a newline is lost if its thread ends without a newline or flush().
  • Native JVM logging (-Xlog) writes straight to the file descriptor, so it stays untagged at node level.

Checks

  • cargo test -p chunk-environment operator (6), cargo test -p chunk-cli local (22), and clippy and fmt on chunk-control, chunk-environment and chunk-cli.
  • ./gradlew :jvm:runtime:test :jvm:multistom:test :jvm:multistom-kotlin:test, plus google-java-format and ktlint on the touched files.
  • buf lint and buf format.
  • Four review rounds. The last one found nothing.

🤖 Generated with Claude Code

… logs by session

The operator topic's `Node` now carries the host's open sessions: ID, session
type, destination key, open claims and phase. The topic counts open claims per
session from the feed's changes instead of scanning every claim, and reads
session phases from JVM reports whenever a commit or health pass recomputes it.

JVM output written in a session's context starts with `[session:<id>] `: the
runtime binds the session around its handler callbacks, multistom around its
tick work, scheduler and event listeners, and the Kotlin adapter around every
coroutine resumption. Untagged output stays at the node level.

The JVM tab nests sessions under their node, filters the log to the selected
session, shows its details and session counts in the header, and colors nodes
and sessions in interleaved lines.

Closes #140
…wnership as before

Session output is buffered per thread and written one tagged line at a time
under a lock shared by System.out and System.err, so concurrent lines no
longer interleave or lose their tag, and it is encoded as UTF-8 whatever the
target's charset.

The session's event node is attached to the process again, with its ownership
predicate binding the session itself. Its priority and ownership filtering
match the unwrapped node, and direct dispatch to it binds the session too.

Refs #140
…ts the same bound or not

Partial and over-long lines are now written as complete tagged lines so
another writer's output can't land inside them, the line cap bounds each
write, and checkError reports target failures. Session events are always
re-dispatched once through the node, so a failing session listener never
stops global listeners.

Refs #140

This branch has not been deployed

No deployments
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.

cli: list open sessions under nodes in the chunk dev JVM tab

1 participant