Skip to content

Commit ac6faa7

Browse files
committed
feat: update package versions and add Node engine requirements; refactor chat navigation shortcuts
- Previous Tab and Next Tab now behave as workspace-local back/forward history - Prepared crewcode-plugin-api and crewcode-plugin-cli version 0.1.2. - Added public publish metadata and Node >=18 engines. - Fixed API ESM imports by emitting .js extensions. - Upgraded Vite-compatible tooling: - @vitejs/plugin-react → 5.2.0 - Vitest → 4.1.11 - Removed the xterm 5-only canvas addon and retained WebGL/built-in renderer fallback. - Updated TypeScript module resolution for modern Vite packages. - Regenerated package-lock.json.
1 parent 70e22ea commit ac6faa7

13 files changed

Lines changed: 259 additions & 147 deletions

File tree

‎packages/crewcode-plugin-api/package.json‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
{
22
"name": "crewcode-plugin-api",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"description": "Typed browser API for isolated CrewCode plugin panels.",
55
"license": "Apache-2.0",
66
"type": "module",
7+
"engines": {
8+
"node": ">=18"
9+
},
10+
"publishConfig": {
11+
"access": "public"
12+
},
713
"keywords": [
814
"crewcode",
915
"plugin",

‎packages/crewcode-plugin-api/src/browser-global.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createCrewCodeApi } from './create-api'
1+
import { createCrewCodeApi } from './create-api.js'
22

33
// Entry for the no-build browser helper (bundled to browser/crewcode-plugin-api.js).
44
// Exposes the ready-to-use singleton plus the factory so authors can reconfigure

‎packages/crewcode-plugin-api/src/index.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
export * from './create-api'
1+
export * from './create-api.js'
22

3-
import { createCrewCodeApi } from './create-api'
3+
import { createCrewCodeApi } from './create-api.js'
44

55
// Default singleton for `import { crewcode } from 'crewcode-plugin-api'`.
66
// Authors who need custom options can call createCrewCodeApi() themselves.

‎packages/crewcode-plugin-cli/package.json‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
{
22
"name": "crewcode-plugin-cli",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"description": "Command-line tool for scaffolding, developing, and packaging CrewCode plugins.",
55
"license": "Apache-2.0",
66
"type": "module",
7+
"engines": {
8+
"node": ">=18"
9+
},
10+
"publishConfig": {
11+
"access": "public"
12+
},
713
"keywords": [
814
"crewcode",
915
"plugin",

‎src/renderer/src/App.tsx‎

Lines changed: 63 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,14 @@ import { useTerminalSessions } from './hooks/useTerminalSessions'
8282
import { useTerminalUnreadSync, useClearPane } from './stores/terminal-unread-store'
8383
import { composerDraftActions } from './stores/composer-draft-store'
8484
import { useUserRequestsByTab } from './stores/bridge-activity-store'
85-
import { useChatRecency } from './hooks/useChatRecency'
8685
import { useCompletedChats } from './hooks/useCompletedChats'
86+
import {
87+
EMPTY_WORKSPACE_NAVIGATION_HISTORY,
88+
moveInTabHistory,
89+
moveInWorkspaceHistory,
90+
recordTabVisit,
91+
recordWorkspaceVisit,
92+
} from './workspace-navigation-history'
8793
import { useCodeEditorSessions } from './hooks/useEditorSessions'
8894
import { terminalTabDisplay } from './terminal-tab-display'
8995
import { playNotificationSound, usesNativeNotificationSound } from './notifications/notification-sounds'
@@ -490,6 +496,24 @@ export default function App() {
490496
const sessions = chatSessions.getSessions(activeTabId)
491497
const sessActive = chatSessions.getActiveId(activeTabId)
492498
const activeSession = chatSessions.getActiveSession(activeTabId)
499+
const workspaceNavigationHistoryRef = useRef(EMPTY_WORKSPACE_NAVIGATION_HISTORY)
500+
const tabNavigationHistoryByWorkspaceRef = useRef<Record<string, typeof EMPTY_WORKSPACE_NAVIGATION_HISTORY>>({})
501+
useEffect(() => {
502+
if (!activeWs || !activeTabId) return
503+
const visit = {
504+
wsId: activeWs,
505+
tabId: activeTabId,
506+
sessionId: activeTab?.kind === 'chat' ? (sessActive || undefined) : undefined,
507+
}
508+
workspaceNavigationHistoryRef.current = recordWorkspaceVisit(
509+
workspaceNavigationHistoryRef.current,
510+
visit,
511+
)
512+
tabNavigationHistoryByWorkspaceRef.current[activeWs] = recordTabVisit(
513+
tabNavigationHistoryByWorkspaceRef.current[activeWs] ?? EMPTY_WORKSPACE_NAVIGATION_HISTORY,
514+
visit,
515+
)
516+
}, [activeTab?.kind, activeTabId, activeWs, sessActive])
493517
const lastSoloSessionIdRef = useRef<string | null>(null)
494518
if (activeTab?.kind === 'chat' && sessActive) lastSoloSessionIdRef.current = sessActive
495519
const handleRenameWindowTab = useCallback((tabId: string, label: string) => {
@@ -807,12 +831,8 @@ export default function App() {
807831
// (useUnreadByPane) re-render on output.
808832
useTerminalUnreadSync(pty.panes, activeTabId)
809833
const clearPane = useClearPane()
810-
// Counts (not message arrays) come straight from the store; this re-renders
811-
// App only when a scope gains/loses a message, never on a streamed token.
812-
// Two separate lists on purpose: recency drives next/prev-chat cycling, while
813-
// completion drives the drawer's Completed section. Conflating them made the
814-
// Completed list show chats that merely had a transcript.
815-
const { rankByScope, touch: touchChatRecency } = useChatRecency()
834+
// Completion metadata (not message arrays) comes straight from the store, so
835+
// streamed tokens do not make App rebuild the drawer's Completed section.
816836
const {
817837
completedAtByScope,
818838
dismissedAtByScope,
@@ -838,19 +858,6 @@ export default function App() {
838858
}))
839859
}, [pty.panes, tabInfoById, ws.workspaces])
840860

841-
// Recently-active chats, newest first — powers next/prev-chat cycling only.
842-
const recentChats = useMemo(() => {
843-
const entries: { sessionId: string; tabId: string; wsId: string; rank: number }[] = []
844-
for (const workspace of ws.workspaces) {
845-
for (const session of sessionsByWorkspace[workspace.id] ?? []) {
846-
const rank = rankByScope[session.id] ?? 0
847-
if (rank === 0) continue
848-
entries.push({ sessionId: session.id, tabId: session.tabId, wsId: workspace.id, rank })
849-
}
850-
}
851-
return entries.sort((a, b) => b.rank - a.rank).slice(0, 6)
852-
}, [ws.workspaces, sessionsByWorkspace, rankByScope])
853-
854861
// Chat sessions that have actually finished an agent turn, newest first
855862
// (capped). The drawer passively hides entries after one hour; keep timestamps
856863
// here so expiry never mutates or deletes the underlying chat.
@@ -1037,9 +1044,8 @@ export default function App() {
10371044
restoreChatTabInWorkspace(targetWs.id, targetWs.name, session.tabId)
10381045
jumpToWorkspaceTab(targetWs.id, session.tabId)
10391046
}
1040-
touchChatRecency(session.id)
10411047
window.setTimeout(() => window.dispatchEvent(new CustomEvent('crewcode:focus-composer')), 80)
1042-
}, [chatSessions, jumpToWorkspaceTab, restoreChatTabInWorkspace, touchChatRecency, workspaceByChatTabId, ws.workspaces])
1048+
}, [chatSessions, jumpToWorkspaceTab, restoreChatTabInWorkspace, workspaceByChatTabId, ws.workspaces])
10431049

