Skip to content

Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.

Room resources: no Resources button on each row; a document's reader opens its page instead

Simon Flackd6d2501d33eb
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-resources-panel.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-resources-panel.tsx
index 4ad06d87b..c83359eeb 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-resources-panel.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-resources-panel.tsx
@@ -1,15 +1,5 @@
import { useQuery, useQueryClient } from '@tanstack/react-query';
-import {
- ExternalLink,
- FileText,
- Library,
- Link2,
- Loader2,
- Package,
- Plus,
- Search,
- X,
-} from 'lucide-react';
+import { ExternalLink, FileText, Link2, Loader2, Package, Plus, Search, X } from 'lucide-react';
import { observer } from 'mobx-react-lite';
import { type ReactNode, useState } from 'react';
import { opensAsConsoleChat } from '@renderer/features/chats/console-chat-redirect';
@@ -210,11 +200,6 @@ const ResourceSection = observer(function ResourceSection({
? () => setReading(resource)
: null
}
- onShowInLibrary={
- serverId !== null && kind !== 'packages'
- ? () => navigate('libraryItem', { serverId, kind, itemId: resource.id })
- : null
- }
removeLabel={canUnlink ? `Detach ${resource.name}` : null}
busy={busy === resource.id}
onRemove={() => void detach(resource)}
@@ -265,6 +250,14 @@ const ResourceSection = observer(function ResourceSection({
roomId={roomId}
document={reading}
onClose={() => setReading(null)}
+ onOpenInResources={
+ serverId !== null && !reading.roomScoped
+ ? () => {
+ setReading(null);
+ navigate('libraryItem', { serverId, kind: 'documents', itemId: reading.id });
+ }
+ : null
+ }
/>
)}
</section>
@@ -279,14 +272,11 @@ function ResourceRow({
busy,
confirm = false,
onRemove,
- onShowInLibrary = null,
}: {
resource: RoomResource;
/** The packages that brought it in, by name. */
via: string[];
onOpen: (() => void) | null;
- /** Opens its page in the Library; null for what has none there. */
- onShowInLibrary?: (() => void) | null;
/** The remove button's label, or null for someone who may not remove it. */
removeLabel: string | null;
busy: boolean;
@@ -331,17 +321,6 @@ function ResourceRow({
) : (
<div className="flex min-w-0 flex-1 items-center gap-3">{body}</div>
)}
- {onShowInLibrary && (
- <Button
- variant="ghost"
- size="icon-xs"
- aria-label={`Show ${resource.name} in Resources`}
- title="Show in Resources"
- onClick={onShowInLibrary}
- >
- <Library />
- </Button>
- )}
{removeLabel && confirm && armed && (
<span className="flex shrink-0 items-center gap-1">
<span className="text-xs text-foreground-muted">Delete for everyone?</span>
@@ -483,11 +462,14 @@ function DocumentDialog({
roomId,
document,
onClose,
+ onOpenInResources,
}: {
workspaceId: string;
roomId: string;
document: RoomResource;
onClose: () => void;
+ /** Opens a document from Resources on its own page there; null for one written in the room. */
+ onOpenInResources: (() => void) | null;
}) {
// The room's listing already carries the content; an older server's may not.
const content = useQuery({
@@ -530,6 +512,13 @@ function DocumentDialog({
)}
</div>
)}
+ {onOpenInResources && (
+ <div className="flex justify-end">
+ <Button size="sm" variant="outline" onClick={onOpenInResources}>
+ Open in Resources
+ </Button>
+ </div>
+ )}
</DialogContentArea>
</DialogContent>
</Dialog>
diff --git a/console/apps/switch-console-desktop/src/renderer/tests/browser/room-resources-panel.test.tsx b/console/apps/switch-console-desktop/src/renderer/tests/browser/room-resources-panel.test.tsx
index 3fea355f4..8d7edb9f2 100644
--- a/console/apps/switch-console-desktop/src/renderer/tests/browser/room-resources-panel.test.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/tests/browser/room-resources-panel.test.tsx
@@ -230,18 +230,23 @@ describe('the Resources tab', () => {
expect(el.querySelector('[aria-label^="Delete"]')).toBeNull();
});
- it('opens a reference or document from the library on its Library page, not a room-only one', async () => {
+ it('opens a document from Resources on its page there from the reader, not one written in the room', async () => {
const el = await renderPanel();
- await act(async () =>
- el.querySelector<HTMLButtonElement>('[aria-label="Show Guide in Resources"]')!.click()
- );
+ expect(el.querySelector('[aria-label$=" in Resources"]')).toBeNull();
+ const open = (name: string) =>
+ act(async () =>
+ [...el.querySelectorAll('button')].find((b) => b.textContent?.includes(name))!.click()
+ );
+ await open('Guide');
+ for (let i = 0; i < 4; i++) await act(async () => await Promise.resolve());
+ const goTo = [...document.querySelectorAll('[data-slot="dialog-content"] button')].find(
+ (b) => b.textContent === 'Open in Resources'
+ ) as HTMLButtonElement;
+ await act(async () => goTo.click());
expect(navigate).toHaveBeenCalledWith('libraryItem', {
serverId: 'srv-1',
kind: 'documents',
itemId: 'd-1',
});
- expect(el.querySelector('[aria-label="Show Repo in Resources"]')).not.toBeNull();
- expect(el.querySelector('[aria-label="Show Standup notes in Resources"]')).toBeNull();
- expect(el.querySelector('[aria-label="Show Onboarding in Resources"]')).toBeNull();
});
});