Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,25 @@ jobs:
args.write_text(json.dumps(data, indent=2) + '\n')
PYTHON

- name: Create or upload the release assets
- name: Update existing release assets
if: steps.preflight.outputs.existing_release == 'true'
run: |
python3 - <<'PYTHON'
import os, subprocess
from pathlib import Path
groups = [sorted(Path('firmware').glob(pattern)) for pattern in ('**/*.bin', '**/flasher_args.json', '**/*.zip')]
if any(not files for files in groups):
raise SystemExit('A required release asset pattern matched no files')
subprocess.run(['gh', 'release', 'upload', os.environ['RELEASE_TAG'],
*[str(path) for files in groups for path in files],
'--clobber', '--repo', os.environ['GITHUB_REPOSITORY']], check=True)
PYTHON
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ steps.preflight.outputs.tag }}

- name: Create the first release for a new version
if: steps.preflight.outputs.existing_release == 'false'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.preflight.outputs.tag }}
Expand Down
22 changes: 13 additions & 9 deletions components/ts_webui/web/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,15 @@ input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-

/* ===== 页面:系统(设备面板 / 风扇 / LED) ===== */
.acts{align-items:center}
.page-system{container:system-page / inline-size}
.sys-mid{display:grid;grid-template-columns:minmax(0,1fr) clamp(340px,24vw,420px);gap:16px;align-items:stretch;flex:none}
.sys-mid>.card{display:flex;flex-direction:column}
.card.in{background:rgba(255,255,255,.62);border-radius:var(--r-inner)}
.empty{padding:20px 0;text-align:center;color:var(--ink-3)}
.device-panel{container:device-panel / inline-size}
/* Shared tracks: a model and a one-cell widget always have the same width. */
.qa-grid,.dw-grid{--device-columns:1;--widget-medium-span:1;--widget-large-span:1;display:grid;grid-template-columns:repeat(var(--device-columns),minmax(0,1fr));gap:12px}
.qa-grid>.empty{grid-column:1/-1}
/* Controls need 289px; round to 292px and keep cells stable as column count changes. */
.qa-grid,.dw-grid{--device-columns:1;--widget-medium-span:1;--widget-large-span:1;display:grid;grid-template-columns:repeat(var(--device-columns),minmax(0,292px));gap:12px}
.qa-grid,.dw-grid{container-type:inline-size}
.qa-grid>.empty{grid-column:1/-1;width:100cqi}
.quick-action-card{display:flex;flex-direction:column;justify-content:flex-start;gap:6px;background:rgba(255,255,255,.62);border-radius:var(--r-inner);padding:16px;min-width:0;cursor:default}
.quick-action-card[data-allowed=true]:hover{background:rgba(255,255,255,.8)}
.quick-action-head,.quick-action-foot{display:flex;align-items:center;justify-content:space-between;gap:8px;min-width:0}
Expand All @@ -286,10 +287,12 @@ input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-
.dw-card>.t-label>.i{flex:none}
.dw-card[data-type=log][data-layout=auto],.dw-layout-medium{grid-column:span var(--widget-medium-span)}
.dw-layout-large{grid-column:span var(--widget-large-span)}
.dw-layout-full{grid-column:1/-1}
/* The labelled controls need 289px including padding; round to the 4px grid. */
@container device-panel (min-width:596px){.qa-grid,.dw-grid{--device-columns:2;--widget-medium-span:2;--widget-large-span:2}}
@container device-panel (min-width:900px){.qa-grid,.dw-grid{--device-columns:3;--widget-large-span:3}}
.dw-layout-full{grid-column:1/-1;width:100cqi}
/* One shared container avoids adding columns again when the fan moves below.
Two cells need 596px + 40px panel padding; three beside the fan need
900px + 40px panel padding + 16px gap + 340px fan = 1296px. */
@container system-page (min-width:636px){.qa-grid,.dw-grid{--device-columns:2;--widget-medium-span:2;--widget-large-span:2}}
@container system-page (min-width:1296px){.qa-grid,.dw-grid{--device-columns:3;--widget-large-span:3}}
.dw-ring{display:grid;place-items:center;width:100%;min-height:64px;margin:8px 0 2px}
.dw-ring>svg,.dw-ring-value{grid-area:1/1}
.dw-ring>svg{max-width:100%}
Expand Down Expand Up @@ -590,7 +593,8 @@ input[type=color].swi::-webkit-color-swatch{border:0;border-radius:50%}
.led-grid,.net-tiles{grid-template-columns:repeat(2,minmax(0,1fr))}
.led-grid>:last-child:nth-child(odd),.net-tiles>:last-child:nth-child(odd){grid-column:1/-1}
}
@media (max-width:1389px){
/* Two device cells (596px), panel padding (40px), gap (16px), fan (340px). */
@container system-page (width < 992px){
.sys-mid{grid-template-columns:minmax(0,1fr)}
.fan-body{display:grid;grid-template-columns:minmax(0,1.3fr) minmax(0,1fr);grid-template-areas:"fan status" "fan test";gap:16px 32px;align-content:start}
.fan-body>.fans-grid{grid-area:fan;max-width:560px}
Expand Down
21 changes: 19 additions & 2 deletions tests/ci/test_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ def get(path):
if '/releases/' in path:return {'tag_name':'v0.6.3'}
if '/compare/' in path:return {'status':status} if status else None
return {'object':{'type':'commit','sha':'old'}}
if status=='ahead':self.assertTrue(release.prepare_release(profile.UPSTREAM,'main','v0.6.3','new',get)[0])
if status=='ahead':
state=release.prepare_release(profile.UPSTREAM,'main','v0.6.3','new',get)
self.assertTrue(state[0]);self.assertTrue(state[2])
else:
with self.assertRaises(ValueError):release.prepare_release(profile.UPSTREAM,'main','v0.6.3','new',get)
for mode in ('tag','published'):
Expand All @@ -138,8 +140,23 @@ def test_tag_write_disallows_force(self):
request=call.call_args.args[0]
self.assertEqual(request.method,'PATCH');self.assertEqual(json.loads(request.data),{'sha':'new','force':False})

def test_preflight_outputs_existing_release_for_the_upload_route(self):
from unittest.mock import patch
for existing in (True,False):
with self.subTest(existing=existing),tempfile.TemporaryDirectory() as folder:
output=Path(folder)/'outputs'
env={'GITHUB_EVENT_NAME':'push','GITHUB_REF':'refs/heads/main',
'BUILD_VERSION':'0.6.5+fixture','BUILD_COMMIT':'new',
'GITHUB_REPOSITORY':profile.UPSTREAM,'GITHUB_OUTPUT':str(output)}
with patch.dict(os.environ,env),patch.object(release,'validate_security_artifacts',return_value={'version':env['BUILD_VERSION']}),patch.object(release.subprocess,'check_output',return_value='new\n'),patch.object(release,'prepare_release',return_value=(existing,'fixture',existing)),patch.object(release,'advance_tag') as advance:
release.main()
self.assertEqual(output.read_text(),f'tag=v0.6.5\nexisting_release={str(existing).lower()}\n')
if existing:advance.assert_called_once_with(profile.UPSTREAM,'v0.6.5','new')
else:advance.assert_not_called()

def test_main_new_release_allows_absent_tag_but_refuses_wrong_commit(self):
self.assertFalse(release.prepare_release(profile.UPSTREAM,'main','v0.6.1','new',lambda path:None)[0])
state=release.prepare_release(profile.UPSTREAM,'main','v0.6.1','new',lambda path:None)
self.assertFalse(state[0]);self.assertFalse(state[2])
for commit in ('new','old'):
def get(path):return None if '/releases/' in path else {'object':{'type':'commit','sha':commit}}
if commit=='new':self.assertFalse(release.prepare_release(profile.UPSTREAM,'main','v0.6.1','new',get)[0])
Expand Down
6 changes: 5 additions & 1 deletion tests/prompts/configuration.browser.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,11 @@ test('empty, loading and unavailable states retain the dashboard widget and appr
await kit.withPage(lang,call=>call.endpoint==='automation/rules/list'?{code:0,data:{...d.status(),rules:[],loaded:mode==='empty',load_error:mode==='unavailable'?'configuration_unavailable':''}}:d.respond(call),async({page})=>{
await page.evaluate(async role=>{api.level=role;await loadSystemPage();await refreshQuickActions();},role);
const grid=page.locator('#quick-actions-grid');assert.equal(await grid.isVisible(),true);
assert(await grid.evaluate(e=>Math.abs(e.firstElementChild.getBoundingClientRect().width-e.getBoundingClientRect().width)<1),'notice spans the widget width');
for(const width of [390,1049,1050,1389,1440,2560]){
await page.setViewportSize({width,height:900});
assert(await grid.evaluate(e=>Math.abs(e.firstElementChild.getBoundingClientRect().width-e.getBoundingClientRect().width)<1),`notice spans the widget width at ${width}px`);
assert(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth),`notice does not overflow at ${width}px`);
}
assert.equal(await grid.locator('button').count(),role==='root'?1:0);
if(mode==='unavailable'){
assert.match(await grid.innerText(),lang==='zh-CN'?/配置无法读取/:/could not be read/);
Expand Down
42 changes: 32 additions & 10 deletions tests/prompts/widgets-layout.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ before(async()=>{browser=await chromium.launch({channel:'chrome',headless:true})
after(async()=>{await browser?.close();});
async function fixture(width,language='en-US'){
const page=await browser.newPage({viewport:{width,height:1000}});
await page.setContent(`<style>${css}</style><main style="padding:16px"><section class="device-panel"><div class="dw-grid" id="grid"></div></section></main>`);
await page.setContent(`<style>${css}</style><main class="page-system" style="padding:16px"><section class="card device-panel"><div class="dw-grid" id="grid"></div></section></main>`);
await page.addScriptTag({content:iconHelpers+'\n'+functions+`;window.i18n={registerLanguage:(id,data)=>window.language=data};window.escapeHtml=s=>s;window.sanitizeWidgetIcon=()=>'';`});
await page.addScriptTag({content:fs.readFileSync(path.join(root,'js/lang',language+'.js'),'utf8')});
await page.evaluate(()=>{window.t=key=>key.split('.').reduce((o,k)=>o?.[k],window.language)||key;});
Expand Down Expand Up @@ -137,8 +137,8 @@ for(const width of [375,600,601,768,900,901,1200,1201,1440]){
test(`${width}px: mixed layout sizes never create implicit grid columns`,async()=>{
const page=await fixture(width);
try{
const panelWidth=await page.locator('.device-panel').evaluate(el=>el.clientWidth);
const expectedColumns=panelWidth>=900?3:panelWidth>=596?2:1;
const pageWidth=width-32;
const expectedColumns=pageWidth>=1296?3:pageWidth>=636?2:1;
await page.evaluate(()=>{
widgets=['large','medium','small','auto','full'].map(layout=>({id:layout,type:'ring',label:'GPU',layout,unit:'MB',decimals:1}));
document.getElementById('grid').innerHTML=widgets.map(renderWidgetHtml).join('');
Expand All @@ -150,7 +150,7 @@ for(const width of [375,600,601,768,900,901,1200,1201,1440]){
});
const m=await measure();assert.equal(m.columns.length,expectedColumns);
assert(m.columns.every(n=>Math.abs(n-m.columns[0])<1));
for(const c of m.cards){const span=Math.min(expectedColumns,{large:3,medium:2,small:1,auto:1,full:expectedColumns}[c.layout]);assert(Math.abs(c.width-(m.columns[0]*span+12*(span-1)))<1,JSON.stringify(c));}
for(const c of m.cards){const span=Math.min(expectedColumns,{large:3,medium:2,small:1,auto:1,full:expectedColumns}[c.layout]);const expectedWidth=c.layout==='full'?m.gridWidth:m.columns[0]*span+12*(span-1);assert(Math.abs(c.width-expectedWidth)<1,JSON.stringify(c));}
assert.deepEqual(await violations(page),[]);
await page.setViewportSize({width:375,height:1000});assert.equal((await measure()).columns.length,1);
await page.setViewportSize({width:1440,height:1000});assert.equal((await measure()).columns.length,3);
Expand Down Expand Up @@ -178,32 +178,54 @@ for(const language of ['zh-CN','en-US']){
});
}

test('model and widget tracks stay equal throughout resizing, including the fan breakpoint',async()=>{
test('card widths and column counts stay stable while widening and narrowing',async()=>{
const page=await browser.newPage();
try{
await page.setContent(`<style>${css}</style><main style="padding:24px"><div class="sys-mid"><section class="card device-panel"><div class="qa-grid"><div class="quick-action-card">Qwen3.6-35B-A3B</div></div><hr><div class="dw-grid"><div class="w-tile dw-card">GPU</div><div class="w-tile dw-card">Temperature</div><div class="w-tile dw-card dw-layout-medium">Medium</div><div class="w-tile dw-card dw-layout-large">Large</div><div class="w-tile dw-card dw-layout-full">Full</div></div></section><section class="card">Fan</section></div></main>`);
const widths=[...new Set([...Array.from({length:98},(_,i)=>360+i*16),600,601,1388,1389,1390,1391,1920,2560])].sort((a,b)=>a-b);
for(const width of widths){
await page.setContent(`<style>${css}</style><main class="page-system" style="padding:24px"><div class="sys-mid"><section class="card device-panel"><div class="qa-grid"><div class="quick-action-card">Qwen3.6-35B-A3B</div></div><hr><div class="dw-grid"><div class="w-tile dw-card">GPU</div><div class="w-tile dw-card">Temperature</div><div class="w-tile dw-card dw-layout-medium">Medium</div><div class="w-tile dw-card dw-layout-large">Large</div><div class="w-tile dw-card dw-layout-full">Full</div></div></section><section class="card fan-panel">Fan</section></div></main>`);
const widths=Array.from({length:2560-320+1},(_,i)=>320+i);
let previousColumns=1,previousFanBeside=false;
const measurements=new Map();
for(const [index,width] of [...widths,...widths.toReversed()].entries()){
const widening=index<widths.length;
await page.setViewportSize({width,height:1000});
const result=await page.evaluate(()=>{
const model=document.querySelector('.qa-grid'),widgets=document.querySelector('.dw-grid');
const box=el=>{const {x,width}=el.getBoundingClientRect();return {x,width};};
return {modelTracks:getComputedStyle(model).gridTemplateColumns,widgetTracks:getComputedStyle(widgets).gridTemplateColumns,model:box(model.firstElementChild),widget:box(widgets.firstElementChild),overflow:document.documentElement.scrollWidth>innerWidth,cards:[...widgets.children].map(box),grid:box(widgets)};
const fanBeside=Math.abs(document.querySelector('.fan-panel').getBoundingClientRect().y-document.querySelector('.device-panel').getBoundingClientRect().y)<1;
return {modelTracks:getComputedStyle(model).gridTemplateColumns,widgetTracks:getComputedStyle(widgets).gridTemplateColumns,model:box(model.firstElementChild),widget:box(widgets.firstElementChild),fanBeside,overflow:document.documentElement.scrollWidth>innerWidth,cards:[...widgets.children].map(box),grid:box(widgets)};
});
const modelTracks=result.modelTracks.split(' ').map(Number.parseFloat),widgetTracks=result.widgetTracks.split(' ').map(Number.parseFloat);
assert.equal(modelTracks.length,widgetTracks.length,`${width}px column counts differ`);
assert(modelTracks.every((track,index)=>Math.abs(track-widgetTracks[index])<1),`${width}px tracks differ`);
assert(modelTracks.length<=3);
if(width>=1374)assert.equal(modelTracks.length,3,`${width}px keeps three columns across the fan breakpoint`);
assert(widening?modelTracks.length>=previousColumns:modelTracks.length<=previousColumns,`${width}px reverses column count while resizing`);
assert(widening?Number(result.fanBeside)>=Number(previousFanBeside):Number(result.fanBeside)<=Number(previousFanBeside),`${width}px reverses the fan arrangement while resizing`);
previousColumns=modelTracks.length;
previousFanBeside=result.fanBeside;
const summary={model:result.model,tracks:result.modelTracks,fanBeside:result.fanBeside};
if(widening)measurements.set(width,summary);else assert.deepEqual(summary,measurements.get(width),`${width}px depends on resize direction`);
assert(Math.abs(result.model.width-Math.min(292,result.grid.width))<1,`${width}px stretches a single-cell card`);
if(width>=1440)assert.equal(modelTracks.length,3,`${width}px desktop keeps three columns`);
assert(Math.abs(result.model.width-result.widget.width)<1,`${width}px widths differ`);
assert(Math.abs(result.model.x-result.widget.x)<1,`${width}px starts differ`);
for(const card of result.cards)assert(card.x+card.width<=result.grid.x+result.grid.width+1,`${width}px spanning widget escapes`);
assert(Math.abs(result.cards.at(-1).width-result.grid.width)<1,`${width}px full-width widget does not fill its grid`);
assert.equal(result.overflow,false,`${width}px overflows`);
if(width===1440||width===2560){
const before=result.model.width;
await page.locator('.qa-grid').evaluate(grid=>{grid.innerHTML+=Array.from({length:4},()=>'<div class="quick-action-card">Another model</div>').join('');});
assert(Math.abs(await page.locator('.quick-action-card').first().evaluate(el=>el.getBoundingClientRect().width)-before)<1,'model count does not change cell width');
}
}
await page.setViewportSize({width:1390,height:1000});
for(const width of [991,991.25,991.5,991.75,992]){
await page.locator('.page-system').evaluate((el,width)=>{el.style.width=(width+48)+'px';},width);
const result=await page.evaluate(()=>({
cardWidth:document.querySelector('.quick-action-card').getBoundingClientRect().width,
fanBeside:Math.abs(document.querySelector('.fan-panel').getBoundingClientRect().y-document.querySelector('.device-panel').getBoundingClientRect().y)<1
}));
assert(Math.abs(result.cardWidth-292)<.01,`${width}px fractional boundary compresses cards`);
assert.equal(result.fanBeside,width>=992,`${width}px switches the fan before both panels fit`);
}
}finally{await page.close();}
});
4 changes: 2 additions & 2 deletions tests/prompts/widgets-structure.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ test('stylesheet retains migrated bounds, overlay, wrapping and responsive span
'.dw-card[data-type=log][data-layout=auto],.dw-layout-medium{grid-column:span var(--widget-medium-span)}',
'.dw-log-line{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
'.dw-log-tools>.btn,.dw-log-tools>.state{flex-shrink:0;max-width:100%;white-space:normal;overflow-wrap:anywhere}',
'grid-template-columns:repeat(var(--device-columns),minmax(0,1fr))'
'grid-template-columns:repeat(var(--device-columns),minmax(0,292px))'
]) assert(css.includes(rule), rule);
assert(css.includes('.device-panel{container:device-panel / inline-size}'));
assert(css.includes('.page-system{container:system-page / inline-size}'));
assert(css.includes('.dw-ring-value{z-index:1;width:100%;'));
});
Loading
Loading