Files
DeepSeek-Reasonix/desktop/main.go
T
SivanColaandreasonix b87a878cad feat(desktop): project topic tabs and context inspector (#2925)
* feat(desktop): add project tabs and context inspector

* feat(desktop): refine project workspace UI

* fix 打开一致加载

* 顶部统一logo+左侧边栏+统一菜单

* 底部最低宽度

* update much

* update code

* update code

* feat(desktop): refine workspace layout and message actions

* fix(desktop): scope file refs to active tab root

* test(desktop): stabilize capabilities config dirs

* fix(desktop): protect sessions open in other tabs

* fix(desktop): resume scoped history in matching tab

* chore(desktop): drop committed scratch artifacts; ignore tmp/ and .codex/

The project-tabs branch carried 30 throwaway screenshots, a mock HTML,
and a codex env file into the tree because tmp/ and .codex/ were never
ignored. Remove them and add the ignore rules so scratch output stays
out of future commits.

* test(desktop): isolate AppData per test so the suite passes on Windows

The new project/topic/workspace tests only overrode HOME and
XDG_CONFIG_HOME, but desktopConfigDir() and config.MemoryUserDir()
resolve through os.UserConfigDir(), which reads %AppData% on Windows and
ignores those vars. With AppData pointed at one shared TestMain dir, the
project/topic/workspace registries leaked across tests: full-package
runs failed (project tree len 2 want 1, trash mixing other tests'
sessions, Plugins[0] reading a neighbor's MCP entry) while each test
passed alone.

Route every test through isolateDesktopUserDirs, which already sets
HOME, USERPROFILE, XDG_CONFIG_HOME, and AppData to a per-test temp dir.
go test ./... (and -race) now pass on Windows.

---------

Co-authored-by: reasonix <[email protected]>
2026-06-04 19:41:16 -07:00

110 lines
4.1 KiB
Go

// Command reasonix-desktop is the Wails shell around the Reasonix kernel: a native
// window hosting a webview frontend, with the Go-side control.Controller bound
// directly to the UI (no HTTP hop — bindings in, runtime events out). It lives in
// a nested module (reasonix/desktop) so the CGO/WebKit desktop build never touches
// the CLI's CGO_ENABLED=0 single-static-binary guarantee, while still importing
// the same internal/* kernel.
package main
import (
"embed"
"github.com/wailsapp/wails/v2"
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
"github.com/wailsapp/wails/v2/pkg/options/linux"
"github.com/wailsapp/wails/v2/pkg/options/mac"
"github.com/wailsapp/wails/v2/pkg/options/windows"
// Blank imports wire compile-time built-ins into their registries, exactly as
// cmd/reasonix does — boot.Build resolves providers/tools from these registries.
_ "reasonix/internal/provider/anthropic"
_ "reasonix/internal/provider/openai"
_ "reasonix/internal/tool/builtin"
)
// assets embeds the built frontend. `all:` so dotfiles (e.g. the dist .gitkeep
// that keeps this directive compilable before the first `pnpm build`) are
// included. A real run requires `pnpm build` (or `wails build`) to populate dist.
//
//go:embed all:frontend/dist
var assets embed.FS
// version is injected at build time via `wails build -ldflags "-X main.version=..."`,
// mirroring cmd/reasonix/main.go. The auto-updater reads it (App.Version) to compare
// against the published manifest; an un-injected dev build stays "dev" and never
// prompts to update.
var version = "dev"
func main() {
app := NewApp()
// Restore saved window size, or fall back to the default.
width, height := 1240, 720
if saved, ok := loadWindowState(); ok {
if saved.Width > 0 {
width = saved.Width
}
if saved.Height > 0 {
height = saved.Height
}
}
err := wails.Run(&options.App{
Title: "Reasonix",
Width: width,
Height: height,
MinWidth: 760,
MinHeight: 480,
// Match the dark UI shell so the initial webview background doesn't flash
// white before CSS loads — particularly visible on WebKitGTK.
BackgroundColour: &options.RGBA{R: 26, G: 26, B: 46, A: 255},
AssetServer: &assetserver.Options{Assets: assets},
OnStartup: app.startup,
OnDomReady: app.domReady,
OnBeforeClose: app.beforeClose,
OnShutdown: app.shutdown,
Bind: []any{app},
SingleInstanceLock: singleInstanceLock(app),
// Start hidden — domReady positions and shows the window after restoring
// geometry, so the user never sees the default size/position flash.
StartHidden: true,
// Native application menu (File > Settings, Edit, Window).
Menu: app.createAppMenu(),
// Native OS file drops: the webview withholds dropped files' paths from the
// HTML drop event, so the frontend (composer) reads them via runtime.OnFileDrop
// against the --wails-drop-target element instead.
DragAndDrop: &options.DragAndDrop{EnableFileDrop: true},
// --- per-platform adaptation (see desktop/README.md for the rationale) ---
Mac: &mac.Options{
// Inset traffic-lights over a frameless-feeling header; the frontend
// leaves a drag region at the top (CSS --wails-draggable).
TitleBar: mac.TitleBarHiddenInset(),
// Follow the OS appearance so the title bar matches light/dark system
// preference instead of being locked to dark.
Appearance: mac.DefaultAppearance,
},
Windows: &windows.Options{
// Follow the OS theme so the title bar matches light/dark system
// preference instead of being locked to dark.
Theme: windows.SystemDefault,
},
Linux: &linux.Options{
ProgramName: "Reasonix",
// WebKitGTK GPU compositing is inconsistent across distros/drivers and
// is the one real cross-platform rough edge for a Go+webview stack:
// "always" can yield blank or flickering webviews on some setups, so
// we let the webview decide on demand. Users still hitting artifacts
// can fall back to WEBKIT_DISABLE_COMPOSITING_MODE=1 (see README).
WebviewGpuPolicy: linux.WebviewGpuPolicyOnDemand,
},
})
if err != nil {
println("Error:", err.Error())
}
}