Skip to content
5 changes: 5 additions & 0 deletions .changeset/chat-delete-controls.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@truefoundry/trueforge-ui": patch
---

Wire remote chat session deletion and improve the history delete action styling.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export type ThreadListContainerProps = {
};

const deleteItemClass =
'flex w-full cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none text-failure-bg hover:bg-ghost-button-hover hover:text-failure-bg focus:bg-ghost-button-hover focus:text-failure-bg data-[highlighted]:bg-ghost-button-hover data-[highlighted]:text-failure-bg';
'flex w-full cursor-pointer select-none items-center gap-2 rounded-md px-2 py-1.5 text-sm font-medium text-[var(--failure-bg,#ef4444)] outline-none transition-colors hover:bg-[rgb(239_68_68_/_0.12)] focus:bg-[rgb(239_68_68_/_0.12)] data-[highlighted]:bg-[rgb(239_68_68_/_0.12)] data-[highlighted]:text-[var(--failure-bg,#ef4444)]';
Comment thread
govindavashishtha marked this conversation as resolved.
Resolved

function ThreadListItemDeleteMenu() {
const compact = useCompactLayout();
Expand Down Expand Up @@ -94,7 +94,7 @@ function ThreadListItemDeleteMenu() {
<ThreadListItemMorePrimitive.Content
align="end"
sideOffset={4}
className="z-50 min-w-[8rem] rounded-md border border-border bg-card-bg p-1 text-text-primary shadow-md"
className="font-sans-flex z-50 min-w-[8rem] rounded-md border border-[var(--border,#e4e4e7)] bg-[var(--card-bg,#ffffff)] p-1 text-[var(--text-primary,#09090b)] shadow-md"
Comment thread
chiragjn marked this conversation as resolved.
Resolved
>
<ThreadListItemPrimitive.Delete asChild>
<ThreadListItemMorePrimitive.Item className={deleteItemClass}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ export function createHarnessChatServer(
return toUiSession(response.data);
},

async deleteSession({ sessionId }) {
await client.sessions.delete(sessionId);
},

async updateSession({ sessionId, agentSpec }) {
// Named (reference) sessions reject agent updates server-side.
const response = await client.sessions.update(sessionId, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const session = {

const turnRequests: unknown[] = [];
const sessionRequests: unknown[] = [];
const deletedSessions: string[] = [];
const subscribeRequests: (string | null)[] = [];

const fetchMock: typeof fetch = async (input, init) => {
Expand All @@ -36,6 +37,10 @@ const fetchMock: typeof fetch = async (input, init) => {
}
return Response.json({ data: session });
}
if (url.endsWith('/api/v1/sessions/ses_1') && method === 'DELETE') {
deletedSessions.push('ses_1');
return new Response(null, { status: 204 });
}
if (url.includes('/api/v1/sessions?') || url.endsWith('/api/v1/sessions')) {
return Response.json({ data: [session], pagination: { limit: 20, next_page_token: 'tok_2' } });
}
Expand Down Expand Up @@ -242,6 +247,18 @@ describe('createHarnessChatServer', () => {
assert.equal(found.agentName, undefined);
});

it('deletes sessions through the Harness SDK client', async () => {
deletedSessions.length = 0;
const server = createHarnessChatServer({ fetch: fetchMock });
if (server.deleteSession === undefined) {
throw new Error('Expected deleteSession to be implemented');
}

await server.deleteSession({ sessionId: 'ses_1' });

assert.deepEqual(deletedSessions, ['ses_1']);
});

it('subscribes to a turn and forwards afterSequenceNumber', async () => {
const server = createHarnessChatServer({ fetch: fetchMock });
assert.ok(server.subscribeToTurn);
Expand Down