Skip to content

Plan observer_cli 2.0 structure refactor#135

Merged
zhongwencool merged 58 commits into
developfrom
v2.x
Jul 6, 2026
Merged

Plan observer_cli 2.0 structure refactor#135
zhongwencool merged 58 commits into
developfrom
v2.x

Conversation

@zhongwencool

Copy link
Copy Markdown
Owner

Highlights:
  - Remove low-value tests for less_server unknown calls/casts, plugin missing-module/empty-sheet paths, duplicate formatter checks, and fake dist-node list checks
  - Replace direct plugin manager/render-worker checks with integration-style coverage through observer_cli_plugin:start/1
  - Stop the plugin render worker before deleting ETS state during quit/restart paths to avoid stale-worker races
  - Strengthen plugin sheet/header and formatter fallback assertions

  Validation:
  - rebar3 fmt
  - git diff --check
  - rebar3 fmt --check
  - rebar3 compile
  - rebar3 as ci compile
  - rebar3 eunit: 257 tests, 0 failures
  - rebar3 as test eunit: 257 tests, 0 failures
  - rebar3 xref
  - rebar3 dialyzer
Change highlights:
- Separate command, collection, and rendering seams across Home, Application, ETS, Mnesia, Network, System, Process detail, Port detail, and escript startup paths.
- Add behavior-focused tests for startup, shared navigation, plugin routing, formatter fallback, escript remote handling, page rendering fragments, and collection seams.
- Harden empty Plugin manager input handling so page, interval, numeric jump, and default jump inputs no-op instead of crashing when no plugin is configured.
- Keep the change internal: no new dependency, no generic TUI framework, no public snapshot CLI, and no plugin API break in this slice.

Verification:
- Ran `rebar3 fmt`.
- Ran `rebar3 as test eunit --module=observer_cli_plugin_test,observer_cli_plugin_render_test`: 32 tests, 0 failures.
- Ran `git diff --check`.
- Ran `rebar3 eunit`: 311 tests, 0 failures.
- Ran `epmd -daemon && rebar3 as test do eunit, covertool generate`: 311 tests, 0 failures; total coverage 96.9%.
- Ran `rebar3 compile`, `rebar3 xref`, `rebar3 as ci compile`, and `rebar3 check` successfully.
改动重点:
- Add the issue #133 Phase 0 baseline evidence file with current validation commands, coverage, public entry points, compatibility boundaries, and explicit non-goals.
- Keep the slice documentation-only and scoped to ignored .agents evidence.

验证:
- gh issue view 133 --json number,title,state,updatedAt,body confirmed the source issue state.
- epmd -daemon && rebar3 as test do eunit, covertool generate passed with 311 tests, 0 failures, and 96.9% line coverage.
- rebar3 check passed.
- git diff --cached --check and scope review passed; manual terminal QA was skipped because this slice only records baseline evidence.
改动重点:
- Add a scoped public-entry inventory under .agents for normal/local/remote/escript/plugin startup, formatter configuration, and major interactive commands.
- Keep the slice documentation-only, with no runtime behavior, plugin API, formatter, or command changes.

验证:
- gh issue view 133 --repo zhongwencool/observer_cli --json number,title,state,updatedAt,body,comments confirmed the source issue state.
- rebar3 as test eunit --module=observer_cli_start_test,observer_cli_lib_test,observer_cli_process_test,observer_cli_port_test,observer_cli_plugin_test,observer_cli_escriptize_test passed with 176 tests and 0 failures.
- git diff --cached --check and scope review passed before commit.
改动重点:
- Add a Phase 0 smoke EUnit that drives observer_cli:start/1 through startup quit, top-menu page switches, interval changes, pagination, and direct process-pid jump input.
- Record checklist item 3 evidence in .agents/observer-cli-2-refactor/SMOKE_BEHAVIOR_TESTS.md; keep the process-jump case isolated so linked render-worker shutdown does not cancel EUnit.

验证:
- Ran rebar3 fmt.
- Ran rebar3 as test eunit --module=observer_cli_start_test: 12 tests, 0 failures.
- Ran rebar3 eunit: 312 tests, 0 failures; the existing observer_cli_process:render_state/3 timeout warning remained non-fatal.
- Ran git diff --check and git diff --cached --check.
改动重点:
- Added observer_cli_test_io helpers for stable plain-text fragment checks and ANSI boundary checks without asserting volatile runtime values.
- Added observer_cli_golden_test as the deterministic base test for those helpers and recorded Phase 0 item 4 evidence under .agents.

验证:
- Ran rebar3 fmt.
- Ran rebar3 as test eunit --module=observer_cli_golden_test: 2 tests, 0 failures.
- Ran rebar3 eunit: 314 tests, 0 failures.
- Ran git diff --check and rebar3 check.
改动重点:
- Add a Home golden-output test covering menu labels, footer commands, top-n title fragments, and wide summary fragments.
- Reuse the Home footer rendering path in tests and keep border padding before trailing reset/border suffixes so ANSI boundary checks catch stale redraw artifacts.