10441050
// Flat, cross-workspace view of the archive for the Archive page.
10451051
const archivedEntries = useMemo<ArchivedEntry[]>(() => {
@@ -1097,8 +1103,7 @@ export default function App() {
10971103
if (targetWsId) jumpToWorkspaceTab(targetWsId, chatTabId)
10981104
else setActiveTabId(chatTabId)
10991105
if (session) chatSessions.activate(session.tabId, session.id)
1100-
touchChatRecency(scopeId)
1101-
}, [chatSessions, jumpToWorkspaceTab, restoreChatTabInWorkspace, sessionById, setActiveTabId, tabInfoById, touchChatRecency, workspaceByChatTabId, ws.workspaces])
1106+
}, [chatSessions, jumpToWorkspaceTab, restoreChatTabInWorkspace, sessionById, setActiveTabId, tabInfoById, workspaceByChatTabId, ws.workspaces])
11021107

11031108
const voiceNotificationSource = useCallback((scopeId: string): { chatName: string; workspaceName?: string } => {
11041109
const session = sessionById[scopeId]
@@ -1205,8 +1210,6 @@ export default function App() {
12051210
const preview = replyPreview(reply.text)
12061211
if (!preview) return
12071212

1208-
// A finished turn counts as both recent (for cycling) and completed.
1209-
touchChatRecency(scopeId)
12101213
completeChatRecency(scopeId)
12111214
show({
12121215
type: 'info',
@@ -1224,7 +1227,7 @@ export default function App() {
12241227
queueNativeNotification({ chatName, preview, scopeId })
12251228
}
12261229
})
1227-
}, [activeWs, completeChatRecency, touchChatRecency, navigateToChatScope, queueNativeNotification, sessionById, show, subscribeBridgeTurnEnd, tabInfoById, workspaceByChatTabId, ws.workspaces])
1230+
}, [activeWs, completeChatRecency, navigateToChatScope, queueNativeNotification, sessionById, show, subscribeBridgeTurnEnd, tabInfoById, workspaceByChatTabId, ws.workspaces])
12281231

