-
Notifications
You must be signed in to change notification settings - Fork 31
Feature/kiloclaw admin cli admin view and schema #2376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
evanjacobson
wants to merge
4
commits into
main
Choose a base branch
from
feature/kiloclaw-admin-cli_admin-view-and-schema
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
21e503b
feat(kiloclaw): add admin CLI run management and audit logging
evanjacobson 7cac452
Merge branch 'main' into feature/kiloclaw-admin-cli_admin-view-and-sc…
evanjacobson 2a0a60a
fix(kiloclaw): clarify cancel retry intent and use drizzle isNull hel…
evanjacobson 05e2faf
fix(kiloclaw): reconcile stale CLI run state
evanjacobson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,10 +25,12 @@ import { | |
| } from 'lucide-react'; | ||
| import { formatDistanceToNow } from 'date-fns'; | ||
| import { cn } from '@/lib/utils'; | ||
| import { stripAnsi } from '@/lib/stripAnsi'; | ||
|
|
||
| const PAGE_SIZE = 25; | ||
|
|
||
| type RunStatus = 'all' | 'running' | 'completed' | 'failed' | 'cancelled'; | ||
| type InitiatedBy = 'all' | 'admin' | 'user'; | ||
|
|
||
| function StatusBadge({ status }: { status: string }) { | ||
| switch (status) { | ||
|
|
@@ -65,12 +67,6 @@ function StatusBadge({ status }: { status: string }) { | |
| } | ||
| } | ||
|
|
||
| /** Strip ANSI escape codes for display in browser. */ | ||
| function stripAnsi(raw: string): string { | ||
| // eslint-disable-next-line no-control-regex | ||
| return raw.replace(/\x1b\[[0-?]*[ -/]*[@-~]/g, ''); | ||
| } | ||
|
|
||
| function formatDuration(start: string, end: string): string { | ||
| const ms = new Date(end).getTime() - new Date(start).getTime(); | ||
| if (ms < 1000) return `${ms}ms`; | ||
|
|
@@ -87,6 +83,7 @@ export function CliRunsTab() { | |
| const [search, setSearch] = useState(''); | ||
| const [debouncedSearch, setDebouncedSearch] = useState(''); | ||
| const [statusFilter, setStatusFilter] = useState<RunStatus>('all'); | ||
| const [initiatedByFilter, setInitiatedByFilter] = useState<InitiatedBy>('all'); | ||
| const [selectedRunId, setSelectedRunId] = useState<string | null>(null); | ||
|
|
||
| const [debounceTimer, setDebounceTimer] = useState<ReturnType<typeof setTimeout> | null>(null); | ||
|
|
@@ -108,6 +105,7 @@ export function CliRunsTab() { | |
| limit: PAGE_SIZE, | ||
| search: debouncedSearch || undefined, | ||
| status: statusFilter, | ||
| initiatedBy: initiatedByFilter, | ||
| }, | ||
| { staleTime: 10_000 } | ||
| ) | ||
|
|
@@ -145,6 +143,22 @@ export function CliRunsTab() { | |
| <SelectItem value="cancelled">Cancelled</SelectItem> | ||
| </SelectContent> | ||
| </Select> | ||
| <Select | ||
| value={initiatedByFilter} | ||
| onValueChange={v => { | ||
| setInitiatedByFilter(v as InitiatedBy); | ||
| setPage(0); | ||
| }} | ||
| > | ||
| <SelectTrigger className="w-[150px]"> | ||
| <SelectValue /> | ||
| </SelectTrigger> | ||
| <SelectContent> | ||
| <SelectItem value="all">All users</SelectItem> | ||
| <SelectItem value="admin">Admin</SelectItem> | ||
| <SelectItem value="user">User</SelectItem> | ||
| </SelectContent> | ||
| </Select> | ||
| {isLoading && <Loader2 className="h-4 w-4 animate-spin" />} | ||
| {pagination && ( | ||
| <span className="text-muted-foreground ml-auto text-sm"> | ||
|
|
@@ -172,9 +186,19 @@ export function CliRunsTab() { | |
| )} | ||
| > | ||
| <div className="flex items-center justify-between gap-2"> | ||
| <span className="truncate font-mono text-xs"> | ||
| {run.user_email ?? run.user_id} | ||
| </span> | ||
| <div className="flex min-w-0 items-center gap-1.5"> | ||
| <span className="truncate font-mono text-xs"> | ||
| {run.user_email ?? run.user_id} | ||
| </span> | ||
| {run.initiated_by_admin_id && ( | ||
| <Badge | ||
| variant="outline" | ||
| className="shrink-0 border-purple-500/30 text-purple-400" | ||
| > | ||
| Admin | ||
| </Badge> | ||
| )} | ||
| </div> | ||
| <StatusBadge status={run.status} /> | ||
| </div> | ||
| <p className="text-muted-foreground truncate text-xs"> | ||
|
|
@@ -252,6 +276,8 @@ function RunDetail({ | |
| id: string; | ||
| user_id: string; | ||
| user_email: string | null; | ||
| initiated_by_admin_id: string | null; | ||
| initiated_by_admin_email: string | null; | ||
| prompt: string; | ||
| status: string; | ||
| exit_code: number | null; | ||
|
|
@@ -273,6 +299,11 @@ function RunDetail({ | |
| <span className="truncate font-mono text-xs">{run.user_email ?? run.user_id}</span> | ||
| <StatusBadge status={run.status} /> | ||
| </div> | ||
| {run.initiated_by_admin_id && ( | ||
| <p className="text-muted-foreground text-xs"> | ||
| Initiated by {run.initiated_by_admin_email ?? 'Admin'} | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is useful info at a glance for us internally. Will not be available for users. |
||
| </p> | ||
| )} | ||
| <p className="text-sm">{run.prompt}</p> | ||
| <div className="text-muted-foreground flex items-center gap-2 text-xs"> | ||
| <span>Started {formatDistanceToNow(new Date(run.started_at), { addSuffix: true })}</span> | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Routes the user back to the settings page instead of the chat page