验证:
- Ran rebar3 fmt.
- Ran rebar3 as test eunit --module=observer_cli_golden_test.
- Ran rebar3 as test eunit --module=observer_cli_golden_test,observer_cli_core_test,observer_cli_lib_test.
- Ran git diff --check, rebar3 eunit, and rebar3 check.
改动重点:
- Add a deterministic System golden output test covering section titles, grouping fragments, ANSI boundaries, and wide terminal value-column growth.
- Record checklist item 6 evidence and validation in the golden output test notes without changing runtime CLI behavior.

验证:
- Ran rebar3 fmt.
- Ran rebar3 as test eunit --module=observer_cli_system_test with 24 tests and 0 failures.
- Ran rebar3 as test eunit --module=observer_cli_golden_test,observer_cli_system_test with 27 tests and 0 failures.
- Ran git diff --check, rebar3 eunit with 316 tests and 0 failures, and rebar3 check.
改动重点:
- Add stable golden fragment assertions for Process and Port detail titles, footers, link and monitor sections, and dead-object messages.
- Extend the test IO helper with captured output support and expose the existing dead-view renderers only under TEST so runtime CLI behavior is unchanged.
- Record item 7 evidence in the Phase 0 golden-output notes.

验证:
- Ran rebar3 fmt.
- Ran rebar3 as test eunit --module=observer_cli_process_test,observer_cli_port_test,observer_cli_golden_test; 86 tests passed.
- Ran git diff --check.
- Ran rebar3 eunit; 320 tests passed.
- Ran rebar3 check.
改动重点:
- Strengthen plugin config assertions and multi-plugin shortcut coverage without changing runtime code.
- Add sheet sort-order and row drill-down assertions using existing plugin test fixtures and record Goal 08 evidence.

验证:
- Ran rebar3 fmt.
- Ran rebar3 as test eunit --module=observer_cli_plugin_test,observer_cli_plugin_render_test (33 tests, 0 failures).
- Ran git diff --check, rebar3 eunit (321 tests, 0 failures), and rebar3 check.
改动重点:
- Extend observer_cli_escriptize tests for invalid escript argument counts and interval parse failures.
- Add a usage-path guard proving invalid escript args do not invoke the runner.
- Strengthen remote_load peer coverage by asserting observer_cli application env is copied to the remote node.

验证:
- Ran rebar3 fmt.
- Ran rebar3 as test eunit --module=observer_cli_escriptize_test,observer_cli_start_test (48 tests, 0 failures).
- Ran git diff --check.
- Ran rebar3 eunit (322 tests, 0 failures; existing render_state timeout warning observed).
改动重点:
- Add scoped Goal 10 evidence documenting the full validation refresh and current covertool results.
- Record that total coverage and all key modules meet the 95% threshold without adding runtime code or broader refactor changes.

验证:
- Ran git diff --check, rebar3 fmt, rebar3 compile, rebar3 eunit, rebar3 xref, rebar3 as ci compile, rebar3 check, and epmd -daemon && rebar3 as test do eunit, covertool generate.
改动重点:
- Move shared pure command parsing into observer_cli_command:parse_shared/1 and keep observer_cli_lib:parse_cmd/3 as the IO/routing boundary.
- Route Process, Port, and Plugin numeric fallback parsing through observer_cli_command:parse_integer/1 without changing action names or return values.
- Record Goal 11 evidence and refresh the public command inventory references.

验证:
- Ran rebar3 fmt, git diff --check, rebar3 compile, rebar3 as ci compile, rebar3 eunit, and rebar3 check.
- Ran rebar3 as test eunit --module=observer_cli_lib_test,observer_cli_process_test,observer_cli_port_test,observer_cli_plugin_test (134 tests, 0 failures).
- Full rebar3 eunit passed with 322 tests, 0 failures; existing non-fatal observer_cli_process:render_state/3 timeout warning observed.
改动重点:
- Add explicit Home parser assertions for proc_count sort commands, proc_window commands, default and numeric jumps, scheduler toggle, PID jumps, malformed PID input, and unknown input.
- Record Goal 12 evidence under .agents without changing parser return values, CLI behavior, or plugin API behavior.

验证:
- Ran rebar3 fmt.
- Ran rebar3 as test eunit --module=observer_cli_lib_test with 27 tests and 0 failures.
- Ran git diff --check.
- Ran rebar3 eunit with 324 tests and 0 failures; observed the existing non-fatal observer_cli_process:render_state/3 timeout warning.
- Ran rebar3 check.
改动重点:
- Add shared parser assertions for Network, ETS/Mnesia, and Application sorting, pagination aliases, hide, interval, and quit inputs.
- Record Goal 13 evidence with validation results and the manual-QA skip reason.

