Skip to content

Commit 0bda2fd

Browse files
ammar-agentammario
andauthored
🤖 Fix: fmt-check silently passing + add screenshot script (#124)
## Problems 1. **`fmt-check` was silently passing even with unformatted code** - Makefile piped `prettier --check` through `grep -v 'No files matching'` - Piping replaced prettier's exit code (1) with grep's (0) - CI showed warnings but jobs passed ✅ 2. **No convenient workflow for adding screenshots to docs** ## Solutions **Fixed fmt-check exit code handling:** ```diff -@Bun x prettier --check $(PRETTIER_PATTERNS) 2>&1 | grep -v 'No files matching' +@Bun x prettier --check $(PRETTIER_PATTERNS) ``` **Added `scripts/quick-cp-screenshot.sh`:** - Finds latest screenshot from `~/Documents/Screenshots` or `~/Desktop` - Converts PNG to WebP using `cwebp -q 85` (as lint requires) - Saves to `docs/img/<name>.webp` - Removes original screenshot Usage: `./scripts/quick-cp-screenshot.sh my-feature` **Formatted previously unformatted files:** - `vim.ts`, `vim.test.ts` (from PR #116) - `vim-mode.md` (underscore escaping) - `context-management.md` (existing edits from main) These files were already unformatted in main because fmt-check was passing incorrectly. ## Verification `make fmt-check` now properly fails when files need formatting: ``` [warn] docs/vim-mode.md make[1]: *** [Makefile:89: fmt-check] Error 1 ``` _Generated with `cmux`_ --------- Co-authored-by: Ammar Bandukwala <ammar@ammar.io>
1 parent d62c282 commit 0bda2fd

File tree

8 files changed

+77
-14
lines changed

8 files changed

+77
-14
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ fmt: ## Format code with Prettier
8686

8787
fmt-check: ## Check code formatting
8888
@echo "Checking TypeScript/JSON/Markdown formatting..."
89-
@bun x prettier --check $(PRETTIER_PATTERNS) 2>&1 | grep -v 'No files matching'
89+
@bun x prettier --check $(PRETTIER_PATTERNS)
9090

9191
fmt-shell: ## Format shell scripts with shfmt
9292
@./scripts/fmt.sh --shell

docs/context-management.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,23 @@ Commands for managing conversation history length and token usage.
44

55
## Comparison
66

7-
| Feature | `/clear` | `/truncate` | `/compact` |
8-
| ------------------------ | -------- | ----------- | ---------------- |
9-
| **Speed** | Instant | Instant | Slower (uses AI) |
10-
| **Context Preservation** | None | Temporal | Intelligent |
11-
| **Cost** | Free | Free | Uses API tokens |
12-
| **Reversible** | No | No | No |
7+
| Approach | `/clear` | `/truncate` | `/compact` | Plan Compaction |
8+
| ------------------------ | -------- | ----------- | ---------------- | --------------- |
9+
| **Speed** | Instant | Instant | Slower (uses AI) | Instant |
10+
| **Context Preservation** | None | Temporal | Intelligent | Intelligent |
11+
| **Cost** | Free | Free | Uses API tokens | Free |
12+
| **Reversible** | No | No | No | Yes |
13+
14+
## Plan Compaction
15+
16+
If you've produced a plan, you can opportunistically click "Compact Here" on the plan to use it
17+
as the entire conversation history. This operation is instant as all of the LLM's work was already
18+
done when it created the plan.
19+
20+
![Plan Compaction](./img/plan-compact.webp)
21+
22+
This is a form of "opportunistic compaction" and is special in that you can review the post-compact
23+
context before the old context is permanently removed.
1324

1425
## `/clear` - Clear All History
1526

docs/img/plan-compact.webp

248 KB
Loading

docs/vim-mode.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Vim mode is always enabled. Press **ESC** to enter normal mode from insert mode.
4848
### Line Movement
4949

5050
- **0** - Move to beginning of line
51-
- **_** - Move to first non-whitespace character of line
51+
- **\_** - Move to first non-whitespace character of line
5252
- **$** - Move to end of line
5353
- **Home** - Same as **0**
5454
- **End** - Same as **$**
@@ -102,7 +102,7 @@ Vim's power comes from combining operators with motions. All operators work with
102102
- **e** - To end of word
103103
- **$** - To end of line
104104
- **0** - To beginning of line
105-
- **_** - To first non-whitespace character
105+
- **\_** - To first non-whitespace character
106106

107107
### Examples
108108

scripts/quick-cp-screenshot.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6+
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
7+
8+
# Check if filename argument is provided
9+
if [ -z "$1" ]; then
10+
echo "Usage: $0 <filename>"
11+
echo "Example: $0 command-palette"
12+
echo ""
13+
echo "This will find the latest screenshot, convert it to WebP, and save as docs/img/<filename>.webp"
14+
exit 1
15+
fi
16+
17+
FILENAME="$1"
18+
19+
# Remove .webp or .png extension if provided
20+
FILENAME="${FILENAME%.webp}"
21+
FILENAME="${FILENAME%.png}"
22+
23+
# Find the latest screenshot - check custom location first, then Desktop
24+
LATEST_SCREENSHOT=$(ls -t ~/Documents/Screenshots/Screen*.png ~/Desktop/Screen*.png 2>/dev/null | head -1)
25+
26+
if [ -z "$LATEST_SCREENSHOT" ]; then
27+
echo "❌ Error: No screenshots found in ~/Documents/Screenshots/ or ~/Desktop/"
28+
exit 1
29+
fi
30+
31+
echo "Found screenshot: $LATEST_SCREENSHOT"
32+
33+
# Ensure docs/img directory exists
34+
mkdir -p "$PROJECT_ROOT/docs/img"
35+
36+
OUTPUT_FILE="$PROJECT_ROOT/docs/img/$FILENAME.webp"
37+
38+
# Convert PNG to WebP using cwebp (as suggested by lint)
39+
echo "Converting to WebP..."
40+
if ! command -v cwebp &> /dev/null; then
41+
echo "❌ Error: cwebp not found. Install with: brew install webp"
42+
exit 1
43+
fi
44+
45+
cwebp "$LATEST_SCREENSHOT" -o "$OUTPUT_FILE" -q 85
46+
47+
# Remove the original screenshot
48+
rm "$LATEST_SCREENSHOT"
49+
50+
echo "✅ Screenshot saved as: docs/img/$FILENAME.webp"
51+
echo " Original screenshot removed"

src/components/tools/ProposePlanToolCall.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ export const ProposePlanToolCall: React.FC<ProposePlanToolCallProps> = ({
273273
// Create a compacted message with the plan content
274274
// Format: Title as H1 + plan content
275275
const compactedContent = `# ${args.title}\n\n${args.plan}`;
276-
276+
277277
const summaryMessage = createCmuxMessage(
278278
`compact-${Date.now()}-${Math.random().toString(36).substring(2, 11)}`,
279279
"assistant",
@@ -285,7 +285,7 @@ export const ProposePlanToolCall: React.FC<ProposePlanToolCallProps> = ({
285285
);
286286

287287
const result = await window.api.workspace.replaceChatHistory(workspaceId, summaryMessage);
288-
288+
289289
if (!result.success) {
290290
console.error("Failed to compact:", result.error);
291291
}

src/utils/vim.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,4 +515,3 @@ describe("Vim Command Integration Tests", () => {
515515
});
516516
});
517517
});
518-

src/utils/vim.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ export function moveToFirstNonWhitespace(text: string, cursor: number): number {
103103
return i >= lineEnd ? lineStart : i;
104104
}
105105

106-
107106
/**
108107
* Move cursor vertically by delta lines, maintaining desiredColumn if provided.
109108
*/
@@ -743,7 +742,10 @@ function tryHandleNavigation(state: VimState, key: string): VimKeyResult | null
743742
}
744743

745744
case "_":
746-
return handleKey(state, { cursor: moveToFirstNonWhitespace(text, cursor), desiredColumn: null });
745+
return handleKey(state, {
746+
cursor: moveToFirstNonWhitespace(text, cursor),
747+
desiredColumn: null,
748+
});
747749

748750
case "$":
749751
case "End": {

0 commit comments

Comments
 (0)