fix(dsh): preserve acrylic and restore durable native model settings
Core regression / Python core and release configuration (push) Successful in 15s
Core regression / JavaScript syntax (push) Successful in 3s
Core regression / Python core and release configuration (pull_request) Successful in 15s
Core regression / JavaScript syntax (pull_request) Successful in 3s
Core regression / Python core and release configuration (push) Successful in 15s
Core regression / JavaScript syntax (push) Successful in 3s
Core regression / Python core and release configuration (pull_request) Successful in 15s
Core regression / JavaScript syntax (pull_request) Successful in 3s
This commit is contained in:
1 parent
3cec9adc5f
commit
374e1cd5bf
11 files changed
+262
-17
No files matched your search
@@ -29,6 +29,7 @@ from dx_productivity.trial_task_center.target_plan import ComponentTarget,Target
|
||||
def main():
|
||||
parser=argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--output',type=Path,default=Path('build/acrylic-acceptance'))
|
||||
parser.add_argument('--dsh-switch',action='store_true',help='Measure live Acrylic after entering the actual DSH WebEngine page')
|
||||
args=parser.parse_args();out=args.output.resolve();out.mkdir(parents=True,exist_ok=True)
|
||||
app=QApplication([]);app.setFont(QFont('Microsoft YaHei UI',9))
|
||||
def settle(seconds=.2):
|
||||
@@ -80,6 +81,9 @@ def main():
|
||||
assert window.property('acrylicEnabled'),'Native Acrylic not available under current system policy'
|
||||
report['native_enabled']=True
|
||||
def capture(name):
|
||||
report.setdefault('surfaces',{})[name]={
|
||||
'hwnd':int(window.winId()),'translucent':window.testAttribute(Qt.WidgetAttribute.WA_TranslucentBackground),
|
||||
'alpha':window.windowHandle().format().alphaBufferSize(),'acrylic':window.property('acrylicEnabled')}
|
||||
settle(.7)
|
||||
QToolTip.hideText();settle(.12)
|
||||
geo=window.geometry();scale=screen.devicePixelRatio()
|
||||
@@ -121,6 +125,40 @@ def main():
|
||||
assert report['right_header_backdrop_difference']>2,report
|
||||
assert report['right_execution_backdrop_difference']>2,report
|
||||
assert report['opaque_table_backdrop_difference']<1.5,report
|
||||
if args.dsh_switch:
|
||||
from PySide6.QtTest import QTest
|
||||
QTest.mouseClick(window.dsh_navigation,Qt.MouseButton.LeftButton)
|
||||
deadline=time.monotonic()+120
|
||||
while time.monotonic()<deadline:
|
||||
settle(.1)
|
||||
if window._dsh_view is not None and window._dsh_view._started:break
|
||||
assert window._dsh_view is not None and window._dsh_view._started,'DSH did not start'
|
||||
# READY precedes the Chromium load; require the real visible page.
|
||||
loaded=[]
|
||||
window._dsh_view.web.page().runJavaScript("document.body?.innerText?.includes('DSH助手')",loaded.append)
|
||||
deadline=time.monotonic()+60
|
||||
while time.monotonic()<deadline:
|
||||
settle(.1)
|
||||
if loaded and loaded[-1]:break
|
||||
if loaded:
|
||||
loaded.clear()
|
||||
window._dsh_view.web.page().runJavaScript("document.body?.innerText?.includes('DSH助手')",loaded.append)
|
||||
assert loaded and loaded[-1],'Official DSH UI did not load'
|
||||
capture('dsh-before-return')
|
||||
QTest.mouseClick(window.task_center_navigation,Qt.MouseButton.LeftButton)
|
||||
settle(.5)
|
||||
background.phase=0;background.update();capture('returned-backdrop-a')
|
||||
background.phase=1;background.update();capture('returned-backdrop-b')
|
||||
returned=ImageChops.difference(captures['returned-backdrop-a'],captures['returned-backdrop-b'])
|
||||
assert report['surfaces']['native-app-backdrop-a']['hwnd']==report['surfaces']['returned-backdrop-a']['hwnd'],report
|
||||
report['after_dsh_sidebar_difference']=mean(returned.crop(sidebar))
|
||||
report['after_dsh_header_difference']=mean(returned.crop(header))
|
||||
report['after_dsh_table_difference']=mean(returned.crop(table))
|
||||
(out/'surface-probe.json').write_text(json.dumps(report,indent=2),encoding='utf8')
|
||||
assert report['after_dsh_sidebar_difference']>2,report
|
||||
assert report['after_dsh_header_difference']>2,report
|
||||
assert report['after_dsh_table_difference']<1.5,report
|
||||
report['real_dsh_switch_restored_acrylic']=True
|
||||
window.plan_panel.find_text.setText('RV');window.plan_panel.find()
|
||||
report['visible_search_feedback']=window.plan_panel.find_result.isVisible()
|
||||
assert '2 / 6'in window.plan_panel.find_result.text()
|
||||
@@ -158,7 +196,11 @@ def main():
|
||||
window._finish_run();window._update_gates()
|
||||
window.project_options_button.setChecked(True);settle(.2)
|
||||
report['options_exposed']=window.run_panel.copy_value_check.isVisible()
|
||||
window.plan_panel.discard_all();window.close();settle(.3);store.close();logging.shutdown()
|
||||
window.plan_panel.discard_all();window.close()
|
||||
deadline=time.monotonic()+15
|
||||
while window.isVisible() and time.monotonic()<deadline:settle(.1)
|
||||
assert not window.isVisible(),'Window did not finish shutdown'
|
||||
settle(.3);store.close();logging.shutdown()
|
||||
background.close();app.processEvents()
|
||||
(out/'acceptance.json').write_text(json.dumps(report,ensure_ascii=False,indent=2)+'\n',encoding='utf-8')
|
||||
print(json.dumps(report,ensure_ascii=True))
|
||||
|
||||
@@ -32,6 +32,7 @@ def main():
|
||||
parser.add_argument('--port', type=int, default=9227)
|
||||
parser.add_argument('--provider-config', type=Path)
|
||||
parser.add_argument('--live-model', action='store_true')
|
||||
parser.add_argument('--model-settings-check', action='store_true', help='Create an isolated custom provider using a local model-list fixture')
|
||||
parser.add_argument('--incident', action='store_true', help='Inject a read-only controlled failure and verify automatic diagnosis and Git escalation')
|
||||
parser.add_argument('--outbox-only', action='store_true', help='Verify failed publication stays in local outbox without creating another real issue')
|
||||
parser.add_argument('--without-git', action='store_true', help='Simulate a client with no Git credentials or executable')
|
||||
@@ -146,6 +147,8 @@ def main():
|
||||
command = ['node', str(REPO / 'tools' / script), str(output), str(args.port), '--confirm-cancel']
|
||||
if args.live_model:
|
||||
command.append('--live-model')
|
||||
if args.model_settings_check:
|
||||
command.append('--model-settings-check')
|
||||
if args.outbox_only:
|
||||
command.append('--outbox-only')
|
||||
state['child'] = subprocess.Popen(command, cwd=REPO, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/** Real settings form, provider discovery and persistence against an owned fixture. */
|
||||
import assert from 'node:assert/strict';
|
||||
import {createServer} from 'node:http';
|
||||
import path from 'node:path';
|
||||
|
||||
export async function verifyModelSettings(c, output) {
|
||||
const requests=[];
|
||||
const server=createServer((req,res)=>{
|
||||
requests.push({method:req.method,path:req.url});
|
||||
res.writeHead(req.url==='/v1/models'?200:404,{'Content-Type':'application/json'});
|
||||
res.end(JSON.stringify({object:'list',data:[{id:'issue16-fixture-model',object:'model',owned_by:'acceptance'}]}));
|
||||
});
|
||||
await new Promise(resolve=>server.listen(0,'127.0.0.1',resolve));
|
||||
const endpoint=`http://127.0.0.1:${server.address().port}/v1`;
|
||||
const visible=selector=>`[...document.querySelectorAll(${JSON.stringify(selector)})].find(e=>e.getBoundingClientRect().width>0)`;
|
||||
const button=text=>`[...document.querySelectorAll('button')].find(e=>e.getBoundingClientRect().width>0&&e.textContent.trim()===${JSON.stringify(text)})`;
|
||||
async function wait(expression){
|
||||
const end=Date.now()+20000;
|
||||
while(Date.now()<end){if(await c.evaluate(expression))return;await new Promise(r=>setTimeout(r,100));}
|
||||
throw Error('Models acceptance timed out: '+expression);
|
||||
}
|
||||
async function type(selector,text){
|
||||
await c.click(visible(selector));
|
||||
await c.call('Input.insertText',{text});
|
||||
await wait(`(${visible(selector)})?.value===${JSON.stringify(text)}`);
|
||||
}
|
||||
try{
|
||||
// The caller has reached the actual upstream Custom model API form.
|
||||
await type('input[aria-label="Provider ID"]','issue16-fixture');
|
||||
await type('input[aria-label="API 地址"]',endpoint);
|
||||
const protocol='select[aria-label="API 协议"]';
|
||||
// This is a native keyboard selection, not a direct settings RPC.
|
||||
const choices=await c.evaluate(`[...(${visible(protocol)}).options].map(x=>x.value)`);
|
||||
const target=choices.indexOf('openai-completions');
|
||||
assert.ok(target>=0);
|
||||
await c.click(visible(protocol));
|
||||
await c.call('Input.dispatchKeyEvent',{type:'keyDown',key:'Home',code:'Home',windowsVirtualKeyCode:36});
|
||||
await c.call('Input.dispatchKeyEvent',{type:'keyUp',key:'Home',code:'Home',windowsVirtualKeyCode:36});
|
||||
for(let i=0;i<target;i++){
|
||||
await c.call('Input.dispatchKeyEvent',{type:'keyDown',key:'ArrowDown',code:'ArrowDown',windowsVirtualKeyCode:40});
|
||||
await c.call('Input.dispatchKeyEvent',{type:'keyUp',key:'ArrowDown',code:'ArrowDown',windowsVirtualKeyCode:40});
|
||||
}
|
||||
await c.call('Input.dispatchKeyEvent',{type:'keyDown',key:'Enter',code:'Enter',windowsVirtualKeyCode:13});
|
||||
await c.call('Input.dispatchKeyEvent',{type:'keyUp',key:'Enter',code:'Enter',windowsVirtualKeyCode:13});
|
||||
await wait(`(${visible(protocol)}).value==='openai-completions'`);
|
||||
await c.click(button('获取可用模型'));
|
||||
await wait(`document.body.innerText.includes('issue16-fixture-model')`);
|
||||
assert.deepEqual(requests,[{method:'GET',path:'/v1/models'}]);
|
||||
const candidate=`[...document.querySelectorAll('[role="dialog"] label')].find(e=>e.textContent.includes('issue16-fixture-model'))?.querySelector('input[type="checkbox"]')`;
|
||||
if(!await c.evaluate(`(${candidate})?.checked`))await c.click(candidate);
|
||||
assert.equal(await c.evaluate(`(${candidate})?.checked`),true);
|
||||
await c.click(button('添加所选'));
|
||||
await wait(`!![...document.querySelectorAll('input')].find(x=>x.value==='issue16-fixture-model')`);
|
||||
await c.screenshot(path.join(output,'custom-model-discovery.png'));
|
||||
await c.click(button('创建提供商'));
|
||||
await wait(`!document.querySelector('input[aria-label="Provider ID"]')`);
|
||||
await wait(`document.body.innerText.includes('issue16-fixture')`);
|
||||
// Reopen the real editor to read committed fields, not the submitted draft.
|
||||
await c.click(`[...document.querySelectorAll('li')].find(e=>e.textContent.includes('issue16-fixture'))?.querySelector('button')`);
|
||||
await wait(`document.body.innerText.includes('自定义设置')`);
|
||||
await c.click(`[...document.querySelectorAll('summary')].find(e=>e.textContent.includes('自定义设置'))`);
|
||||
await wait(`!![...document.querySelectorAll('input')].find(x=>x.value==='issue16-fixture-model')`);
|
||||
await c.screenshot(path.join(output,'custom-model-persisted.png'));
|
||||
return {status:'passed',provider:'issue16-fixture',model:'issue16-fixture-model',requests,
|
||||
credentialsUsed:false,remoteModelCalls:false};
|
||||
}finally{
|
||||
server.closeAllConnections();await new Promise(resolve=>server.close(resolve));
|
||||
}
|
||||
}
|
||||
@@ -33,9 +33,21 @@ try {
|
||||
assert.equal(await c.evaluate(`${accountEntries}.length`),0);
|
||||
report.checks.push('one click opens native tool settings with DSH capabilities and no account entry');
|
||||
await c.screenshot(path.join(output,'dsh-tool-settings.png'));
|
||||
await c.call('Input.dispatchKeyEvent',{type:'keyDown',key:'Escape',code:'Escape'});
|
||||
await c.call('Input.dispatchKeyEvent',{type:'keyUp',key:'Escape',code:'Escape'});
|
||||
await wait(`!document.querySelector('[data-testid="dx-tool-settings-panel"]')`);
|
||||
await c.click(`[...document.querySelectorAll('[data-shortcut-modal="settings"] nav button')].find(e=>e.textContent.trim()==='模型')`);
|
||||
await wait(`document.body.innerText.includes('自定义模型 API')||document.body.innerText.includes('添加模型提供商')`);
|
||||
if(!await c.evaluate(`document.body.innerText.includes('自定义模型 API')`))
|
||||
await c.click(`[...document.querySelectorAll('button')].find(e=>e.textContent.includes('添加模型提供商'))`);
|
||||
await wait(`document.body.innerText.includes('自定义模型 API')`);
|
||||
await c.click(`[...document.querySelectorAll('button')].find(e=>e.textContent.trim()==='自定义模型 API')`);
|
||||
await wait(`!!document.querySelector('input[aria-label="Provider ID"]')&&document.body.innerText.includes('获取可用模型')`);
|
||||
report.checks.push('actual model settings clicks reveal custom API and fetch-model controls');
|
||||
await c.screenshot(path.join(output,'dsh-custom-model-settings.png'));
|
||||
if(process.argv.includes('--model-settings-check')){
|
||||
const {verifyModelSettings}=await import('./verify_dsh_model_settings.mjs');
|
||||
report.modelSettings=await verifyModelSettings(c,output);
|
||||
}
|
||||
await c.click(`[...document.querySelectorAll('[data-shortcut-modal="settings"] button')].find(e=>e.textContent.trim()==='关闭')`);
|
||||
await wait(`!document.querySelector('[role="dialog"]')`);
|
||||
await c.screenshot(path.join(output,'dsh-tool-home.png'));
|
||||
const context=await c.evaluate(`fetch('/dx/context').then(r=>r.json())`);
|
||||
assert.ok(context.task_id,'Select a task in the task center before running this test.');
|
||||
@@ -92,7 +104,7 @@ try {
|
||||
report.checks.push('real API reply rendered through the official Harness conversation');
|
||||
await c.click(`document.querySelector('[contenteditable="true"]')`);
|
||||
await c.call('Input.insertText',{text:'请分析当前任务的下一步。'});
|
||||
} else report.reason='No model credential configured in this isolated acceptance profile.';
|
||||
} else report.reason='Live model generation was not requested for this acceptance run.';
|
||||
await c.screenshot(path.join(output,'dsh-native-final.png'));
|
||||
if(process.argv.includes('--confirm-cancel')) {
|
||||
await c.click(`[...document.querySelectorAll('button')].find(e=>e.textContent.trim()==='准备失败项重试')`);
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/** Boot the actual Harness over native user settings and a legacy profile. */
|
||||
import assert from 'node:assert/strict';
|
||||
import {mkdtemp,mkdir,readFile,writeFile,readdir} from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import {bootRuntime,overlay,prepareProfileDirectory} from '../integration/dsh/start.mjs';
|
||||
|
||||
const output=path.resolve('build/dsh-profile-settings-verification');
|
||||
await mkdir(output,{recursive:true});
|
||||
const base=await mkdtemp(path.join(output,'run-'));
|
||||
process.env.DX_DSH_HOME=path.join(base,'home');
|
||||
process.env.DX_DSH_CONTEXT_FILE=path.join(base,'context.json');
|
||||
await writeFile(process.env.DX_DSH_CONTEXT_FILE,JSON.stringify({task_id:'',revision:'settings-test',status:'observe'}));
|
||||
const dir=path.join(process.env.DX_DSH_HOME,'profiles/dx-task');
|
||||
await mkdir(dir,{recursive:true});
|
||||
const profile=[{id:'llm-pi-ai',config:{providers:{'profile-fixture':{
|
||||
api:'openai-completions',baseURL:'http://127.0.0.1:1/v1',models:[{id:'persisted-fixture-model'}]}}}}];
|
||||
const patch=path.join(dir,'cordis.patch.yml');
|
||||
const original='# Native user settings\n'+JSON.stringify(profile,null,2)+'\n';
|
||||
await writeFile(patch,original);
|
||||
await prepareProfileDirectory(dir);await prepareProfileDirectory(dir);
|
||||
assert.equal(await readFile(patch,'utf8'),original,'application preparation must not rewrite a native user layer');
|
||||
const legacyDir=path.join(base,'legacy');
|
||||
await mkdir(legacyDir,{recursive:true});
|
||||
const old=JSON.stringify([...overlay(),...profile],null,2);
|
||||
await writeFile(path.join(legacyDir,'cordis.patch.yml'),old);
|
||||
await prepareProfileDirectory(legacyDir);
|
||||
const migrated=await readFile(path.join(legacyDir,'cordis.patch.yml'),'utf8');
|
||||
assert.ok(JSON.parse(migrated).some(x=>x.id==='llm-pi-ai'&&x.config.providers['profile-fixture']));
|
||||
const backups=(await readdir(legacyDir)).filter(x=>x.includes('.legacy-'));
|
||||
assert.equal(backups.length,1);
|
||||
assert.equal(await readFile(path.join(legacyDir,backups[0]),'utf8'),old);
|
||||
await prepareProfileDirectory(legacyDir);
|
||||
assert.equal(await readFile(path.join(legacyDir,'cordis.patch.yml'),'utf8'),migrated);
|
||||
const {ctx,shutdown}=await bootRuntime({announce:false});
|
||||
try{
|
||||
assert.deepEqual((await ctx.llm.listModels('profile-fixture')).map(x=>x.id),['persisted-fixture-model']);
|
||||
assert.equal(ctx.tools.schemas().length,7);
|
||||
console.log(JSON.stringify({status:'passed',nativeSettingsPreserved:true,actualProviderRestored:true,
|
||||
legacyMigrationPreservedModels:true,byteBackup:true,modelRequests:0}));
|
||||
}finally{await shutdown.shutdown(0);}
|
||||
Reference in new issue
Block a user