fix(assistant): green CI round, trip notes the assistant can keep, calmer change cards

- the assistant keeps facts for a trip (remember_for_trip) as a change card,
  applied into the user's trip notes; existing expenses can be changed
- change card fields as a few icon chips with the rest folded under Details,
  the day band marks only what changes, the week grid as compact tiles
- no map button on receipts of things that have no place on the map
- tests follow the composer's accessible name, the receipt's status icon and
  the GL map's container; the hanging stream helper honours an early abort
- Postgres probe: qualified columns in the upsert updates; entities restored
  to the generator's output; strict ratchet reads the SDK client as untyped
This commit is contained in:
Maurice
2026-10-21 21:22:12 +02:00
parent 123e27643d
commit d24db65cb8
63 changed files with 509 additions and 133 deletions
@@ -21,7 +21,9 @@ export class AssistantMessages {
export const AssistantMessagesSchema = defineEntity({
class: AssistantMessages,
repository: () => AssistantMessagesRepository,
indexes: [{ name: 'idx_assistant_messages_thread', properties: ['thread_id', 'id'] }],
indexes: [
{ name: 'idx_assistant_messages_thread', properties: ['thread_id', 'id'] },
],
properties: {
id: p.integer().primary(),
thread: () => p.manyToOne(AssistantThreads).ref().deleteRule('cascade').hidden(),
@@ -30,8 +30,7 @@ export const AssistantToolCallsSchema = defineEntity({
id: p.text().primary(),
thread: () => p.manyToOne(AssistantThreads).ref().deleteRule('cascade').hidden(),
thread_id: p.integer().persist(false),
message: () =>
p.manyToOne(AssistantMessages).ref().deleteRule('cascade').hidden().index('idx_assistant_tool_calls_message'),
message: () => p.manyToOne(AssistantMessages).ref().deleteRule('cascade').hidden().index('idx_assistant_tool_calls_message'),
message_id: p.integer().persist(false).index('idx_assistant_tool_calls_message'),
provider_call_id: p.text(),
tool_name: p.text(),
@@ -117,7 +117,7 @@ export class AiConnectionsRepository extends TrekRepository<AiConnections> {
: oc.column('user_id').where('user_id', 'is not', null);
return target.doUpdateSet({
...columns,
secrets_version: (eb) => eb('secrets_version', '+', 1),
secrets_version: (eb) => eb('ai_connections.secrets_version', '+', 1),
status: 'ok',
updated_at: () => this.now(),
});
@@ -35,9 +35,9 @@ export class AssistantUsageRepository extends TrekRepository<AssistantUsage> {
})
.onConflict((oc) =>
oc.columns(['user_id', 'day', 'paid_by']).doUpdateSet({
turns: (eb) => eb('turns', '+', eb.ref('excluded.turns')),
input_tokens: (eb) => eb('input_tokens', '+', eb.ref('excluded.input_tokens')),
output_tokens: (eb) => eb('output_tokens', '+', eb.ref('excluded.output_tokens')),
turns: (eb) => eb('assistant_usage.turns', '+', eb.ref('excluded.turns')),
input_tokens: (eb) => eb('assistant_usage.input_tokens', '+', eb.ref('excluded.input_tokens')),
output_tokens: (eb) => eb('assistant_usage.output_tokens', '+', eb.ref('excluded.output_tokens')),
}),
)
.execute();