Skip to content

feat(code): add opencode#2962

Draft
adboio wants to merge 1 commit into
mainfrom
06-27-feat_code_add_opencode
Draft

feat(code): add opencode#2962
adboio wants to merge 1 commit into
mainfrom
06-27-feat_code_add_opencode

Conversation

@adboio

@adboio adboio commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Problem

Changes

How did you test this?

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

adboio commented Jun 27, 2026

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit d495259.

@greptile-apps

greptile-apps Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "feat(code): add opencode" | Re-trigger Greptile

} catch {
// npx cache absent — fine.
}
return found.sort((a, b) => fs.statSync(b).mtimeMs - fs.statSync(a).mtimeMs);

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.

P1 The fs.statSync calls inside the sort comparator sit outside the surrounding try/catch. readdirSync and existsSync are guarded, but the subsequent sort is not. If any file in found is deleted or becomes inaccessible between the existsSync check and the statSync call (e.g., a concurrent npm operation flushes the npx cache), the sort throws synchronously and propagates through resolveOpencodeBinaryPath — preventing getOpencodeBinaryPath() from returning the bundled binary path even when it exists, and causing session initialization to fail.

Suggested change
return found.sort((a, b) => fs.statSync(b).mtimeMs - fs.statSync(a).mtimeMs);
try {
return found.sort(
(a, b) => fs.statSync(b).mtimeMs - fs.statSync(a).mtimeMs,
);
} catch {
return found;
}

Comment on lines +53 to +56
if (options.length === 0) return option;
const isGroup = "group" in options[0];

if (isGroup) {

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.

P2 The isGroup flag is set by inspecting only options[0]. If opencode ever returns a mixed-shape array — even one flat option following a group — all entries after the first will be cast to the wrong type. In the flat branch, isPosthogModel(opt) accesses opt.value which is undefined for group objects, throwing a TypeError. Using Array.prototype.every gives a safe exhaustive guard at negligible cost.

Suggested change
if (options.length === 0) return option;
const isGroup = "group" in options[0];
if (isGroup) {
if (options.length === 0) return option;
const isGroup = options.every((o) => "group" in o);
if (isGroup) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant