-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrender_workspace_preview.py
More file actions
63 lines (59 loc) · 5.06 KB
/
Copy pathrender_workspace_preview.py
File metadata and controls
63 lines (59 loc) · 5.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"""Render the actual Qt UI using a disposable demo profile, without model calls."""
import os
os.environ.setdefault('QT_QPA_PLATFORM', 'offscreen')
import argparse
from contextlib import ExitStack
from pathlib import Path
import tempfile
from unittest.mock import patch
from PySide6.QtWidgets import QApplication
from PySide6.QtGui import QFontDatabase
import studio
def render(path, width=1440, height=900, steps=False, jobs=False, providers=False):
app=QApplication.instance() or QApplication([])
# Qt's offscreen Windows platform needs explicit font registration.
fonts=Path(os.environ.get('WINDIR','C:/Windows'))/'Fonts'
for name in ('segoeui.ttf','segoeuib.ttf','seguisb.ttf','seguisym.ttf','consola.ttf'):
if (fonts/name).is_file():QFontDatabase.addApplicationFont(str(fonts/name))
app.setStyleSheet(studio.STYLE)
with tempfile.TemporaryDirectory() as folder, ExitStack() as stack:
root=Path(folder)
for name,value in [('HOME',root),('STATE',root),('SESSION',root/'studio.json'),('CONNECTIONS',root/'connections.json'),('PROVIDERS',root/'providers.json')]:
stack.enter_context(patch.object(studio,name,value))
stack.enter_context(patch.object(studio.Studio,'health'))
stack.enter_context(patch.object(studio.Studio,'install_tray'))
window=studio.Studio();window.resize(width,height)
window.task['title']='Game project · UI demonstration'
window.task['project']=str(root)
window.title.setText(window.task['title']);window.project_label.setText('Demo project')
window.task['messages']=[
{'role':'user','content':'Add a pause menu to my game, check the project, and capture evidence.'},
{'role':'assistant','content':'**UI demonstration — not an executed model response**\n\nA game-development task can bring together project inspection, edits, checks and evidence.\n\n1. Inspect the engine and project conventions.\n2. Implement the requested feature.\n3. Run the available project checks.\n4. Test the affected flow and report what was actually verified.\n\nKeep reusable decisions in **Project memory**, use **Steer** during a run, and review file changes in the workspace.'}]
window.refresh_tasks();window.render();window.right.setCurrentIndex(3)
window.health_label.setText('Choose your local or self-hosted model')
window.connection_label.setText('Your own SSH connections')
window.use_starter('Build a game feature')
if steps:
window.task['task_goal']={'objective':'Add a usable pause menu to the existing game.','criteria':[{'id':'c1','text':'Escape opens and closes the pause menu','status':'pending','evidence':''},{'id':'c2','text':'Project checks pass and gameplay is inspected','status':'pending','evidence':''}],'next_action':'Implement the menu, then inspect the result.'}
window.task['task_goal_project']=str(root)
window.task['plan']={'steps':[{'step':'Inspect the project and conventions','status':'completed'},{'step':'Implement the requested game feature','status':'in_progress'},{'step':'Run checks and collect evidence','status':'pending'}],'explanation':'UI demonstration only: a task checklist maintained by the agent.'}
window.task['verification']={'status':'not run','summary':'This demonstration has not executed a check.'}
window.task['project_context']={'engine':'Godot (demo)','checks':{'commands':[]}}
window.refresh_plan();window.right.setCurrentIndex(5)
if jobs:
window.handle_event('job',{'id':'demo-only','state':'completed','command':['python','-m','unittest'], 'cwd':'Demo project', 'seconds':1.2,'exit_code':0,'output':'UI DEMONSTRATION ONLY\n\nThis panel shows command output, exit status and cancellation.\nThis is illustrative text, not an executed test result.'})
window.right.setCurrentIndex(window.jobs_tab)
window.prompt.clear()
window.use_starter('Build and collect outputs')
window.show();app.processEvents()
target=Path(path);target.parent.mkdir(parents=True,exist_ok=True)
if providers:
from provider_dialog import ProviderDialog
dialog=ProviderDialog(window,root/'providers.json');dialog.preset.setCurrentIndex(1);dialog.show();app.processEvents()
if not dialog.grab().save(str(target)):raise RuntimeError('Provider preview rendering failed')
dialog.close();dialog.deleteLater();app.processEvents()
elif not window.grab().save(str(target)):raise RuntimeError('Preview rendering failed')
window.allow_quit=True;window.close();window.deleteLater();app.processEvents()
if __name__=='__main__':
parser=argparse.ArgumentParser();parser.add_argument('path');parser.add_argument('--width',type=int,default=1440);parser.add_argument('--height',type=int,default=900);parser.add_argument('--steps',action='store_true');parser.add_argument('--jobs',action='store_true');parser.add_argument('--providers',action='store_true')
args=parser.parse_args();render(args.path,args.width,args.height,args.steps,args.jobs,args.providers)