feat: history/favorites panel, image preview, context strip
Co-Authored-By: Ovis Fast (Claude) <[email protected]>
This commit is contained in:
1 parent
6360c75ff8
commit
7116af9434
9 files changed
+930
-79
No files matched your search
+443
-76
@@ -18,8 +18,8 @@
|
||||
// Enter. The composer says "Wysłano do terminala" and takes the confirmation
|
||||
// from the agent's status.
|
||||
|
||||
import { View, div } from "gpui-kit";
|
||||
import { v_flex, h_flex, TextareaState, Textarea } from "gpui-base";
|
||||
import { View, div, image } from "gpui-kit";
|
||||
import { v_flex, h_flex, TextareaState, Textarea, InputState, VirtualListScrollHandle } from "gpui-base";
|
||||
import {
|
||||
agents as liveAgents,
|
||||
panes as livePanes,
|
||||
@@ -40,7 +40,7 @@ import { keyIntent } from "./keys.js";
|
||||
import { decide, shouldDrain, shouldStartCountdown, sendNow as sendToTerminal } from "./delivery.js";
|
||||
import { detect as detectTrigger, rank, merge, startsLine } from "./suggest.js";
|
||||
import * as catalog from "./catalog.js";
|
||||
import { LIMITS, validate, mention, removeMention, kindOf } from "./attachments.js";
|
||||
import { LIMITS, validate, mention, removeMention, kindOf, formatBytes } from "./attachments.js";
|
||||
import {
|
||||
clipboardScript,
|
||||
parseClipboardResult,
|
||||
@@ -52,7 +52,8 @@ import {
|
||||
supportsImages,
|
||||
} from "./clipboard.js";
|
||||
import * as storage from "./storage.js";
|
||||
import { record } from "./history.js";
|
||||
import { record, panelState, moveIndex, otherTab, toggleFavorite, isFavorite } from "./history.js";
|
||||
import { renderPanel, renderPreview } from "./panel.js";
|
||||
import {
|
||||
agentKey,
|
||||
agentName,
|
||||
@@ -151,7 +152,7 @@ export default class Composer extends View {
|
||||
this.closed = false;
|
||||
|
||||
this.textarea = TextareaState.new({ value: "", placeholder: PLACEHOLDER, rows: 1 });
|
||||
this.textarea.set_auto_grow(1, 6);
|
||||
this.textarea.set_auto_grow(1, 10);
|
||||
this.textarea.set_soft_wrap(true);
|
||||
this.textarea.on("change", (event, cx) => this.changed(cx));
|
||||
this.textarea.on("submit", (event, cx) => this.submitted(event, cx));
|
||||
@@ -169,6 +170,30 @@ export default class Composer extends View {
|
||||
});
|
||||
this.handle = cx.focus_handle();
|
||||
|
||||
// The History | Favourites panel (null when closed): the tab, the row that
|
||||
// is picked, where the caret was when it opened, and the history as it was
|
||||
// read then. Each tab has a search field of its own.
|
||||
this.panel = null;
|
||||
this.panelInputs = {
|
||||
history: InputState.new({ placeholder: "Szukaj w historii…" }),
|
||||
favorites: InputState.new({ placeholder: "Szukaj w ulubionych…" }),
|
||||
};
|
||||
for (const input of Object.values(this.panelInputs)) {
|
||||
input.on("change", (event, cx) => {
|
||||
if (!this.panel) return;
|
||||
this.panel.index = 0;
|
||||
this.scrollPanel(0);
|
||||
cx.notify();
|
||||
});
|
||||
input.on("submit", (event, cx) => this.panelPick(this.panel?.index ?? 0, cx));
|
||||
}
|
||||
this.panelScroll = VirtualListScrollHandle.new();
|
||||
this.favorites = storage.loadFavorites(this.store);
|
||||
|
||||
// The preview of an image (null when closed).
|
||||
this.preview = null;
|
||||
this.previewHandle = cx.focus_handle();
|
||||
|
||||
// The keys the field swallows: it binds the arrows and Tab to its own
|
||||
// actions and eats them before they reach the element. Ctrl+C is not bound
|
||||
// here - it stays "copy". The composer takes these keys as actions of its
|
||||
@@ -479,7 +504,7 @@ export default class Composer extends View {
|
||||
return {
|
||||
hasKeyboard: this.hasKeyboard,
|
||||
menuOpen: !!this.menu && (this.menu.items ?? []).length > 0,
|
||||
panelOpen: this.panelOpen === true,
|
||||
panelOpen: this.panel !== null,
|
||||
empty: this.value.trim() === "",
|
||||
status: agent ? this.statusOf(agent) : null,
|
||||
};
|
||||
@@ -551,14 +576,209 @@ export default class Composer extends View {
|
||||
if (command === "escape") this.intent({ key: "escape" }, cx);
|
||||
}
|
||||
|
||||
/** Task 7: the history panel. Nothing to open yet. */
|
||||
openPanel() {}
|
||||
// --- the History | Favourites panel ---------------------------------------
|
||||
|
||||
/** Task 7: the history panel. Nothing to close yet. */
|
||||
closePanel() {}
|
||||
/** The panel opens over the composer; the caret of the field is remembered. */
|
||||
openPanel(tab = "history") {
|
||||
if (!this.target()) {
|
||||
this.notice("Wybierz agenta, aby otworzyć historię.", "error");
|
||||
return;
|
||||
}
|
||||
this.closeMenu();
|
||||
|
||||
let caret = { start: 0, end: 0 };
|
||||
try {
|
||||
const range = this.textarea.selected_range();
|
||||
caret = { start: range.start, end: range.end };
|
||||
} catch {
|
||||
// The caret is unknown - the text goes in at the start.
|
||||
}
|
||||
|
||||
this.favorites = storage.loadFavorites(this.store);
|
||||
this.panel = { tab, index: 0, caret, history: storage.loadHistory(this.store) };
|
||||
for (const input of Object.values(this.panelInputs)) input.set_value("");
|
||||
this.panelInputs[tab].focus();
|
||||
this.scrollPanel(0);
|
||||
}
|
||||
|
||||
/** The panel closes; the field gets the keyboard and the caret back. */
|
||||
closePanel(restore = true) {
|
||||
if (!this.panel) return;
|
||||
const { caret } = this.panel;
|
||||
this.panel = null;
|
||||
this.textarea.focus();
|
||||
if (restore) this.restoreSelection(caret);
|
||||
}
|
||||
|
||||
/** The selection (or the caret) of the field. */
|
||||
restoreSelection(range) {
|
||||
try {
|
||||
this.textarea.set_selected_range({ start: range.start, end: range.end });
|
||||
} catch {
|
||||
// The field does not answer - the selection stays where it is.
|
||||
}
|
||||
}
|
||||
|
||||
/** The row that is picked scrolls into view. */
|
||||
scrollPanel(index) {
|
||||
try {
|
||||
this.panelScroll.scroll_to_item(index);
|
||||
} catch {
|
||||
// The list is not drawn yet - it starts at the top anyway.
|
||||
}
|
||||
}
|
||||
|
||||
/** What the panel draws. */
|
||||
panelView() {
|
||||
const tab = this.panel.tab;
|
||||
const query = this.panelInputs[tab].value();
|
||||
const state = panelState({ history: this.panel.history, favorites: this.favorites, tab, query });
|
||||
const index = Math.min(this.panel.index, Math.max(0, state.hits.length - 1));
|
||||
return {
|
||||
tab,
|
||||
state,
|
||||
query,
|
||||
index,
|
||||
input: this.panelInputs[tab],
|
||||
scroll: this.panelScroll,
|
||||
isFavorite: (text) => isFavorite(this.favorites, text),
|
||||
};
|
||||
}
|
||||
|
||||
/** The keys of the panel - on the panel itself, not on the composer's actions. */
|
||||
panelKey(event, cx) {
|
||||
if (!this.panel) return;
|
||||
const key = String(event.key ?? "").toLowerCase();
|
||||
const m = event.modifiers ?? {};
|
||||
const view = this.panelView();
|
||||
|
||||
if (key === "escape") {
|
||||
this.closePanel();
|
||||
} else if (key === "arrowdown" || key === "down") {
|
||||
this.movePanel(1, view);
|
||||
} else if (key === "arrowup" || key === "up") {
|
||||
this.movePanel(-1, view);
|
||||
} else if (key === "tab") {
|
||||
this.panelTab(otherTab(this.panel.tab), cx);
|
||||
} else if (key === "enter") {
|
||||
this.panelPick(view.index, cx);
|
||||
} else if (key === "d" && m.control === true) {
|
||||
const hit = view.state.hits[view.index];
|
||||
if (hit) this.toggleFavoriteText(hit.item.text, cx);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
cx.stop_propagation();
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
movePanel(step, view) {
|
||||
this.panel.index = moveIndex(view.index, step, view.state.hits.length);
|
||||
this.scrollPanel(this.panel.index);
|
||||
}
|
||||
|
||||
/** The other tab; what was searched for goes with the person. */
|
||||
panelTab(tab, cx) {
|
||||
if (!this.panel || tab === this.panel.tab) return;
|
||||
const query = this.panelInputs[this.panel.tab].value();
|
||||
this.panel.tab = tab;
|
||||
this.panel.index = 0;
|
||||
this.panelInputs[tab].set_value(query);
|
||||
this.panelInputs[tab].focus();
|
||||
this.scrollPanel(0);
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
/** The search is cleared. */
|
||||
panelClear(cx) {
|
||||
if (!this.panel) return;
|
||||
this.panelInputs[this.panel.tab].set_value("");
|
||||
this.panelInputs[this.panel.tab].focus();
|
||||
this.panel.index = 0;
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
/** A row was clicked: it is named by its key (the id of the entry). */
|
||||
panelPickKey(key, cx) {
|
||||
if (!this.panel) return;
|
||||
const index = this.panelView().state.hits.findIndex((hit) => String(hit.item.id) === key);
|
||||
if (index >= 0) this.panelPick(index, cx);
|
||||
}
|
||||
|
||||
/**
|
||||
* The row goes into the field at the place the caret was - nothing is sent.
|
||||
* The panel closes, the field gets the keyboard and the selection back, and
|
||||
* `replace` puts the text in as typing would.
|
||||
*/
|
||||
panelPick(index, cx) {
|
||||
if (!this.panel) return;
|
||||
const hit = this.panelView().state.hits[index];
|
||||
if (!hit) return;
|
||||
|
||||
const { caret } = this.panel;
|
||||
this.panel = null;
|
||||
this.textarea.focus();
|
||||
this.restoreSelection(caret);
|
||||
this.textarea.replace(hit.item.text);
|
||||
this.scheduleDraftSave(cx);
|
||||
this.notice("Wstawiono w miejscu kursora — nic nie zostało wysłane.");
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
/** A row was right-clicked: its text is a favourite, or no longer. */
|
||||
panelToggleKey(key, cx) {
|
||||
if (!this.panel) return;
|
||||
const hit = this.panelView().state.hits.find((entry) => String(entry.item.id) === key);
|
||||
if (hit) this.toggleFavoriteText(hit.item.text, cx);
|
||||
}
|
||||
|
||||
/** The star next to the field: the text of the field is a favourite, or no longer. */
|
||||
toggleCurrentFavorite(cx) {
|
||||
if (this.value.trim() === "") {
|
||||
this.notice("Wpisz tekst, aby dodać go do ulubionych.", "error", cx);
|
||||
return;
|
||||
}
|
||||
this.toggleFavoriteText(this.value, cx);
|
||||
}
|
||||
|
||||
toggleFavoriteText(text, cx) {
|
||||
this.favorites = toggleFavorite(this.favorites, text, Date.now());
|
||||
try {
|
||||
storage.saveFavorites(this.store, this.favorites);
|
||||
} catch (err) {
|
||||
this.notice(`Nie udało się zapisać ulubionych: ${errorText(err)}`, "error");
|
||||
}
|
||||
if (this.panel) this.panel.index = Math.min(this.panel.index, Math.max(0, this.panelView().state.hits.length - 1));
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
// --- the preview of an image ----------------------------------------------
|
||||
|
||||
openPreview(file, cx) {
|
||||
this.preview = { path: file.path, caption: `${file.name} · ${formatBytes(file.bytes) || "?"} · Esc zamyka` };
|
||||
// The overlay is drawn on the next frame; it takes the keyboard then.
|
||||
cx.timer.after(30, () => {
|
||||
try {
|
||||
this.previewHandle.focus();
|
||||
} catch {
|
||||
// Esc still reaches the composer's own handler.
|
||||
}
|
||||
});
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
closePreview(cx) {
|
||||
this.preview = null;
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
/** The keyboard of the composer. */
|
||||
key(event, cx) {
|
||||
if (this.preview && String(event.key).toLowerCase() === "escape") {
|
||||
this.closePreview(cx);
|
||||
cx.stop_propagation();
|
||||
return;
|
||||
}
|
||||
const m = event.modifiers ?? {};
|
||||
const handled = this.intent(
|
||||
{ key: event.key, shift: m.shift === true, ctrl: m.control === true, alt: m.alt === true },
|
||||
@@ -1058,6 +1278,19 @@ export default class Composer extends View {
|
||||
}
|
||||
}
|
||||
|
||||
/** "Edytuj": the message comes off the queue and goes into the field, at the caret. */
|
||||
editQueued(agent, id, cx) {
|
||||
const key = agentKey(agent);
|
||||
const item = (this.state.queue[key] ?? []).find((entry) => entry.id === id);
|
||||
if (!item || item.state === "sending") return;
|
||||
|
||||
this.textarea.focus();
|
||||
this.textarea.replace(item.text);
|
||||
this.discard(agent, id, cx);
|
||||
this.scheduleDraftSave(cx);
|
||||
this.notice("Wiadomość wróciła do edytora — nic nie zostało wysłane.", undefined, cx);
|
||||
}
|
||||
|
||||
/** The queued message is not wanted any more. */
|
||||
discard(agent, id, cx) {
|
||||
const key = agentKey(agent);
|
||||
@@ -1120,9 +1353,15 @@ export default class Composer extends View {
|
||||
addMention(key, remote) {
|
||||
const token = mention(remote);
|
||||
if (key === this.currentKey) {
|
||||
// The person may be typing: the caret stays where it was in the text,
|
||||
// pushed on by what went in before it.
|
||||
const caret = this.caret();
|
||||
const result = insertMentions(this.value, [token]);
|
||||
const inserted = result.value.length - this.value.length;
|
||||
const at = result.caret - inserted;
|
||||
this.textarea.set_value(result.value);
|
||||
this.value = result.value;
|
||||
this.restoreCaret(caret >= at ? caret + inserted : caret);
|
||||
return;
|
||||
}
|
||||
const result = insertMentions(this.state.drafts[key] ?? "", [token]);
|
||||
@@ -1621,6 +1860,7 @@ export default class Composer extends View {
|
||||
|
||||
return v_flex()
|
||||
.id("ovis-composer")
|
||||
.relative()
|
||||
.track_focus(this.handle)
|
||||
.key_context(CONTEXT)
|
||||
.on_key_down((event, cx) => this.key(event, cx))
|
||||
@@ -1647,10 +1887,39 @@ export default class Composer extends View {
|
||||
this.renderNotice(t),
|
||||
this.renderCard(t, agent, key, status),
|
||||
this.renderContext(t, agent),
|
||||
this.renderPanelLayer(t),
|
||||
this.renderPreviewLayer(t),
|
||||
].filter(Boolean),
|
||||
);
|
||||
}
|
||||
|
||||
/** The History | Favourites panel: it covers the composer while it is open. */
|
||||
renderPanelLayer(t) {
|
||||
if (!this.panel) return null;
|
||||
|
||||
return div()
|
||||
.id("composer-panel-layer")
|
||||
.absolute()
|
||||
.inset_0()
|
||||
.p(6)
|
||||
.bg(t.canvas)
|
||||
.child(
|
||||
renderPanel(t, this.panelView(), {
|
||||
key: (event, cx) => this.panelKey(event, cx),
|
||||
tab: (tab, cx) => this.panelTab(tab, cx),
|
||||
pick: (key, cx) => this.panelPickKey(key, cx),
|
||||
toggle: (key, cx) => this.panelToggleKey(key, cx),
|
||||
clear: (cx) => this.panelClear(cx),
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
/** The preview of an image, over everything. */
|
||||
renderPreviewLayer(t) {
|
||||
if (!this.preview) return null;
|
||||
return renderPreview(t, this.preview, this.previewHandle, { close: (cx) => this.closePreview(cx) });
|
||||
}
|
||||
|
||||
/** The menu of the suggestions, above the card. */
|
||||
renderMenu(t) {
|
||||
const menu = this.menu;
|
||||
@@ -1786,16 +2055,21 @@ export default class Composer extends View {
|
||||
}
|
||||
|
||||
const buttons = [];
|
||||
// An uncertain entry may have reached the agent - it is not sent again.
|
||||
if (item.state !== "uncertain") {
|
||||
buttons.push(
|
||||
this.renderButton(t, "Wyślij teraz", `send-${item.id}`, (event, cx) =>
|
||||
this.sendQueued(agent, item.id, cx),
|
||||
),
|
||||
);
|
||||
}
|
||||
// An uncertain entry may have reached the agent: it is never sent on its
|
||||
// own, only when the person says "Ponów" (the same road as "Wyślij teraz").
|
||||
buttons.push(
|
||||
this.renderButton(t, "Odrzuć", `drop-${item.id}`, (event, cx) => this.discard(agent, item.id, cx)),
|
||||
this.renderButton(
|
||||
t,
|
||||
item.state === "uncertain" ? "Ponów" : "Wyślij teraz",
|
||||
`send-${item.id}`,
|
||||
(event, cx) => this.sendQueued(agent, item.id, cx),
|
||||
),
|
||||
);
|
||||
buttons.push(
|
||||
this.renderButton(t, "Edytuj", `edit-${item.id}`, (event, cx) => this.editQueued(agent, item.id, cx)),
|
||||
);
|
||||
buttons.push(
|
||||
this.renderButton(t, "Usuń", `drop-${item.id}`, (event, cx) => this.discard(agent, item.id, cx)),
|
||||
);
|
||||
|
||||
return h_flex().gap(6).flex_none().children(buttons);
|
||||
@@ -1890,25 +2164,75 @@ export default class Composer extends View {
|
||||
.children(
|
||||
[
|
||||
files.length ? this.renderFiles(t, agent) : null,
|
||||
Textarea.new(this.textarea)
|
||||
.w_full()
|
||||
.px(10)
|
||||
.py(8)
|
||||
.rounded(8)
|
||||
.bg(t.background)
|
||||
.text_color(active ? t.foreground : t.dim)
|
||||
.text_size(13),
|
||||
// The focus is on a terminal that is not an agent: the field is
|
||||
// silent and says why; the draft stays where it is.
|
||||
active
|
||||
? Textarea.new(this.textarea)
|
||||
.w_full()
|
||||
.px(10)
|
||||
.py(8)
|
||||
.rounded(8)
|
||||
.bg(t.background)
|
||||
.text_color(t.foreground)
|
||||
.text_size(13)
|
||||
: div()
|
||||
.id("composer-inactive")
|
||||
.w_full()
|
||||
.px(10)
|
||||
.py(8)
|
||||
.rounded(8)
|
||||
.bg(t.background)
|
||||
.text_size(13)
|
||||
.text_color(t.dim)
|
||||
.child("Ten terminal nie jest agentem. Wybierz agenta z listy, aby pisać."),
|
||||
h_flex()
|
||||
.gap(8)
|
||||
.items_center()
|
||||
.child(this.renderPlus(t, agent))
|
||||
.child(this.renderChip(t, agent, status))
|
||||
.child(
|
||||
this.renderIcon(t, "composer-history", "🕘", false, active, (event, cx) => {
|
||||
this.openPanel("history");
|
||||
cx.notify();
|
||||
}),
|
||||
)
|
||||
.child(
|
||||
this.renderIcon(
|
||||
t,
|
||||
"composer-star",
|
||||
isFavorite(this.favorites, this.value) ? "★" : "☆",
|
||||
isFavorite(this.favorites, this.value),
|
||||
active,
|
||||
(event, cx) => this.toggleCurrentFavorite(cx),
|
||||
),
|
||||
)
|
||||
.child(div().flex_1())
|
||||
.child(this.renderChip(t, agent, status, files.length))
|
||||
.child(stop ? this.renderStop(t, agent) : this.renderSend(t, agent, over)),
|
||||
].filter(Boolean),
|
||||
);
|
||||
}
|
||||
|
||||
/** A round icon button next to the field (history, star). */
|
||||
renderIcon(t, id, glyph, lit, enabled, action) {
|
||||
return div()
|
||||
.id(id)
|
||||
.size(28)
|
||||
.rounded(999)
|
||||
.flex_none()
|
||||
.flex()
|
||||
.items_center()
|
||||
.justify_center()
|
||||
.bg(t.chrome)
|
||||
.text_size(14)
|
||||
.text_color(lit ? t.working : enabled ? t.muted : t.dim)
|
||||
.cursor_pointer()
|
||||
.hover((s) => s.bg(t.hover).text_color(lit ? t.working : t.foreground))
|
||||
.on_click((event, cx) => {
|
||||
if (enabled) action(event, cx);
|
||||
})
|
||||
.child(glyph);
|
||||
}
|
||||
|
||||
/** The "+" button: pick files with the system dialog. */
|
||||
renderPlus(t, agent) {
|
||||
return div()
|
||||
@@ -1937,56 +2261,91 @@ export default class Composer extends View {
|
||||
.id("composer-files")
|
||||
.gap(6)
|
||||
.flex_wrap()
|
||||
.children(
|
||||
files.map((file) =>
|
||||
h_flex()
|
||||
.id(`file-${file.id}`)
|
||||
.gap(6)
|
||||
.px(8)
|
||||
.h(24)
|
||||
.rounded(8)
|
||||
.bg(file.state === "error" ? t.blocked + "26" : t.chrome)
|
||||
.children(files.map((file) => this.renderTile(t, agent, file)));
|
||||
}
|
||||
|
||||
/** One tile: the thumbnail (or the extension), the name, the size or the reason, the buttons. */
|
||||
renderTile(t, agent, file) {
|
||||
const error = file.state === "error";
|
||||
const adding = file.state === "adding";
|
||||
const extension = (file.name.split(".").pop() || "").slice(0, 4);
|
||||
|
||||
const thumb =
|
||||
file.kind === "image"
|
||||
? div()
|
||||
.id(`file-thumb-${file.id}`)
|
||||
.size(36)
|
||||
.flex_none()
|
||||
.rounded(5)
|
||||
.overflow_hidden()
|
||||
.cursor_pointer()
|
||||
.when(adding, (el) => el.opacity(0.35))
|
||||
.on_click((event, cx) => this.openPreview(file, cx))
|
||||
.child(image(file.path).size(36))
|
||||
: div()
|
||||
.size(36)
|
||||
.flex_none()
|
||||
.rounded(5)
|
||||
.bg(t.hover)
|
||||
.flex()
|
||||
.items_center()
|
||||
.child(
|
||||
div()
|
||||
.text_size(11.5)
|
||||
.text_color(file.state === "error" ? t.blocked : t.foreground)
|
||||
.truncate()
|
||||
.child(file.name),
|
||||
)
|
||||
.when(file.state === "adding", (el) =>
|
||||
el.child(div().text_size(10.5).text_color(t.dim).child("dodawanie…")),
|
||||
)
|
||||
.when(file.state === "error", (el) =>
|
||||
el.child(
|
||||
div()
|
||||
.id(`file-retry-${file.id}`)
|
||||
.px(4)
|
||||
.text_size(11)
|
||||
.text_color(t.blocked)
|
||||
.cursor_pointer()
|
||||
.hover((s) => s.text_color(t.foreground))
|
||||
.on_click((event, cx) => this.retryFile(agent, file.id, cx))
|
||||
.child("Ponów"),
|
||||
),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.id(`file-x-${file.id}`)
|
||||
.px(4)
|
||||
.text_size(12)
|
||||
.text_color(t.dim)
|
||||
.cursor_pointer()
|
||||
.hover((s) => s.text_color(t.foreground))
|
||||
.on_click((event, cx) => this.removeFile(agent, file.id, cx))
|
||||
.child("✕"),
|
||||
),
|
||||
.justify_center()
|
||||
.text_size(10)
|
||||
.text_color(t.dim)
|
||||
.child(extension);
|
||||
|
||||
return h_flex()
|
||||
.id(`file-${file.id}`)
|
||||
.gap(7)
|
||||
.h(44)
|
||||
.px(4)
|
||||
.items_center()
|
||||
.rounded(8)
|
||||
.border(1)
|
||||
.border_color(error ? t.blocked : t.border)
|
||||
.bg(t.chrome)
|
||||
.child(thumb)
|
||||
.child(
|
||||
v_flex()
|
||||
.min_w(0)
|
||||
.max_w(190)
|
||||
.child(div().text_size(12).text_color(t.foreground).truncate().child(file.name))
|
||||
.child(
|
||||
div()
|
||||
.text_size(11)
|
||||
.text_color(error ? t.blocked : t.dim)
|
||||
.truncate()
|
||||
.child(error ? file.error ?? "" : adding ? "dodawanie…" : formatBytes(file.bytes)),
|
||||
),
|
||||
)
|
||||
.when(error, (el) =>
|
||||
el.child(
|
||||
div()
|
||||
.id(`file-retry-${file.id}`)
|
||||
.px(4)
|
||||
.text_size(11)
|
||||
.text_color(t.blocked)
|
||||
.cursor_pointer()
|
||||
.hover((s) => s.text_color(t.foreground))
|
||||
.on_click((event, cx) => this.retryFile(agent, file.id, cx))
|
||||
.child("Ponów"),
|
||||
),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.id(`file-x-${file.id}`)
|
||||
.px(4)
|
||||
.text_size(12)
|
||||
.text_color(t.dim)
|
||||
.cursor_pointer()
|
||||
.hover((s) => s.text_color(t.foreground))
|
||||
.on_click((event, cx) => this.removeFile(agent, file.id, cx))
|
||||
.child("✕"),
|
||||
);
|
||||
}
|
||||
|
||||
/** The chip of the agent: its program and what it is doing. */
|
||||
renderChip(t, agent, status) {
|
||||
renderChip(t, agent, status, fileCount = 0) {
|
||||
if (!agent) {
|
||||
return div()
|
||||
.px(8)
|
||||
@@ -2000,7 +2359,7 @@ export default class Composer extends View {
|
||||
.child("brak agenta");
|
||||
}
|
||||
|
||||
const name = agent.program?.name ?? agentName(agent);
|
||||
const name = agent.tab_name || agent.program?.name || agentName(agent);
|
||||
const color = t[status] ?? t.dim;
|
||||
|
||||
return h_flex()
|
||||
@@ -2012,7 +2371,8 @@ export default class Composer extends View {
|
||||
.bg(t.chrome)
|
||||
.child(div().size(7).rounded(4).flex_none().bg(color))
|
||||
.child(div().text_size(11.5).text_color(t.foreground).child(name))
|
||||
.child(div().text_size(11).text_color(color).child(statusText(status)));
|
||||
.child(div().text_size(11).text_color(color).child(statusText(status)))
|
||||
.when(fileCount > 0, (el) => el.child(div().text_size(11).text_color(t.dim).child(`📎 ${fileCount}`)));
|
||||
}
|
||||
|
||||
/** The button that sends the message. */
|
||||
@@ -2069,8 +2429,15 @@ export default class Composer extends View {
|
||||
.px(2)
|
||||
.text_size(11)
|
||||
.text_color(t.dim)
|
||||
.child(div().truncate().child(context.cwd ? shortPath(context.cwd) : ""))
|
||||
.when(context.branch, (el) => el.child(div().flex_none().child(context.branch)))
|
||||
.child(
|
||||
div()
|
||||
.truncate()
|
||||
.child(
|
||||
[agent?.space_name, context.cwd ? shortPath(context.cwd) : "", context.branch ? `⑂ ${context.branch}` : ""]
|
||||
.filter(Boolean)
|
||||
.join(" · "),
|
||||
),
|
||||
)
|
||||
.child(div().flex_1())
|
||||
.child(
|
||||
div()
|
||||
|
||||
Reference in new issue
Block a user