Skip to content

Commit 6fb5ac5

Browse files
Merge pull request anomalyco#11 from different-ai/fix/permission-modal-actions
fix: unblock permission prompt actions
2 parents 232fc19 + 0c985d4 commit 6fb5ac5

3 files changed

Lines changed: 107 additions & 6 deletions

File tree

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
---
2+
name: solidjs-patterns
3+
description: SolidJS reactivity + UI state patterns for OpenWork
4+
---
5+
6+
## Why this skill exists
7+
8+
OpenWork’s UI is SolidJS: it updates via **signals**, not React-style rerenders.
9+
Most “UI stuck” bugs are actually **state coupling** bugs (e.g. one global `busy()` disabling an unrelated action), not rerender issues.
10+
11+
This skill captures the patterns we want to consistently use in OpenWork.
12+
13+
## Core rules
14+
15+
- Prefer **fine-grained signals** over shared global flags.
16+
- Keep async actions **scoped** (each action gets its own `pending` state).
17+
- Derive UI state via `createMemo()` instead of duplicating booleans.
18+
- Avoid mutating arrays/objects stored in signals; always create new values.
19+
20+
## Scoped async actions (recommended)
21+
22+
When an operation can overlap with others (permissions, installs, background refresh), don’t reuse a global `busy()`.
23+
24+
Use a dedicated signal per action:
25+
26+
```ts
27+
const [replying, setReplying] = createSignal(false);
28+
29+
async function respond() {
30+
if (replying()) return;
31+
setReplying(true);
32+
try {
33+
await doTheThing();
34+
} finally {
35+
setReplying(false);
36+
}
37+
}
38+
```
39+
40+
### Why
41+
42+
A single `busy()` boolean creates deadlocks:
43+
44+
- Long-running task sets `busy(true)`
45+
- A permission prompt appears and its buttons are disabled by `busy()`
46+
- The task can’t continue until permission is answered
47+
- The user can’t answer because buttons are disabled
48+
49+
Fix: permission UI must be disabled only by a **permission-specific** pending state.
50+
51+
## Signal snapshots in async handlers
52+
53+
If you read signals inside an async function and you need stable values, snapshot early:
54+
55+
```ts
56+
const request = activePermission();
57+
if (!request) return;
58+
const requestID = request.id;
59+
60+
await respondPermission(requestID, "always");
61+
```
62+
63+
## Derived UI state
64+
65+
Prefer `createMemo()` for computed disabled states:
66+
67+
```ts
68+
const canSend = createMemo(() => prompt().trim().length > 0 && !busy());
69+
```
70+
71+
## Lists
72+
73+
- Use setter callbacks for derived updates:
74+
75+
```ts
76+
setItems((current) => current.filter((x) => x.id !== id));
77+
```
78+
79+
- Don’t mutate `current` in-place.
80+
81+
## Practical checklist (SolidJS UI changes)
82+
83+
- Does any button depend on a global flag that could be true during long-running work?
84+
- Could two async actions overlap and fight over one boolean?
85+
- Is any UI state duplicated (can be derived instead)?
86+
- Do event handlers read signals after an `await` where values might have changed?
87+
88+
## References
89+
90+
- SolidJS: https://www.solidjs.com/docs/latest
91+
- SolidJS signals: https://www.solidjs.com/docs/latest/api#createsignal
92+
- SolidJS memos: https://www.solidjs.com/docs/latest/api#creatememo

‎AGENTS.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@ Key primitives to expose:
8686
| Interaction latency | <100ms |
8787
| Bundle size (JS) | <200KB gzipped |
8888

89+
## Skill: SolidJS Patterns
90+
91+
When editing SolidJS UI (`src/**/*.tsx`), consult:
92+
93+
- `.opencode/skill/solidjs-patterns/SKILL.md`
94+
95+
This captures OpenWork’s preferred reactivity + UI state patterns (avoid global `busy()` deadlocks; use scoped async state).
96+
8997
## Skill: Trigger a Release
9098

9199
OpenWork releases are built by GitHub Actions (`Release App`) and publish signed + notarized macOS DMGs to the GitHub Release for a tag.

‎src/App.tsx‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,7 @@ export default function App() {
544544
Array<{ id: string; content: string; status: string; priority: string }>
545545
>([]);
546546
const [pendingPermissions, setPendingPermissions] = createSignal<PendingPermission[]>([]);
547+
const [permissionReplyBusy, setPermissionReplyBusy] = createSignal(false);
547548

548549
const [prompt, setPrompt] = createSignal("");
549550
const [lastPromptSent, setLastPromptSent] = createSignal("");
@@ -1361,9 +1362,9 @@ export default function App() {
13611362

13621363
async function respondPermission(requestID: string, reply: "once" | "always" | "reject") {
13631364
const c = client();
1364-
if (!c) return;
1365+
if (!c || permissionReplyBusy()) return;
13651366

1366-
setBusy(true);
1367+
setPermissionReplyBusy(true);
13671368
setError(null);
13681369

13691370
try {
@@ -1372,7 +1373,7 @@ export default function App() {
13721373
} catch (e) {
13731374
setError(e instanceof Error ? e.message : "Unknown error");
13741375
} finally {
1375-
setBusy(false);
1376+
setPermissionReplyBusy(false);
13761377
}
13771378
}
13781379

@@ -3453,7 +3454,7 @@ export default function App() {
34533454
variant="outline"
34543455
class="w-full border-red-500/20 text-red-400 hover:bg-red-950/30"
34553456
onClick={() => respondPermission(activePermission()!.id, "reject")}
3456-
disabled={busy()}
3457+
disabled={permissionReplyBusy()}
34573458
>
34583459
Deny
34593460
</Button>
@@ -3462,15 +3463,15 @@ export default function App() {
34623463
variant="secondary"
34633464
class="text-xs"
34643465
onClick={() => respondPermission(activePermission()!.id, "once")}
3465-
disabled={busy()}
3466+
disabled={permissionReplyBusy()}
34663467
>
34673468
Once
34683469
</Button>
34693470
<Button
34703471
variant="primary"
34713472
class="text-xs font-bold bg-amber-500 hover:bg-amber-400 text-black border-none shadow-amber-500/20"
34723473
onClick={() => respondPermission(activePermission()!.id, "always")}
3473-
disabled={busy()}
3474+
disabled={permissionReplyBusy()}
34743475
>
34753476
Allow
34763477
</Button>

0 commit comments

Comments
 (0)