验证:
- rebar3 fmt
- rebar3 as test eunit --module=observer_cli_lib_test
- git diff --check
- rebar3 eunit
- rebar3 check
改动重点:
- Add Process parser assertions for back, home, subview, interval, jump, unknown input, and quit commands.
- Add less-client navigation coverage for real Home and Back keys and Port parser coverage for jump, interval, unknown input, and terminal-error quit handling.
- Make Port command parsing return quit on terminal input errors instead of falling through to numeric parsing.

验证:
- Ran rebar3 fmt.
- Ran rebar3 as test eunit --module=observer_cli_process_test,observer_cli_port_test,less_client_test with 100 tests and 0 failures.
- Ran git diff --check, rebar3 eunit with 328 tests and 0 failures, and rebar3 check.
改动重点:
- Collapse equivalent shared command aliases for quit, pagination, and PID jump prefixes into guarded branches without changing parser return values.
- Collapse Process and Port q/Q quit aliases into guarded branches and record Goal 15 validation evidence.

验证:
- Ran rebar3 fmt.
- Ran rebar3 as test eunit --module=observer_cli_lib_test,observer_cli_process_test,observer_cli_port_test before and after deletion with 113 tests and 0 failures each.
- Ran git diff --check, rebar3 eunit with 328 tests and 0 failures, and rebar3 check.
改动重点:
- Add intent-revealing ANSI, selected menu item, top-menu, menu-header, and footer helpers while keeping shared legacy wrappers for compatibility.
- Move Home, list pages, Process, Port, Plugin, Help, and less footer call sites to the new helper names without changing rendered text or command behavior.
- Record Goal 16 evidence under .agents with validation results and the unused-wrapper adjustment.

验证:
- Ran rebar3 fmt.
- Ran rebar3 as test eunit --module=observer_cli_lib_test,observer_cli_golden_test,observer_cli_system_test,observer_cli_process_test,observer_cli_port_test,observer_cli_plugin_test,less_client_test with 183 tests and 0 failures.
- Ran git diff --check and git diff --cached --check.
- Ran rebar3 check.
- Ran rebar3 eunit with 328 tests and 0 failures.
改动重点:
- Add observer_cli_lib:layout_base_width/0 and layout_extra_width/1,2 so base and extra width math share the existing rendering helper boundary.
- Route Home, plugin fallback, Process/Port, and menu title width formulas through the shared boundary without changing rendered widths.
- Record Goal 17 evidence under .agents/observer-cli-2-refactor/GOAL_17_WIDTH_HELPERS.md.

验证:
- Ran rebar3 fmt; focused EUnit for lib/core/process/port/plugin-render/golden modules (151 tests, 0 failures); git diff --check; rebar3 check; rebar3 eunit (328 tests, 0 failures).
- Did not rerun manual terminal QA because this slice only moves existing width calculations behind helper functions.
改动重点:
- Expand observer_cli_lib width-helper tests for narrow, exact-base, anti-auto-wrap, and wide terminal boundaries.
- Cover weighted wide-width distribution plus padded bordered lines containing Unicode and ANSI-colored content.
- Record goal 18 evidence under the 2.0 refactor agent notes without touching prerequisite checklist items.

验证:
- Ran rebar3 fmt.
- Ran rebar3 as test eunit --module=observer_cli_lib_test: 31 tests, 0 failures.
- Ran git diff --check.
- Ran rebar3 check.
- Ran rebar3 eunit: 329 tests, 0 failures; existing non-fatal render_state timeout warning still appeared.
改动重点:
- Split Home System and memory/process summary rendering into stable row/cell block construction followed by one shared Home summary renderer.
- Preserved existing grouping, widths, ANSI styles, warning-color cells, unsupported atom-count fallback text, and left Home top-n rendering untouched.

验证:
- Ran rebar3 fmt.
- Ran rebar3 as test eunit --module=observer_cli_core_test,observer_cli_golden_test (31 tests, 0 failures), rebar3 check, git diff --check, rebar3 eunit (329 tests, 0 failures), and rebar3 as ci compile.
改动重点:
- Consolidated the Home top-n renderer into one shared spec-driven path for all sort types while preserving each sort's titles, widths, row formats, value conversion, and pid-info lookup keys.
- Added Goal 20 evidence and focused regression coverage for type-specific Home top-n headers and row widths.

验证:
- Ran rebar3 fmt.
- Ran rebar3 as test eunit --module=observer_cli_core_test,observer_cli_golden_test (32 tests, 0 failures).
- Ran git diff --check, rebar3 compile, rebar3 eunit (330 tests, 0 failures), rebar3 check, and rebar3 as ci compile.
改动重点:
- Route the System worker through `render_system_sections/1` so system info, allocator block sizes, distribution nodes, and cache-hit rates are composed through named section helpers.
- Preserve the existing section renderers, output order, menu/footer behavior, and user-visible System page fragments.
- Add Goal 21 evidence under `.agents/observer-cli-2-refactor/` with the scoped validation record.

