Skip to content

Commit cd6bfb3

Browse files
OpenCode Desktop app (anomalyco#5044)
Co-authored-by: Adam <2363879+adamdotdevin@users.noreply.github.com>
1 parent ba417d8 commit cd6bfb3

File tree

79 files changed

+1410
-260
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+1410
-260
lines changed

.github/workflows/publish.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ permissions:
2626
jobs:
2727
publish:
2828
runs-on: blacksmith-4vcpu-ubuntu-2404
29+
if: github.repository == 'sst/opencode'
2930
steps:
3031
- uses: actions/checkout@v3
3132
with:
@@ -79,3 +80,76 @@ jobs:
7980
GITHUB_TOKEN: ${{ secrets.SST_GITHUB_TOKEN }}
8081
AUR_KEY: ${{ secrets.AUR_KEY }}
8182
OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
83+
84+
publish-tauri:
85+
strategy:
86+
matrix:
87+
settings:
88+
- host: macos-latest
89+
target: x86_64-apple-darwin
90+
- host: macos-latest
91+
target: aarch64-apple-darwin
92+
- host: windows-latest
93+
target: x86_64-pc-windows-msvc
94+
- host: ubuntu-24.04
95+
target: x86_64-unknown-linux-gnu
96+
runs-on: ${{ matrix.settings.host }}
97+
steps:
98+
- uses: actions/checkout@v3
99+
with:
100+
fetch-depth: 0
101+
102+
- run: git fetch --force --tags
103+
104+
- uses: ./.github/actions/setup-bun
105+
106+
- name: install dependencies (ubuntu only)
107+
if: startsWith(matrix.settings.host, 'ubuntu')
108+
run: |
109+
sudo apt-get update
110+
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
111+
112+
- name: install Rust stable
113+
uses: dtolnay/rust-toolchain@stable
114+
with:
115+
targets: ${{ matrix.settings.target }}
116+
117+
- uses: Swatinem/rust-cache@v2
118+
with:
119+
workspaces: packages/tauri/src-tauri
120+
shared-key: ${{ matrix.settings.target }}
121+
122+
- name: Prepare
123+
run: |
124+
cd packages/tauri
125+
bun ./scripts/prepare.ts
126+
env:
127+
OPENCODE_BUMP: ${{ inputs.bump }}
128+
OPENCODE_VERSION: ${{ inputs.version }}
129+
OPENCODE_CHANNEL: latest
130+
NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}
131+
GITHUB_TOKEN: ${{ secrets.SST_GITHUB_TOKEN }}
132+
AUR_KEY: ${{ secrets.AUR_KEY }}
133+
OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
134+
RUST_TARGET: ${{ matrix.settings.target }}
135+
GH_TOKEN: ${{ github.token }}
136+
137+
# Fixes AppImage build issues, can be removed when https://github.com/tauri-apps/tauri/pull/12491 is released
138+
- run: cargo install tauri-cli --git https://github.com/tauri-apps/tauri --branch feat/truly-portable-appimage
139+
if: startsWith(matrix.settings.host, 'ubuntu')
140+
141+
- name: Build and upload artifacts
142+
uses: tauri-apps/tauri-action@390cbe447412ced1303d35abe75287949e43437a
143+
env:
144+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
145+
TAURI_BUNDLER_NEW_APPIMAGE_FORMAT: true
146+
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
147+
with:
148+
projectPath: packages/tauri
149+
uploadWorkflowArtifacts: true
150+
tauriScript: ${{ (startsWith(matrix.settings.host, 'ubuntu') && 'cargo tauri') || '' }}
151+
args: --target ${{ matrix.settings.target }}
152+
updaterJsonPreferNsis: true
153+
releaseDraft: true
154+
tagName: ${{ inputs.version }}
155+
releaseName: ${{ inputs.version }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ refs
1818
Session.vim
1919
opencode.json
2020
a.out
21+
target

bun.lock

Lines changed: 215 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/desktop/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
"version": "1.0.133",
44
"description": "",
55
"type": "module",
6+
"exports": {
7+
".": "./src/index.tsx",
8+
"./vite": "./vite.js"
9+
},
610
"scripts": {
711
"typecheck": "tsgo --noEmit",
812
"start": "vite",

packages/desktop/src/pages/layout.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default function Layout(props: ParentProps) {
3535

3636
return (
3737
<div class="relative h-screen flex flex-col">
38-
<header class="h-12 shrink-0 bg-background-base border-b border-border-weak-base flex">
38+
<header class="h-12 shrink-0 bg-background-base border-b border-border-weak-base flex" data-tauri-drag-region>
3939
<A
4040
href="/"
4141
classList={{
@@ -44,6 +44,7 @@ export default function Layout(props: ParentProps) {
4444
"border-r border-border-weak-base": true,
4545
}}
4646
style={{ width: layout.sidebar.opened() ? `${layout.sidebar.width()}px` : undefined }}
47+
data-tauri-drag-region
4748
>
4849
<Mark class="shrink-0" />
4950
</A>
@@ -215,7 +216,7 @@ export default function Layout(props: ParentProps) {
215216
>
216217
<Tooltip placement="right" value={session.title}>
217218
<div
218-
class="w-full px-2 py-1 rounded-md
219+
class="w-full px-2 py-1 rounded-md
219220
group-data-[active=true]/session:bg-surface-raised-base-hover
220221
group-hover/session:bg-surface-raised-base-hover
221222
group-focus/session:bg-surface-raised-base-hover"

packages/desktop/vite.config.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
11
import { defineConfig } from "vite"
2-
import solidPlugin from "vite-plugin-solid"
3-
import tailwindcss from "@tailwindcss/vite"
4-
import path from "path"
2+
import desktopPlugin from "./vite"
53

64
export default defineConfig({
7-
resolve: {
8-
alias: {
9-
"@": path.resolve(__dirname, "./src"),
10-
},
11-
},
12-
plugins: [tailwindcss(), solidPlugin()] as any,
5+
plugins: [desktopPlugin] as any,
136
server: {
147
host: "0.0.0.0",
158
allowedHosts: true,
@@ -18,7 +11,4 @@ export default defineConfig({
1811
build: {
1912
target: "esnext",
2013
},
21-
worker: {
22-
format: "es",
23-
},
2414
})

packages/desktop/vite.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import solidPlugin from "vite-plugin-solid"
2+
import tailwindcss from "@tailwindcss/vite"
3+
import { fileURLToPath } from "url"
4+
5+
/**
6+
* @type {import("vite").PluginOption}
7+
*/
8+
export default [
9+
{
10+
name: "opencode-desktop:config",
11+
config() {
12+
return {
13+
resolve: {
14+
alias: {
15+
"@": fileURLToPath(new URL("./src", import.meta.url)),
16+
},
17+
},
18+
worker: {
19+
format: "es",
20+
},
21+
}
22+
},
23+
},
24+
tailwindcss(),
25+
solidPlugin(),
26+
]

packages/tauri/index.html

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,28 @@
11
<!doctype html>
22
<html lang="en">
33
<head>
4-
<meta charset="UTF-8" />
5-
<link rel="stylesheet" href="/src/styles.css" />
6-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7-
<title>Tauri App</title>
8-
<script type="module" src="/src/main.ts" defer></script>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1" />
6+
<title>OpenCode</title>
7+
<link rel="icon" type="image/png" href="/favicon-96x96.png" sizes="96x96" />
8+
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
9+
<link rel="shortcut icon" href="/favicon.ico" />
10+
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
11+
<link rel="manifest" href="/site.webmanifest" />
12+
<meta name="theme-color" content="#F8F7F7" />
13+
<meta name="theme-color" content="#131010" media="(prefers-color-scheme: dark)" />
14+
<meta property="og:image" content="/social-share.png" />
15+
<meta property="twitter:image" content="/social-share.png" />
916
</head>
10-
11-
<body>
12-
<main class="container">
13-
<h1>Welcome to Tauri</h1>
14-
15-
<div class="row">
16-
<a href="https://vite.dev" target="_blank">
17-
<img src="/src/assets/vite.svg" class="logo vite" alt="Vite logo" />
18-
</a>
19-
<a href="https://tauri.app" target="_blank">
20-
<img src="/src/assets/tauri.svg" class="logo tauri" alt="Tauri logo" />
21-
</a>
22-
<a href="https://www.typescriptlang.org/docs" target="_blank">
23-
<img src="/src/assets/typescript.svg" class="logo typescript" alt="typescript logo" />
24-
</a>
25-
</div>
26-
<p>Click on the Tauri logo to learn more about the framework</p>
27-
28-
<form class="row" id="greet-form">
29-
<input id="greet-input" placeholder="Enter a name..." />
30-
<button type="submit">Greet</button>
31-
</form>
32-
<p id="greet-msg"></p>
33-
</main>
17+
<body class="antialiased overscroll-none select-none text-12-regular">
18+
<script>
19+
;(function () {
20+
const savedTheme = localStorage.getItem("theme") || "oc-1"
21+
document.documentElement.setAttribute("data-theme", savedTheme)
22+
})()
23+
</script>
24+
<noscript>You need to enable JavaScript to run this app.</noscript>
25+
<div id="root"></div>
26+
<script src="/src/index.ts" type="module"></script>
3427
</body>
3528
</html>

packages/tauri/package.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,26 @@
44
"version": "1.0.133",
55
"type": "module",
66
"scripts": {
7+
"predev": "bun ./scripts/predev.ts",
78
"dev": "vite",
89
"build": "tsc && vite build",
910
"preview": "vite preview",
1011
"tauri": "tauri"
1112
},
1213
"dependencies": {
14+
"@opencode-ai/desktop": "workspace:*",
1315
"@tauri-apps/api": "^2",
14-
"@tauri-apps/plugin-opener": "^2"
16+
"@tauri-apps/plugin-dialog": "~2",
17+
"@tauri-apps/plugin-opener": "^2",
18+
"@tauri-apps/plugin-shell": "~2",
19+
"@tauri-apps/plugin-updater": "~2",
20+
"solid-js": "catalog:"
1521
},
1622
"devDependencies": {
23+
"@actions/artifact": "4.0.0",
1724
"@tauri-apps/cli": "^2",
18-
"vite": "^6.0.3",
19-
"typescript": "~5.6.2"
25+
"@types/bun": "catalog:",
26+
"typescript": "~5.6.2",
27+
"vite": "catalog:"
2028
}
2129
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { $ } from "bun"
2+
import * as path from "node:path"
3+
4+
import { RUST_TARGET } from "./utils"
5+
6+
if (!RUST_TARGET) throw new Error("RUST_TARGET not defined")
7+
8+
const BUNDLE_DIR = `src-tauri/target/${RUST_TARGET}/release/bundle`
9+
const BUNDLES_OUT_DIR = path.join(process.cwd(), `src-tauri/target/bundles`)
10+
11+
await $`mkdir -p ${BUNDLES_OUT_DIR}`
12+
await $`cp -r ${BUNDLE_DIR}/*/OpenCode* ${BUNDLES_OUT_DIR}`

0 commit comments

Comments
 (0)