-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Polish chat UI and provider prompts #2451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sandersonstabo
wants to merge
16
commits into
pingdotgg:main
Choose a base branch
from
sandersonstabo:pr/ui-polish-context-menu
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
07e3b02
UI polish across settings, composer, chat; web context menu fallback;…
c967b6d
fix(ui): muted foreground for disabled ghost toggles
acbc495
Polish chat UI and provider prompts
ff2e8a3
Tighten timeline action and failure styling
8a77ae5
Address review feedback and UI polish
32f4590
Preserve composer draft during pending input selection
c5a5a4c
Style runtime warning work log rows
a8bc432
Speculatively avoid promoted draft repaint
834a239
Address pending input review findings
06e063f
Fix provider status lookup and work log icon alignment
f4eff53
Force-clear stuck active turns, settle latestTurn on session-set, sho…
11511b3
fix(context-window): always include totalProcessedTokens; fix status …
07094ed
fix(ui): align picker chevrons, fix icon margins, and polish commit d…
bbfd10f
Merge remote-tracking branch 'fork/pr/ui-polish-context-menu'
6892790
fix(ui): add mx-0.5 to brain icon in traits picker trigger
6d9d3be
Merge origin/main into pr/ui-polish-context-menu
juliusmarminge File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,191 @@ | ||
| import { existsSync } from "node:fs"; | ||
| import { join } from "node:path"; | ||
| import { Schema } from "effect"; | ||
| import { TextGenerationError } from "@t3tools/contracts"; | ||
|
|
||
| export function isGitRepository(cwd: string): boolean { | ||
| return existsSync(join(cwd, ".git")); | ||
| } | ||
|
|
||
| /** Convert an Effect Schema to a flat JSON Schema object, inlining `$defs` when present. */ | ||
| export function toJsonSchemaObject(schema: Schema.Top): unknown { | ||
| const document = Schema.toJsonSchemaDocument(schema); | ||
| if (document.definitions && Object.keys(document.definitions).length > 0) { | ||
| return { ...document.schema, $defs: document.definitions }; | ||
| } | ||
| return document.schema; | ||
| } | ||
|
|
||
| /** Truncate a text section to `maxChars`, appending a `[truncated]` marker when needed. */ | ||
| export function limitSection(value: string, maxChars: number): string { | ||
| if (value.length <= maxChars) return value; | ||
| const truncated = value.slice(0, maxChars); | ||
| return `${truncated}\n\n[truncated]`; | ||
| } | ||
|
|
||
| export function extractJsonObject(raw: string): string { | ||
| const trimmed = raw.trim(); | ||
| if (trimmed.length === 0) { | ||
| return trimmed; | ||
| } | ||
|
|
||
| const start = trimmed.indexOf("{"); | ||
| if (start < 0) { | ||
| return trimmed; | ||
| } | ||
|
|
||
| let depth = 0; | ||
| let inString = false; | ||
| let escaping = false; | ||
| for (let index = start; index < trimmed.length; index += 1) { | ||
| const char = trimmed[index]; | ||
| if (inString) { | ||
| if (escaping) { | ||
| escaping = false; | ||
| } else if (char === "\\") { | ||
| escaping = true; | ||
| } else if (char === '"') { | ||
| inString = false; | ||
| } | ||
| continue; | ||
| } | ||
|
|
||
| if (char === '"') { | ||
| inString = true; | ||
| continue; | ||
| } | ||
|
|
||
| if (char === "{") { | ||
| depth += 1; | ||
| continue; | ||
| } | ||
|
|
||
| if (char === "}") { | ||
| depth -= 1; | ||
| if (depth === 0) { | ||
| return trimmed.slice(start, index + 1); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return trimmed.slice(start); | ||
| } | ||
|
|
||
| /** Normalise a raw commit subject to imperative-mood, ≤72 chars, no trailing period. */ | ||
| export function sanitizeCommitSubject(raw: string): string { | ||
| const singleLine = raw.trim().split(/\r?\n/g)[0]?.trim() ?? ""; | ||
| const withoutTrailingPeriod = singleLine.replace(/[.]+$/g, "").trim(); | ||
| if (withoutTrailingPeriod.length === 0) { | ||
| return "Update project files"; | ||
| } | ||
|
|
||
| if (withoutTrailingPeriod.length <= 72) { | ||
| return withoutTrailingPeriod; | ||
| } | ||
| return withoutTrailingPeriod.slice(0, 72).trimEnd(); | ||
| } | ||
|
|
||
| /** Normalise a raw PR title to a single line with a sensible fallback. */ | ||
| export function sanitizePrTitle(raw: string): string { | ||
| const singleLine = raw.trim().split(/\r?\n/g)[0]?.trim() ?? ""; | ||
| if (singleLine.length > 0) { | ||
| return singleLine; | ||
| } | ||
| return "Update project changes"; | ||
| } | ||
|
|
||
| /** Normalise a raw thread title to a compact single-line sidebar-safe label. */ | ||
| export function sanitizeThreadTitle(raw: string): string { | ||
| const normalized = raw | ||
| .trim() | ||
| .split(/\r?\n/g)[0] | ||
| ?.trim() | ||
| .replace(/^['"`]+|['"`]+$/g, "") | ||
| .trim() | ||
| .replace(/\s+/g, " "); | ||
|
|
||
| if (!normalized || normalized.trim().length === 0) { | ||
| return "New thread"; | ||
| } | ||
|
|
||
| if (normalized.length <= 50) { | ||
| return normalized; | ||
| } | ||
|
|
||
| return `${normalized.slice(0, 47).trimEnd()}...`; | ||
| } | ||
|
|
||
| /** Normalise model output for tool work-log rows (UI adds the >_ prefix). */ | ||
| export function sanitizeToolWorkLogSummaryLine(raw: string, fallbackLabel: string): string { | ||
| const stripped = raw | ||
| .trim() | ||
| .split(/\r?\n/g)[0] | ||
| ?.replace(/^>\s*[__]\s*/i, "") | ||
| .replace(/^>\s*/, "") | ||
| .trim() | ||
| .replace(/\s+/g, " "); | ||
|
|
||
| const base = | ||
| stripped && stripped.length > 0 | ||
| ? stripped | ||
| : (fallbackLabel.trim().split(/\r?\n/g)[0]?.trim() ?? "").replace(/\s+/g, " "); | ||
|
|
||
| if (!base || base.length === 0) { | ||
| return "Working"; | ||
| } | ||
|
|
||
| const withoutTrailingPeriod = base.replace(/[.]+$/g, "").trim(); | ||
| const singleLine = withoutTrailingPeriod.length > 0 ? withoutTrailingPeriod : base; | ||
| if (singleLine.length <= 160) { | ||
| return singleLine; | ||
| } | ||
| return `${singleLine.slice(0, 157).trimEnd()}...`; | ||
| } | ||
|
|
||
| /** CLI name to human-readable label, e.g. "codex" → "Codex CLI (`codex`)" */ | ||
| function cliLabel(cliName: string): string { | ||
| const capitalized = cliName.charAt(0).toUpperCase() + cliName.slice(1); | ||
| return `${capitalized} CLI (\`${cliName}\`)`; | ||
| } | ||
|
|
||
| /** | ||
| * Normalize an unknown error from a CLI text generation process into a | ||
| * typed `TextGenerationError`. Parameterized by CLI name so both Codex | ||
| * and Claude (and future providers) can share the same logic. | ||
| */ | ||
| export function normalizeCliError( | ||
| cliName: string, | ||
| operation: string, | ||
| error: unknown, | ||
| fallback: string, | ||
| ): TextGenerationError { | ||
| if (Schema.is(TextGenerationError)(error)) { | ||
| return error; | ||
| } | ||
|
|
||
| if (error instanceof Error) { | ||
| const lower = error.message.toLowerCase(); | ||
| if ( | ||
| error.message.includes(`Command not found: ${cliName}`) || | ||
| lower.includes(`spawn ${cliName}`) || | ||
| lower.includes("enoent") | ||
| ) { | ||
| return new TextGenerationError({ | ||
| operation, | ||
| detail: `${cliLabel(cliName)} is required but not available on PATH.`, | ||
| cause: error, | ||
| }); | ||
| } | ||
| return new TextGenerationError({ | ||
| operation, | ||
| detail: `${fallback}: ${error.message}`, | ||
| cause: error, | ||
| }); | ||
| } | ||
|
|
||
| return new TextGenerationError({ | ||
| operation, | ||
| detail: fallback, | ||
| cause: error, | ||
| }); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fully duplicated utility functions across two files
Medium Severity
Seven exported functions in
apps/server/src/git/Utils.ts(toJsonSchemaObject,limitSection,extractJsonObject,sanitizeCommitSubject,sanitizePrTitle,sanitizeThreadTitle,normalizeCliError) are exact duplicates of functions already inapps/server/src/textGeneration/TextGenerationUtils.ts. The existing callers all import fromTextGenerationUtils.ts, making the copies ingit/Utils.tsunused dead code. OnlysanitizeToolWorkLogSummaryLineis unique and actually imported fromgit/Utils.ts.Reviewed by Cursor Bugbot for commit 6d9d3be. Configure here.