feat: add app status tracking to the backend (#17163)

This does ~95% of the backend work required to integrate the AI work.

Most left to integrate from the tasks branch is just frontend, which
will be a lot smaller I believe.

The real difference between this branch and that one is the abstraction
-- this now attaches statuses to apps, and returns the latest status
reported as part of a workspace.

This change enables us to have a similar UX to in the tasks branch, but
for agents other than Claude Code as well. Any app can report status
now.
This commit is contained in:
Kyle Carberry
2025-03-31 10:55:44 -04:00
committed by GitHub
parent 489641d0be
commit 8ea956fc11
35 changed files with 1668 additions and 69 deletions
+33
View File
@@ -293,6 +293,12 @@ CREATE TYPE workspace_app_open_in AS ENUM (
'slim-window'
);
CREATE TYPE workspace_app_status_state AS ENUM (
'working',
'complete',
'failure'
);
CREATE TYPE workspace_transition AS ENUM (
'start',
'stop',
@@ -1896,6 +1902,19 @@ CREATE SEQUENCE workspace_app_stats_id_seq
ALTER SEQUENCE workspace_app_stats_id_seq OWNED BY workspace_app_stats.id;
CREATE TABLE workspace_app_statuses (
id uuid DEFAULT gen_random_uuid() NOT NULL,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
agent_id uuid NOT NULL,
app_id uuid NOT NULL,
workspace_id uuid NOT NULL,
state workspace_app_status_state NOT NULL,
needs_user_attention boolean NOT NULL,
message text NOT NULL,
uri text,
icon text
);
CREATE TABLE workspace_apps (
id uuid NOT NULL,
created_at timestamp with time zone NOT NULL,
@@ -2359,6 +2378,9 @@ ALTER TABLE ONLY workspace_app_stats
ALTER TABLE ONLY workspace_app_stats
ADD CONSTRAINT workspace_app_stats_user_id_agent_id_session_id_key UNIQUE (user_id, agent_id, session_id);
ALTER TABLE ONLY workspace_app_statuses
ADD CONSTRAINT workspace_app_statuses_pkey PRIMARY KEY (id);
ALTER TABLE ONLY workspace_apps
ADD CONSTRAINT workspace_apps_agent_id_slug_idx UNIQUE (agent_id, slug);
@@ -2451,6 +2473,8 @@ CREATE UNIQUE INDEX idx_users_email ON users USING btree (email) WHERE (deleted
CREATE UNIQUE INDEX idx_users_username ON users USING btree (username) WHERE (deleted = false);
CREATE INDEX idx_workspace_app_statuses_workspace_id_created_at ON workspace_app_statuses USING btree (workspace_id, created_at DESC);
CREATE UNIQUE INDEX notification_messages_dedupe_hash_idx ON notification_messages USING btree (dedupe_hash);
CREATE UNIQUE INDEX organizations_single_default_org ON organizations USING btree (is_default) WHERE (is_default = true);
@@ -2802,6 +2826,15 @@ ALTER TABLE ONLY workspace_app_stats
ALTER TABLE ONLY workspace_app_stats
ADD CONSTRAINT workspace_app_stats_workspace_id_fkey FOREIGN KEY (workspace_id) REFERENCES workspaces(id);
ALTER TABLE ONLY workspace_app_statuses
ADD CONSTRAINT workspace_app_statuses_agent_id_fkey FOREIGN KEY (agent_id) REFERENCES workspace_agents(id);
ALTER TABLE ONLY workspace_app_statuses
ADD CONSTRAINT workspace_app_statuses_app_id_fkey FOREIGN KEY (app_id) REFERENCES workspace_apps(id);
ALTER TABLE ONLY workspace_app_statuses
ADD CONSTRAINT workspace_app_statuses_workspace_id_fkey FOREIGN KEY (workspace_id) REFERENCES workspaces(id);
ALTER TABLE ONLY workspace_apps
ADD CONSTRAINT workspace_apps_agent_id_fkey FOREIGN KEY (agent_id) REFERENCES workspace_agents(id) ON DELETE CASCADE;