Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions packages/chell/src/builtins/net/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,13 +376,15 @@ export async function builtin_query(args: string[]): Promise<void> {
? queryResult_renderTable(result.decoded, title !== `Query ${Date.now()}` ? title : undefined)
: queryResult_render(result.decoded);

if (rendered) {
console.log(chalk.green(`✓ Query ${result.queryId} complete`));
console.log(rendered);
} else {
if (!rendered) {
// Nothing matched: browsing or pulling the empty query would be
// meaningless, so no hints.
console.log(chalk.yellow(`⚠ Query ${result.queryId} complete — no studies found.`));
return;
}

console.log(chalk.green(`✓ Query ${result.queryId} complete`));
console.log(rendered);
console.log(chalk.bold(` VFS path: ${chalk.cyan(result.vfsPath)}`));
console.log(chalk.gray(` cd ${result.vfsPath}`));
console.log(chalk.gray(` pull ${result.vfsPath}`));
Expand Down
5 changes: 4 additions & 1 deletion packages/chell/tests/query-builtin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,16 @@ describe('builtin_query', () => {
expect(mockCurrentGet).not.toHaveBeenCalled();
});

it('warns when the query completes with no studies', async () => {
it('warns without browse hints when the query completes with no studies', async () => {
mockCurrentGet.mockResolvedValue('PACSDCM');
mockCreate.mockResolvedValue(ok({ id: 9 }));
mockQueryGet.mockResolvedValue(ok({ status: 'succeeded' }));
mockDecode.mockResolvedValue(ok({ json: null }));
await builtin_query(['PatientID:X']);
expect(logSpy).toHaveBeenCalledWith(expect.stringContaining('no studies found'));
const output: string = logSpy.mock.calls.map(c => c.join(' ')).join('\n');
expect(output).not.toContain('VFS path');
expect(output).not.toContain('pull /net/pacs');
});

it('reports a generic failure when the error stack is empty', async () => {
Expand Down
Loading