mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-12-01 00:08:24 +00:00
feat: mention cards, folders and users from home's lists
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
c1d9a086fa
commit
9fad060fe7
@@ -290,7 +290,8 @@ export interface WorkspaceAppElement {
|
||||
summary?: string
|
||||
}
|
||||
|
||||
/** Workspace folder context element — a whole `f/<folder>`, its items read by the chat on
|
||||
/** Workspace folder context element — everything under a path prefix: a folder (`f/team`, or a
|
||||
* subfolder of an owner) or a user's own items (`u/alice`). Its items are read by the chat on
|
||||
* demand like any other workspace reference. */
|
||||
export interface WorkspaceFolderElement {
|
||||
type: 'workspace_folder'
|
||||
@@ -298,26 +299,33 @@ export interface WorkspaceFolderElement {
|
||||
title: string
|
||||
}
|
||||
|
||||
export function folderContextElement(path: string): WorkspaceFolderElement & { deletable: boolean } {
|
||||
export function folderContextElement(
|
||||
path: string
|
||||
): WorkspaceFolderElement & { deletable: boolean } {
|
||||
return { type: 'workspace_folder', path, title: path, deletable: true }
|
||||
}
|
||||
|
||||
const FOLDER_DIR_PREFIX = dirKey('all', 'f/')
|
||||
/** Whether a folder context path is a user's own items (`u/alice`) rather than a folder. */
|
||||
export function isUserContextPath(path: string): boolean {
|
||||
return /^u\/[^/]+$/.test(path)
|
||||
}
|
||||
|
||||
/** Opens every `f/` folder of a flat workspace tree (any depth) on a leaf that picks the folder
|
||||
* itself, so a folder is taken as context from inside it, or by searching its path. */
|
||||
const DIR_PREFIX = dirKey('all', '')
|
||||
|
||||
/** Opens every `f/` and `u/` directory of a flat workspace tree (any depth) on a leaf that picks
|
||||
* the directory itself, so it is taken as context from inside it, or by searching its path. */
|
||||
export function withFolderContextLeaves<L>(
|
||||
nodes: DrillNode<L>[]
|
||||
): DrillNode<L | WorkspaceFolderElement>[] {
|
||||
return nodes.map((node) => {
|
||||
if (node.type !== 'branch') return node
|
||||
const children = withFolderContextLeaves(node.children)
|
||||
if (!node.key.startsWith(FOLDER_DIR_PREFIX)) return { ...node, children }
|
||||
const path = node.key.slice(FOLDER_DIR_PREFIX.length - 'f/'.length)
|
||||
const path = node.key.startsWith(DIR_PREFIX) ? node.key.slice(DIR_PREFIX.length) : ''
|
||||
if (!/^[fu]\/./.test(path)) return { ...node, children }
|
||||
const leaf: DrillLeaf<WorkspaceFolderElement> = {
|
||||
type: 'leaf',
|
||||
key: `folder:${path}`,
|
||||
label: 'Whole folder',
|
||||
label: isUserContextPath(path) ? 'All their items' : 'Whole folder',
|
||||
secondary: path,
|
||||
icon: Folder,
|
||||
data: folderContextElement(path),
|
||||
|
||||
@@ -173,7 +173,7 @@ import { scriptLangToEditorLang } from '$lib/scripts'
|
||||
import { appFileEditorLang } from '../appFileEditorLang'
|
||||
import { searchDocsTool, readDocsPageTool } from '../docs/core'
|
||||
import { createDbSchemaTool } from '../script/core'
|
||||
import { isMentionContext, type ContextElement } from '../context'
|
||||
import { isMentionContext, isUserContextPath, type ContextElement } from '../context'
|
||||
import { getDatatableTools } from '../datatableTools'
|
||||
import { getDatatableMigrationTools } from '../datatableMigrationTools'
|
||||
import { getDucklakeTools } from '../ducklakeTools'
|
||||
@@ -5886,7 +5886,9 @@ function createVariableToDraftState(
|
||||
// `null` clears and omitted keeps the base's. The draft stores a cleared expiry as
|
||||
// `undefined`, since a stored draft goes through a JSON round-trip.
|
||||
value_valid_until:
|
||||
args.value_valid_until === null ? undefined : (args.value_valid_until ?? base?.value_valid_until)
|
||||
args.value_valid_until === null
|
||||
? undefined
|
||||
: (args.value_valid_until ?? base?.value_valid_until)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9785,7 +9787,7 @@ export function prepareGlobalUserMessage(
|
||||
content += '## SELECTED CONTEXT\n'
|
||||
for (const context of selectedWorkspaceItems) {
|
||||
if (context.type === 'workspace_folder') {
|
||||
content += `- type: folder, path: ${context.path} (its items: list_workspace_items with path_prefix "${context.path}/")\n`
|
||||
content += `- type: ${isUserContextPath(context.path) ? 'user' : 'folder'}, path: ${context.path} (its items: list_workspace_items with path_prefix "${context.path}/")\n`
|
||||
continue
|
||||
}
|
||||
const itemType =
|
||||
|
||||
@@ -39,6 +39,7 @@ import type { PasteAttachment } from './pasteTokens'
|
||||
import { dataUrlToImagePart, type AttachedImage } from './imageUtils'
|
||||
import type { AttachedTextFile } from './textFileUtils'
|
||||
import type { CodePieceElement, ContextElement, FlowModuleCodePieceElement } from './context'
|
||||
import { isUserContextPath } from './context'
|
||||
import { workspaceStore } from '$lib/stores'
|
||||
import type { ExtendedOpenFlow } from '$lib/components/flows/types'
|
||||
import { findModuleInFlow, findModuleInModules } from '$lib/components/flows/flowTree'
|
||||
@@ -469,7 +470,7 @@ export function buildContextString(selectedContext: ContextElement[]): string {
|
||||
if (!workspaceItemsContext) {
|
||||
workspaceItemsContext = 'SELECTED WORKSPACE ITEMS:\n'
|
||||
}
|
||||
workspaceItemsContext += `- type: folder, path: ${context.path}\n`
|
||||
workspaceItemsContext += `- type: ${isUserContextPath(context.path) ? 'user' : 'folder'}, path: ${context.path}\n`
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1162,10 +1163,7 @@ export async function processToolCall<T>({
|
||||
// call back for a retry: asked before it, the user would answer twice.
|
||||
const workingScope = toolCallbacks.workingScope
|
||||
const writes =
|
||||
!!tool &&
|
||||
tool.planModeSafe !== true &&
|
||||
!tool.viewOnly &&
|
||||
!isRunTool(tool.def.function.name)
|
||||
!!tool && tool.planModeSafe !== true && !tool.viewOnly && !isRunTool(tool.def.function.name)
|
||||
const scope = writes ? workingScope?.scope() : undefined
|
||||
const outsidePath = scope?.outsidePath(args)
|
||||
let scopeNote = ''
|
||||
|
||||
@@ -125,17 +125,26 @@
|
||||
}
|
||||
}
|
||||
|
||||
// The row menus' actions that need nothing but the kind and path. Moving, deleting,
|
||||
// deploying and sharing need the full item and the row's own drawers, so they stay there.
|
||||
async function menuItems(item: Entry, favorite: boolean): Promise<Item[]> {
|
||||
const kind = await editorKind(item)
|
||||
const base = kind === 'raw_app' ? 'apps_raw' : `${kind}s`
|
||||
const contextElement = itemContextElement({
|
||||
function contextElementFor(item: Entry, kind: RecentKind) {
|
||||
return itemContextElement({
|
||||
kind: kind === 'raw_app' ? 'app' : kind,
|
||||
rawApp: kind === 'raw_app',
|
||||
path: item.path,
|
||||
summary: item.title === item.path ? undefined : item.title
|
||||
})
|
||||
}
|
||||
|
||||
async function mention(item: Entry) {
|
||||
const element = contextElementFor(item, await editorKind(item))
|
||||
if (element) await homeComposerContext.attach(element)
|
||||
}
|
||||
|
||||
// The row menus' actions that need nothing but the kind and path. Moving, deleting,
|
||||
// deploying and sharing need the full item and the row's own drawers, so they stay there.
|
||||
async function menuItems(item: Entry, favorite: boolean): Promise<Item[]> {
|
||||
const kind = await editorKind(item)
|
||||
const base = kind === 'raw_app' ? 'apps_raw' : `${kind}s`
|
||||
const contextElement = contextElementFor(item, kind)
|
||||
return [
|
||||
{
|
||||
displayName: 'Add to AI session context',
|
||||
@@ -365,7 +374,7 @@
|
||||
></a>
|
||||
{#if !favorite && item.at}
|
||||
<span
|
||||
class="shrink-0 text-2xs text-secondary"
|
||||
class="shrink-0 text-2xs text-secondary group-has-[[data-composer-open]]/home:group-hover:hidden group-has-[[data-composer-open]]/home:group-focus-within:hidden"
|
||||
title={recentTooltip(item.at, item.via)}
|
||||
onmouseenter={() => (now = Date.now())}
|
||||
role="note"
|
||||
@@ -373,9 +382,27 @@
|
||||
<TimeAgo date={new Date(item.at).toISOString()} compact noSeconds />
|
||||
</span>
|
||||
{/if}
|
||||
<div class="shrink-0 pr-1 text-secondary">
|
||||
<!-- While Home's composer is open the menu gives way to Mention, like the items' rows
|
||||
(AskAiRowButton). -->
|
||||
<div class="shrink-0 pr-1 text-secondary group-has-[[data-composer-open]]/home:hidden">
|
||||
<DropdownV2 items={() => menuItems(item, favorite)} size="xs" fixedHeight={false} />
|
||||
</div>
|
||||
<!-- Takes the time's place on the hovered or focused card only: holding a place on every
|
||||
card would leave the narrow cards no room for their titles. -->
|
||||
<div
|
||||
class="shrink-0 pr-1 hidden group-has-[[data-composer-open]]/home:group-hover:block group-has-[[data-composer-open]]/home:group-focus-within:block"
|
||||
>
|
||||
<Button
|
||||
variant="subtle"
|
||||
unifiedSize="sm"
|
||||
btnClasses="!text-ai font-medium"
|
||||
title="Mention"
|
||||
aria-label="Mention {item.title}"
|
||||
onClick={() => mention(item)}
|
||||
>
|
||||
+@
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
{/snippet}
|
||||
|
||||
|
||||
@@ -109,6 +109,7 @@
|
||||
? `f/${item.folderName}`
|
||||
: undefined
|
||||
)
|
||||
const mentionRoot = $derived(homeComposerContext.available ? badgeRoot : undefined)
|
||||
|
||||
// Hidden while searching: pipelines aren't part of the text filter (the list
|
||||
// view hides their rows on a query too), so a folder matching the search
|
||||
@@ -287,10 +288,35 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
{#snippet folderBadge()}
|
||||
{#if badgeRoot}
|
||||
<HomeFolderBadge root={badgeRoot} />
|
||||
{/if}
|
||||
{#snippet folderTrailing()}
|
||||
<span class="flex flex-row items-center gap-2">
|
||||
{#if badgeRoot}
|
||||
<HomeFolderBadge root={badgeRoot} />
|
||||
{/if}
|
||||
{#if mentionRoot}
|
||||
{@const path = mentionRoot}
|
||||
<!-- While Home's composer is open its place is kept on every row, so the badges stay put
|
||||
to its left, and it shows on the hovered or tabbed-into row. The row toggles on click,
|
||||
so the press stops here. -->
|
||||
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
<span
|
||||
class="hidden group-has-[[data-composer-open]]/home:inline-flex invisible group-hover/row:visible group-has-[:focus-visible]/row:visible"
|
||||
onclick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<Button
|
||||
variant="subtle"
|
||||
unifiedSize="sm"
|
||||
btnClasses="!text-ai font-medium"
|
||||
title="Add to AI session context"
|
||||
aria-label="Add {path} to AI session context"
|
||||
onClick={() => homeComposerContext.attach(folderContextElement(path))}
|
||||
>
|
||||
+@
|
||||
</Button>
|
||||
</span>
|
||||
{/if}
|
||||
</span>
|
||||
{/snippet}
|
||||
|
||||
{#snippet manageFolderMenu()}
|
||||
@@ -332,7 +358,7 @@
|
||||
onToggle={toggleOwner}
|
||||
indent={visualDepth * 16}
|
||||
actions={onManageFolder && depth === 0 && isFolder(item) ? manageFolderMenu : undefined}
|
||||
trailing={badgeRoot ? folderBadge : undefined}
|
||||
trailing={badgeRoot ? folderTrailing : undefined}
|
||||
>
|
||||
{#snippet detail()}
|
||||
{#if ownerCount != undefined}
|
||||
|
||||
Reference in New Issue
Block a user