Skip to content

App rework#1

Open
attikusfinch wants to merge 8 commits into
TONresistor:mainfrom
attikusfinch:app-rework
Open

App rework#1
attikusfinch wants to merge 8 commits into
TONresistor:mainfrom
attikusfinch:app-rework

Conversation

@attikusfinch

Copy link
Copy Markdown

No description provided.

AttikusFinch and others added 8 commits June 12, 2026 05:30
Uncommitted MVP work carried over before the app rework:
- cmd/gocoon/ui.go: local wallet + chat web UI (uiServer, embedded HTML/CSS/JS)
- cmd/gocoon/desktop_*.go: webview_go desktop window with Win32 frameless chrome
- cmd/gocoon/assets: Cocoon branding (egg logo, icons)
- main.go: `gocoon ui` command, desktop auto-launch, runner path resolution
- docs/app-plan.md: roadmap for the Tauri 2 app and core rework

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- pkg/setup: canonical onboarding package (wallet create/import/restore,
  client-config rendering, backups, funding checks, nanoTON formatting);
  cmd/gocoon and cmd/gocoon-runner now share one implementation
- runner: new --data-dir mode boots the HTTP control plane before any
  config exists; /api/* endpoints drive onboarding (state, wallet
  create/import/backup/qr, engine start/stop, logs); engine extracted into
  a start/stoppable struct so the cocoon client runs in-process
- runner: /v1/chat/completions serves SSE for stream:true requests — full
  upstream passthrough behind GOCOON_UPSTREAM_STREAM=1 (pending live
  verification), otherwise the complete answer is converted into a single
  chat.completion.chunk delta + [DONE], so UI streaming code works today
- wallet import: 24-word mnemonic (owner restore, fresh node key) or full
  backup JSON (exact restore)
- tests: pkg/setup roundtrips, app API handlers, SSE conversion/passthrough

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
JSON file per conversation in <data-dir>/chats/ with atomic writes;
REST: GET/POST /api/chats, GET/PUT/DELETE /api/chats/{id}. Messages are
stored as raw JSON so the UI schema can evolve without core changes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Browser preflight rejected chat persistence (PUT) and deletion because
Access-Control-Allow-Methods only listed GET/POST.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Verified on mainnet 2026-06-12 with a real channel: the proxy completes
stream:true requests but delivers only empty payload chunks, so the
SSE-conversion fallback stays the default. Full chat E2E (register reuse,
inference, SSE delta response) confirmed working.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- pkg/setup: ChannelInfo + FindChannel scan the node wallet transaction
  history for cocoon_client contracts owned by it (the SC address is
  proxy-assigned, so tx history is the only local way to rediscover a
  channel before a session exists); FetchChannelInfo parses the client
  SC storage incl. owner/proxy refs
- app API: /api/state wallet.channel (background scan, 60s cache) - a
  returning user with a staked channel skips the funding screen even
  when the wallet balance is below the recommended amount
- CORS headers on /jsonstats and /request/* (responses were unreadable
  from browser/webview origins: requests reached the server but the
  page saw "Failed to fetch")
- cmd/gocoon channel info now reuses the setup parser

Verified live: channel EQBcyin...FoRo (15 TON stake) found on a wallet
holding only 5.87 TON; session ready; chat answered by Qwen3-32B.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The engine (liteclient stack, store, sessions, discovery), client config,
RunnerState, tools translation, and the whole OpenAI-compatible chat
passthrough (SSE conversion incl.) move from cmd/gocoon-runner into the
exported pkg/core so external modules (the upcoming public API gateway,
a separate project) can embed the same implementation.

- OpenAIProxy gains an OnUsage hook (parsed usage block per completed
  request) and MaxTokens/MaxCoefficient caps for metering and quota
  enforcement by embedders
- RunnerState gets Snapshot()/HasReadySession() accessors instead of
  exposing its mutex
- gocoon-runner is now a thin shell: HTTP control plane, /api app
  endpoints, chat history; behavior unchanged (tests preserved)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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