PXD
v0.2.1-dev

Approval Card

Inline confirmation card for agent workflows. It shows the command an agent wants to run and waits for the user to allow or skip it, reporting the decision back through events.

Default

Run this command?
commands
pnpm db:migrate && pnpm build
<template>
  <PApprovalCard command="pnpm db:migrate && pnpm build" description="commands" @decide="onDecide" />
</template>

<script setup>
import { shallowRef } from 'vue'

const result = shallowRef(null)

function onDecide(value) {
  result.value = value
}
</script>

Command lines

An array renders one command per line. The card settles the whole array with a single decision — ApprovalResult carries no per-line identifier, so render one card per call when the calls must be decided separately.

Run these migrations?
pnpm db:migrate
pnpm build
Install dependencies?
pnpm install
<template>
  <PStack direction="vertical" class="gap-3">
    <PApprovalCard
      title="Run these migrations?"
      :command="['pnpm db:migrate', 'pnpm build']"
      variant="error"
    />

    <PApprovalCard title="Install dependencies?" command="pnpm install" />
  </PStack>
</template>

Custom body

The default slot replaces the command block, so a tool call that writes or edits files can render a diff instead of plain text. command is ignored while the slot is provided.

Apply this patch?
--- a/src/math.ts
+++ b/src/math.ts
@@ -1,3 +1,3 @@
-export const sum = (a, b) => a - b
+export const sum = (a, b) => a + b
<template>
  <PApprovalCard title="Apply this patch?" variant="error">
    <pre class="text-xs m-0 leading-tight overflow-x-auto rounded-lg border border-gray-alpha-300 bg-gray-200 p-3">--- a/src/math.ts
+++ b/src/math.ts
@@ -1,3 +1,3 @@
-export const sum = (a, b) => a - b
+export const sum = (a, b) => a + b</pre>
  </PApprovalCard>
</template>

Variants

variant tints the leading icon.

Run this command?
pnpm lint
Run this command?
pnpm test
Run this command?
pnpm build
Run this command?
rm -rf dist
<template>
  <PStack direction="vertical" class="gap-3">
    <PApprovalCard variant="primary" command="pnpm lint" />
    <PApprovalCard variant="success" command="pnpm test" />
    <PApprovalCard variant="warning" command="pnpm build" />
    <PApprovalCard variant="error" command="rm -rf dist" />
  </PStack>
</template>

Always allow

rememberable adds a checkbox whose state is carried into the approve result. The checkbox label follows locale.approval.remember and can be overridden per card with rememberLabel.

Run this command?
pnpm db:migrate
<template>
  <PApprovalCard rememberable command="pnpm db:migrate" @approve="onApprove" />
</template>

<script setup>
function onApprove(result) {
  console.log(result.remember)
}
</script>

Reject feedback

allowFeedback adds an optional single-line input inline with the actions. Its content is carried into the reject result as reason; an empty input leaves reason undefined. An explicit argument to the imperative reject(reason) wins over the input.

Run this command?
rm -rf dist
<template>
  <PApprovalCard allowFeedback command="rm -rf dist" variant="error" @reject="onReject" />
</template>

<script setup>
function onReject(result) {
  console.log(result.reason)
}
</script>

Timeout

timeout dismisses an undecided card after the given milliseconds. The result carries cause: 'timeout', so the host can tell an expired wait from an active skip. While the timeout is running, a thin countdown bar drains across the top of the card.

dismissed is not approval: a host that suspends a run until the card settles must map every non-approved result to a denial, otherwise a timed-out or skipped request lets the run continue silently.

Run this command?
pnpm deploy
<template>
  <PApprovalCard :timeout="10000" command="pnpm deploy" @decide="onDecide" />
</template>

<script setup>
function onDecide(result) {
  console.log(result)
}
</script>

Controlled

v-model owns the status, so the host can swap the card for a running state once the command is allowed.

Run this command?
pnpm build
<script setup>
import { shallowRef } from 'vue'

const status = shallowRef('pending')
const isRunning = shallowRef(false)

function onApprove() {
  status.value = 'approved'
  isRunning.value = true

  setTimeout(() => {
    status.value = 'pending'
    isRunning.value = false
  }, 1500)
}

function onReset() {
  status.value = 'pending'
}
</script>

<template>
  <PStack direction="vertical" class="gap-3">
    <PApprovalCard v-model="status" :loading="isRunning" command="pnpm build" @approve="onApprove" />

    <PButton @click="onReset">Reset</PButton>
  </PStack>
</template>

Imperative

The card exposes its decisions through a template ref, so a host can settle the request itself.

Run this command?
pnpm build
<template>
  <PStack direction="vertical" class="gap-3">
    <PApprovalCard ref="card" command="pnpm build" />

    <PButton @click="approveAll">Always allow</PButton>
  </PStack>
</template>

<script setup>
import { shallowRef } from 'vue'

const card = shallowRef(null)

function approveAll() {
  card.value.approve()
}
</script>

Props

NameTypeDefaultDescription
model-value'pending' | 'approved' | 'rejected' | 'dismissed'-Controlled status; the card manages its own status when omitted
titleComponentText'Run this command?'Card heading
descriptionComponentText-Secondary line under the title
commandstring | string[]-Command text; an array renders one command per line
variant'primary' | 'error' | 'warning' | 'success''warning'Risk level, tints the leading icon
loadingbooleanfalseDisables the actions and spins the approve button
timeoutnumber0Milliseconds before an undecided card dismisses itself; 0 never times out
rememberablebooleanfalseShows the "Always allow" checkbox
remember-labelComponentText'Always allow'Checkbox label; falls back to locale.approval.remember
allow-feedbackbooleanfalseShows a reason input whose content is carried into the reject result
close-on-press-escapebooleantrueDismisses the card when Escape is pressed while focus is inside it
disabledbooleanfalseDisables the actions

Events

NameTypeDescription
update:model-value(status: ApprovalStatus) => voidEmitted when the card settles on a decision.
decide(result: ApprovalResult) => voidEmitted on every decision, whichever way it went.
approve(result: ApprovalResult) => voidEmitted when the command is allowed.
reject(result: ApprovalResult) => voidEmitted when the command is refused.
interface ApprovalResult {
  status: 'approved' | 'rejected' | 'dismissed'
  /** Only set on `dismissed`: separates an active skip from the timeout that ends the wait. */
  cause?: 'escape' | 'close' | 'timeout'
  reason?: string
  remember?: boolean
}

Slots

NameDescription
defaultReplaces the command block; command is ignored when provided.

Methods

NameTypeDescription
statusApprovalStatusCurrent status of the card.
approve(reason?: string) => voidAllow the command imperatively.
reject(reason?: string) => voidRefuse the command imperatively.
dismiss(cause?: ApprovalCause) => voidEnd the request without allowing or refusing it.
reset() => voidReturn the card to pending and restart the timeout.

Source

Source