12291232
const workspaceAgentStatus = useMemo<Record<string, AgentActivityState | undefined>>(() => {
12301233
const byWorkspace: Record<string, AgentActivityState | undefined> = {}
@@ -1941,37 +1944,34 @@ export default function App() {
19411944
// dispatching a synthetic keydown matching their chord — the local
19421945
// listener at window level picks them up. The global useGlobalShortcuts
19431946
// hook skips LOCAL_SHORTCUTS so we never double-handle a real keypress.
1944-
// Cycle the most-recently-active chats (across workspaces), newest first. The
1945-
// active chat anchors the position; if it isn't in the recency list we start
1946-
// from one end so the first press still moves. We deliberately don't bump
1947-
// recency while cycling — that would re-sort the list mid-cycle.
1948-
const cycleRecentChat = useCallback((delta: 1 | -1) => {
1949-
const list = recentChats
1950-
if (list.length === 0) return
1951-
const idx = list.findIndex(c => c.tabId === activeTabId)
1952-
const from = idx === -1 ? (delta === 1 ? -1 : 0) : idx
1953-
const next = list[((from + delta) % list.length + list.length) % list.length]
1954-
if (!next) return
1955-
if (next.wsId !== activeWs) handleWsSelect(next.wsId)
1956-
setActiveTabInWorkspace(next.wsId, next.tabId)
1957-
}, [recentChats, activeTabId, activeWs, handleWsSelect, setActiveTabInWorkspace])
1958-
1959-
const cycleWorkspace = useCallback((delta: 1 | -1) => {
1960-
const list = ws.workspaces
1961-
if (list.length <= 1) return
1962-
const idx = list.findIndex(workspace => workspace.id === activeWs)
1963-
const from = idx === -1 ? (delta === 1 ? -1 : 0) : idx
1964-
const next = list[((from + delta) % list.length + list.length) % list.length]
1965-
if (next) handleWsSelect(next.id)
1966-
}, [activeWs, handleWsSelect, ws.workspaces])
1967-
1968-
const cycleTab = useCallback((delta: 1 | -1) => {
1969-
if (tabs.length <= 1) return
1970-
const idx = tabs.findIndex(t => t.id === activeTabId)
1971-
if (idx === -1) return
1972-
const next = tabs[(idx + delta + tabs.length) % tabs.length]
1973-
if (next) setActiveTabId(next.id)
1974-
}, [tabs, activeTabId, setActiveTabId])
1947+
// Workspace navigation behaves like browser back/forward history. Each entry
1948+
// remembers the tab and active chat session that was visible in that workspace.
1949+
const navigateWorkspaceHistory = useCallback((delta: -1 | 1) => {
1950+
const moved = moveInWorkspaceHistory(
1951+
workspaceNavigationHistoryRef.current,
1952+
delta,
1953+
new Set(ws.workspaces.map(workspace => workspace.id)),
1954+
)
1955+
if (!moved.visit) return
1956+
workspaceNavigationHistoryRef.current = moved.history
1957+
const target = moved.visit
1958+
startTransition(() => {
1959+
setActiveTabInWorkspace(target.wsId, target.tabId)
1960+
setActiveWs(target.wsId)
1961+
})
1962+
if (target.sessionId) chatSessions.activate(target.tabId, target.sessionId)
1963+
}, [chatSessions, setActiveTabInWorkspace, ws.workspaces])
1964+
1965+
const navigateTabHistory = useCallback((delta: -1 | 1) => {
1966+
if (!activeWs) return
1967+
const history = tabNavigationHistoryByWorkspaceRef.current[activeWs]
1968+
?? EMPTY_WORKSPACE_NAVIGATION_HISTORY
1969+
const moved = moveInTabHistory(history, delta, new Set(tabs.map(tab => tab.id)))
1970+
if (!moved.visit) return
1971+
tabNavigationHistoryByWorkspaceRef.current[activeWs] = moved.history
1972+
setActiveTabId(moved.visit.tabId)
1973+
if (moved.visit.sessionId) chatSessions.activate(moved.visit.tabId, moved.visit.sessionId)
1974+
}, [activeWs, chatSessions, setActiveTabId, tabs])
19751975

19761976
const openInEditor = useCallback(() => {
19771977
const path = activeWorkspace.path
@@ -2044,12 +2044,10 @@ export default function App() {
20442044
switch (id) {
20452045
case 'palette': setPaletteOpen(o => !o); return
20462046
case 'workspaces': setDrawerOpen(o => !o); return
2047-
case 'prev-chat': cycleRecentChat(-1); return
2048-
case 'next-chat': cycleRecentChat(1); return
2049-
case 'next-workspace': cycleWorkspace(1); return
2050-
case 'prev-workspace': cycleWorkspace(-1); return
2051-
case 'next-tab': cycleTab(1); return
2052-
case 'prev-tab': cycleTab(-1); return
2047+
case 'next-workspace': navigateWorkspaceHistory(1); return
2048+
case 'prev-workspace': navigateWorkspaceHistory(-1); return
2049+
case 'next-tab': navigateTabHistory(1); return
2050+
case 'prev-tab': navigateTabHistory(-1); return
20532051
case 'settings-search': handleNewTab('settings'); return
20542052
case 'prompt-picker': setPromptPickerOpen(o => !o); return
20552053
case 'split-terminal-right': openTerminalSplit('right'); return
@@ -2104,7 +2102,7 @@ export default function App() {
21042102
}
21052103
}, [
21062104
activeWorkspace.name, activeWorkspace.path, activeTabId, activeWs, sessActive,
2107-
chatSessions, cycleTab, cycleRecentChat, cycleWorkspace, handleCloseTab, handleNewTab, openInEditor,
2105+
chatSessions, navigateTabHistory, navigateWorkspaceHistory, handleCloseTab, handleNewTab, openInEditor,
21082106
openTerminalSplit, pty, setAddOpen, setDrawerOpen, setPaletteOpen, setSetting, setTweak, startCanvasFromAnywhere, startCrewFromAnywhere,
21092107
settings.appTheme, settings.shortcutOverrides, settings, tweaks.density, tweaks.showTerminal, ws, effectivePath,
21102108
])
@@ -2770,7 +2768,6 @@ export default function App() {
27702768
// to that workspace explicitly instead of using the current-workspace setter.
27712769
if (targetWsId) jumpToWorkspaceTab(targetWsId, session.tabId)
27722770
chatSessions.activate(session.tabId, session.id)
2773-
touchChatRecency(session.id)
27742771
}}
27752772
onSessionAdd={(wsId) => {
27762773
const targetWs = ws.workspaces.find(w => w.id === wsId)
@@ -2806,14 +2803,12 @@ export default function App() {
28062803
if (targetWs) restoreChatTabInWorkspace(entry.wsId, targetWs.name, entry.tabId)
28072804
jumpToWorkspaceTab(entry.wsId, entry.tabId)
28082805
chatSessions.activate(entry.tabId, entry.sessionId)
2809-
touchChatRecency(entry.sessionId)
28102806
}}
28112807
onCompletedChatActivate={(entry) => {
28122808
const targetWs = ws.workspaces.find(w => w.id === entry.wsId)
28132809
if (targetWs) restoreChatTabInWorkspace(entry.wsId, targetWs.name, entry.tabId)
28142810
jumpToWorkspaceTab(entry.wsId, entry.tabId)
28152811
chatSessions.activate(entry.tabId, entry.sessionId)
2816-
touchChatRecency(entry.sessionId)
28172812
// Opening it clears it from Completed until its next finished turn.
28182813
dismissCompletedChat(entry.sessionId)
28192814
}}

‎src/renderer/src/components/terminal/XTermPane.tsx‎

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@ import React, { useEffect, useRef, useState } from 'react'
22
import { Terminal } from '@xterm/xterm'
33
import { FitAddon } from '@xterm/addon-fit'
44
import { WebglAddon } from '@xterm/addon-webgl'
5-
import { CanvasAddon } from '@xterm/addon-canvas'
65
import type { ITerminalAddon } from '@xterm/xterm'
76
import '@xterm/xterm/css/xterm.css'
87

98
import { monoFontStack, resolveTerminalFont, type Gpu } from '../../hooks/useSettings'
109

1110
// Browsers hard-cap live WebGL contexts (~16 in Chromium); past that the oldest
12-
// context is force-lost, which cascades into contextLost→dispose→canvas-fallback
13-
// churn across every terminal. With many agent terminals open that thrash is a
14-
// primary source of Workbench jank. Budget WebGL to a safe count and let the
15-
// overflow terminals ride the Canvas renderer, which needs no GL context.
11+
// context is force-lost, which cascades into contextLost→dispose churn across
12+
// every terminal. With many agent terminals open that thrash is a primary source
13+
// of Workbench jank. Budget WebGL to a safe count and let overflow terminals use
14+
// xterm's built-in renderer, which needs no extra WebGL context.
1615
const MAX_WEBGL_CONTEXTS = 8
1716
let activeWebglContexts = 0
1817
// addon → decrement callback, so disposal from any site (unmount, GPU-toggle,
@@ -25,14 +24,14 @@ function releaseRenderer(addon: ITerminalAddon | null): void {
2524
try { addon.dispose() } catch { /* already gone */ }
2625
}
2726

28-
// Pick a renderer per the user's GPU setting, with the same fallback chain
29-
// VS Code uses: WebGL → Canvas → DOM. Returns null on 'off' or when no GPU
30-
// addon initialized (xterm keeps its built-in DOM renderer in that case).
27+
// Pick a renderer per the user's GPU setting. Returns null on 'off', when the
28+
// WebGL budget is exhausted, or when initialization fails; xterm then keeps its
29+
// built-in renderer. The old CanvasAddon fallback only supports xterm 5.
3130
function loadRenderer(term: Terminal, gpu: Gpu): ITerminalAddon | null {
3231
if (gpu === 'off') return null
3332

3433
const tryWebgl = (): WebglAddon | null => {
35-
// Over budget — skip WebGL so this terminal falls through to Canvas.
34+
// Over budget — skip WebGL so this terminal keeps the built-in renderer.
3635
if (activeWebglContexts >= MAX_WEBGL_CONTEXTS) return null
3736
try {
3837
const addon = new WebglAddon()
@@ -58,19 +57,7 @@ function loadRenderer(term: Terminal, gpu: Gpu): ITerminalAddon | null {
5857
}
5958
}
6059

61-
const tryCanvas = (): CanvasAddon | null => {
62-
try {
63-
const addon = new CanvasAddon()
64-
term.loadAddon(addon)
65-
return addon
66-
} catch {
67-
return null
68-
}
69-
}
70-
71-
if (gpu === 'on') return tryWebgl() ?? tryCanvas()
72-
// 'auto' — WebGL first, Canvas fallback, DOM as last resort.
73-
return tryWebgl() ?? tryCanvas()
60+
return tryWebgl()
7461
}
7562
import { Icon } from '../ui/Icon'
7663
import type { PtyPane } from '../../types'
@@ -199,8 +186,8 @@ export function XTermPane({ pane, shell, argv, env, collapsed = false, onCollaps
199186
termRef.current = term
200187
fitRef.current = fit
201188

202-
// GPU renderer must be loaded *after* term.open so the canvas/WebGL addons
203-
// have a screen element to attach to.
189+
// GPU renderer must be loaded *after* term.open so the WebGL addon has a
190+
// screen element to attach to.
204191
rendererRef.current = loadRenderer(term, settings.gpu)
205192

206193
const fitIfVisible = (): boolean => {

‎src/renderer/src/data/commands.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ const META: Partial<Record<ActionId, { icon: string; hint: string }>> = {
1111
'prev-tab': { icon: 'chevLeft', hint: '' },
1212
'settings-search': { icon: 'search', hint: 'focus settings search' },
1313
'prompt-picker': { icon: 'fileText', hint: 'browse saved prompts' },
14-
'prev-chat': { icon: 'chevLeft', hint: 'previous recent chat' },
15-
'next-chat': { icon: 'chevRight', hint: 'next recent chat' },
1614
'send-message': { icon: 'send', hint: 'send chat message' },
1715
'cycle-mode': { icon: 'bolt', hint: 'ask → plan → build → full access' },
1816
'insert-context': { icon: 'tag', hint: '@ chip' },

‎src/renderer/src/hooks/session-completed-store.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Pure persistence logic for chat completion timestamps, split out from
3-
* useChatRecency so it can be unit-tested without a DOM/localStorage. The hook
4-
* owns the localStorage read/write; this module owns validation and bounding.
3+
* useCompletedChats so it can be unit-tested without a DOM/localStorage. The
4+
* hook owns localStorage read/write; this module owns validation and bounding.
55
*/
66

77
export type CompletedMap = Record<string, number>

0 commit comments

Comments
 (0)