@juicesharp/rpiv-ask-user-question 2.3.1 → 2.5.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juicesharp/rpiv-ask-user-question",
3
- "version": "2.3.1",
3
+ "version": "2.5.0",
4
4
  "description": "Pi extension. A structured questionnaire the model can put to you when it would otherwise guess, with typed options instead of free-form replies.",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -93,7 +93,7 @@
93
93
  }
94
94
  },
95
95
  "dependencies": {
96
- "@juicesharp/rpiv-config": "^2.3.1",
96
+ "@juicesharp/rpiv-config": "^2.5.0",
97
97
  "typebox": "^1.1.24"
98
98
  }
99
99
  }
@@ -139,17 +139,23 @@ export function crossTabPreviewBudget(questions: readonly QuestionData[], paneWi
139
139
  * 1. `labelDriven` = `crossTabMaxLeftWidth(tabs, itemsByTab, paneWidth)`
140
140
  * 2. `previewBudget` = `crossTabPreviewBudget(questions, paneWidth)`
141
141
  * 3. `slackDonation` = `paneWidth − GAP − previewBudget`
142
- * 4. Return `min(max(labelDriven, slackDonation), ceiling)` where `ceiling = paneWidth − GAP − MIN_PREVIEW_WIDTH`
142
+ * 4. Return `min(max(labelDriven, slackDonation), ceiling)` where `ceiling` is the
143
+ * tighter of the preview-width safety limit and `MAX_LEFT_RATIO`
143
144
  *
144
- * Invariants:
145
- * - Floor: result ≥ MIN_LEFT (labelDriven ≥ MIN_LEFT)
146
- * - Preview floor: right column ≥ MIN_PREVIEW_WIDTH (ceiling enforces this)
145
+ * Invariants (hold at side-by-side widths, paneWidth ≥ PREVIEW_MIN_WIDTH — the only
146
+ * mode that consumes this value; narrower panes can pull both ceilings under MIN_LEFT):
147
+ * - Floor: result ≥ MIN_LEFT (ratioCeiling ≥ 50 once paneWidth ≥ 100)
148
+ * - Options cap: left column ≤ paneWidth × MAX_LEFT_RATIO
149
+ * - Preview floor: right column ≥ MIN_PREVIEW_WIDTH — enforced transitively by the
150
+ * MAX_LEFT_RATIO cap (right column keeps ≥ paneWidth/2 − GAP ≥ 48 cols);
151
+ * previewSafetyCeiling is defensive depth that binds only if MAX_LEFT_RATIO
152
+ * ever rises above ~0.53
147
153
  * - Cross-tab stability: both reductions are tab-independent
148
154
  * - Determinism: pure of (questions, itemsByTab, paneWidth)
149
155
  *
150
156
  * `crossTabMaxLeftWidth` is NOT replaced — it continues to exist as the primitive.
151
- * `MAX_LEFT_RATIO` caps the label-driven path inside `adaptiveLeftWidth`; donation
152
- * operates above the cap when preview slack is available.
157
+ * Donation obeys the same `MAX_LEFT_RATIO` cap as the label-driven path; the preview
158
+ * composer right-aligns narrower boxes inside the remaining column.
153
159
  */
154
160
  export function crossTabLeftWidthWithDonation(
155
161
  tabs: ReadonlyArray<{ multiSelect?: boolean }>,
@@ -158,13 +164,14 @@ export function crossTabLeftWidthWithDonation(
158
164
  paneWidth: number,
159
165
  ): number {
160
166
  const labelDriven = crossTabMaxLeftWidth(tabs, itemsByTab, paneWidth);
161
- // Compact-content guard: labels at MIN_LEFT fit below the floor, so widening
162
- // the column would only inject dead space between the option list and the
163
- // preview box. Skip donation and preserve the compact intent.
164
- if (labelDriven <= MIN_LEFT) return labelDriven;
165
167
  const previewBudget = crossTabPreviewBudget(questions, paneWidth);
166
168
  const slackDonation = paneWidth - PREVIEW_COLUMN_GAP - previewBudget;
167
- const ceiling = paneWidth - PREVIEW_COLUMN_GAP - MIN_PREVIEW_WIDTH;
169
+ // At side-by-side widths the ratio ceiling is always the tighter bound
170
+ // (paneWidth/2 ≤ paneWidth − GAP − MIN_PREVIEW_WIDTH once paneWidth ≥ 94);
171
+ // previewSafetyCeiling stays as defensive depth should MAX_LEFT_RATIO grow.
172
+ const previewSafetyCeiling = paneWidth - PREVIEW_COLUMN_GAP - MIN_PREVIEW_WIDTH;
173
+ const ratioCeiling = Math.floor(paneWidth * MAX_LEFT_RATIO);
174
+ const ceiling = Math.min(previewSafetyCeiling, ratioCeiling);
168
175
  return Math.min(Math.max(labelDriven, slackDonation), Math.max(1, ceiling));
169
176
  }
170
177
 
@@ -220,7 +220,14 @@ export class PreviewPane implements StatefulView<PreviewPaneProps>, Component {
220
220
  this.props.focused,
221
221
  this.props.notesVisible,
222
222
  );
223
- const pad = " ".repeat(PREVIEW_PADDING_LEFT);
224
- return contentLines.map((l) => (l === "" ? "" : `${pad}${l}`));
223
+ const boxWidth = Math.max(1, visibleWidth(contentLines[0] ?? ""));
224
+ const boxAlignedPad = Math.max(PREVIEW_PADDING_LEFT, colWidth - boxWidth);
225
+ return contentLines.map((line) => {
226
+ if (line === "") return "";
227
+ // A line wider than the box (a long-locale notes affordance) slides left to
228
+ // stay fully visible; truncation engages only when the column itself runs out.
229
+ const pad = Math.max(PREVIEW_PADDING_LEFT, Math.min(boxAlignedPad, colWidth - visibleWidth(line)));
230
+ return `${" ".repeat(pad)}${truncateToWidth(line, colWidth - pad, "")}`;
231
+ });
225
232
  }
226
233
  }