Vectrum
Sign In
82 lines · 2.6 KB · Rust
//! Vectrum Code: a minimal T3 Code-style desktop client for Claude Code.

// GPUI's derive macros expand to `gpui::` paths; route them through the Kit.
extern crate gpui_kit as gpui;

mod claude;
mod git;
mod models;
mod session;
mod settings;
mod ui;

use std::path::PathBuf;

use gpui_kit::*;

use crate::ui::{icons::AppAssets, metal, workspace::Workspace};

gpui_kit::actions!(
    vectrum_code,
    [
        NewThread,
        OpenProject,
        Interrupt,
        ToggleSidebar,
        ToggleProjectPanel,
        FocusSearch,
        OpenSettings,
        CloseSettings,
        Quit
    ]
);

fn main() {
    let project = std::env::args_os()
        .nth(1)
        .map(PathBuf::from)
        .or_else(|| std::env::current_dir().ok())
        .unwrap_or_else(|| PathBuf::from("."));
    let project = project.canonicalize().unwrap_or(project);

    gpui_kit::application()
        .with_assets(AppAssets)
        .run(move |cx| {
            gpui_kit::init(cx);
            metal::load_fonts(cx);
            metal::restore_colorway(cx);
            models::Catalog::init(cx);

            cx.bind_keys([
                KeyBinding::new("ctrl-n", NewThread, None),
                KeyBinding::new("ctrl-o", OpenProject, None),
                KeyBinding::new("ctrl-b", ToggleSidebar, None),
                KeyBinding::new("ctrl-shift-b", ToggleProjectPanel, None),
                KeyBinding::new("ctrl-k", FocusSearch, None),
                KeyBinding::new("ctrl-,", OpenSettings, None),
                KeyBinding::new("ctrl-q", Quit, None),
                KeyBinding::new("escape", Interrupt, Some("ChatView")),
                KeyBinding::new("escape", CloseSettings, Some("SettingsView")),
            ]);
            cx.on_action(|_: &Quit, cx| cx.quit());
            cx.on_window_closed(|cx, _| cx.quit()).detach();

            let bounds = Bounds::centered(None, size(px(1280.), px(840.)), cx);
            let options = WindowOptions {
                window_bounds: Some(WindowBounds::Windowed(bounds)),
                titlebar: Some(TitlebarOptions {
                    title: Some("Vectrum Code".into()),
                    ..Default::default()
                }),
                app_id: Some("vectrum-code".into()),
                window_min_size: Some(size(px(820.), px(520.))),
                ..Default::default()
            };
            gpui_kit::open_window(options, cx, |window, cx| {
                metal::sync_appearance(window, cx);
                cx.new(|cx| Workspace::new(project, window, cx))
            })
            .expect("failed to open the main window");
            cx.activate(true);
        });
}