Skip to content

Feat/ctx desktop#110

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

Feat/ctx desktop#110
hamzaerbay wants to merge 35 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

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

Copy link
Copy Markdown

Deploying ctx with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4938c8c
Status: ✅  Deploy successful!
Preview URL: https://9f12e355.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>
Comment thread ctx-desktop/src/lib/markdown.tsx Fixed
Comment thread ctx-desktop/src/screens/Search.tsx Fixed
Rounds out the screen coverage with the remaining ctx surfaces:

- Reminders: list / add / dismiss (and dismiss-all) over
  `ctx remind`.
- Scratchpad: list / add / remove over the encrypted `ctx pad`
  (entries shown decrypted; noted in the UI).
- Hub: read-only `ctx connection status`, with a friendly
  "not connected" state when no hub is configured.

Eight thin shell-out commands added to the Rust adapter; args pass
through std::process::Command (no shell), so reminder/entry text is
safe verbatim. Verified: tsc + vite build and cargo check clean.

Spec: specs/ctx-desktop.md
Signed-off-by: Murat Parlakisik <parlakisik@gmail.com>
Signed-off-by: Murat Parlakisik <parlakisik@gmail.com>
Guard each screen's load with a monotonic request id so a fast project switch (or a reload after a mutation) can't let an earlier in-flight load overwrite newer state. Applies to Overview, Tasks, Decisions, Learnings, Health, and Context Packet.

Also key the Tasks list by a stable composite (section|added|text) instead of the array index.

Spec: specs/ctx-desktop.md
Signed-off-by: Murat Parlakisik <parlakisik@gmail.com>
Add a workspace-level Projects screen that surveys every ctx project across one or more registered workspace roots: per-project task counts, health, drift, context size, and git branch, plus a workspace-wide rollup strip and a per-project drill-down (task rows with provenance, each linked to its session journal via a new ctx_journal_show command; degrades to the journal feed on a CLI without 'task list --json').

The app now persists a list of workspace roots (migrated from the legacy single value), scans them in parallel, and de-dupes projects by path. Add/remove roots from the Projects screen or the sidebar.

A 30s timeout on ctx invocations keeps one wedged project from blocking the dashboard fan-out; detached HEAD reports no branch.

Spec: specs/ctx-desktop-projects.md
Signed-off-by: Murat Parlakisik <parlakisik@gmail.com>
Regenerate the Tauri desktop icon set from the canonical ctx logo (assets/ctx-favicon-128.png upscaled to 1024) so the app matches ctx branding instead of the default Tauri icon. Desktop targets only; no mobile icon trees.

Spec: specs/meta/chores.md
Signed-off-by: Murat Parlakisik <parlakisik@gmail.com>
Replace csp:null with a restrictive policy (self origin; data:/asset: images; inline styles for Tailwind; ctx IPC) so the webview that renders arbitrary .context and kb markdown has a defined CSP instead of none.

Spec: specs/ctx-desktop.md
Signed-off-by: Murat Parlakisik <parlakisik@gmail.com>
Six interdependent corner-case fixes across the shared host/frontend files (split per-fix would leave intermediate commits failing clippy on unused code):

- Validate a restored active project on startup (dir_is_ctx_project); a moved/deleted project clears to the chooser instead of erroring on every screen.

- Watch every project's .context/ (watch_projects), not just the active one, so the dashboard reflects external writes to any project while open.

- Broaden the ctx search PATH (Go/local-bin/MacPorts) and add a user-configurable ctx binary path (set_ctx_path) surfaced when ctx isn't found.

- Mint the write-provenance session id once per launch instead of per call, so a session's writes share one journal id and can't collide.

- Cap the dashboard fan-out above 60 projects (opt-in 'Load all') to avoid a process storm on large workspaces.

- Track and flag workspace roots that fail to scan (deleted/unmounted) as missing.

Spec: specs/ctx-desktop-projects.md
Signed-off-by: Murat Parlakisik <parlakisik@gmail.com>
watch_projects emitted the same ctx-changed event as the active-project watch, so every per-project screen refetched on a foreign project's write. Emit ctx-projects-changed on a separate channel and have only the Projects dashboard listen to it; per-project screens keep listening to ctx-changed (active project only).

