Skip to content

Gpt image 2 support#193

Merged
yangjunx21 merged 7 commits intomainfrom
gpt-image-2-support
Apr 23, 2026
Merged

Gpt image 2 support#193
yangjunx21 merged 7 commits intomainfrom
gpt-image-2-support

Conversation

@yangjunx21
Copy link
Copy Markdown
Collaborator

Summary

Lets the agent call gpt-image-2 (or OpenRouter image models) on demand to generate bitmap assets (logos, hero images, illustrations) while producing a design, and embeds them seamlessly in preview + exports. Off by default; users opt in from Settings.

Type of change

  • New feature

Linked issue

Checklist

  • I read docs/VISION.md, docs/PRINCIPLES.md, and CLAUDE.md before starting
  • Commits are signed with DCO (git commit -s)
  • pnpm lint && pnpm typecheck && pnpm test passes locally
  • Added/updated tests for the change
  • Added a changeset (pnpm changeset) if user-visible
  • Updated docs if behavior changed

Dependency additions (if any)

Screenshots / recordings (UI changes)

yangjunx21 and others added 7 commits April 23, 2026 11:31
Signed-off-by: 杨峻骁 <yangjunx21@mails.tsinghua.edu.cn>
Signed-off-by: 杨峻骁 <yangjunx21@mails.tsinghua.edu.cn>
Signed-off-by: 杨峻骁 <yangjunx21@mails.tsinghua.edu.cn>
POSIX-specific assertions were baked into six tests, which made the full
`pnpm test` suite fail on Windows even though the production code is
already cross-platform:

- token-store: `0o600` mode bits aren't enforceable on NTFS (reports
  0o666); guard the assertion with `process.platform !== 'win32'`.
- skills/loader: `new URL(...).pathname` yields `/D:/...` on Windows, so
  `readdir` sees zero files; use `fileURLToPath()` instead.
- opencode-config, locale-ipc, preferences-ipc: replace hard-coded
  forward-slash path strings with `path.join()`-built expectations that
  mirror whatever separator the host OS uses.
- boot-fallback: `/dev/null/...` is only guaranteed-unwritable on POSIX;
  build a parent-is-a-regular-file path instead so `mkdirSync` throws
  ENOTDIR on both platforms.

All 10 workspace packages' tests now pass on Windows.

Made-with: Cursor
Signed-off-by: 杨峻骁 <yangjunx21@mails.tsinghua.edu.cn>
Made-with: Cursor
Signed-off-by: 杨峻骁 <yangjunx21@mails.tsinghua.edu.cn>
CodeQL flagged the anchored-quantifier pair `/\/+$/` + `/^\/+/` inside
`joinEndpoint` (packages/providers/src/images.ts) as a potential ReDoS
on library-supplied input. Replace both regex calls with explicit
single-pass scans over the trailing/leading `/` characters — same
behaviour, trivially linear, no CodeQL alert.

Also unblock the Windows test run on this branch:
- `token-store.test.ts`: a new 0o600-mode assertion added on main
  fails on NTFS (always reports 0o666); guard it the same way the
  existing sibling assertion is guarded.
- `safe-read.test.ts`: the symlink-acceptance case requires admin /
  Developer Mode on Windows and otherwise throws EPERM; skip the
  case when symlink creation is denied, keeping full coverage on
  POSIX CI.

Signed-off-by: 杨峻骁 <yangjunx21@mails.tsinghua.edu.cn>
Made-with: Cursor
Resolve conflict in Settings.tsx: close JSX tags around the new ImageGenerationPanel Save button/wrappers that were dropped during the merge, and drop hardcoded hex fallbacks (#16a34a, #d97706) and text-[10px] in the image-generation status badge in favor of --color-success / --color-warning / text-[var(--text-xs)] tokens.

Made-with: Cursor
@github-actions github-actions Bot added area:desktop apps/desktop (Electron shell, renderer) area:core packages/core (generation orchestration) area:providers packages/providers (pi-ai adapter, model calls) labels Apr 23, 2026
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Findings

  • [Major] Enabled image generation silently degrades by disabling the image tool when credentials are missing. This violates the project rule to avoid silent fallbacks and can produce non-image outputs without explicit user-facing failure. Evidence: apps/desktop/src/main/image-generation-settings.ts:124, apps/desktop/src/main/index.ts:378, apps/desktop/src/main/index.ts:433.
    Suggested fix:
    const cfg = getCachedConfig();
    const imageConfig = cfg ? resolveImageGenerationConfig(cfg) : null;
    if (cfg?.imageGeneration?.enabled === true && imageConfig === null) {
      throw new CodesignError(
        'Image generation is enabled but credentials are missing or invalid. Update Settings > Image Generation.',
        ERROR_CODES.PROVIDER_AUTH_MISSING,
      );
    }

Summary

  • Review mode: initial
  • Not found in repo/docs: docs/VISION.md, docs/PRINCIPLES.md.

Testing

  • Not run (automation)

open-codesign Bot

throw err;
}
}
: undefined;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Major] This branch silently disables generate_image_asset when image generation is enabled but credentials are unavailable (resolveImageGenerationConfig returns null). That is a silent fallback rather than a surfaced error.

Suggested fix:

const cfg = getCachedConfig();
const imageConfig = cfg ? resolveImageGenerationConfig(cfg) : null;
if (cfg?.imageGeneration?.enabled === true && imageConfig === null) {
  throw new CodesignError(
    'Image generation is enabled but credentials are missing or invalid. Update Settings > Image Generation.',
    ERROR_CODES.PROVIDER_AUTH_MISSING,
  );
}

@yangjunx21 yangjunx21 merged commit 1377b4f into main Apr 23, 2026
7 checks passed
@yangjunx21 yangjunx21 deleted the gpt-image-2-support branch April 23, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core packages/core (generation orchestration) area:desktop apps/desktop (Electron shell, renderer) area:providers packages/providers (pi-ai adapter, model calls)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant