-
Notifications
You must be signed in to change notification settings - Fork 663
fix: cua unknow #1595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
fix: cua unknow #1595
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # CUA Settings Empty Message Plan | ||
|
|
||
| ## Scope | ||
|
|
||
| The issue is isolated to the static Computer Use plugin settings UI in | ||
| `plugins/cua/settings/assets/index.js`. | ||
|
|
||
| ## Implementation | ||
|
|
||
| - Keep `setText()` as the fallback helper for data rows that should display `Unknown`. | ||
| - Change `setMessage()` so the transient status/error area writes the provided text verbatim and | ||
| allows an empty string after success. | ||
| - Add a jsdom regression test that loads the static settings script, invokes the Check button, and | ||
| verifies the message area is empty after a successful permission check. | ||
|
|
||
| ## Test Strategy | ||
|
|
||
| - Run the focused renderer test for the plugin settings script. | ||
| - Run repository-required formatting, i18n, and lint checks. | ||
|
|
||
| ## Risks | ||
|
|
||
| - Low. The change only affects the bottom message element and keeps status rows unchanged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # CUA Settings Empty Message | ||
|
|
||
| ## User Story | ||
|
|
||
| As a user checking Computer Use plugin permissions, I want the plugin settings page to show the | ||
| permission results only in the status rows so that a completed check does not leave an unrelated | ||
| `Unknown` message at the bottom of the page. | ||
|
|
||
| ## Acceptance Criteria | ||
|
|
||
| - A successful permission check updates the Accessibility and Screen Recording rows. | ||
| - After a successful permission check with no diagnostic error, the bottom message area is empty. | ||
| - Runtime fields can still show `Unknown` when their underlying status values are unavailable. | ||
|
|
||
| ## Non-goals | ||
|
|
||
| - Redesigning the plugin settings layout. | ||
| - Changing runtime or permission detection behavior. | ||
|
|
||
| ## Open Questions | ||
|
|
||
| None. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| # CUA Settings Empty Message Tasks | ||
|
|
||
| - [x] Confirm the source of the bottom `Unknown` message. | ||
| - [x] Update message rendering to allow an empty success state. | ||
| - [x] Add focused regression coverage. | ||
| - [x] Run `pnpm run format`, `pnpm run i18n`, and `pnpm run lint`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| import { readFile } from 'node:fs/promises' | ||
| import { resolve } from 'node:path' | ||
| import { beforeEach, describe, expect, it, vi } from 'vitest' | ||
|
|
||
| const scriptPath = resolve(process.cwd(), 'plugins/cua/settings/assets/index.js') | ||
|
|
||
| const flushPromises = async (): Promise<void> => { | ||
| await new Promise((resolve) => setTimeout(resolve, 0)) | ||
| } | ||
|
|
||
| const renderSettingsDom = (): void => { | ||
| document.body.innerHTML = ` | ||
| <span id="plugin-state"></span> | ||
| <strong id="runtime-state"></strong> | ||
| <strong id="runtime-version"></strong> | ||
| <code id="runtime-command"></code> | ||
| <code id="runtime-helper-app"></code> | ||
| <strong id="mcp-state"></strong> | ||
| <strong id="permission-accessibility"></strong> | ||
| <strong id="permission-screen-recording"></strong> | ||
| <p id="message"></p> | ||
| <a id="project-link"></a> | ||
| <button id="check"></button> | ||
| <button id="guide"></button> | ||
| <button id="disable"></button> | ||
| ` | ||
| } | ||
|
|
||
| type CuaSettingsWindow = Window & { deepchatPlugin?: unknown } | ||
|
|
||
| describe('CUA plugin settings', () => { | ||
| beforeEach(() => { | ||
| renderSettingsDom() | ||
| delete (window as CuaSettingsWindow).deepchatPlugin | ||
| }) | ||
|
|
||
| it('clears the bottom message after a successful permission check', async () => { | ||
| const pluginWindow = window as CuaSettingsWindow | ||
|
|
||
| pluginWindow.deepchatPlugin = { | ||
| getStatus: vi.fn().mockResolvedValue({ | ||
| enabled: true, | ||
| runtime: { | ||
| state: 'ready', | ||
| version: '0.1.5', | ||
| command: '/mock/cua-driver', | ||
| helperAppPath: '/mock/DeepChat Computer Use.app' | ||
| }, | ||
| mcpServers: [ | ||
| { | ||
| serverId: 'cua-driver', | ||
| enabled: true, | ||
| running: true | ||
| } | ||
| ] | ||
| }), | ||
| invokeAction: vi.fn().mockResolvedValue({ | ||
| ok: true, | ||
| data: { | ||
| accessibility: 'granted', | ||
| screenRecording: 'denied' | ||
| } | ||
| }), | ||
| disable: vi.fn() | ||
| } | ||
|
|
||
| window.eval(await readFile(scriptPath, 'utf8')) | ||
| await flushPromises() | ||
|
|
||
| document.getElementById('check')?.click() | ||
| await flushPromises() | ||
|
|
||
| expect(document.getElementById('permission-accessibility')?.textContent).toBe('Granted') | ||
| expect(document.getElementById('permission-screen-recording')?.textContent).toBe('Denied') | ||
| expect(document.getElementById('message')?.textContent).toBe('') | ||
| }) | ||
| }) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: ThinkInAIXYZ/deepchat
Length of output: 162
Replace
window.evalto avoid security lint failure.Line 67 uses
window.eval, which is flagged bylint/security/noGlobalEvaland will fail required lint checks.🔧 Proposed fix (load script via ESM import)
📝 Committable suggestion
🧰 Tools
🪛 Biome (2.4.14)
[error] 67-67: eval() exposes to security risks and performance issues.
(lint/security/noGlobalEval)
🤖 Prompt for AI Agents