Files
codecraft/web/src/router.ts
T
Richard ZinkandClaude Opus 5.5 f3a2fe3816 Initial CodeCraft: web-based coding harness for AI models
Rust backend (axum/tokio): agent loop with streaming, tools (fs, bash,
web_fetch, todo, ask_user, subagents, skills, craft snapshots/compare),
permissions with modes and rules, Anthropic + OpenAI-compatible providers,
MCP client (stdio/HTTP, elicitation), SQLite sessions, usage statistics,
compaction, commented TOML config editable via toml_edit.

React PWA: chat with live streaming, permission/question cards, modes
(build/plan/craft), settings for providers/models/prices/MCP/permissions,
raw config editor, statistics dashboard, i18n (en/de). Docker setup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 14:39:24 +01:00

18 lines
522 B
TypeScript

import { useSyncExternalStore } from "react";
/** Hash routes: #/ , #/s/<id>, #/new, #/settings[/tab], #/stats */
export function useRoute(): string[] {
const hash = useSyncExternalStore(
(l) => {
window.addEventListener("hashchange", l);
return () => window.removeEventListener("hashchange", l);
},
() => location.hash,
);
return hash.replace(/^#\/?/, "").split("/").filter(Boolean);
}
export function navigate(path: string) {
location.hash = path.startsWith("/") ? path : `/${path}`;
}