Skip to content

graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs

Python

GUI/harness UX: image thumbnails, clear-on-send, kimi reasoning, codedb steer

Rach Pradhan4e238fe5663a
diff --git a/gui/src-tauri/Cargo.lock b/gui/src-tauri/Cargo.lock
index 95f9d0de..30045043 100644
--- a/gui/src-tauri/Cargo.lock
+++ b/gui/src-tauri/Cargo.lock
@@ -350,6 +350,12 @@ version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
+[[package]]
+name = "byteorder-lite"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495"
+
[[package]]
name = "bytes"
version = "1.11.1"
@@ -499,10 +505,12 @@ version = "0.2.16"
dependencies = [
"anyhow",
"async-trait",
+ "base64 0.22.1",
"bstr",
"bytes",
"diesel",
"futures",
+ "image",
"log",
"portable-pty",
"pretty_assertions",
@@ -524,6 +532,12 @@ dependencies = [
"uuid",
]
+[[package]]
+name = "color_quant"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
+
[[package]]
name = "combine"
version = "4.6.7"
@@ -1084,7 +1098,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
dependencies = [
"libc",
- "windows-sys 0.52.0",
+ "windows-sys 0.61.2",
]
[[package]]
@@ -1475,6 +1489,16 @@ dependencies = [
"wasip3",
]
+[[package]]
+name = "gif"
+version = "0.14.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ee8cfcc411d9adbbaba82fb72661cc1bcca13e8bba98b364e62b2dba8f960159"
+dependencies = [
+ "color_quant",
+ "weezl",
+]
+
[[package]]
name = "gio"
version = "0.18.4"
@@ -1911,7 +1935,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e795dff5605e0f04bff85ca41b51a96b83e80b281e96231bcaaf1ac35103371"
dependencies = [
"byteorder",
- "png",
+ "png 0.17.16",
]
[[package]]
@@ -2029,6 +2053,34 @@ dependencies = [
"icu_properties",
]
+[[package]]
+name = "image"
+version = "0.25.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "85ab80394333c02fe689eaf900ab500fbd0c2213da414687ebf995a65d5a6104"
+dependencies = [
+ "bytemuck",
+ "byteorder-lite",
+ "color_quant",
+ "gif",
+ "image-webp",
+ "moxcms",
+ "num-traits",
+ "png 0.18.1",
+ "zune-core",
+ "zune-jpeg",
+]
+
+[[package]]
+name = "image-webp"
+version = "0.2.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "525e9ff3e1a4be2fbea1fdf0e98686a6d98b4d8f937e1bf7402245af1909e8c3"
+dependencies = [
+ "byteorder-lite",
+ "quick-error",
+]
+
[[package]]
name = "indexmap"
version = "1.9.3"
@@ -2434,6 +2486,16 @@ dependencies = [
"uuid",
]
+[[package]]
+name = "moxcms"
+version = "0.8.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bb85c154ba489f01b25c0d36ae69a87e4a1c73a72631fc6c0eb6dde34a73e44b"
+dependencies = [
+ "num-traits",
+ "pxfm",
+]
+
[[package]]
name = "muda"
version = "0.17.2"
@@ -2449,7 +2511,7 @@ dependencies = [
"objc2-core-foundation",
"objc2-foundation",
"once_cell",
- "png",
+ "png 0.17.16",
"serde",
"thiserror 2.0.18",
"windows-sys 0.60.2",
@@ -2994,6 +3056,19 @@ dependencies = [
"miniz_oxide",
]
+[[package]]
+name = "png"
+version = "0.18.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "60769b8b31b2a9f263dae2776c37b1b28ae246943cf719eb6946a1db05128a61"
+dependencies = [
+ "bitflags 2.11.1",
+ "crc32fast",
+ "fdeflate",
+ "flate2",
+ "miniz_oxide",
+]
+
[[package]]
name = "portable-atomic"
version = "1.13.1"
@@ -3159,6 +3234,18 @@ dependencies = [
"syn 1.0.109",
]
+[[package]]
+name = "pxfm"
+version = "0.1.29"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e0c5ccf5294c6ccd63a74f1565028353830a9c2f5eb0c682c355c471726a6e3f"
+
+[[package]]
+name = "quick-error"
+version = "2.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3"
+
[[package]]
name = "quick-xml"
version = "0.38.4"
@@ -4439,7 +4526,7 @@ dependencies = [
"ico",
"json-patch",
"plist",
- "png",
+ "png 0.17.16",
"proc-macro2",
"quote",
"semver",
@@ -5071,7 +5158,7 @@ dependencies = [
"objc2-core-graphics",
"objc2-foundation",
"once_cell",
- "png",
+ "png 0.17.16",
"serde",
"thiserror 2.0.18",
"windows-sys 0.60.2",
@@ -5559,6 +5646,12 @@ dependencies = [
"windows-core 0.61.2",
]
+[[package]]
+name = "weezl"
+version = "0.1.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a28ac98ddc8b9274cb41bb4d9d4d5c425b6020c50c46f25559911905610b4a88"
+
[[package]]
name = "widestring"
version = "1.2.1"
@@ -6335,3 +6428,18 @@ name = "zmij"
version = "1.0.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa"
+
+[[package]]
+name = "zune-core"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cb8a0807f7c01457d0379ba880ba6322660448ddebc890ce29bb64da71fb40f9"
+
+[[package]]
+name = "zune-jpeg"
+version = "0.5.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "27bc9d5b815bc103f142aa054f561d9187d191692ec7c2d1e2b4737f8dbd7296"
+dependencies = [
+ "zune-core",
+]
diff --git a/gui/src-tauri/Cargo.toml b/gui/src-tauri/Cargo.toml
index f209c966..55eba63f 100644
--- a/gui/src-tauri/Cargo.toml
+++ b/gui/src-tauri/Cargo.toml
@@ -46,6 +46,8 @@ url = { version = "2.5.8", features = ["serde"] }
urlencoding = "2.1.3"
uuid = { version = "1.23.0", features = ["v4", "serde"] }
portable-pty = "0.9.0"
+image = { version = "0.25", default-features = false, features = ["png", "jpeg", "gif", "webp", "bmp"] }
+base64 = "0.22"
[dev-dependencies]
pretty_assertions = "1.4.1"
diff --git a/gui/src-tauri/src/commands.rs b/gui/src-tauri/src/commands.rs
index 7effa14a..721cd5ba 100644
--- a/gui/src-tauri/src/commands.rs
+++ b/gui/src-tauri/src/commands.rs
@@ -268,6 +268,29 @@ pub(crate) async fn save_pasted_image(data: Vec<u8>, ext: String) -> Result<Stri
Ok(path.to_string_lossy().into_owned())
}
+/// Decodes an image, downscales it to fit `max_dim` (default 96px, aspect
+/// preserved), and re-encodes it as a compressed JPEG returned as a data URL —
+/// so the composer can show a real thumbnail without loading the full file into
+/// the webview. Runs the CPU-bound work off the async runtime.
+#[tauri::command]
+pub(crate) async fn image_thumbnail(path: String, max_dim: Option<u32>) -> Result<String, String> {
+ let max = max_dim.unwrap_or(96).clamp(16, 512);
+ tokio::task::spawn_blocking(move || {
+ use base64::Engine as _;
+ let img = image::open(&path).map_err(|error| error.to_string())?;
+ // `thumbnail` is a fast box filter that preserves aspect ratio.
+ let rgb = img.thumbnail(max, max).to_rgb8();
+ let mut buf = std::io::Cursor::new(Vec::new());
+ image::codecs::jpeg::JpegEncoder::new_with_quality(&mut buf, 70)
+ .encode_image(&rgb)
+ .map_err(|error| error.to_string())?;
+ let b64 = base64::engine::general_purpose::STANDARD.encode(buf.get_ref());
+ Ok::<String, String>(format!("data:image/jpeg;base64,{b64}"))
+ })
+ .await
+ .map_err(|error| error.to_string())?
+}
+
#[tauri::command]
pub(crate) async fn set_active_agent(
agent_id: String,
diff --git a/gui/src-tauri/src/lib.rs b/gui/src-tauri/src/lib.rs
index 0b9f49be..5d171067 100644
--- a/gui/src-tauri/src/lib.rs
+++ b/gui/src-tauri/src/lib.rs
@@ -35,7 +35,7 @@ use commands::{
pick_directory, pick_workspace, push_git_branch, quick_start_project, reload_mcp_servers,
remove_mcp_server, remove_provider, rename_saved_workspace, rename_workspace, respond_followup,
run_slash_command, save_conversation_layout, select_conversation, send_prompt,
- save_pasted_image, set_active_agent, set_effort, set_fast, start_new_chat, start_provider_auth, stop_prompt, terminal_close,
+ image_thumbnail, save_pasted_image, set_active_agent, set_effort, set_fast, start_new_chat, start_provider_auth, stop_prompt, terminal_close,
terminal_open, terminal_resize, terminal_write, update_prompt_settings,
update_saved_workspace_layout, workspace_query, workspace_sync,
};
@@ -104,6 +104,7 @@ pub fn run() {
set_effort,
set_fast,
save_pasted_image,
+ image_thumbnail,
list_mcp_servers,
import_mcp_config,
remove_mcp_server,
diff --git a/gui/src-tauri/src/runtime/simple.rs b/gui/src-tauri/src/runtime/simple.rs
index 74589c04..34d259d4 100644
--- a/gui/src-tauri/src/runtime/simple.rs
+++ b/gui/src-tauri/src/runtime/simple.rs
@@ -208,6 +208,7 @@ impl RuntimeManager {
let effort_capable = match model.provider.as_str() {
"codex" => true,
"codegraff" | "deepseek" => !model.name.starts_with("gpt-"),
+ "kimi" => true,
_ => false,
};
let reasoning_efforts: Vec<String> = if effort_capable {
diff --git a/gui/src/app/SessionProvider.tsx b/gui/src/app/SessionProvider.tsx
index ca450ff0..ba4a3196 100644
--- a/gui/src/app/SessionProvider.tsx
+++ b/gui/src/app/SessionProvider.tsx
@@ -517,6 +517,10 @@ export function SessionProvider({ children }: SessionProviderProps) {
// submit path in useConversationActions.
const attachments = getAttachments(promptDraftKey);
const prompt = appendAttachmentsToPrompt(trimmedPrompt, attachments);
+ // Clear the welcome composer immediately on send (prompt already
+ // captured) so the draft + attachment don't linger while the turn runs.
+ sessionStore.getState().clearPromptDraft(promptDraftKey);
+ sessionStore.getState().clearAttachments(promptDraftKey);
let nextPromptDraftKey: string | null = promptDraftKey;
sessionStore.getState().setPromptDraftPending(promptDraftKey, true);
diff --git a/gui/src/components/attachments/AttachmentCard.tsx b/gui/src/components/attachments/AttachmentCard.tsx
index 7cedc45c..51b85c44 100644
--- a/gui/src/components/attachments/AttachmentCard.tsx
+++ b/gui/src/components/attachments/AttachmentCard.tsx
@@ -1,5 +1,7 @@
+import { useEffect, useState } from "react";
import { FileIcon, FileTextIcon, ImageIcon, XIcon } from "lucide-react";
-import { convertFileSrc } from "@tauri-apps/api/core";
+
+import { imageThumbnail } from "@/services/desktop/client";
import { cn } from "@/utils/cn";
import type { Attachment } from "./attachmentTypes";
@@ -24,17 +26,27 @@ export function AttachmentCard({
onOpen?: (path: string) => void;
}) {
const isInteractive = onOpen != null;
+ const [thumbnail, setThumbnail] = useState<string | null>(null);
+ useEffect(() => {
+ if (attachment.kind !== "image") return;
+ let cancelled = false;
+ imageThumbnail(attachment.path).then(
+ (url) => {
+ if (!cancelled) setThumbnail(url);
+ },
+ () => {},
+ );
+ return () => {
+ cancelled = true;
+ };
+ }, [attachment.kind, attachment.path]);
const subtitle = attachment.ext ? attachment.ext.toUpperCase() : "FILE";
const content = (
<>
<div className="flex size-8 shrink-0 items-center justify-center overflow-hidden rounded-md bg-muted">
- {attachment.kind === "image" ? (
- <img
- src={convertFileSrc(attachment.path)}
- alt=""
- className="size-full object-cover"
- />
+ {attachment.kind === "image" && thumbnail ? (
+ <img src={thumbnail} alt="" className="size-full object-cover" />
) : (
<KindIcon kind={attachment.kind} />
)}
diff --git a/gui/src/hooks/useConversationActions.ts b/gui/src/hooks/useConversationActions.ts
index be56e31d..263053e7 100644
--- a/gui/src/hooks/useConversationActions.ts
+++ b/gui/src/hooks/useConversationActions.ts
@@ -103,6 +103,11 @@ export function useConversationActions(binding?: ChatBinding | null) {
const attachments = getAttachments(promptDraftKey);
const prompt = appendAttachmentsToPrompt(trimmedPrompt, attachments);
+ // Clear the composer immediately on send so the draft + any attachment
+ // don't linger in the bar while the turn runs (the prompt is already
+ // captured above).
+ sessionStore.getState().clearPromptDraft(promptDraftKey);
+ sessionStore.getState().clearAttachments(promptDraftKey);
sessionStore.getState().setPromptDraftPending(promptDraftKey, true);
try {
const snapshot = await desktopClient.sendPrompt({
@@ -112,8 +117,6 @@ export function useConversationActions(binding?: ChatBinding | null) {
workspacePath,
});
sessionStore.getState().applySessionSnapshot(snapshot);
- sessionStore.getState().clearPromptDraft(promptDraftKey);
- sessionStore.getState().clearAttachments(promptDraftKey);
} catch {
return;
} finally {
diff --git a/gui/src/services/desktop/client.ts b/gui/src/services/desktop/client.ts
index 0db5541b..4796e40f 100644
--- a/gui/src/services/desktop/client.ts
+++ b/gui/src/services/desktop/client.ts
@@ -491,6 +491,14 @@ export function savePastedImage(
return invokeCommand("save_pasted_image", { data, ext });
}
+/** Returns a compressed JPEG thumbnail of an image file as a data URL. */
+export function imageThumbnail(
+ path: string,
+ maxDim?: number,
+): Promise<string> {
+ return invokeCommand("image_thumbnail", { path, maxDim: maxDim ?? null });
+}
+
export function listMcpServers(
workspacePath?: string | null,
): Promise<McpSettingsPayload> {
diff --git a/src/main.zig b/src/main.zig
index b6ac9cbb..d5519682 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -372,7 +372,9 @@ const main_system_prompt =
\\user's machine. Use the provided tools to inspect and modify the current
\\working directory and to run commands. read_file before editing; prefer
\\edit_file for changes to existing files and write_file only for new
- \\files or full rewrites. Some bash commands need user approval — if one
+ \\files or full rewrites. To navigate code — finding symbols, callers,
+ \\definitions, or where logic lives — prefer the codedb tool (it's indexed
+ \\and structural) over bash grep/find/ls. Some bash commands need user approval — if one
\\is declined, try another approach or ask. For independent,
\\self-contained chunks of work — exploring several directories, running
\\unrelated checks, summarizing multiple files — fan out: call the
@@ -6780,7 +6782,8 @@ const Agent = struct {
fn effortApplies(self: *const Agent) bool {
return self.provider.kind == .responses or
std.mem.eql(u8, self.provider.id, "codegraff") or
- std.mem.eql(u8, self.provider.id, "deepseek");
+ std.mem.eql(u8, self.provider.id, "deepseek") or
+ std.mem.eql(u8, self.provider.id, "kimi");
}
fn toolsJson(self: *const Agent) []const u8 {