Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix (chat): auto attachments fix channels, images, projects (#666)

Eric Hayesd484cfa1d6de
diff --git a/js/app/packages/core/component/AI/component/AIChatEmptyState.tsx b/js/app/packages/core/component/AI/component/AIChatEmptyState.tsx
index 00fe30b18a..3d83d3139a 100644
--- a/js/app/packages/core/component/AI/component/AIChatEmptyState.tsx
+++ b/js/app/packages/core/component/AI/component/AIChatEmptyState.tsx
@@ -1,9 +1,7 @@
import { BrightJoins } from '@core/component/BrightJoins';
-import { useSettingsState } from '@core/constant/SettingsState';
import { useOpenInstructionsMd } from '../util/instructions';
export function AiChatEmptyState() {
- const { setActiveTabId, openSettings } = useSettingsState();
const openInstructions = useOpenInstructionsMd();
return (
<div class="relative p-2 border border-edge-muted bg-dialog text-sm flex flex-col gap-2 text-ink">
@@ -32,20 +30,6 @@ export function AiChatEmptyState() {
</span>
to feed AI some basic context on what you do, who you work with, etc
</div>
- <div>
- Check your AI
- <span
- class="font-medium text-accent underline mx-1"
- onClick={() => {
- setActiveTabId('AI Memory');
- openSettings();
- }}
- >
- {' '}
- Memories
- </span>
- that are auto-generated for accuracy and relevance
- </div>
</div>
);
}
diff --git a/js/app/packages/core/component/AI/component/input/useChatInput.tsx b/js/app/packages/core/component/AI/component/input/useChatInput.tsx
index 795af97c85..d20e577018 100644
--- a/js/app/packages/core/component/AI/component/input/useChatInput.tsx
+++ b/js/app/packages/core/component/AI/component/input/useChatInput.tsx
@@ -98,8 +98,8 @@ export function useChatInput(
on(tabAttachments, (tabs, p) => {
for (const prev of p ?? []) {
// remove stuff from closed tabs
- if (!tabs.find((t) => t.id === prev.id)) {
- attachments.removeAttachment(prev.id);
+ if (!tabs.find((t) => t.attachmentId === prev.attachmentId)) {
+ attachments.removeAttachment(prev.attachmentId);
}
}
for (const tab of tabs) {
diff --git a/js/app/packages/core/component/AI/signal/tabAttachments.ts b/js/app/packages/core/component/AI/signal/tabAttachments.ts
index 7637e0bdd9..470178b990 100644
--- a/js/app/packages/core/component/AI/signal/tabAttachments.ts
+++ b/js/app/packages/core/component/AI/signal/tabAttachments.ts
@@ -11,16 +11,17 @@ import type {
FileType,
} from '@service-cognition/generated/schemas';
import { emailClient } from '@service-email/client';
-import type { BasicDocument } from '@service-storage/generated/schemas/basicDocument';
import { useHistory } from '@service-storage/history';
import type { SplitContent } from 'app/component/split-layout/layoutManager';
import { globalSplitManager } from 'app/signal/splitLayout';
import type { Accessor } from 'solid-js';
import { createMemo, createResource } from 'solid-js';
+type Item = ReturnType<ReturnType<typeof useHistory>>[number] | null;
+
function convertSplitToAttachment(
split: SplitContent,
- item: BasicDocument | null,
+ item: Item,
channel: ChannelWithParticipants | null = null,
email: EmailEntity | null = null
): Attachment | null {
@@ -29,15 +30,16 @@ function convertSplitToAttachment(
switch (split.type) {
case 'image':
- if (!item) return null;
+ if (!item || item.type !== 'document') return null;
const imageName = item.name || 'Image';
const imageExtension = (item.fileType || 'png') as FileType;
+ // this is correct
metadata = {
- type: 'image',
- image_name: imageName,
- image_extension: imageExtension,
+ type: 'document',
+ document_name: imageName,
+ document_type: imageExtension,
};
- attachmentType = 'image';
+ attachmentType = 'document';
break;
case 'channel':
if (!channel) return null;
@@ -59,8 +61,16 @@ function convertSplitToAttachment(
};
attachmentType = 'email';
break;
+ case 'project':
+ if (!item || item.type !== 'project') return null;
+ metadata = {
+ type: 'project',
+ project_name: item.name,
+ };
+ attachmentType = 'project';
+ break;
default:
- if (!item) return null;
+ if (!item || item.type !== 'document') return null;
const documentName = item.name || 'Document';
const documentType = (item.fileType || 'txt') as FileType;
metadata = {
@@ -101,7 +111,7 @@ export function useTabAttachments(): Accessor<ChatAttachmentWithName[]> {
string,
{
split: SplitContent;
- item: BasicDocument | null;
+ item: Item;
channel: ChannelWithParticipants | null;
email: EmailEntity | null;
}
@@ -117,39 +127,42 @@ export function useTabAttachments(): Accessor<ChatAttachmentWithName[]> {
}
const key = `${split.content.type}:${split.content.id}`;
- if (!uniqueSplits.has(key)) {
- // For email splits, find in email list
- if (split.content.type === 'email') {
- const emailItem = emailList.find(
- (email) => email.id === split.content.id
- );
- if (!emailItem) {
- continue;
- }
-
- uniqueSplits.set(key, {
- split: split.content,
- item: null,
- channel: null,
- email: emailItem,
- });
+ // For email splits, find in email list
+ if (split.content.type === 'email') {
+ const emailItem = emailList.find(
+ (email) => email.id === split.content.id
+ );
+ if (!emailItem) {
continue;
}
- // Find matching item in history
- const historyItem =
- historyItems.find((item) => item.id === split.content.id) || null;
- if (!historyItem || historyItem.type !== 'document') {
- continue;
- }
+ uniqueSplits.set(key, {
+ split: split.content,
+ item: null,
+ channel: null,
+ email: emailItem,
+ });
+ continue;
+ }
- // Find matching channel if this is a channel split
- const channelItem =
- split.content.type === 'channel'
- ? channelList.find((channel) => channel.id === split.content.id) ||
- null
- : null;
+ const channelItem =
+ split.content.type === 'channel'
+ ? channelList.find((channel) => channel.id === split.content.id) ||
+ null
+ : null;
+ if (split.content.type === 'channel') {
+ uniqueSplits.set(key, {
+ split: split.content,
+ item: null,
+ channel: channelItem,
+ email: null,
+ });
+ continue;
+ }
+ const historyItem =
+ historyItems.find((item) => item.id === split.content.id) || null;
+ if (historyItem) {
uniqueSplits.set(key, {
split: split.content,
item: historyItem,