验证:
- Ran `rebar3 fmt`.
- Ran `rebar3 as test eunit --module=observer_cli_system_test` and `rebar3 as test eunit --module=observer_cli_system_test,observer_cli_golden_test`.
- Ran `git diff --check`, `rebar3 compile`, `rebar3 eunit`, `rebar3 check`, and `rebar3 as ci compile`.
改动重点:
- Split Process Info rendering into section composition plus local meta, memory, and garbage-collection field helpers without changing labels, ordering, widths, or colors.
- Reused the existing links/monitors and reductions/memory renderers through a new Process detail section boundary, and shared the non-State subview menu/body/footer wrapper while leaving the State less-client path unchanged.
- Added focused Process tests and a goal evidence file for checklist item 22.

验证:
- Ran `rebar3 fmt`.
- Ran `rebar3 as test eunit --module=observer_cli_process_test,observer_cli_golden_test` with 60 tests and 0 failures.
- Ran `rebar3 check` after fixing the Dialyzer queue-opaque warning surfaced by the new section helper.
- Ran `git diff --check`, `rebar3 compile`, `rebar3 eunit` with 333 tests and 0 failures, and `rebar3 as ci compile`.
- Manual terminal QA was not rerun because this slice only changes behavior-preserving rendering helper boundaries.
改动重点:
- Add a Port Info section boundary that composes attr/value, link/monitor, socket peer, stats, and options rendering without changing output.
- Split attr/value and socket-peer helpers and cover the section composition with a focused regression.
- Record Goal 23 evidence under `.agents/observer-cli-2-refactor/`.

验证:
- Ran `rebar3 fmt`.
- Ran `rebar3 as test eunit --module=observer_cli_port_test,observer_cli_golden_test` with 32 tests and 0 failures.
- Ran `git diff --check`, `rebar3 compile`, `rebar3 eunit` with 334 tests and 0 failures, `rebar3 check`, and `rebar3 as ci compile`.
改动重点:
- Add Goal 24 evidence documenting the focused golden/stable-fragment EUnit rerun after Phase 2 rendering helper cleanup.
- Leave production and test code unchanged; record the covered Home, System, Process, and Port output surfaces plus skipped validation boundaries.

验证:
- Ran `rebar3 as test eunit --module=observer_cli_golden_test,observer_cli_core_test,observer_cli_system_test,observer_cli_process_test,observer_cli_port_test` with 143 tests and 0 failures.
- Ran `git diff --check --cached` and reviewed the staged scope before committing.
改动重点:
- Add Goal 25 evidence that maps each major page from collected Erlang terms/maps/proplists to the existing TUI render input boundary.
- Document that this slice adds no behavior layer, no production-code change, and no user-visible rendering change.

验证:
- Ran `rebar3 compile` successfully.
- Ran focused EUnit for core page boundary modules with 225 tests and 0 failures.
- Ran `git diff --cached --check` successfully.
改动重点:
- Build a Home snapshot in redraw_running/8 that separates runtime summary sampling, process ranking, scheduler row sizing, and TUI rendering without intentional behavior changes.
- Split IO/GC diff from scheduler usage diff in node_stats/2 and keep test-only render wrappers under -ifdef(TEST).
- Add a focused Home snapshot EUnit assertion and ignored .agents evidence for goal 26.

验证:
- rebar3 fmt
- git diff --check
- rebar3 compile
- rebar3 as ci compile
- rebar3 as test eunit --module=observer_cli_core_test,observer_cli_golden_test
- rebar3 eunit
- rebar3 check
改动重点:
- Split System collection into OS process metrics, runtime system info, allocator/cache data, and pre-collected distribution-node rows consumed by render sections.
- Move distribution queue size and limit lookup out of row rendering while preserving the existing System page output shape and tests.
- Record Goal 27 evidence under the refactor notes.

验证:
- Ran rebar3 fmt.
- Ran rebar3 compile and rebar3 as ci compile.
- Ran rebar3 as test eunit --module=observer_cli_system_test, rebar3 eunit, git diff --check, and rebar3 check.
改动重点:
- Move Application row collection into collect_app_render_info/3 so rendering consumes collected sorted and paginated rows.
- Keep the existing sublist_top_n_attrs sorting path and sort keys while adding focused coverage for Application row order and pagination.
- Record goal 28 evidence under .agents/observer-cli-2-refactor.

验证:
- Ran rebar3 fmt.
- Ran rebar3 as test eunit --module=observer_cli_application_test (10 tests, 0 failures).
- Ran git diff --check, rebar3 compile, rebar3 as ci compile, rebar3 eunit (336 tests, 0 failures), and rebar3 check.
改动重点:
- Split Network IO sampling into collected summary terms before rendering while preserving the existing Byte Input/Output and Total Input/Output values.
- Collect per-port Network row maps before rendering, preserving count/window mode, selected-row formatting, non-count IO column ordering, and reversed port store entries for drill-down fallback.
- Add focused Network seam tests and Goal 30 evidence under `.agents/observer-cli-2-refactor/`.

