fix(shared): persist and reuse MCP report name across platform reconnects#2305
fix(shared): persist and reuse MCP report name across platform reconnects#2305yuyutaotao wants to merge 3 commits intomainfrom
Conversation
Deploying midscene with
|
| Latest commit: |
69a4a1e
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://ca2fe4d5.midscene.pages.dev |
| Branch Preview URL: | https://codex-add-report-name-handli.midscene.pages.dev |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2948b1b8ec
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const REPORT_NAME_STATE_FILE = 'current-report-name'; | ||
|
|
||
| function getReportNameStateFilePath() { | ||
| return path.join(getMidsceneRunBaseDir(), REPORT_NAME_STATE_FILE); |
There was a problem hiding this comment.
Isolate persisted report name per MCP session
Persisting the active report to a single global file (midscene_run/current-report-name) makes every new MCP connection in the same working directory reuse the same report indefinitely, because this state is never scoped or rotated. In practice, unrelated runs (or a second MCP client started later) will append into prior sessions, merging independent executions and corrupting report boundaries/results.
Useful? React with 👍 / 👎.
Motivation
act/agent executions append to a single report instead of creating duplicates.midscene_runto communicate the currentreportFileNamebetween separate CLI/process invocations.Description
packages/shared/src/mcp/report-file-name.tswithreadPersistedReportFileName()andpersistReportFileName()to read/write./midscene_run/current-report-name.packages/shared/src/mcp/index.tsand addreportFileName?: stringto theBaseAgenttype inpackages/shared/src/mcp/types.ts.BaseMidsceneToolswithgetPersistedReportFileName()andpersistAgentReportFileName()to centralize reading and writing the persisted name inpackages/shared/src/mcp/base-tools.ts.reportFileNameinto agent creation and persist the agent'sreportFileNameafter initialization for Web (bridge/puppeteer/CDP), iOS, Android, and Computer MCP tool managers (updated files underpackages/web-integration,packages/ios,packages/android,packages/computer).packages/shared/tests/unit-test/report-file-name.test.tscovering normal read/write and empty-name validation.Testing
pnpm run lintwhich completed successfully.pnpm --filter @midscene/shared exec vitest --run tests/unit-test/report-file-name.test.tsand it passed.npx nx build @midscene/shared,@midscene/ios,@midscene/computer, and@midscene/web, all succeeded in this environment.npx nx build @midscene/androidfailed in this environment due to networkENETUNREACHduring the scrcpy prebuild download (environment-specific, unrelated to code change).npx nx test @midscene/sharedin this environment reported failures in unrelated existing shared tests that require extra prebuilt artifacts (IIFE bundle / tool-generator), while the new focused tests passed.Codex Task