Skip to content

Feat/ctx desktop#110

Draft
hamzaerbay wants to merge 19 commits into
mainfrom
feat/ctx-desktop
Draft

Feat/ctx desktop#110
hamzaerbay wants to merge 19 commits into
mainfrom
feat/ctx-desktop

Conversation

@hamzaerbay
Copy link
Copy Markdown
Collaborator

Summary

Adds ctx Desktop (ctx-desktop/), a cross-platform desktop GUI client for ctx — a calm, local-first window into a project's persistent AI context. It is a thin client over the ctx CLI: every read/write shells out to ctx, so .context/ stays the source of truth. Stack: Tauri 2 + React + TypeScript + Tailwind v4.

Screens (P0)

  • Overview — task/decision/learning counts + context file/token totals
  • Tasks — list, status filter, inline add (with target section), one-click complete
  • Decisions — searchable browse + three-field ADR authoring form
  • Learnings — searchable browse + authoring
  • Context Packet — budget slider re-running ctx agent --format json, live preview with per-section included/dropped, copy packet / copy command
  • Journal — session timeline (verbatim from ctx journal source)
  • Health — every ctx doctor check with guided fixes (inspect drift, ctx drift --fix, ctx compact --archive) behind a confirm

Platform

  • Workspace switcher — pick a root; depth-bounded Rust scan finds every .context/ project and fills a dropdown
  • fs-watch — auto-refreshes screens on external CLI/agent writes
  • doctor health pill in the top bar (click-through to Health)

Architecture

  • All ctx access funnels through src-tauri/src/ctx_adapter.rs (Rust) + src/adapter/ctx.ts (TS).
  • Spawns ctx via std::process::Command (no shell plugin); writes synthesize provenance (--session-id, --branch/--commit from git).
  • discover.rs (workspace scan, unit-tested) and watcher.rs (fs-watch via notify).

Dependency note

List/count views call ctx <artifact> list --json (added on feat/ctx-artifact-list-json, not yet released). Authoring, Context Packet, Journal, and Health work on stock ctx 0.8.1.

Docs & spec

  • Build/run: ctx-desktop/README.md · Design spec: specs/ctx-desktop.md

Test plan

  • cd ctx-desktop && npm install && npm run tauri dev launches
  • Workspace… scans and the dropdown switches projects
  • Add + complete a task; add a decision and a learning
  • Context Packet slider updates preview; copy actions work
  • Health runs drift/compact fixes
  • With list --json ctx installed, list/count views populate

hamzaerbay added 15 commits May 31, 2026 09:11
Tauri 2 + React + TS + Tailwind v4 in ctx-desktop/. Rust adapter
shells out to ctx via std::process::Command (no shell plugin);
TS adapter mirrors the CLI JSON schemas. Overview screen detects
the ctx binary and shows live task/decision/learning counts plus
status totals, degrading gracefully when a command is missing.

Run: cd ctx-desktop && npm install && npm run tauri dev

Spec: specs/ctx-desktop.md

Signed-off-by: hamzaerbay <hamzaerbay@gmail.com>
Left-nav routing with a shared project path/version top bar.
Tasks screen lists entries with status filter, inline add
(ctx task add, provenance synthesized from git in the Rust
adapter), and one-click complete. Overview now takes the dir
as a prop from the shell.

Spec: specs/ctx-desktop.md

Signed-off-by: hamzaerbay <hamzaerbay@gmail.com>
Searchable list of decisions with expandable context/rationale/
consequence, plus a three-field authoring form wired to
ctx decision add (provenance synthesized from git). Registered
the decisions view in the nav shell.

Spec: specs/ctx-desktop.md

Signed-off-by: hamzaerbay <hamzaerbay@gmail.com>
Searchable list of learnings with expandable context/lesson/
application, plus a quick-add form wired to ctx learning add
(provenance synthesized from git). Registered in the nav shell.

Spec: specs/ctx-desktop.md

