|
1 | 1 | import { For, Show, createEffect, createMemo, createSignal, on, onCleanup } from "solid-js" |
2 | 2 | import type { QuestionRequest, Todo } from "@opencode-ai/sdk/v2" |
3 | 3 | import { Button } from "@opencode-ai/ui/button" |
4 | | -import { BasicTool } from "@opencode-ai/ui/basic-tool" |
5 | 4 | import { PromptInput } from "@/components/prompt-input" |
6 | 5 | import { QuestionDock } from "@/components/question-dock" |
7 | 6 | import { SessionTodoDock } from "@/components/session-todo-dock" |
@@ -123,63 +122,84 @@ export function SessionPromptDock(props: { |
123 | 122 | </Show> |
124 | 123 |
|
125 | 124 | <Show when={props.permissionRequest()} keyed> |
126 | | - {(perm) => ( |
127 | | - <div data-component="tool-part-wrapper" data-permission="true" class="mb-3"> |
128 | | - <BasicTool |
129 | | - icon="checklist" |
130 | | - locked |
131 | | - defaultOpen |
132 | | - trigger={{ |
133 | | - title: props.t("notification.permission.title"), |
134 | | - subtitle: |
135 | | - perm.permission === "doom_loop" |
136 | | - ? props.t("settings.permissions.tool.doom_loop.title") |
137 | | - : perm.permission, |
138 | | - }} |
139 | | - > |
140 | | - <Show when={perm.patterns.length > 0}> |
141 | | - <div class="flex flex-col gap-1 py-2 px-3 max-h-40 overflow-y-auto no-scrollbar"> |
142 | | - <For each={perm.patterns}> |
143 | | - {(pattern) => <code class="text-12-regular text-text-base break-all">{pattern}</code>} |
144 | | - </For> |
| 125 | + {(perm) => { |
| 126 | + const toolTitle = () => { |
| 127 | + const key = `settings.permissions.tool.${perm.permission}.title` |
| 128 | + const value = props.t(key) |
| 129 | + if (value === key) return perm.permission |
| 130 | + return value |
| 131 | + } |
| 132 | + |
| 133 | + const toolDescription = () => { |
| 134 | + const key = `settings.permissions.tool.${perm.permission}.description` |
| 135 | + const value = props.t(key) |
| 136 | + if (value === key) return "" |
| 137 | + return value |
| 138 | + } |
| 139 | + |
| 140 | + return ( |
| 141 | + <div> |
| 142 | + <div data-component="question-prompt" data-permission="true"> |
| 143 | + <div data-slot="question-body"> |
| 144 | + <div data-slot="question-header"> |
| 145 | + <div data-slot="question-header-title"> |
| 146 | + {props.t("notification.permission.title")}{" "} |
| 147 | + <span class="text-13-regular text-text-weak">{toolTitle()}</span> |
| 148 | + </div> |
| 149 | + </div> |
| 150 | + |
| 151 | + <div data-slot="question-content"> |
| 152 | + <Show when={toolDescription()}> |
| 153 | + <div data-slot="question-hint">{toolDescription()}</div> |
| 154 | + </Show> |
| 155 | + |
| 156 | + <Show when={perm.patterns.length > 0}> |
| 157 | + <div data-slot="question-options"> |
| 158 | + <For each={perm.patterns}> |
| 159 | + {(pattern) => ( |
| 160 | + <div class="px-[10px]"> |
| 161 | + <code class="text-12-regular text-text-base break-all">{pattern}</code> |
| 162 | + </div> |
| 163 | + )} |
| 164 | + </For> |
| 165 | + </div> |
| 166 | + </Show> |
| 167 | + </div> |
145 | 168 | </div> |
146 | | - </Show> |
147 | | - <Show when={perm.permission === "doom_loop"}> |
148 | | - <div class="text-12-regular text-text-weak pb-2 px-3"> |
149 | | - {props.t("settings.permissions.tool.doom_loop.description")} |
| 169 | + |
| 170 | + <div data-slot="question-footer"> |
| 171 | + <div /> |
| 172 | + <div data-slot="question-footer-actions"> |
| 173 | + <Button |
| 174 | + variant="ghost" |
| 175 | + size="normal" |
| 176 | + onClick={() => props.onDecide("reject")} |
| 177 | + disabled={props.responding} |
| 178 | + > |
| 179 | + {props.t("ui.permission.deny")} |
| 180 | + </Button> |
| 181 | + <Button |
| 182 | + variant="secondary" |
| 183 | + size="normal" |
| 184 | + onClick={() => props.onDecide("always")} |
| 185 | + disabled={props.responding} |
| 186 | + > |
| 187 | + {props.t("ui.permission.allowAlways")} |
| 188 | + </Button> |
| 189 | + <Button |
| 190 | + variant="primary" |
| 191 | + size="normal" |
| 192 | + onClick={() => props.onDecide("once")} |
| 193 | + disabled={props.responding} |
| 194 | + > |
| 195 | + {props.t("ui.permission.allowOnce")} |
| 196 | + </Button> |
| 197 | + </div> |
150 | 198 | </div> |
151 | | - </Show> |
152 | | - </BasicTool> |
153 | | - <div data-component="permission-prompt"> |
154 | | - <div data-slot="permission-actions"> |
155 | | - <Button |
156 | | - variant="ghost" |
157 | | - size="small" |
158 | | - onClick={() => props.onDecide("reject")} |
159 | | - disabled={props.responding} |
160 | | - > |
161 | | - {props.t("ui.permission.deny")} |
162 | | - </Button> |
163 | | - <Button |
164 | | - variant="secondary" |
165 | | - size="small" |
166 | | - onClick={() => props.onDecide("always")} |
167 | | - disabled={props.responding} |
168 | | - > |
169 | | - {props.t("ui.permission.allowAlways")} |
170 | | - </Button> |
171 | | - <Button |
172 | | - variant="primary" |
173 | | - size="small" |
174 | | - onClick={() => props.onDecide("once")} |
175 | | - disabled={props.responding} |
176 | | - > |
177 | | - {props.t("ui.permission.allowOnce")} |
178 | | - </Button> |
179 | 199 | </div> |
180 | 200 | </div> |
181 | | - </div> |
182 | | - )} |
| 201 | + ) |
| 202 | + }} |
183 | 203 | </Show> |
184 | 204 |
|
185 | 205 | <Show when={!props.blocked}> |
|
0 commit comments