@north-light/crouter 0.3.295 → 0.3.297

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.
@@ -86,12 +86,29 @@ function inboxSummary(card) {
86
86
  * model-fallback prompt names its two routes, so it is recognized by the one
87
87
  * clause both of its variants build around. */
88
88
  function recoverySummary(card) {
89
- switch (card.body) {
90
- case AUTH_FAULT_RECOVERY_BODY: return 'provider credentials updated';
91
- case CONNECTION_FAULT_RECOVERY_BODY: return 'network connection restored';
92
- case PROVIDER_FAULT_RECOVERY_BODY: return 'provider retry';
93
- default: return card.body.includes('automatically switched to ') ? 'model route changed' : 'runtime recovery';
94
- }
89
+ const base = (() => {
90
+ switch (card.body) {
91
+ case AUTH_FAULT_RECOVERY_BODY: return 'provider credentials updated';
92
+ case CONNECTION_FAULT_RECOVERY_BODY: return 'network connection restored';
93
+ case PROVIDER_FAULT_RECOVERY_BODY: return 'provider retry';
94
+ default: return card.body.includes('automatically switched to ') ? 'model route changed' : 'runtime recovery';
95
+ }
96
+ })();
97
+ return `${base}${retryAttemptSuffix(card)}`;
98
+ }
99
+ /** A provider-fault retry rolls the conversation back to where the attempt
100
+ * began, so every superseded attempt leaves the active branch and this one
101
+ * card is the whole visible record of the sequence. The attempt facts are what
102
+ * tell a reader which attempt they are looking at; a card without them (an
103
+ * auth reload, a model-route change) reads exactly as it did before. */
104
+ function retryAttemptSuffix(card) {
105
+ const attempt = Number(card.facts['attempt']);
106
+ const max = Number(card.facts['max']);
107
+ if (!Number.isInteger(attempt) || attempt < 1)
108
+ return '';
109
+ return Number.isInteger(max) && max >= attempt
110
+ ? ` — attempt ${attempt} of ${max}`
111
+ : ` — attempt ${attempt}`;
95
112
  }
96
113
  /** The comment notice opens by naming what happened to the comment
97
114
  * (daemon/review/comment-notify.ts). */