@pi-kaush/pi-content-layout 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ - Render active input with the theme's `userMessageText` foreground, restoring
6
+ that base color after embedded ANSI resets while preserving inline identifier
7
+ highlighting.
5
8
  - Move user-run `!` bash block styling to `@pi-kaush/pi-tool-call-markers`,
6
9
  which now owns every execution row (tools, grouping, subagents, thinking
7
10
  labels, and bash blocks). This package narrows to the transcript surface:
package/README.md CHANGED
@@ -48,9 +48,10 @@ The package is not published while its version is `0.0.0`; use the repository pa
48
48
  The active editor surface and submitted message body paint with a fixed
49
49
  near-black `#071312` background (`PROMPT_SURFACE_BG`) so both user-input
50
50
  surfaces stay identical; the theme's `selectedBg` token continues to serve
51
- selections and dialogs. The extension consumes theme tokens for its rails and hints: `accent`
52
- for the submitted-prompt rail, `muted` for the editor scroll hints, and
53
- `bashMode` / `error` / `warning` / `dim` for the user-bash rail.
51
+ selections and dialogs. Active input uses the theme's `userMessageText`
52
+ foreground and restores it after embedded ANSI resets without overriding
53
+ inline identifier colors. The extension also consumes `accent` for the
54
+ submitted-prompt rail and `muted` for editor scroll hints.
54
55
 
55
56
  Themes control colors, while this extension controls width and component
56
57
  shape; a theme cannot provide the layout itself.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-kaush/pi-content-layout",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Inset Pi's conversation surface and style active and submitted prompts as matching blocks.",
5
5
  "license": "MIT",
6
6
  "author": "Kaushik Gopal",
package/src/render.ts CHANGED
@@ -88,6 +88,41 @@ function reapplyBackgroundAfterReset(
88
88
  });
89
89
  }
90
90
 
91
+ function leavesForegroundReset(rawParameters: string): boolean {
92
+ const parameters =
93
+ rawParameters === "" ? [0] : rawParameters.split(";").map(Number);
94
+ let foregroundIsDefault = false;
95
+ for (let index = 0; index < parameters.length; index++) {
96
+ const parameter = parameters[index];
97
+ if (parameter === 38) {
98
+ foregroundIsDefault = false;
99
+ const mode = parameters[index + 1];
100
+ if (mode === 5) index += 2;
101
+ if (mode === 2) index += 4;
102
+ } else if (parameter === 0 || parameter === 39) {
103
+ foregroundIsDefault = true;
104
+ } else if (
105
+ parameter !== undefined &&
106
+ ((parameter >= 30 && parameter <= 37) ||
107
+ (parameter >= 90 && parameter <= 97))
108
+ ) {
109
+ foregroundIsDefault = false;
110
+ }
111
+ }
112
+ return foregroundIsDefault;
113
+ }
114
+
115
+ function paintForeground(text: string, foregroundAnsi: string): string {
116
+ const content = text.replace(
117
+ SGR_PATTERN,
118
+ (sequence, rawParameters: string) =>
119
+ leavesForegroundReset(rawParameters)
120
+ ? `${sequence}${foregroundAnsi}`
121
+ : sequence,
122
+ );
123
+ return `${foregroundAnsi}${content}\x1b[39m`;
124
+ }
125
+
91
126
  export function paintBackground(
92
127
  line: string,
93
128
  width: number,
@@ -113,7 +148,11 @@ function activeBlockLine(
113
148
  theme: Theme,
114
149
  ): string {
115
150
  const hint = isBoundary ? scrollHint(line) : undefined;
116
- const body = hint ? theme.fg("muted", ` ${hint}`) : isBoundary ? "" : line;
151
+ const body = hint
152
+ ? theme.fg("muted", ` ${hint}`)
153
+ : isBoundary
154
+ ? ""
155
+ : paintForeground(line, theme.getFgAnsi("userMessageText"));
117
156
  const innerWidth = Math.max(0, width - ACTIVE_SIDE_PADDING * 2);
118
157
  const padding = " ".repeat(ACTIVE_SIDE_PADDING);
119
158
  return paintBackground(