Signed-off-by: hamzaerbay <hamzaerbay@gmail.com>
The differentiator: a debounced budget slider re-runs ctx agent
--format json, with a used/budget bar and per-section
included/dropped affordance. Copy packet (markdown via
ctx agent --budget N) and copy command actions.

Spec: specs/ctx-desktop.md

Signed-off-by: hamzaerbay <hamzaerbay@gmail.com>
Journal screen renders ctx journal source verbatim (no journal
JSON mode upstream yet) with a limit selector. Top bar gains a
doctor health pill (ok/warn/error from ctx doctor --json) that
tracks the active project.

Spec: specs/ctx-desktop.md

Signed-off-by: hamzaerbay <hamzaerbay@gmail.com>
Top bar gains a native folder picker (tauri-plugin-dialog) and a
recent-projects dropdown persisted in localStorage. Selecting or
picking a project repoints every screen and the health pill.

Spec: specs/ctx-desktop.md

Signed-off-by: hamzaerbay <hamzaerbay@gmail.com>
Rust watcher (notify) on the active <dir>/.context emits a
ctx-changed event; a debounced frontend hook bumps a reload key
that every screen depends on. The GUI is one writer among several
(human CLI + AI agents) and no longer shows stale state.

Completes the P0 GUI surface.

Spec: specs/ctx-desktop.md

Signed-off-by: hamzaerbay <hamzaerbay@gmail.com>
Two decisions (std::process::Command over tauri-plugin-shell;
journal rendered verbatim pending journal --json) and two
learnings (Tauri 2 needs rustc >= 1.88; macOS GUI PATH must be
augmented to find a user-installed ctx).

Spec: specs/ctx-desktop.md

Signed-off-by: hamzaerbay <hamzaerbay@gmail.com>
Choose a workspace folder; a depth-bounded Rust walk
(discover_projects, skips node_modules/target/.git, caps at 200)
finds every dir with a .context/ and populates a project
dropdown. Switching repoints all screens, the health pill, and
the watcher. Workspace + active project persist in localStorage;
the manual path field stays as a fallback. Unit-tested.

Spec: specs/ctx-desktop.md

Signed-off-by: hamzaerbay <hamzaerbay@gmail.com>
The workspace switcher supersedes the manual path input + Open
button, so they are removed. Project dropdown and Workspace button
share a uniform h-8 height, with a spacer pushing the health and
version pills to the right.

Spec: specs/ctx-desktop.md

Signed-off-by: hamzaerbay <hamzaerbay@gmail.com>
Projects with Phase sections require ctx task add --section. The
Tasks form now has a section field (datalist of existing
sections, defaults to Misc) and passes it through, fixing the
"task requires --section flag" error. Section persists across
adds for batch entry into one phase.

Spec: specs/ctx-desktop.md

Signed-off-by: hamzaerbay <hamzaerbay@gmail.com>
Complete now passes the task's 1-based pending-order number
(computed locally to match ctx) instead of its text, fixing the
"multiple tasks match" error on duplicate-text tasks. The doctor
pill gains a hover tooltip listing the actual warning/error
messages (filtered to warning/error, matching the count).

Spec: specs/ctx-desktop.md

Signed-off-by: hamzaerbay <hamzaerbay@gmail.com>
New Health screen lists every ctx doctor check, highlights
warnings/errors, and offers guided fixes: inspect drift, auto-fix
drift (ctx drift --fix), and compact/archive (ctx compact
--archive) behind an inline confirm, with command output shown.
The top-bar doctor pill is now clickable through to it.

Spec: specs/ctx-desktop.md

Signed-off-by: hamzaerbay <hamzaerbay@gmail.com>
Replace the Tauri stub README with prerequisites, setup, dev and
production build commands, the ctx list --json CLI dependency,
architecture overview, and troubleshooting notes.

Spec: specs/ctx-desktop.md