验证:
- `rebar3 fmt` passed.
- `rebar3 as test eunit --module=observer_cli_inet_test` passed with 24 tests and 0 failures.
- `rebar3 compile`, `git diff --check`, `rebar3 as ci compile`, `rebar3 eunit`, and `rebar3 check` passed.
改动重点:
- Normalize Process garbage-collection data from recon into a map before rendering while preserving the existing dead-process and State recon error paths.
- Normalize Port type data from recon into a map for socket peer, stats, and options rendering while preserving missing-field output behavior.
- Add focused detail collection/rendering assertions and record Goal 31 validation evidence.

验证:
- Ran rebar3 fmt.
- Ran rebar3 as test eunit --module=observer_cli_process_test,observer_cli_port_test,observer_cli_golden_test with 90 tests and 0 failures.
- Ran git diff --check, rebar3 compile, rebar3 as ci compile, rebar3 eunit with 344 tests and 0 failures, and rebar3 check.
改动重点:
- Strengthen Home, System, Application, ETS, Mnesia, Network, Process, and Port tests to assert collected term shapes and important seam fields without pinning volatile runtime counters.
- Add Goal 32 evidence documenting the test-only scope, preserved CLI behavior, validation commands, skipped manual QA reason, and known baseline warning noise.

验证:
- gh issue view 133 --json number,title,updatedAt,body --jq '{number,title,updatedAt,line79:(.body|split("\\n")[78])}'
- rebar3 fmt
- rebar3 as test eunit --module=observer_cli_core_test,observer_cli_system_test,observer_cli_application_test,observer_cli_ets_test,observer_cli_mnesia_test,observer_cli_inet_test,observer_cli_process_test,observer_cli_port_test
- git diff --check
- rebar3 eunit
- rebar3 as ci compile
改动重点:
- Add Goal 33 evidence documenting that future JSON / term output must consume collected Erlang terms or maps before TUI rendering instead of parsing terminal text.
- List the current internal collection/render seams for Home, System, Application, ETS, Mnesia, Network, Process detail, and Port detail, and record this slice's non-goals.

验证:
- Confirmed issue #133 line 80 with `gh issue view 133 --json number,title,updatedAt,body --jq '{number,title,updatedAt,line80:(.body|split("\\n")[79])}'`.
- Checked documented collector/render names with `rg -n "collect_.*\\(|render_.*snapshot|render_.*info|render_.*rows" src/observer_cli*.erl test/observer_cli*_test.erl`.
- Ran `git diff --no-index --check /dev/null .agents/observer-cli-2-refactor/GOAL_33_SNAPSHOT_SEAM.md` and `git diff --cached --check`; skipped rebar3 because this was a docs-only slice with no Erlang source or test changes.
改动重点:
- Add Goal 34 evidence identifying shared start, quit, interval, pagination, timer, and worker-cleanup behavior across current view manager loops.
- Record the narrow extraction boundary for the next slice without changing Erlang source or introducing a generic manager framework.

验证:
- Verified issue #133 checklist line with gh issue view.
- Reviewed manager lifecycle paths with grep over src/observer_cli*.erl and checked the staged docs diff with git diff --cached --check.
- Skipped rebar3 because this slice only adds ignored .agents documentation and does not change Erlang source, tests, or runtime behavior.
改动重点:
- Add observer_cli_lib:next_page/2 for shared page lower-bound updates.
- Use the helper in Home, Application, ETS, Mnesia, Network, and Plugin pagination paths without changing cleanup or timer behavior.
- Record Goal 35 evidence and keep the scope below a generic view framework.

验证:
- Ran rebar3 fmt.
- Ran rebar3 as test eunit --module=observer_cli_lib_test,observer_cli_plugin_test with 58 tests and 0 failures.
- Ran git diff --check, rebar3 compile, rebar3 eunit with 346 tests and 0 failures, rebar3 as ci compile, and rebar3 check.
改动重点:
- Split Home manager command dispatch into local action helpers while preserving the existing cleanup resource for scheduler wall-time restoration.
- Kept Home quit and process drill-down behavior explicit, including store cleanup and store-backed row selection semantics.
- Added focused coverage for Home process row selection and recorded Goal 36 evidence.

验证:
- Ran gh issue view 133 to confirm checklist item 36 and issue updatedAt 2026-07-05T12:39:22Z.
- Ran rebar3 fmt; rebar3 as test eunit --module=observer_cli_core_test,observer_cli_start_test; git diff --check; rebar3 compile; rebar3 check; rebar3 eunit; rebar3 as ci compile.
改动重点:
- Reuse local cleanup-and-start helpers in Application, ETS, and Mnesia managers for sort, interval, and page actions without changing command behavior.
- Move page up/down updates in those managers behind local restart_page helpers while preserving observer_cli_lib:next_page/2 lower-bound behavior.
- Record Goal 37 scope, non-goals, and validation evidence under .agents/observer-cli-2-refactor/.

