Feature: Report activity history on Linux clients
Implement COMMAND_QUERY_ACTIVITY -> TOKEN_REPORT_ACTIVITY with two backends picked at startup. With a desktop, a sampler thread reads the foreground window every second and books dwell time like the Windows client: under five seconds is dropped, five idle minutes close the window, the last 500 records stay newest first, each line being "[YYYY-MM-DD HH:MM:SS] [title] duration". It uses its own ActivityChecker because an Xlib connection cannot be shared with the heartbeat thread, and it is stopped before main's locals go away. A reachable X server is not enough: the window backend is only chosen when the root window carries _NET_SUPPORTING_WM_CHECK, so Xvfb or a bare X without an EWMH window manager falls back to the headless backend instead of sampling a window id that never appears. Without a desktop the answer is computed on demand: logins from "last -n 100 -F" plus bash/zsh history of root and /home/*, tagged [登录] or [命令] after a [来源] header. Both halves are merged and sorted by timestamp; three fifths of the budget goes to logins and reboot records are capped at ten, since a WSL or container writes one reboot per start. activity_commands=0 drops the command half. A single detached thread builds and sends it, only while the main link is up. The MCP gate now admits Linux for get_activity_history and documents both shapes. test/unit/linux covers the parsers, ordering and UTF-8 truncation; 15 cases pass. Co-Authored-By: deepseek-flash
This commit is contained in:
1 parent
5f40f3726c
commit
d8048979e3
6 files changed
+940
-14
No files matched your search
+22
-1
@@ -343,6 +343,26 @@ if(UNIX)
|
||||
target_link_libraries(quality_load_test Threads::Threads)
|
||||
endif()
|
||||
|
||||
# ============================================
|
||||
# Linux 历史活动(无头后端)解析测试
|
||||
# 直接 include 真实的 linux/LinuxActivityHistory.h,不复制实现;窗口后端要 X11,不在这里测
|
||||
# ============================================
|
||||
add_executable(linux_activity_test
|
||||
unit/linux/ActivityHistoryTest.cpp
|
||||
)
|
||||
|
||||
target_include_directories(linux_activity_test PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../linux
|
||||
)
|
||||
|
||||
target_link_libraries(linux_activity_test
|
||||
GTest::gtest_main
|
||||
)
|
||||
|
||||
if(UNIX)
|
||||
target_link_libraries(linux_activity_test Threads::Threads)
|
||||
endif()
|
||||
|
||||
# ============================================
|
||||
# 时间验证测试 (授权模块)
|
||||
# ============================================
|
||||
@@ -416,6 +436,7 @@ gtest_discover_tests(rgb565_test)
|
||||
gtest_discover_tests(scroll_detector_test)
|
||||
gtest_discover_tests(quality_adaptive_test)
|
||||
gtest_discover_tests(quality_load_test)
|
||||
gtest_discover_tests(linux_activity_test)
|
||||
gtest_discover_tests(date_verify_test)
|
||||
|
||||
# 自定义目标:运行所有测试
|
||||
@@ -425,5 +446,5 @@ add_custom_target(run_tests
|
||||
file_transfer_test chunk_manager_test sha256_verify_test resume_state_test
|
||||
header_test packet_fragment_test http_mask_test
|
||||
diff_algorithm_test rgb565_test scroll_detector_test quality_adaptive_test
|
||||
quality_load_test date_verify_test
|
||||
quality_load_test linux_activity_test date_verify_test
|
||||
)
|
||||
Reference in new issue
Block a user