Archived
fix: use suffix for unnamed session labels
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@jmfederico/pi-web": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Show the random-looking suffix for unnamed sessions so newly created empty sessions are easier to distinguish.
|
||||||
@@ -2,6 +2,7 @@ import { LitElement, css, html, type PropertyValues } from "lit";
|
|||||||
import { customElement, property, state } from "lit/decorators.js";
|
import { customElement, property, state } from "lit/decorators.js";
|
||||||
import type { SessionActivity, SessionInfo, SessionStatus } from "../api";
|
import type { SessionActivity, SessionInfo, SessionStatus } from "../api";
|
||||||
import { isCachedNewSessionInfo } from "../cachedNewSessions";
|
import { isCachedNewSessionInfo } from "../cachedNewSessions";
|
||||||
|
import { shortSessionId } from "../sessionLabels";
|
||||||
import { isSessionActive } from "../../../shared/activity";
|
import { isSessionActive } from "../../../shared/activity";
|
||||||
import { actionMenuPanelStyle } from "./actionMenu";
|
import { actionMenuPanelStyle } from "./actionMenu";
|
||||||
import { renderActionActivityIndicator, type ActivityIndicatorKind } from "./activityBadge";
|
import { renderActionActivityIndicator, type ActivityIndicatorKind } from "./activityBadge";
|
||||||
@@ -11,7 +12,7 @@ import { listStyles } from "./shared";
|
|||||||
|
|
||||||
function sessionLabel(session: SessionInfo): string {
|
function sessionLabel(session: SessionInfo): string {
|
||||||
if (session.name !== undefined && session.name !== "") return session.name;
|
if (session.name !== undefined && session.name !== "") return session.name;
|
||||||
return session.firstMessage !== "" ? session.firstMessage : session.id.slice(0, 8);
|
return session.firstMessage !== "" ? session.firstMessage : shortSessionId(session.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SessionRow {
|
export interface SessionRow {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { LitElement, css, html } from "lit";
|
import { LitElement, css, html } from "lit";
|
||||||
import { customElement, property, query, state } from "lit/decorators.js";
|
import { customElement, property, query, state } from "lit/decorators.js";
|
||||||
import type { Machine, Project, SessionInfo, Workspace } from "../../api";
|
import type { Machine, Project, SessionInfo, Workspace } from "../../api";
|
||||||
|
import { shortSessionId } from "../../sessionLabels";
|
||||||
import type { NavigationSection } from "../../appShell/navigationState";
|
import type { NavigationSection } from "../../appShell/navigationState";
|
||||||
|
|
||||||
@customElement("app-context-bar")
|
@customElement("app-context-bar")
|
||||||
@@ -193,7 +194,7 @@ function workspaceContextTitle(workspace: Workspace | undefined): string {
|
|||||||
function sessionContextLabel(session: SessionInfo | undefined): string {
|
function sessionContextLabel(session: SessionInfo | undefined): string {
|
||||||
const name = session?.name?.trim();
|
const name = session?.name?.trim();
|
||||||
const firstMessage = session?.firstMessage.trim();
|
const firstMessage = session?.firstMessage.trim();
|
||||||
return name !== undefined && name !== "" ? name : firstMessage !== undefined && firstMessage !== "" ? firstMessage : session?.id.slice(0, 8) ?? "No session";
|
return name !== undefined && name !== "" ? name : firstMessage !== undefined && firstMessage !== "" ? firstMessage : session === undefined ? "No session" : shortSessionId(session.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function sessionContextTitle(session: SessionInfo | undefined): string {
|
function sessionContextTitle(session: SessionInfo | undefined): string {
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import { describe, expect, it } from "vitest";
|
||||||
|
import { shortSessionId } from "./sessionLabels";
|
||||||
|
|
||||||
|
describe("shortSessionId", () => {
|
||||||
|
it("uses the random-looking suffix of UUIDv7 session ids", () => {
|
||||||
|
expect(shortSessionId("019f22c5-d53e-7489-997f-fce1e570a202")).toBe("e570a202");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("keeps short ids intact", () => {
|
||||||
|
expect(shortSessionId("abc123")).toBe("abc123");
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
export function shortSessionId(id: string): string {
|
||||||
|
return id.slice(-8);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user