验证:
- Ran rebar3 fmt.
- Ran rebar3 as test eunit --module=observer_cli_application_test,observer_cli_ets_test,observer_cli_mnesia_test; 30 tests, 0 failures.
- Ran git diff --check, rebar3 compile, rebar3 eunit, rebar3 as ci compile, and rebar3 check; full eunit passed with 347 tests and the existing non-fatal observer_cli_process:render_state/3 timeout warning.
改动重点:
- Consolidate Network mode/type restarts and page restarts through local helpers while preserving inline interval updates and store-backed port drill-down branches.
- Record Goal 38 scope, non-goals, and validation evidence under the 2.0 refactor artifacts.

验证:
- Ran `rebar3 fmt`, `rebar3 as test eunit --module=observer_cli_inet_test`, `git diff --check`, `rebar3 compile`, `rebar3 eunit`, `rebar3 as ci compile`, and `rebar3 check`.
改动重点:
- Split Port manager action handling from command parsing so Home and Network navigation live in the manager loop without changing command return atoms.
- Reused small local Process helpers for Home and Plugin back navigation while keeping state subview switching and worker messages unchanged.
- Added Goal 39 evidence with scope, non-goals, validation, and skipped manual QA rationale.

验证:
- Ran `gh issue view 133 --repo zhongwencool/observer_cli --json number,title,updatedAt,body --jq ...` to confirm checklist item 39 and issue updatedAt `2026-07-05T12:39:22Z`.
- Ran `rebar3 fmt`, `rebar3 as test eunit --module=observer_cli_process_test,observer_cli_port_test`, `git diff --check`, `rebar3 compile`, `rebar3 as ci compile`, `rebar3 eunit`, and `rebar3 check`.
- Skipped manual terminal QA because this slice only moves local manager dispatch and stop/start helpers while existing focused navigation tests cover Process/Port Home, Back, Network, interval, and subview paths.
改动重点:
- Removed `clean/1` exports that only forwarded to `observer_cli_lib:exit_processes/1` from Application, ETS, Help, Network, Mnesia, and System.
- Kept Home cleanup routed through `observer_cli:clean/1` so scheduler wall-time restoration remains unchanged while plain top-menu cleanup uses `exit_processes/1` directly.
- Added Goal 40 evidence and moved cleanup proof into `observer_cli_lib_test` top-menu cleanup cases.

验证:
- Ran `gh issue view 133 --json title,body,updatedAt,url --jq '{title,updatedAt,url,body}'` to confirm checklist item 40.
- Ran `rebar3 fmt`, focused EUnit for touched modules, `git diff --check`, `rebar3 compile`, `rebar3 eunit`, `rebar3 as ci compile`, and `rebar3 check`.
- Skipped manual terminal QA because this only deletes pure cleanup forwarding wrappers and preserves the same cleanup helper path covered by EUnit.
改动重点:
- Add Goal 41 evidence documenting the current observer_cli plugin callback/config usage without changing runtime code.
- List the plugin capabilities that must survive the 2.0 boundary: attributes, sheet header, sheet body, shortcuts, sorting, and row handlers.
- Note current public plugin examples and the position-based API seams reserved for the next design slice.

验证:
- Confirmed issue #133 and checklist item 41 with `gh issue view 133 --json number,title,updatedAt,body`.
- Ran `rebar3 as test eunit --module=observer_cli_plugin_test,observer_cli_plugin_render_test` with 33 tests and 0 failures.
- Ran `git diff --cached --check` before committing.
改动重点:
- Add Goal 42 evidence for the smallest plugin 2.0 API break: named callback result maps, column-id sheet rows, sort ids, and explicit row handles.
- Keep the slice documentation-only so runtime CLI behavior, public plugin docs, and tests remain unchanged for Goals 43-45.

验证:
- Ran `gh issue view 133 --json number,title,updatedAt,body` to confirm the issue item and update timestamp.
- Ran `rebar3 as test eunit --module=observer_cli_plugin_test,observer_cli_plugin_render_test` with 33 tests and 0 failures.
- Ran `git diff --no-index --check -- /dev/null .agents/observer-cli-2-refactor/GOAL_42_PLUGIN_2_API_DESIGN.md` and `git diff --cached --check`.
改动重点:
- Add observer_cli_plugin_compat helpers that normalize 2.0 plugin callback maps, migrate sort_column and handler tuple config, and raise clear plugin_api_error reasons for rejected 1.x shapes.
- Add compatibility EUnit coverage for retained config/cell behavior, missing-callback fallback, migrated config keys, invalid columns/sorts, legacy callback returns, and non-pid default handles.
- Record Goal 43 scope, compatibility decisions, validation, and skipped terminal QA evidence under .agents.

验证:
- rebar3 fmt
- rebar3 as test eunit --module=observer_cli_plugin_test,observer_cli_plugin_render_test,observer_cli_plugin_compat_test -> 38 tests, 0 failures
- rebar3 compile
- git diff --check and git diff --cached --check
- rebar3 as ci compile
- rebar3 eunit -> 352 tests, 0 failures
- rebar3 check
改动重点:
- Route plugin attribute, header, body, sorting, and row-selection rendering through the normalized 2.0 map-shaped structures.
- Update plugin-focused tests and the local test plugin to cover column-id sorting, explicit row handles, and unchanged plugin page controls.
- Record goal 44 scope, behavior decisions, validation, and skipped runtime QA evidence.

