agent-loft 0.2.70 → 0.2.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/web/css/topbar.css +4 -0
- package/web/state.js +1 -1
- package/web/views/layout.js +4 -3
- package/web/views/messages.js +16 -3
package/package.json
CHANGED
package/web/css/topbar.css
CHANGED
package/web/state.js
CHANGED
|
@@ -14,7 +14,7 @@ export const S = {
|
|
|
14
14
|
draftExpert: localStorage.getItem("aim.expert") || null,
|
|
15
15
|
/** 自己的专家(bootstrap 里给,设置里改了重新拉) */
|
|
16
16
|
experts: [],
|
|
17
|
-
/** 新对话(还没发消息)选的工作目录,null
|
|
17
|
+
/** 新对话(还没发消息)选的工作目录,null 表示工作区根目录。顶部新建时继承最近会话的目录 */
|
|
18
18
|
draftCwd: null,
|
|
19
19
|
/** 这个新对话的目录是自己选的:换专家时不再改成专家的默认目录。建好会话后清掉 */
|
|
20
20
|
draftCwdPicked: false,
|
package/web/views/layout.js
CHANGED
|
@@ -24,7 +24,7 @@ import { openBotConversations, openConvContextMenu, runDesktopMenu } from "./top
|
|
|
24
24
|
import { syncDraftExpert } from "./experts.js";
|
|
25
25
|
import { confirmDialog, showMenu } from "../lib/overlay.js";
|
|
26
26
|
import { applyShellInfo, handleAllowEmbed, HOME, mountSwitcher, refreshShellPush, routeToServer, shellBooted, switchServer } from "../lib/shell.js";
|
|
27
|
-
import { bindScrollWatch, newDraft, openConversation, scrollToBottom } from "./messages.js";
|
|
27
|
+
import { bindScrollWatch, latestConversation, newDraft, openConversation, scrollToBottom } from "./messages.js";
|
|
28
28
|
import { bindFileDrop, renderComposer } from "./composer.js";
|
|
29
29
|
import { openSearch } from "./conv-search.js";
|
|
30
30
|
import { createNav } from "./msg-nav.js";
|
|
@@ -165,9 +165,10 @@ export async function boot() {
|
|
|
165
165
|
if (srv && srv !== HOME) routeToServer(srv, decodeURIComponent(landing.hash.slice(1)));
|
|
166
166
|
const fromHash = decodeURIComponent(location.hash.slice(1));
|
|
167
167
|
// 地址里带了会话就打开它;否则打开「最近」里最近活跃的那个对话,一个都没有才进新对话页
|
|
168
|
-
const latest =
|
|
168
|
+
const latest = latestConversation();
|
|
169
169
|
if (fromHash === "tasks") openTasksView();
|
|
170
170
|
else if (fromHash === "library") openLibraryView();
|
|
171
|
+
else if (fromHash === "new") newDraft({ inheritLatest: true });
|
|
171
172
|
else if (fromHash.startsWith("remote") && remoteTabs().length) {
|
|
172
173
|
// 刷新前在远程控制里:底下先放上最近的对话,切回对话时就是它
|
|
173
174
|
if (latest) await openConversation(latest.key);
|
|
@@ -272,7 +273,7 @@ function renderLayout() {
|
|
|
272
273
|
h(
|
|
273
274
|
"div",
|
|
274
275
|
{ class: "side-top" },
|
|
275
|
-
h("button", { class: "btn new-chat", onclick: () => (newDraft(), closeSide()) }, icon("plus"), "新建"),
|
|
276
|
+
h("button", { class: "btn new-chat", onclick: () => (newDraft({ inheritLatest: true }), closeSide()) }, icon("plus"), "新建"),
|
|
276
277
|
),
|
|
277
278
|
createSidebarNav({ search: openSearch, tasks: openTasksView, library: openLibraryView, remote: openRemoteView, settings: openSettings }),
|
|
278
279
|
ui.convList,
|
package/web/views/messages.js
CHANGED
|
@@ -13,7 +13,7 @@ import { changeCwd, doAction, forkConversation } from "./conv-actions.js";
|
|
|
13
13
|
import { scheduleNav } from "./msg-nav.js";
|
|
14
14
|
import { linkReplyFiles } from "./file-preview.js";
|
|
15
15
|
import { setTodos } from "./todos.js";
|
|
16
|
-
import { expertIcon, findExpert } from "./experts.js";
|
|
16
|
+
import { expertIcon, findExpert, setDraftExpert } from "./experts.js";
|
|
17
17
|
import { preloadCommands } from "./slash.js";
|
|
18
18
|
|
|
19
19
|
// ---------- 打开会话 ----------
|
|
@@ -27,7 +27,20 @@ function leaveTasksView() {
|
|
|
27
27
|
document.dispatchEvent(new Event("aim:leave-view"));
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export function
|
|
30
|
+
export function latestConversation() {
|
|
31
|
+
return [...S.convs.values()].filter((c) => !c.hidden).sort((a, b) => b.activeAt - a.activeAt)[0];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function newDraft({ inheritLatest = false } = {}) {
|
|
35
|
+
if (inheritLatest) {
|
|
36
|
+
const latest = latestConversation();
|
|
37
|
+
if (latest) {
|
|
38
|
+
// 目录和专家一起继承,根目录也显式保留,避免创建时退回专家的默认目录。
|
|
39
|
+
S.draftCwd = latest.cwd || S.workspaceRoot || null;
|
|
40
|
+
S.draftCwdPicked = true;
|
|
41
|
+
setDraftExpert(latest.expert?.id ?? latest.agent);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
31
44
|
leaveTasksView();
|
|
32
45
|
if (S.current) WS.raw({ t: "unsub", key: S.current });
|
|
33
46
|
S.current = null;
|
|
@@ -41,7 +54,7 @@ export function newDraft() {
|
|
|
41
54
|
setTodos(null);
|
|
42
55
|
setBusy(false);
|
|
43
56
|
renderScheduled();
|
|
44
|
-
history.replaceState(history.state, "",
|
|
57
|
+
history.replaceState(history.state, "", "#new");
|
|
45
58
|
WS.presence();
|
|
46
59
|
renderTopbar();
|
|
47
60
|
renderEmpty();
|