Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Relax comment policy; improve error logging

Richie McIlroy9150f90a0e9e
diff --git a/AGENTS.md b/AGENTS.md
index 7c157d063..c76bc41f7 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -5,7 +5,7 @@
These rules are enforced by CI (`cargo clippy -D warnings`, Biome). Fixing them afterwards is wasted effort — emit code in the correct shape the FIRST time. Every CI failure caused by one of these rules means the agent didn't read this section.
### Zero-tolerance rules
-- **No code comments anywhere.** Not `//`, `/* */`, `///`, `//!`, `#`, JSDoc, nor doc-strings injected into new code. Code must be self-explanatory via naming and types. This applies to every language: Rust, TS, JS, Python, shell, SQL, TOML, etc.
+- **Default to no code comments. Add a comment only after solving a bug or working through a complex issue, and only when it captures non-obvious context that a future investigator or reviewer genuinely needs** — e.g. why the fix looks the way it does, the upstream/platform bug being worked around, a non-obvious invariant or trade-off chosen after investigation, or a link to the PR/issue that explains the decision. Bad cases that remain banned: narrating what the code does, restating types, JSDoc that paraphrases parameter names, "TODO: refactor" or "this should be cleaner" notes, and any comment that just describes the change you are currently making. When in doubt, prefer better naming/types over a comment. Applies to every language: Rust, TS, JS, Python, shell, SQL, TOML, etc.
- **Never edit generated files**: `**/tauri.ts`, `**/queries.ts`, `apps/desktop/src-tauri/gen/**`, `packages/ui-solid/src/auto-imports.d.ts`, Drizzle migration SQL under `packages/database/migrations/`.
- **Never start additional dev servers** (`pnpm dev`, `pnpm dev:web`, `pnpm dev:desktop`, Docker services). Assume they are already running.
@@ -69,7 +69,7 @@ Additionally, `unused_must_use = "deny"` applies to all Rust code: every `Result
- Naming: files kebab‑case (`user-menu.tsx`); React/Solid components PascalCase; hooks `useX`; Rust modules snake_case; crates kebab‑case.
- Runtime: Node 20, pnpm 10.5.2, Rust 1.88+, Docker for MySQL/MinIO.
-(See **Pre-Generation Invariants** at the top of this file for the zero-comments rule and the denied clippy/Biome patterns. Those are the source of truth — do not duplicate or weaken them here.)
+(See **Pre-Generation Invariants** at the top of this file for the comments policy and the denied clippy/Biome patterns. Those are the source of truth — do not duplicate or weaken them here.)
## Testing
- TS/JS: Vitest where present (e.g., desktop). Name tests `*.test.ts(x)` near sources.
@@ -86,7 +86,7 @@ Additionally, `unused_must_use = "deny"` applies to all Rust code: every `Result
- Database flow: always `db:generate` → `db:push` before relying on new schema.
- Keep secrets out of VCS; configure via `.env` from `pnpm env-setup`.
- macOS note: desktop permissions (screen/mic) apply to the terminal running `pnpm dev:desktop`.
-- All other agent-facing rules (no comments, no editing generated files, clippy/Biome shape, post-edit gates) live in **Pre-Generation Invariants** at the top of this file.
+- All other agent-facing rules (comments policy, no editing generated files, clippy/Biome shape, post-edit gates) live in **Pre-Generation Invariants** at the top of this file.
## Effect Usage
- Next.js API routes in `apps/web/app/api/*` are built with `@effect/platform`'s `HttpApi` builder; copy the existing class/group/endpoint pattern instead of ad-hoc handlers.
diff --git a/CLAUDE.md b/CLAUDE.md
index ab2526c45..4a502d891 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -7,7 +7,7 @@ This file provides comprehensive guidance to Claude Code when working with code
These rules are enforced by CI (`cargo clippy -D warnings`, Biome). Fixing violations after the fact is wasted effort — emit code in the correct shape the FIRST time. Every CI failure tied to a rule below means this section was not respected.
### Zero-tolerance rules
-- **No code comments anywhere.** Not `//`, `/* */`, `///`, `//!`, `#`, JSDoc, nor doc strings injected into new code. Applies to Rust, TS, JS, Python, shell, SQL, TOML — every language. Code must explain itself through naming and types.
+- **Default to no code comments. Add a comment only after solving a bug or working through a complex issue, and only when it captures non-obvious context that a future investigator or reviewer genuinely needs.** Good cases: why a fix looks the way it does, the upstream/platform bug being worked around, a non-obvious invariant or trade-off chosen after investigation, a link to the PR/issue that explains the decision. Bad cases that remain banned: narrating what the code does, restating types, JSDoc that paraphrases parameter names, "TODO: refactor" or "this should be cleaner" notes, and any comment explaining the change you are currently making. When in doubt, prefer better naming/types over a comment. Applies to every language: Rust, TS, JS, Python, shell, SQL, TOML, etc.
- **Never edit generated files**: `**/tauri.ts`, `**/queries.ts`, `apps/desktop/src-tauri/gen/**`, `packages/ui-solid/src/auto-imports.d.ts`.
- **Never start additional dev servers** (`pnpm dev`, `pnpm dev:web`, `pnpm dev:desktop`, Docker). Assume the developer has them running.
@@ -412,7 +412,7 @@ Minimize `useEffect` usage: compute during render, handle logic in event handler
- Components: PascalCase; hooks: camelCase starting with `use`; Rust modules snake_case; crates kebab-case.
- Biome formats and lints TS/JS/JSON/CSS (tab indent, double quotes, organizeImports). rustfmt + the workspace clippy lints handle Rust.
-The zero-comment rule, the denied clippy patterns, and the Biome style invariants all live in **Pre-Generation Invariants** at the top of this file — that section is authoritative.
+The comments policy, the denied clippy patterns, and the Biome style invariants all live in **Pre-Generation Invariants** at the top of this file — that section is authoritative.
## Rust Clippy Rules (Workspace Lints)
diff --git a/apps/desktop/src-tauri/src/export.rs b/apps/desktop/src-tauri/src/export.rs
index d0b7ca754..09d13739f 100644
--- a/apps/desktop/src-tauri/src/export.rs
+++ b/apps/desktop/src-tauri/src/export.rs
@@ -49,9 +49,11 @@ async fn run_protected_export(
panic = %panic_msg,
"export task panicked"
);
- let message = format!("Export task panicked: {panic_msg}");
- sentry::capture_message(&message, sentry::Level::Error);
- Err(message)
+ sentry::capture_message(
+ &format!("Export task panicked: {panic_msg}"),
+ sentry::Level::Error,
+ );
+ Err("Export failed unexpectedly".to_string())
}
}
}
@@ -407,9 +409,11 @@ pub async fn generate_export_preview(
panic = %panic_msg,
"generate_export_preview panicked"
);
- let message = format!("Export preview panicked: {panic_msg}");
- sentry::capture_message(&message, sentry::Level::Error);
- Err(message)
+ sentry::capture_message(
+ &format!("Export preview panicked: {panic_msg}"),
+ sentry::Level::Error,
+ );
+ Err("Export preview failed unexpectedly".to_string())
}
}
}
@@ -676,9 +680,11 @@ pub async fn generate_export_preview_fast(
panic = %panic_msg,
"generate_export_preview_fast panicked"
);
- let message = format!("Export preview panicked: {panic_msg}");
- sentry::capture_message(&message, sentry::Level::Error);
- Err(message)
+ sentry::capture_message(
+ &format!("Export preview panicked: {panic_msg}"),
+ sentry::Level::Error,
+ );
+ Err("Export preview failed unexpectedly".to_string())
}
}
}
diff --git a/apps/desktop/src-tauri/src/main.rs b/apps/desktop/src-tauri/src/main.rs
index 80b337f88..4de5aa7b6 100644
--- a/apps/desktop/src-tauri/src/main.rs
+++ b/apps/desktop/src-tauri/src/main.rs
@@ -4,7 +4,7 @@
use std::sync::Arc;
use cap_desktop_lib::DynLoggingLayer;
-use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
+use tracing_subscriber::{Layer, layer::SubscriberExt, util::SubscriberInitExt};
fn main() {
#[cfg(debug_assertions)]
@@ -12,13 +12,6 @@ fn main() {
std::env::set_var("RUST_LOG", "trace");
}
- #[cfg(not(debug_assertions))]
- if std::env::var_os("RUST_BACKTRACE").is_none() {
- unsafe {
- std::env::set_var("RUST_BACKTRACE", "full");
- }
- }
-
// We have to hold onto the ClientInitGuard until the very end
let _sentry_guard = std::option_env!("CAP_DESKTOP_SENTRY_URL").map(|url| {
let sentry_client = sentry::init((
@@ -78,7 +71,11 @@ fn main() {
eprintln!("Failed to create logs directory: {e}");
});
- let file_appender = tracing_appender::rolling::daily(&logs_dir, "cap-desktop.log");
+ let info_file_appender = tracing_appender::rolling::daily(&logs_dir, "cap-desktop.log");
+ let (info_file_writer, _info_logger_guard) = tracing_appender::non_blocking(info_file_appender);
+
+ let errors_file_appender =
+ tracing_appender::rolling::daily(&logs_dir, "cap-desktop-errors.log");
let (otel_layer, _tracer) = if cfg!(debug_assertions) {
use opentelemetry::trace::TracerProvider;
@@ -131,7 +128,14 @@ fn main() {
tracing_subscriber::fmt::layer()
.with_ansi(false)
.with_target(true)
- .with_writer(file_appender),
+ .with_writer(info_file_writer),
+ )
+ .with(
+ tracing_subscriber::fmt::layer()
+ .with_ansi(false)
+ .with_target(true)
+ .with_writer(errors_file_appender)
+ .with_filter(tracing_subscriber::filter::LevelFilter::WARN),
)
.init();
diff --git a/apps/desktop/src/routes/(window-chrome)/onboarding.tsx b/apps/desktop/src/routes/(window-chrome)/onboarding.tsx
index fb4448f77..6d741d097 100644
--- a/apps/desktop/src/routes/(window-chrome)/onboarding.tsx
+++ b/apps/desktop/src/routes/(window-chrome)/onboarding.tsx
@@ -306,7 +306,7 @@ export default function OnboardingPage() {
const isMacOS = createMemo(() => ostype() === "macos");
const minStep = createMemo(() => (isMacOS() ? 0 : 1));
- const [step, setStep] = createSignal(ostype() === "macos" ? 0 : 1);
+ const [step, setStep] = createSignal(minStep());
const [showStartupOverlay, setShowStartupOverlay] = createSignal(true);
const [isExiting, setIsExiting] = createSignal(false);
const [permissionsNeeded, setPermissionsNeeded] = createSignal(false);