验证:
- Ran rebar3 fmt.
- Ran rebar3 as test eunit --module=observer_cli_plugin_test,observer_cli_plugin_render_test,observer_cli_plugin_compat_test with 38 tests and 0 failures.
- Ran rebar3 compile, rebar3 as ci compile, rebar3 eunit with 352 tests and 0 failures, rebar3 check, and git diff --cached --check.
改动重点:
- Update docs/plugin.md to describe the map-based plugin 2.0 callback contract, column-id sorting, explicit row handles, and new handler configuration.
- Add a 1.x-to-2.0 migration guide with old-to-new callback/config mappings and a minimal before/after example.
- Record goal 45 scope, documentation decisions, validation, and skipped broad validation evidence.

验证:
- Ran gh issue view 133 --json body,updatedAt,title to confirm checklist item 45.
- Ran git diff --check and git diff --cached --check.
- Ran rebar3 ex_doc and confirmed the generated migration link target in doc/plugin.html.
- Ran rebar3 as test eunit --module=observer_cli_plugin_test,observer_cli_plugin_render_test,observer_cli_plugin_compat_test with 38 tests and 0 failures.
改动重点:
- Add Goal 46 evidence that records the plugin-focused EUnit run and full EUnit run after the plugin 2.0 API boundary work.
- Document that no Erlang source, tests, docs, generated docs, or built-in CLI page behavior changed in this validation-only slice.
- Note the known non-fatal render_state timeout warning and the deferred manual terminal QA boundary.

验证:
- Ran `gh issue view 133 --json number,title,updatedAt,url,body` to confirm issue #133 checklist item 46.
- Ran `rebar3 as test eunit --module=observer_cli_plugin_test,observer_cli_plugin_render_test,observer_cli_plugin_compat_test` with 38 tests and 0 failures.
- Ran `rebar3 eunit` with 352 tests and 0 failures.
- Ran `git diff --cached --check` before committing.
改动重点:
- Add a developer documentation page that maps 2.0 entry points, commands, collection, rendering, pagination, plugin, formatter, and snapshot-seam ownership.
- Include the new page in ExDoc extras and record Goal 47 validation evidence under `.agents/observer-cli-2-refactor/`.
- Keep the slice docs-only with no Erlang source, generated docs, README, changelog, plugin guide, formatter guide, or runtime behavior changes.

验证:
- Confirmed issue #133 checklist item 47 with `gh issue view`.
- Checked documented module and function names with focused `rg` searches over `src/`.
- Ran `git diff --check`, `rebar3 ex_doc`, generated-doc inclusion `rg`, and `git diff --cached --check`.
- Skipped EUnit and terminal QA because this docs-only slice changes no Erlang or runtime paths; the skip reason is recorded in the Goal 47 evidence file.
改动重点:
- Add a README 2.0 draft note limited to preserved CLI behavior, plugin API breaking changes, and future AI-friendly snapshots.
- Add a docs/CHANGELOG.md 2.0.0 draft entry and goal 48 evidence file.

验证:
- Confirmed issue #133 line 104 with gh.
- Ran git diff --check, rebar3 ex_doc, generated-doc rg checks, and git diff --cached --check.
- Did not run EUnit, compile, xref, covertool, or manual terminal QA because this docs-only slice changed no Erlang runtime paths; goal 49 owns the full validation bundle.
改动重点:
- Add Goal 49 evidence documenting the requested formatting, compile, CI compile, xref, EUnit, and covertool results.
- Record that no source or user-visible CLI behavior changed and that formatting produced no tracked diff.

验证:
- Ran rebar3 fmt, rebar3 compile, rebar3 as ci compile, rebar3 xref, rebar3 eunit, and epmd -daemon && rebar3 as test do eunit, covertool generate.
- Confirmed EUnit passed with 352 tests and covertool generated observer_cli.covertool.xml with line-rate 0.966.
- Ran git diff --check --cached and reviewed git status --short --branch before committing.
改动重点:
- Add Goal 50 evidence for the real PTY sweep of Home, System, Process, Port, Network, ETS, Mnesia, Application, Doc, and empty Plugin state.
- Record the exact normal-shell scope and skipped raw/remote/escript validation boundaries for neighboring goals.

验证:
- Ran `gh issue view 133 --json number,title,updatedAt,state,body` to confirm checklist item 50 scope.
- Ran `stty rows 40 cols 120; rebar3 shell`, then `observer_cli:start().` and manually inspected Home, System, Network, ETS, Mnesia, Application, Doc, empty Plugin, and Process Info in a real PTY.
- Ran a dedicated `rebar3 shell` PTY with a live `gen_tcp:listen/2` fixture and `observer_cli_port:start(LS, #view_opts{}).` to inspect Port Info.
- Ran `git status --short --branch`, reviewed the staged diff, and ran `git diff --cached --check`.
改动重点:
- Load dependency application metadata before collecting escript remote-load modules so simulated target nodes receive recon modules such as recon_lib.
- Add a focused regression test for unloaded recon metadata and record Goal 51 remote/escript startup evidence under .agents.