Signed-off-by: hamzaerbay <hamzaerbay@gmail.com>
hamzaerbay added a commit to hamzaerbay/ctx that referenced this pull request May 31, 2026
…ktop tasks

Capture the 7 confirmed findings from the security/performance/
scalability review of ctx Desktop as actionable tasks so the
follow-up work survives across sessions. Two merge-blockers
(argument injection via missing -- separator, hardcoded personal
DEFAULT_DIR) plus CSP hardening and four caching/watcher efficiency
items.

Spec: specs/ctx-desktop.md
Signed-off-by: hamzaerbay <hamzaerbay@gmail.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Jun 4, 2026

Deploying ctx with  Cloudflare Pages  Cloudflare Pages

Latest commit: 240fa05
Status: ✅  Deploy successful!
Preview URL: https://6800e533.ctx-bhl.pages.dev
Branch Preview URL: https://feat-ctx-desktop.ctx-bhl.pages.dev

View logs

Completes the canonical context-file coverage in the nav (Tasks,
Decisions, Learnings already had screens; Conventions and the
Constitution did not). Both are read-only viewers rendered by a
shared CanonicalDoc component with a minimal Markdown renderer
(headings, bullets, checkboxes, rules, inline bold/code; editorial
HTML comments stripped).

Data comes from a new allowlisted Rust command ctx_read_doc that
reads .context/<NAME>.md directly — the one read that doesn't
funnel through ctx, because no ctx command returns a single file's
full content (the agent packet is budget-trimmed and omits the
constitution) and these files are the source of truth. A missing
file shows a friendly empty state.

Verified: tsc + vite build and cargo check both clean.

Spec: specs/ctx-desktop.md
Signed-off-by: Murat Parlakisik <parlakisik@gmail.com>
A dedicated, always-available view for `ctx drift` — inspecting
stale paths, broken references, and constitution violations on
demand, with the mutating `--fix` behind a confirm. The Health
screen only offers drift actions when the doctor flags staleness;
this screen runs drift regardless and shows the full report.

Reuses the existing ctxDrift adapter (no Rust/CLI change). Nav:
... Journal · Drift · Health.

Verified: tsc + vite build clean.

Spec: specs/ctx-desktop.md
Signed-off-by: Murat Parlakisik <parlakisik@gmail.com>
Client-side search across the canonical context — Tasks, Decisions,
Learnings, Conventions, and the Constitution — with results grouped
by kind, a matched snippet, and one-click jump to the owning screen.
Pure frontend: aggregates data the existing adapters already expose
(there is no `ctx search` CLI command), loaded once per project and
filtered in-memory as you type.

Nav: Overview · Search · ... Verified: tsc + vite build clean.

Spec: specs/ctx-desktop.md
Signed-off-by: Murat Parlakisik <parlakisik@gmail.com>
A two-pane KB browser: left rail lists the top-level kb docs
(Overview, Evidence Index, Source Map/Coverage, Outstanding
Questions) and the topics grouped by parent folder (the grouped
reindex layout); the right pane renders the selected file's
Markdown.

Backed by two new Rust commands: kb_info inventories
.context/kb/ (existence, present docs, recursively-walked topic
slugs) and kb_read returns a kb-relative file with strict
segment validation (no empty/'.'/'..'/backslash) to block
traversal. A project with no kb shows a friendly empty state.

Also extracts the Markdown renderer to src/lib/markdown.tsx so
CanonicalDoc and the KB browser share it (no duplicate copy).

Verified: tsc + vite build and cargo check both clean.

Spec: specs/ctx-desktop.md
Signed-off-by: Murat Parlakisik <parlakisik@gmail.com>
// and paragraphs, with inline bold/code. HTML comments (editorial
// notes) are stripped. Good enough for the context/kb docs.
export function renderMarkdown(md: string): ReactNode[] {
const clean = md.replace(/<!--[\s\S]*?-->/g, "");
Comment on lines +57 to +58
return md
.replace(/<!--[\s\S]*?-->/g, "")
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.

3 participants