Compare commits

...

1 Commits

Author SHA1 Message Date
ONLY-yours 120eef1bef feat: update the use send as write 2026-01-02 14:08:28 +08:00
3 changed files with 27 additions and 14 deletions
@@ -48,6 +48,7 @@ const StarterList = memo(() => {
useInitBuiltinAgent(BUILTIN_AGENT_SLUGS.agentBuilder);
useInitBuiltinAgent(BUILTIN_AGENT_SLUGS.groupAgentBuilder);
useInitBuiltinAgent(BUILTIN_AGENT_SLUGS.pageAgent);
const [inputActiveMode, setInputActiveMode] = useHomeStore((s) => [
s.inputActiveMode,
@@ -94,12 +95,6 @@ const StarterList = memo(() => {
return;
}
// Special case: write mode navigates to /page
if (key === 'write') {
navigate('/page');
return;
}
// Toggle mode: if clicking the active mode, clear it; otherwise set it
if (inputActiveMode === key) {
setInputActiveMode(null);
+23 -6
View File
@@ -8,6 +8,7 @@ import { agentSelectors, builtinAgentSelectors } from '@/store/agent/selectors';
import { getChatGroupStoreState } from '@/store/agentGroup';
import { useChatStore } from '@/store/chat';
import type { HomeStore } from '@/store/home/store';
import { standardizeIdentifier } from '@/utils/identifier';
import { setNamespace } from '@/utils/storeDebug';
import type { StarterMode } from './initialState';
@@ -176,19 +177,35 @@ export const createHomeInputSlice: StateCreator<
set({ homeInputLoading: true }, false, n('sendAsWrite/start'));
try {
// 1. Create new Document
const agentState = getAgentStoreState();
// 1. Get model/provider config from inbox agent
const inboxAgentId = builtinAgentSelectors.inboxAgentId(agentState);
const inboxConfig = inboxAgentId
? agentSelectors.getAgentConfigById(inboxAgentId)(agentState)
: null;
const model = inboxConfig?.model;
const provider = inboxConfig?.provider;
// 2. Create new Document
const newDoc = await documentService.createDocument({
editorData: '',
editorData: '{}',
title: message?.slice(0, 50) || 'Untitled',
});
// 2. Navigate to Page
// 3. Navigate to Page
const { navigate } = get();
if (navigate) {
navigate(`/page/${newDoc.id}`);
navigate(`/page/${standardizeIdentifier(newDoc.id)}`);
}
// 3. Send message with document scope context
// 4. Update pageAgent's model config and send message
const pageAgentId = builtinAgentSelectors.pageAgentId(agentState);
if (pageAgentId && model && provider) {
await agentState.updateAgentConfigById(pageAgentId, { model, provider });
}
// 5. Send message with document scope context
const { sendMessage } = useChatStore.getState();
await sendMessage({
context: {
@@ -198,7 +215,7 @@ export const createHomeInputSlice: StateCreator<
message,
});
// 4. Clear mode
// 6. Clear mode
set({ inputActiveMode: null }, false, n('sendAsWrite/clearMode'));
return newDoc.id;
+3 -2
View File
@@ -4,6 +4,7 @@ import { documentService } from '@/services/document';
import { useChatStore } from '@/store/chat';
import { useGlobalStore } from '@/store/global';
import type { SessionStore } from '@/store/session/store';
import { standardizeIdentifier } from '@/utils/identifier';
import { setNamespace } from '@/utils/storeDebug';
import type { StarterMode } from './initialState';
@@ -89,14 +90,14 @@ export const createHomeInputSlice: StateCreator<
try {
// 1. Create new Document
const newDoc = await documentService.createDocument({
editorData: '',
editorData: '{}',
title: message?.slice(0, 50) || 'Untitled',
});
// 2. Navigate to Page
const navigate = useGlobalStore.getState().navigate;
if (navigate) {
navigate(`/page/${newDoc.id}`);
navigate(`/page/${standardizeIdentifier(newDoc.id)}`);
}
// 3. Send message with document scope context