验证:
- Ran rebar3 fmt.
- Ran rebar3 as test eunit --module=observer_cli_escriptize_test,observer_cli_start_test, which passed 49 tests with only existing deprecated catch warnings.
- Ran simulated peer-node remote startup smoke, which returned remote_start_result=quit.
- Ran rebar3 escriptize and a piped escript startup smoke against a short-name target node without observer_cli code paths; the remote Home screen rendered and ended with quit without undef or ERROR REPORT output.
- Ran git diff --check, rebar3 compile, and rebar3 check.
改动重点:
- Add the Goal 52 final diff review evidence file covering the branch diff scope, stale local planning doc cleanup, and the decision to leave split-goal inputs for Goal 53.
- Confirm no tracked temporary helper modules, duplicated test fixtures, stale public docs, CLI behavior, or plugin API behavior changed in this slice.

验证:
- Ran `gh issue view 133 --json number,title,state,updatedAt,body` to confirm the checklist line.
- Ran `git diff --check main...HEAD`, `rebar3 fmt`, `rebar3 xref`, and `rebar3 eunit` with 353 tests and 0 failures.
- Ran stale-marker `rg` review and checked `git status --short --branch` before adding evidence.
改动重点:
- Add Goal 53 closeout evidence for the GitHub follow-up issue and #133 closure.
- Keep the repo diff limited to ignored .agents evidence; no CLI code, tests, or user-facing docs changed.

验证:
- Verified #134 is open and #133 is closed with gh issue view.
- Checked staged scope with git status --short --branch, git diff --cached --stat, and git diff --cached --check.
- Did not run rebar3 because this slice changed only closeout evidence.
Changes:
- Replace deprecated test-only catch expressions around Mnesia schema cleanup with try/catch blocks.
- Convert escriptize error-path assertions to try/catch or ?assertError so expected failures stay explicit without deprecated catch syntax.
- Suppress OTP net_address untyped-record noise locally in the system test module, matching the production module boundary.

Validation:
- Ran rebar3 fmt.
- Ran rebar3 ct -c -v and confirmed the reported warnings are gone.
- Ran rebar3 as test eunit --module=observer_cli_mnesia_test,observer_cli_escriptize_test,observer_cli_system_test with 70 tests and 0 failures.
- Ran rebar3 as ci compile.
- Ran rebar3 as test do eunit, cover with 353 tests and 0 failures.
- Ran git diff --check.
改动重点:
- Replace the selected-row green background with terminal inverse video so row text follows the user's terminal contrast settings.
- Keep the existing shared CHOOSE_BG marker aligned with inverse video for other row-selection paths.
- Add a focused TopN rendering assertion that selected rows contain inverse video and no longer emit the green background escape.

验证:
- Ran `rebar3 fmt --check`.
- Ran `rebar3 as test eunit --module=observer_cli_core_test,observer_cli_inet_test,observer_cli_plugin_test` with 81 tests and 0 failures.
- Ran `git diff --check`.
- Ran `rebar3 compile`.
- Did not run live Ghostty visual verification; change is limited to ANSI selection escapes and covered by focused rendering tests.
Change highlights:
- Add integration-leaning EUnit coverage for pager, home/process/app/ets/network/mnesia/plugin worker and manager paths, plugin API validation, Mnesia disc-only tables, and loopback TCP network rendering.
- Extend the test IO helper with delayed get_line replies so timer/redraw branches are exercised without changing production code.
- Keep runtime source files untouched while aggregate coverage reaches 2139/2160 lines, or 99.027778%.

Validation:
- Ran rebar3 fmt.
- Ran rebar3 eunit: 377 tests, 0 failures.
- Ran rebar3 cover: total 99%.
- Ran rebar3 covertool generate: line-rate 0.99, 2139/2160 lines.
- Ran rebar3 as ci compile.
- Ran git diff --check.
@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.56522% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.02%. Comparing base (48e2ae4) to head (65995b7).

Files with missing lines Patch % Lines
src/observer_cli.erl 98.44% 2 Missing ⚠️
src/observer_cli_plugin.erl 98.83% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #135      +/-   ##
===========================================
+ Coverage    92.37%   99.02%   +6.65%     
===========================================
  Files           17       19       +2     
  Lines         2058     2160     +102     
===========================================
+ Hits          1901     2139     +238     
+ Misses         157       21     -136     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zhongwencool zhongwencool merged commit 0b41126 into develop Jul 6, 2026
10 checks passed
@zhongwencool zhongwencool deleted the v2.x branch July 6, 2026 03:58
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