Spec: specs/ctx-desktop-projects.md
Signed-off-by: Murat Parlakisik <parlakisik@gmail.com>
The KB browser and canonical-doc viewer use a minimal markdown renderer that only handled headings/bullets/bold/code, so table-heavy kb docs (evidence-index, source-coverage) rendered as mush. Add GitHub-style tables (with column alignment), fenced code blocks, clickable [text](url) links that open in the system browser via the opener plugin (so they don't navigate the webview or trip the CSP), and light indentation for nested list items.

Spec: specs/ctx-desktop.md
Signed-off-by: Murat Parlakisik <parlakisik@gmail.com>
A table with many columns or long cells overflowed the KB doc width. Wrap tables in an overflow-x-auto container so they scroll within their own box, and let cells wrap (break-words, align-top).

Spec: specs/ctx-desktop.md
Signed-off-by: Murat Parlakisik <parlakisik@gmail.com>
The header health pill only re-ran ctx doctor on a project switch, so it lagged the Health screen after external writes. Subscribe it to the active-project ctx-changed channel so it updates live like the screens.

Spec: specs/ctx-desktop-projects.md
Signed-off-by: Murat Parlakisik <parlakisik@gmail.com>
…nd injection

A line-by-line review of the desktop's API surface (the Tauri IPC
commands wrapping ctx CLI spawns) found 13 issues; this pass fixes
all of them without adding behavior:

- run every command async off the UI thread; kill and reap
  timed-out children instead of leaking threads and processes
- complete tasks by exact text: cached pending-numbers silently
  completed the wrong task when agents wrote .context/ concurrently
- omit --branch/--commit for projects without usable git state so
  adds work where the UI itself shows "no git"
- probe task list --json support once per project and gate the
  dependent screens instead of hard-failing on older ctx builds
- separate flags from user text with a -- terminator everywhere
  (leading-dash text could override real flags)
- attribute watcher events to a project root so only the affected
  card refreshes and the grid never blanks out on foreign writes
- guard a stale scanAll from overwriting newer project sets
- defense-in-depth: contain kb reads to the canonical kb root,
  bound topic recursion, invalidate stale drill-down caches, and
  validate a custom ctx binary before persisting it

Spec: specs/ctx-desktop-api-hardening.md
Signed-off-by: Murat Parlakisik <parlakisik@gmail.com>
…wn codebase

The enrichment layer dated from 2026-04 (19.3k symbols); the
codebase is now 27.9k. Re-ran the enrichment pass against a fresh
GitNexus index: re-verified 9 danger-zone blast radii (desc.Text
d=1 940, was "30+"; rc.RC newly CRITICAL), refreshed the extension
inventories (42 commands, 15 MCP tools, 12 drift checks, 8 setup
deployers), rebuilt the flow hotspot table, and flagged that the
new hub/steering/trigger/kb subsystems have no manual baseline
yet. CLAUDE.md/AGENTS.md GitNexus sections regenerated by the
reindex.

Spec: specs/architecture-enrichment-refresh.md
Signed-off-by: Murat Parlakisik <parlakisik@gmail.com>
CodeQL flagged the single-pass comment strip in renderMarkdown and
Search's docLines (js/incomplete-multi-character-sanitization): one
replace pass can splice a new <!-- together from surrounding text.
Share one stripHtmlComments helper that loops until stable.

Spec: specs/ctx-desktop.md
Signed-off-by: Murat Parlakisik <parlakisik@gmail.com>
Auto-generated counter bump from npx gitnexus analyze.

Spec: specs/meta/chores.md
Signed-off-by: Murat Parlakisik <parlakisik@gmail.com>
Union-merged the DECISIONS/LEARNINGS context logs (main's 2026-06-07
consolidation + this branch's desktop entries) and kept the branch's
GitNexus blocks in AGENTS.md/CLAUDE.md.

Spec: specs/ctx-desktop.md
Signed-off-by: Murat Parlakisik <parlakisik@gmail.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.

3 participants