Skip to content

fix(github): use canonical share URL from API instead of constructing it#26431

Closed
xxiaoxiong wants to merge 2 commits intoanomalyco:devfrom
xxiaoxiong:fix/github-action-share-url
Closed

fix(github): use canonical share URL from API instead of constructing it#26431
xxiaoxiong wants to merge 2 commits intoanomalyco:devfrom
xxiaoxiong:fix/github-action-share-url

Conversation

@xxiaoxiong
Copy link
Copy Markdown

Summary

Fixes GitHub Actions bot comments that were generating broken share links using the old URL format.

Problem

GitHub Actions bot comments append share links like:

https://opencode.ai/s/It7ivB4n

These links now 404. The canonical share URL format has changed to:

https://opncd.ai/share/uaFpXIla

Root Cause

The code was:

  1. Calling the share API but ignoring the returned URL
  2. Manually constructing the share URL using session.id.slice(-8)
  3. Hardcoding the base URL as https://opencode.ai

This broke when:

  • The share service started returning different IDs than session IDs
  • The base URL changed from opencode.ai to opncd.ai
  • The path changed from /s/ to /share/

Solution

Use the canonical share URL returned by the share API instead of constructing it manually.

Before:

await Effect.runPromise(sessionShare.share(session.id))
shareId = session.id.slice(-8)
const link = `${shareBaseUrl}/s/${shareId}`

After:

const result = await Effect.runPromise(sessionShare.share(session.id))
shareUrl = result.url
const link = shareUrl

Changes

packages/opencode/src/cli/cmd/github.ts:

  • Renamed shareId to shareUrl to reflect that it now stores the full URL
  • Capture result.url from sessionShare.share() instead of deriving from session ID
  • Use shareUrl directly in links and comments
  • Extract share ID from URL for social card image generation

github/index.ts:

  • Same changes for the legacy GitHub action path
  • Use SDK client session.share() response: result.data?.share?.url

Testing

  • The share API already returns the correct URL format
  • Social card image generation still works (extracts ID from URL)
  • Comment deduplication still works (checks for full URL in existing comments)
  • No runtime behavior changes beyond using the correct URL

Impact

  • GitHub Actions comments will now include working share links
  • Existing broken links in old comments remain broken (cannot be fixed retroactively)
  • Future comments will use the canonical URL format

Fixes #26417

xxiaoxiong added 2 commits May 9, 2026 08:38
The SessionPromptData type was missing the 'format' field that exists
in the OpenAPI spec. This field allows users to specify structured
output formats (text or json_schema) when sending prompts.

Added missing types:
- OutputFormatText: for plain text output
- OutputFormatJsonSchema: for JSON schema-based structured output
- OutputFormat: union type of the above
- format?: OutputFormat field in SessionPromptData.body

This allows TypeScript users to use the format parameter without
type errors, matching the actual API behavior.

Fixes anomalyco#26408
GitHub Actions bot comments were using the old hardcoded URL format
'https://opencode.ai/s/<id>' which now 404s. The canonical share URL
format is now 'https://opncd.ai/share/<id>' and is returned by the
share API.

Changes:
- Capture the full share URL from sessionShare.share() result
- Use the returned URL directly in comments and links
- Extract share ID from URL for social card image generation
- Update both packages/opencode/src/cli/cmd/github.ts and github/index.ts

Before:
  shareId = session.id.slice(-8)
  link = `${shareBaseUrl}/s/${shareId}`

After:
  shareUrl = result.url  // e.g. 'https://opncd.ai/share/xxx'
  link = shareUrl

Fixes anomalyco#26417
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label May 9, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

The following comment was made by an LLM, it may be inaccurate:

Potential duplicate found:

This PR appears to be addressing the same issue: fixing broken share links in GitHub Actions bot comments. It's likely either a related fix or a duplicate attempt to resolve the same problem with the canonical share URL format change.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label May 9, 2026
@github-actions github-actions Bot closed this May 9, 2026
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.

Fix GitHub action opencode session share links

1 participant