融合最新主分支运行视窗改进
合并运行视窗按预览文档尺寸自适应能力 保留账号画布绑定与 Direct 恢复修复 同时保留运行视窗与账号绑定共享决策
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+190
-8
@@ -1,4 +1,22 @@
|
||||
/* eslint-disable react-refresh/only-export-components -- The URL guard is exported with its small rendering adapter for focused tests. */
|
||||
/* eslint-disable react-refresh/only-export-components -- The URL and fit helpers are exported with their small rendering adapter for focused tests. */
|
||||
|
||||
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||
|
||||
export const LOCAL_GAME_PREVIEW_SIZE_MESSAGE =
|
||||
'genarrative.local-preview-size.v1';
|
||||
|
||||
export type LocalGamePreviewContentSize = {
|
||||
contentWidth: number;
|
||||
contentHeight: number;
|
||||
viewportWidth: number;
|
||||
viewportHeight: number;
|
||||
};
|
||||
|
||||
export type LocalGamePreviewFitLayout = {
|
||||
width: number;
|
||||
height: number;
|
||||
scale: number;
|
||||
};
|
||||
|
||||
export type LocalGamePreviewLike = {
|
||||
status?: string | null;
|
||||
@@ -25,6 +43,77 @@ export function resolveEmbeddedPreviewUrl(
|
||||
}
|
||||
}
|
||||
|
||||
function positiveFiniteDimension(value: unknown) {
|
||||
return typeof value === 'number' && Number.isFinite(value) && value > 0
|
||||
? Math.min(value, 100_000)
|
||||
: null;
|
||||
}
|
||||
|
||||
export function parseLocalGamePreviewContentSize(
|
||||
value: unknown,
|
||||
): LocalGamePreviewContentSize | null {
|
||||
if (!value || typeof value !== 'object') return null;
|
||||
const candidate = value as Record<string, unknown>;
|
||||
if (candidate.type !== LOCAL_GAME_PREVIEW_SIZE_MESSAGE) return null;
|
||||
const contentWidth = positiveFiniteDimension(candidate.contentWidth);
|
||||
const contentHeight = positiveFiniteDimension(candidate.contentHeight);
|
||||
const viewportWidth = positiveFiniteDimension(candidate.viewportWidth);
|
||||
const viewportHeight = positiveFiniteDimension(candidate.viewportHeight);
|
||||
if (
|
||||
contentWidth === null ||
|
||||
contentHeight === null ||
|
||||
viewportWidth === null ||
|
||||
viewportHeight === null
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
return { contentWidth, contentHeight, viewportWidth, viewportHeight };
|
||||
}
|
||||
|
||||
export function resolveLocalGamePreviewFitLayout(
|
||||
container: { width: number; height: number },
|
||||
content: LocalGamePreviewContentSize | null,
|
||||
): LocalGamePreviewFitLayout {
|
||||
const containerWidth = Math.max(1, container.width);
|
||||
const containerHeight = Math.max(1, container.height);
|
||||
if (!content) {
|
||||
return { width: containerWidth, height: containerHeight, scale: 1 };
|
||||
}
|
||||
const width = Math.max(containerWidth, content.contentWidth);
|
||||
const height = Math.max(containerHeight, content.contentHeight);
|
||||
return {
|
||||
width,
|
||||
height,
|
||||
scale: Math.min(1, containerWidth / width, containerHeight / height),
|
||||
};
|
||||
}
|
||||
|
||||
export function resolveLocalGamePreviewContentSizeUpdate(
|
||||
current: LocalGamePreviewContentSize | null,
|
||||
next: LocalGamePreviewContentSize,
|
||||
nativeViewport: { width: number; height: number },
|
||||
appliedViewport: { width: number; height: number },
|
||||
): LocalGamePreviewContentSize | null {
|
||||
const reportsViewport = (viewport: { width: number; height: number }) =>
|
||||
Math.abs(next.viewportWidth - viewport.width) < 1 &&
|
||||
Math.abs(next.viewportHeight - viewport.height) < 1;
|
||||
if (!reportsViewport(nativeViewport) && !reportsViewport(appliedViewport)) {
|
||||
return current;
|
||||
}
|
||||
if (
|
||||
current &&
|
||||
current.contentWidth === next.contentWidth &&
|
||||
current.contentHeight === next.contentHeight
|
||||
) {
|
||||
return current;
|
||||
}
|
||||
return {
|
||||
...next,
|
||||
viewportWidth: nativeViewport.width,
|
||||
viewportHeight: nativeViewport.height,
|
||||
};
|
||||
}
|
||||
|
||||
export function LocalGamePreviewFrame({
|
||||
preview,
|
||||
title,
|
||||
@@ -35,16 +124,109 @@ export function LocalGamePreviewFrame({
|
||||
className?: string;
|
||||
}) {
|
||||
const embeddedUrl = resolveEmbeddedPreviewUrl(preview);
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
const iframeRef = useRef<HTMLIFrameElement>(null);
|
||||
const measuredContainerSizeRef = useRef({ width: 1, height: 1 });
|
||||
const contentSizeRef = useRef<LocalGamePreviewContentSize | null>(null);
|
||||
const [containerSize, setContainerSize] = useState({ width: 1, height: 1 });
|
||||
const [contentSize, setContentSize] =
|
||||
useState<LocalGamePreviewContentSize | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const container = containerRef.current;
|
||||
if (!container) return;
|
||||
const update = () => {
|
||||
const rect = container.getBoundingClientRect();
|
||||
const next = {
|
||||
width: Math.max(1, rect.width),
|
||||
height: Math.max(1, rect.height),
|
||||
};
|
||||
const current = measuredContainerSizeRef.current;
|
||||
if (
|
||||
Math.abs(current.width - next.width) < 0.5 &&
|
||||
Math.abs(current.height - next.height) < 0.5
|
||||
) {
|
||||
return;
|
||||
}
|
||||
measuredContainerSizeRef.current = next;
|
||||
setContainerSize(next);
|
||||
if (contentSizeRef.current) {
|
||||
contentSizeRef.current = null;
|
||||
setContentSize(null);
|
||||
}
|
||||
};
|
||||
update();
|
||||
if (typeof window.ResizeObserver === 'function') {
|
||||
const observer = new window.ResizeObserver(update);
|
||||
observer.observe(container);
|
||||
return () => observer.disconnect();
|
||||
}
|
||||
window.addEventListener('resize', update);
|
||||
return () => window.removeEventListener('resize', update);
|
||||
}, [embeddedUrl]);
|
||||
|
||||
useEffect(() => {
|
||||
if (contentSizeRef.current) {
|
||||
contentSizeRef.current = null;
|
||||
setContentSize(null);
|
||||
}
|
||||
}, [embeddedUrl]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!embeddedUrl) return;
|
||||
const expectedOrigin = new URL(embeddedUrl).origin;
|
||||
const handleMessage = (event: MessageEvent) => {
|
||||
if (
|
||||
event.origin !== expectedOrigin ||
|
||||
event.source !== iframeRef.current?.contentWindow
|
||||
) {
|
||||
return;
|
||||
}
|
||||
const next = parseLocalGamePreviewContentSize(event.data);
|
||||
if (!next) return;
|
||||
const current = contentSizeRef.current;
|
||||
const nativeViewport = measuredContainerSizeRef.current;
|
||||
const appliedViewport = resolveLocalGamePreviewFitLayout(
|
||||
nativeViewport,
|
||||
current,
|
||||
);
|
||||
const resolved = resolveLocalGamePreviewContentSizeUpdate(
|
||||
current,
|
||||
next,
|
||||
nativeViewport,
|
||||
appliedViewport,
|
||||
);
|
||||
if (resolved === current) return;
|
||||
contentSizeRef.current = resolved;
|
||||
setContentSize(resolved);
|
||||
};
|
||||
window.addEventListener('message', handleMessage);
|
||||
return () => window.removeEventListener('message', handleMessage);
|
||||
}, [embeddedUrl]);
|
||||
|
||||
const fit = useMemo(
|
||||
() => resolveLocalGamePreviewFitLayout(containerSize, contentSize),
|
||||
[containerSize, contentSize],
|
||||
);
|
||||
if (!embeddedUrl) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<iframe
|
||||
className={className}
|
||||
title={title}
|
||||
src={embeddedUrl}
|
||||
sandbox="allow-scripts allow-same-origin allow-forms allow-pointer-lock"
|
||||
allow="autoplay; fullscreen; gamepad"
|
||||
/>
|
||||
<div ref={containerRef} className="local-game-preview-frame">
|
||||
<iframe
|
||||
ref={iframeRef}
|
||||
className={className}
|
||||
title={title}
|
||||
src={embeddedUrl}
|
||||
scrolling="no"
|
||||
style={{
|
||||
width: `${fit.width}px`,
|
||||
height: `${fit.height}px`,
|
||||
transform: `translate(-50%, -50%) scale(${fit.scale})`,
|
||||
}}
|
||||
sandbox="allow-scripts allow-same-origin allow-forms allow-pointer-lock"
|
||||
allow="autoplay; fullscreen; gamepad"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1886,12 +1886,26 @@ textarea {
|
||||
background: #05070b;
|
||||
}
|
||||
|
||||
.game-chat-preview iframe {
|
||||
display: block;
|
||||
.local-game-preview-frame {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
background: #05070b;
|
||||
}
|
||||
|
||||
.local-game-preview-frame iframe {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
display: block;
|
||||
max-width: none;
|
||||
max-height: none;
|
||||
border: 0;
|
||||
background: #fff;
|
||||
transform-origin: center;
|
||||
}
|
||||
|
||||
.game-chat-conversation {
|
||||
@@ -6098,13 +6112,7 @@ iframe.preview-frame {
|
||||
}
|
||||
|
||||
.game-run-preview iframe {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
border: 0;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.game-run-preview-empty {
|
||||
|
||||
@@ -3463,7 +3463,16 @@ export function registerProjectWorkbenchFoundationTests() {
|
||||
/\.game-run-surface\s*\{[^}]*grid-template-rows:\s*minmax\(300px, 1fr\) auto[^}]*grid-row:\s*2 \/ -1[^}]*height:\s*100%/s,
|
||||
);
|
||||
expect(styles).toMatch(
|
||||
/\.game-run-preview iframe\s*\{[^}]*position:\s*absolute[^}]*inset:\s*0[^}]*width:\s*100%[^}]*height:\s*100%[^}]*min-height:\s*0/s,
|
||||
/\.local-game-preview-frame\s*\{[^}]*position:\s*relative[^}]*width:\s*100%[^}]*height:\s*100%[^}]*min-width:\s*0[^}]*min-height:\s*0[^}]*overflow:\s*hidden/s,
|
||||
);
|
||||
expect(styles).toMatch(
|
||||
/\.local-game-preview-frame iframe\s*\{[^}]*position:\s*absolute[^}]*top:\s*50%[^}]*left:\s*50%[^}]*display:\s*block[^}]*max-width:\s*none[^}]*max-height:\s*none[^}]*border:\s*0[^}]*transform-origin:\s*center/s,
|
||||
);
|
||||
const runPreviewIframeRule =
|
||||
styles.match(/\.game-run-preview iframe\s*\{([^}]*)\}/s)?.[1] ?? '';
|
||||
expect(runPreviewIframeRule).toContain('min-height: 0;');
|
||||
expect(runPreviewIframeRule).not.toMatch(
|
||||
/(?:^|;)\s*(?:position|inset|width|height)\s*:/,
|
||||
);
|
||||
expect(styles).not.toMatch(/\.game-run-slice-controls/);
|
||||
const agentDockRule = styles.match(/\.game-agent-dock\s*\{([^}]*)\}/s);
|
||||
|
||||
@@ -0,0 +1,188 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import {
|
||||
LOCAL_GAME_PREVIEW_SIZE_MESSAGE,
|
||||
parseLocalGamePreviewContentSize,
|
||||
resolveLocalGamePreviewContentSizeUpdate,
|
||||
resolveLocalGamePreviewFitLayout,
|
||||
} from '../src/features/project-workspace/LocalGamePreviewFrame';
|
||||
|
||||
describe('local game preview viewport fitting', () => {
|
||||
it('keeps a game at native size when its content fits', () => {
|
||||
expect(
|
||||
resolveLocalGamePreviewFitLayout(
|
||||
{ width: 1200, height: 700 },
|
||||
{
|
||||
contentWidth: 1200,
|
||||
contentHeight: 700,
|
||||
viewportWidth: 1200,
|
||||
viewportHeight: 700,
|
||||
},
|
||||
),
|
||||
).toEqual({ width: 1200, height: 700, scale: 1 });
|
||||
});
|
||||
|
||||
it('scales the complete game document into the available viewport', () => {
|
||||
expect(
|
||||
resolveLocalGamePreviewFitLayout(
|
||||
{ width: 1200, height: 700 },
|
||||
{
|
||||
contentWidth: 1200,
|
||||
contentHeight: 1000,
|
||||
viewportWidth: 1200,
|
||||
viewportHeight: 700,
|
||||
},
|
||||
),
|
||||
).toEqual({ width: 1200, height: 1000, scale: 0.7 });
|
||||
});
|
||||
|
||||
it('accepts the native viewport report and keeps viewport out of fit state', () => {
|
||||
const nativeViewport = { width: 1200, height: 700 };
|
||||
const report = {
|
||||
contentWidth: 1200,
|
||||
contentHeight: 1000,
|
||||
viewportWidth: 1200,
|
||||
viewportHeight: 700,
|
||||
};
|
||||
|
||||
expect(
|
||||
resolveLocalGamePreviewContentSizeUpdate(
|
||||
null,
|
||||
report,
|
||||
nativeViewport,
|
||||
nativeViewport,
|
||||
),
|
||||
).toEqual(report);
|
||||
});
|
||||
|
||||
it('accepts changed content after the iframe has adopted the first fit viewport', () => {
|
||||
const nativeViewport = { width: 1200, height: 700 };
|
||||
const current = {
|
||||
contentWidth: 1200,
|
||||
contentHeight: 1000,
|
||||
viewportWidth: 1200,
|
||||
viewportHeight: 700,
|
||||
};
|
||||
const changed = {
|
||||
contentWidth: 1200,
|
||||
contentHeight: 1400,
|
||||
viewportWidth: 1200,
|
||||
viewportHeight: 1000,
|
||||
};
|
||||
|
||||
expect(
|
||||
resolveLocalGamePreviewContentSizeUpdate(
|
||||
current,
|
||||
changed,
|
||||
nativeViewport,
|
||||
{
|
||||
width: 1200,
|
||||
height: 1000,
|
||||
},
|
||||
),
|
||||
).toEqual({
|
||||
contentWidth: 1200,
|
||||
contentHeight: 1400,
|
||||
viewportWidth: 1200,
|
||||
viewportHeight: 700,
|
||||
});
|
||||
});
|
||||
|
||||
it('shrinks the fitted frame when content becomes shorter inside the applied viewport', () => {
|
||||
const nativeViewport = { width: 1200, height: 700 };
|
||||
const current = {
|
||||
contentWidth: 1200,
|
||||
contentHeight: 1000,
|
||||
viewportWidth: 1200,
|
||||
viewportHeight: 700,
|
||||
};
|
||||
const changed = {
|
||||
contentWidth: 1200,
|
||||
contentHeight: 800,
|
||||
viewportWidth: 1200,
|
||||
viewportHeight: 1000,
|
||||
};
|
||||
|
||||
const updated = resolveLocalGamePreviewContentSizeUpdate(
|
||||
current,
|
||||
changed,
|
||||
nativeViewport,
|
||||
{ width: 1200, height: 1000 },
|
||||
);
|
||||
expect(updated).toEqual({
|
||||
contentWidth: 1200,
|
||||
contentHeight: 800,
|
||||
viewportWidth: 1200,
|
||||
viewportHeight: 700,
|
||||
});
|
||||
expect(resolveLocalGamePreviewFitLayout(nativeViewport, updated)).toEqual({
|
||||
width: 1200,
|
||||
height: 800,
|
||||
scale: 0.875,
|
||||
});
|
||||
});
|
||||
|
||||
it('keeps the current state for repeated content dimensions and fit viewport feedback', () => {
|
||||
const nativeViewport = { width: 1200, height: 700 };
|
||||
const current = {
|
||||
contentWidth: 1200,
|
||||
contentHeight: 1400,
|
||||
viewportWidth: 1200,
|
||||
viewportHeight: 700,
|
||||
};
|
||||
|
||||
expect(
|
||||
resolveLocalGamePreviewContentSizeUpdate(
|
||||
current,
|
||||
{ ...current, viewportHeight: 1400 },
|
||||
nativeViewport,
|
||||
{ width: 1200, height: 1400 },
|
||||
),
|
||||
).toBe(current);
|
||||
});
|
||||
|
||||
it('ignores delayed reports from a stale fitted viewport', () => {
|
||||
const nativeViewport = { width: 1200, height: 700 };
|
||||
const current = {
|
||||
contentWidth: 1200,
|
||||
contentHeight: 1400,
|
||||
viewportWidth: 1200,
|
||||
viewportHeight: 700,
|
||||
};
|
||||
|
||||
expect(
|
||||
resolveLocalGamePreviewContentSizeUpdate(
|
||||
current,
|
||||
{
|
||||
contentWidth: 1200,
|
||||
contentHeight: 1100,
|
||||
viewportWidth: 1200,
|
||||
viewportHeight: 1000,
|
||||
},
|
||||
nativeViewport,
|
||||
{ width: 1200, height: 1400 },
|
||||
),
|
||||
).toBe(current);
|
||||
});
|
||||
|
||||
it('rejects malformed or unrelated cross-frame messages', () => {
|
||||
expect(
|
||||
parseLocalGamePreviewContentSize({
|
||||
type: LOCAL_GAME_PREVIEW_SIZE_MESSAGE,
|
||||
contentWidth: 1200,
|
||||
contentHeight: Number.NaN,
|
||||
viewportWidth: 1200,
|
||||
viewportHeight: 700,
|
||||
}),
|
||||
).toBeNull();
|
||||
expect(
|
||||
parseLocalGamePreviewContentSize({
|
||||
type: 'unrelated',
|
||||
contentWidth: 1200,
|
||||
contentHeight: 700,
|
||||
viewportWidth: 1200,
|
||||
viewportHeight: 700,
|
||||
}),
|
||||
).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -66,7 +66,10 @@
|
||||
- 原生读取必须在命令入口、权限 / 登记复核后、打开文件后、每个固定上限读取块之间、签名 / 图片结构校验前、漂移复核前和 base64 编码前检查取消。取消的排队任务不得打开文件,取消的在途任务不得生成 data URL 或 Blob URL;全局 permit 只能在对应原生任务结束后释放。重复 `requestId` 失败关闭,取消未知或已完成 scope 幂等成功;成功、失败和取消均必须清理活动 request / scope registry。为防止近期 request ID 重放和已取消 scope 复活,原生管理器继续保留有界 tombstone:seen request 最多 `8192` 项;非活动 cancelled scope 的保留预算为 `1024` 项,仍有请求的已取消 scope 必须临时钉住,最后一个请求结束后立即重新淘汰到预算内。明确取消只静默收口旧 scope,当前 scope 的真实 transient / permanent 失败语义不变。
|
||||
- 安全读取失败、图片解码失败或视频无可解码画面时,卡片展示稳定类型占位,不挂载破图,不降级为项目外 URL 或裸路径读取。滚动可见性不得自动重试已失败预取;读取漂移、文件替换和通用暂时失败标记为 transient,用户再次打开详情或点击播放时可以显式重试。超尺寸、损坏、类型不支持和不安全 SVG 等永久失败继续缓存且不得用“关闭后重试”误导用户。
|
||||
|
||||
### 3.4 数值微调
|
||||
### 3.4 运行视窗与数值微调
|
||||
|
||||
- 运行视窗必须占满中央工作区为游戏保留的可用区域。loopback 预览页通过客户端本地 preview server 注入的只读尺寸桥上报文档实际宽高;宿主只接受当前 iframe、当前 loopback origin 的固定版本消息,并将完整游戏文档等比缩放、居中放入视窗。iframe 首次适配后发生的真实内容增高或缩短仍必须被接受;仅浏览上下文宽高回灌或内容宽高未变化时保持当前状态,不触发重复渲染。
|
||||
- 窗口或中央区域尺寸变化后必须重新测量和适配;内容已经放得下时保持 `1:1`,不得无故放大。游戏文档宽高超过视窗时缩小整体画面,不显示 iframe 横向或纵向滚动条,也不得用单纯裁切替代完整展示。尺寸桥以根布局 `ResizeObserver` 为主,并在页面可见时每 `500ms` 至多探测 `512` 个元素作为绝对定位溢出的低频兜底;探测截断时不得用部分样本下调尺寸,viewport 耦合的 `100vh / 100% / bottom / right` 布局也不得形成自反馈。相同测量结果去重,不监听整页属性、文本或子节点突变;桥不读取项目正文、不修改 manifest、游戏文件或运行业务状态。桥脚本只能注入到真实 HTML 标签上下文,不能把脚本、样式、模板或注释中的 `</body>` / `</html>` 文本误判为结束标签;省略结束标签的 UTF-8 HTML 仍需安全注入。
|
||||
|
||||
- 数值修改立即写入当前项目的编辑态配置。
|
||||
- 当前已拉起的体验预览和测试切片不热更新;必须重新拉起后才能消费新值。
|
||||
|
||||
@@ -14375,6 +14375,12 @@
|
||||
- 集成边界:`resource_editor`、素材画布参考准备、`canvas.asset_generate` 的 art-spec 派生和直连只读恢复统一消费当前 principal binding;PR 176 rebase 后必须删除或整合其局部 canonical cache,不能保留第二套账号身份系统。External v1 的项目、素材目录和项目资源创建接口新增可选 `Idempotency-Key` 请求头并同步 OpenAPI;客户端用 binding key 派生稳定值,服务端按 `owner + 接口命名空间 + key` 生成稳定 ID,同键同正文返回原记录、同键异正文冲突。
|
||||
- 验收:至少覆盖 A 生成到本地后切 B 重登记、B 请求零 A 远端 ID、重启后复用 B、切回 A 复用 A、两个同名本地项目隔离、项目改名不漂移、源 SHA 或 kind 变化重登记、A 在途任务切 B 零网络,以及 sidecar 零凭据和身份篡改失败关闭。
|
||||
|
||||
## 2026-08-23 AI 游戏运行视窗按预览文档实际尺寸自适应
|
||||
|
||||
- 背景:项目开发工作台的中央运行视窗尺寸小于部分生成游戏的页面布局高度时,滚动条来自 loopback iframe 内部;宿主只隐藏 overflow 会直接裁掉标题、Canvas 或控制区,不能满足完整试玩。
|
||||
- 决策:客户端本地 preview server 为 UTF-8 HTML 注入固定同源尺寸桥;注入器按真实 HTML tokenizer 边界保守处理注释异常结束、DOCTYPE 引号、script escaped / double-escaped、raw-text、template、plaintext、foreign content 与重复 `src`,省略结束标签时只在已证明安全的文档位置注入。桥通过根节点 `ResizeObserver`、页面 load、窗口 resize 与字体就绪重新测量;页面可见时以 `500ms` 低频兜底探测至多 `512` 个元素边界,探测截断时不采用可能低估的部分样本,并排除随 viewport 同步变化的布局自反馈。它不订阅整页 DOM 突变,并只在尺寸元组真实变化时上报文档与浏览上下文宽高。宿主只接受当前 iframe source 与当前授权 loopback origin 的固定版本消息,按实际内容和可用容器计算最大为 `1` 的等比缩放并居中显示;首次缩放后仍接受内容宽高真实变化,重复内容尺寸或仅 viewport 回灌不更新状态,容器 resize 后重新以原生视口测量。运行视窗不再提供 iframe 横纵滚动条,内容适配不改游戏文件、manifest、PreviewRegistry 或运行业务状态,非 UTF-8 HTML 保持原样。
|
||||
- 验证:前端纯函数覆盖无需缩放、纵向超高缩放、首次缩放后的增高 / 缩短、重复内容尺寸去重、过期 viewport 与非法消息;Rust preview server 测试锁定尺寸去重、无全页 MutationObserver、低频有界探测、截断保护、固定 body 与 viewport 耦合布局不振荡、真实 HTML 上下文注入、注释异常结束、DOCTYPE 引号、script escaped / double-escaped、raw-text / template / plaintext / foreign content、省略结束标签、大小写结束标签、重复 `src` 和幂等注入;再以桌面最小窗口和更高窗口人工确认完整画面、动态内容变化后仍适配、无纵向滚动条且指针 / 键盘交互仍可用。
|
||||
|
||||
## 2026-08-23 Direct Codex 显式重生成与切片一等资源
|
||||
|
||||
- 决策:`taonier_prepare_game_art` 使用 `reuse-or-create | regenerate` 两态合同;旧调用缺省复用,只有用户显式重做或换风格才允许重生成。`regenerate` 只绕过本地完整包复用,不绕过未决 External Editor operation;旧账本 prompt 与本次 prompt 不一致时必须进入结果未知/对账,零新 POST。
|
||||
|
||||
@@ -548,7 +548,7 @@ game-project/
|
||||
- 中间主视窗提供 `resource-overview / asset-canvas / resource-editor / run` 四种状态。2026-08-10 起普通用户“新增资源”显示为禁用态且处理函数拒绝 create;所有现役资源从聚焦态“编辑资源”进入非破坏性派生。静态图片继续进入 refine 素材创作无限画布,SVG、视频、音频、文档/代码、Agent 回执和项目版本进入统一资源编辑壳并按能力分流;底层 create 合同仅保留兼容。编辑面板只替换中央区域,不覆盖右侧 Supervisor 或底部 Agent。`code-prototype` 任务完成前运行入口保持视觉不可用,但仍可点击查看“当前无可运行版本”,不能使用会阻断说明交互的原生 `disabled` 或 `aria-disabled`;完成后才允许进入运行表现层。切回资源总览只修改前端展示态,不伪造后端预览暂停结果。
|
||||
- 资源管理从当前 `GameCreationAppManifest`(包含可选 `versions`)、合法 Agent 文本回执、已导入附件和已完成任务明确登记的产物派生资源,固定按文档、项目版本、美术资源、音乐音效资源分区;未知任务产物不再兜底为版本,未完成任务或未在 `artifacts` 中登记的任意本地音频也不冒充正式资源。`按依赖 / 按类型` 使用各自前端排列,dependency 模式额外绘制当前 manifest 与资源投影可证明的依赖关系。排列与图层都不写回 manifest,不能推断或伪造缺失依赖。
|
||||
- 资源卡支持点击聚焦、搜索和类型筛选。2026-07-28 起完成两套二维坐标与本地 CAS sidecar;2026-07-31 起 dependency 模式增加不持久化的原生 SVG 关系图层。2026-08-03 mentor 决定暂缓资源总览卡片拖动,当前卡片不挂载 Pointer Down / Move / Up / Cancel 拖动入口,只允许自动布局和点击聚焦。聚焦态替换中央主视窗内容,保留左侧导航、右侧对话和底部 Agent 状态栏,退出后恢复搜索、布局模式、滚动位置与选中资源;不提供通用工具栏、工具侧边栏或可拖动标题栏。阶段四已补齐安全本地文档、扩展美术媒体与音频聚焦,正文独立滚动,视频 / 音频使用内置媒体控件,失败显示空态。该资源总览边界不限制后续素材创作无限画布内的图片图层移动/缩放、生成和正式回写。
|
||||
- 运行表现层首版直接嵌入当前项目的 loopback 游戏画面,并展示上一项 / 暂停继续 / 下一项切片控制、素材信息和数值微调面板。`preview.start` 启动本地 server 后把真实 URL 回写工作台,`preview.open` 只激活客户端内运行视图,不再调用系统浏览器;切片、参数调整和自然语言新增调节项首版仍只保留本地 UI 草稿,不修改代码或 manifest。
|
||||
- 运行表现层首版直接嵌入当前项目的 loopback 游戏画面,并展示上一项 / 暂停继续 / 下一项切片控制、素材信息和数值微调面板。`preview.start` 启动本地 server 后把真实 URL 回写工作台,`preview.open` 只激活客户端内运行视图,不再调用系统浏览器;切片、参数调整和自然语言新增调节项首版仍只保留本地 UI 草稿,不修改代码或 manifest。preview server 对 UTF-8 HTML 响应注入固定同源尺寸桥脚本;注入点通过真实 HTML tokenizer 边界定位,保守处理注释异常结束、DOCTYPE 引号、script escaped / double-escaped、raw-text、template、plaintext、foreign content 与重复 `src`,并支持省略 `</body>` / `</html>`。桥以 `ResizeObserver` 观察 `documentElement / body` 根布局,结合页面 load、窗口 resize 与字体就绪重新测量;页面可见时另以 `500ms` 低频兜底探测至多 `512` 个元素的实际边界,探测截断时保留 body / scroll 上界,并按连续测量排除随 viewport 同步变化的 `100vh / 100% / bottom / right` 自反馈。相同尺寸元组去重后才以固定版本 `postMessage` 上报,不订阅整页 `MutationObserver`。宿主同时校验消息 origin 和 `event.source`,以实际内容宽高与当前容器宽高计算不超过 `1` 的等比缩放;首次适配后仍接受内容宽高的真实变化,但仅 viewport 回灌或重复内容尺寸不更新 React 状态。容器 resize 后回到原生视口重新测量;放得下时保持 `1:1`,超出时完整缩小并居中,iframe 禁止横纵滚动条,不能以 `overflow: hidden` 直接裁掉超出内容。非 UTF-8 HTML 原样返回,不因适配桥破坏已有预览。
|
||||
- 右侧继续复用现有 Project Supervisor 会话、Runtime 澄清和确认链路;输入区展示 `严格审批 / 风险审批 / 无需审批` 独立面板。P0 只有严格审批可选;风险审批和无需审批保持视觉不可用但允许点击查看原因,不替代 Runtime 的逐动作权限、确认、sandbox 或 reconciliation 门禁。风险 Rank 算法记录在 `docs/project-memory/todos/【待解决】AI游戏创作高风险审批Rank-2026-07-20.md`,前端不得自行计算。
|
||||
- 底部状态栏默认展示策划、美术、程序 3 组,并允许在同一栏展开数值、音频、发布组;状态来自 manifest 与当前 Supervisor run 的 Runtime,悬停显示当前任务与进度。累计泥点必须等待后端计费归因投影;Agent.md 编辑和自定义 Skill 在来源审核、版本、权限、sandbox 与回滚合同完备前不向普通用户开放。
|
||||
- 当前 run 专业状态与项目历史成果分离:状态继续严格匹配当前 `parentRunId`;已有文本成果从专业 Agent 持久对话中合法的 `agent-finalization-<32 lower hex>` assistant 恢复,并以“历史成果”来源投影到资源管理文档区。新 run 失败、待确认、候选为空或持久对话瞬时读取失败不得清除已恢复的旧成功回执,普通失败 assistant 也不得被当作成果。
|
||||
|
||||
Reference in New Issue
Block a user